From 138af3cbeab9de26d8a70735ff6543efb38dbba6 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Mon, 24 Feb 2025 20:39:18 +0200 Subject: [PATCH 1/5] fix: handle devfile retrieval for disconnected clusters in DevfilesHelper --- tests/e2e/utils/DevfilesHelper.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/e2e/utils/DevfilesHelper.ts b/tests/e2e/utils/DevfilesHelper.ts index 0edccaf2251..abb4ef558a7 100644 --- a/tests/e2e/utils/DevfilesHelper.ts +++ b/tests/e2e/utils/DevfilesHelper.ts @@ -21,6 +21,12 @@ import { CLASSES } from '../configs/inversify.types'; export class DevfilesHelper { public getInternalClusterURLToDevFile(devFileName: string): string { const devfileSampleURIPrefix: string = `/dashboard/api/airgap-sample/devfile/download?id=${devFileName}`; + + // internal clusterIP is restricted by proxy when get devfile from the disconnected cluster + if (BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()) { + return `${BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL}${devfileSampleURIPrefix}`; + } + let serviceClusterIp: string = ''; let servicePort: string = ''; serviceClusterIp = this.getShellExecutor().executeArbitraryShellScript( From 63df3eee135ba8f54eb9e8ed7abdff2695829308 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Wed, 26 Feb 2025 21:34:20 +0200 Subject: [PATCH 2/5] Log command Signed-off-by: Dmytro Nochevnov --- tests/e2e/utils/DevfilesHelper.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/utils/DevfilesHelper.ts b/tests/e2e/utils/DevfilesHelper.ts index abb4ef558a7..763035eea5e 100644 --- a/tests/e2e/utils/DevfilesHelper.ts +++ b/tests/e2e/utils/DevfilesHelper.ts @@ -24,6 +24,8 @@ export class DevfilesHelper { // internal clusterIP is restricted by proxy when get devfile from the disconnected cluster if (BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()) { + Logger.debug('Cluster is disconnected, using the base URL'); + return `${BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL}${devfileSampleURIPrefix}`; } From 880b008230e3a540cec354960c0541b34d362a74 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Wed, 26 Feb 2025 21:42:40 +0200 Subject: [PATCH 3/5] fix curl from https Signed-off-by: Dmytro Nochevnov --- tests/e2e/utils/DevfilesHelper.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/e2e/utils/DevfilesHelper.ts b/tests/e2e/utils/DevfilesHelper.ts index 763035eea5e..56cdc2a9529 100644 --- a/tests/e2e/utils/DevfilesHelper.ts +++ b/tests/e2e/utils/DevfilesHelper.ts @@ -24,8 +24,6 @@ export class DevfilesHelper { // internal clusterIP is restricted by proxy when get devfile from the disconnected cluster if (BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()) { - Logger.debug('Cluster is disconnected, using the base URL'); - return `${BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL}${devfileSampleURIPrefix}`; } @@ -49,7 +47,7 @@ export class DevfilesHelper { public obtainDevFileContentUsingPod(podName: string, containerName: string, devFileName: string): string { const clusterURL: string = this.getInternalClusterURLToDevFile(devFileName); this.getShellExecutor().executeCommand( - `oc exec -i ${podName} -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -c ${containerName} -- sh -c 'curl -o /tmp/${devFileName}-devfile.yaml ${clusterURL}'` + `oc exec -i ${podName} -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -c ${containerName} -- sh -c 'curl -k -o /tmp/${devFileName}-devfile.yaml ${clusterURL}'` ); return this.getShellExecutor() .executeArbitraryShellScript( From 45ad9a5d97a073da0f46fa298c86fb810a394ac3 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Wed, 26 Feb 2025 23:51:08 +0200 Subject: [PATCH 4/5] Use devspaces-dashboard.openshift-devspaces.svc to get devfile yaml Signed-off-by: Dmytro Nochevnov --- tests/e2e/utils/DevfilesHelper.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/tests/e2e/utils/DevfilesHelper.ts b/tests/e2e/utils/DevfilesHelper.ts index 56cdc2a9529..4d190d54398 100644 --- a/tests/e2e/utils/DevfilesHelper.ts +++ b/tests/e2e/utils/DevfilesHelper.ts @@ -22,20 +22,7 @@ export class DevfilesHelper { public getInternalClusterURLToDevFile(devFileName: string): string { const devfileSampleURIPrefix: string = `/dashboard/api/airgap-sample/devfile/download?id=${devFileName}`; - // internal clusterIP is restricted by proxy when get devfile from the disconnected cluster - if (BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()) { - return `${BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL}${devfileSampleURIPrefix}`; - } - - let serviceClusterIp: string = ''; - let servicePort: string = ''; - serviceClusterIp = this.getShellExecutor().executeArbitraryShellScript( - `oc get svc devspaces-dashboard -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -o=jsonpath='{.spec.clusterIP}'` - ); - servicePort = this.getShellExecutor().executeArbitraryShellScript( - `oc get svc devspaces-dashboard -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -o=jsonpath='{.spec.ports[*].port}'` - ); - return `http://${serviceClusterIp}:${servicePort}${devfileSampleURIPrefix}`; + return `http://devspaces-dashboard.openshift-devspaces.svc:8080${devfileSampleURIPrefix}`; } /** From 913315ca893fc44bb8a7f880be9e0b7f5edd7147 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 27 Feb 2025 00:00:15 +0200 Subject: [PATCH 5/5] Clean up Signed-off-by: Dmytro Nochevnov --- tests/e2e/utils/DevfilesHelper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/utils/DevfilesHelper.ts b/tests/e2e/utils/DevfilesHelper.ts index 4d190d54398..f65d2c7e967 100644 --- a/tests/e2e/utils/DevfilesHelper.ts +++ b/tests/e2e/utils/DevfilesHelper.ts @@ -34,7 +34,7 @@ export class DevfilesHelper { public obtainDevFileContentUsingPod(podName: string, containerName: string, devFileName: string): string { const clusterURL: string = this.getInternalClusterURLToDevFile(devFileName); this.getShellExecutor().executeCommand( - `oc exec -i ${podName} -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -c ${containerName} -- sh -c 'curl -k -o /tmp/${devFileName}-devfile.yaml ${clusterURL}'` + `oc exec -i ${podName} -n ${BASE_TEST_CONSTANTS.TS_PLATFORM}-${BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()} -c ${containerName} -- sh -c 'curl -o /tmp/${devFileName}-devfile.yaml ${clusterURL}'` ); return this.getShellExecutor() .executeArbitraryShellScript(