From baf70730a03334a08e75680daa08e9b6b86a96d8 Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 27 Mar 2026 12:01:40 +0200 Subject: [PATCH 1/3] new KubedockPodmanPersistUserHomeTest e2e test --- .../KubedockPodmanPersistUserHomeTest.spec.ts | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 tests/e2e/specs/miscellaneous/KubedockPodmanPersistUserHomeTest.spec.ts diff --git a/tests/e2e/specs/miscellaneous/KubedockPodmanPersistUserHomeTest.spec.ts b/tests/e2e/specs/miscellaneous/KubedockPodmanPersistUserHomeTest.spec.ts new file mode 100644 index 00000000000..bf1f8b8a28b --- /dev/null +++ b/tests/e2e/specs/miscellaneous/KubedockPodmanPersistUserHomeTest.spec.ts @@ -0,0 +1,162 @@ +/** ******************************************************************* + * copyright (c) 2023 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ + +/** + * p03 - Test image build with spec.devEnvironments.persistUserHome enabled + * + * Prerequisites: + * - Install Dev Spaces with spec.devEnvironments.persistUserHome: true in devspaces CheCluster + * + * Test flow: + * 1. Go to User Dashboard and create workspace from sample + * 2. Open workspace and test image build using kubedock and podman + */ + +import { ViewSection } from 'monaco-page-objects'; +import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; +import { CLASSES, TYPES } from '../../configs/inversify.types'; +import { e2eContainer } from '../../configs/inversify.config'; +import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; +import { registerRunningWorkspace } from '../MochaHooks'; +import { LoginTests } from '../../tests-library/LoginTests'; +import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; +import { expect } from 'chai'; +import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor'; +import { ShellString } from 'shelljs'; +import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; +import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil'; +import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; +import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS'; +import { ShellExecutor } from '../../utils/ShellExecutor'; + +suite(`Test image build with persistUserHome enabled (kubedock and podman) ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void { + const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests); + const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); + const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); + const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); + const shellExecutor: ShellExecutor = e2eContainer.get(CLASSES.ShellExecutor); + const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get( + CLASSES.KubernetesCommandLineToolsExecutor + ); + + let workspaceName: string = ''; + let defaultPersistentHomeValue: boolean = false; + const cheClusterName: string = 'devspaces'; + + const testScript: string = + '# Enable Kubedock\n' + + 'export KUBEDOCK_ENABLED=true\n' + + 'echo KUBEDOCK_ENABLED\n' + + '/entrypoint.sh\n' + + 'cd $PROJECT_SOURCE\n' + + 'export ARCH=$(uname -m)\n' + + 'export DATE=$(date +"%m%d%y")\n' + + 'export USER=$(oc whoami)\n' + + 'export TKN=$(oc whoami -t)\n' + + 'export REG="image-registry.openshift-image-registry.svc:5000"\n' + + 'export PROJECT=$(oc project -q)\n' + + 'export IMG="${REG}/${PROJECT}/hello:${DATE}"\n' + + 'podman login --tls-verify=false --username ${USER} --password ${TKN} ${REG}\n' + + 'podman build -t ${IMG} -f Dockerfile.${ARCH}\n' + + 'podman push --tls-verify=false ${IMG}\n'; + + const runTestScript: string = + '# Enable Kubedock\n' + + 'export KUBEDOCK_ENABLED=true\n' + + 'echo KUBEDOCK_ENABLED\n' + + '/entrypoint.sh\n' + + 'export DATE=$(date +"%m%d%y")\n' + + 'export USER=$(oc whoami)\n' + + 'export TKN=$(oc whoami -t)\n' + + 'export REG="image-registry.openshift-image-registry.svc:5000"\n' + + 'export PROJECT=$(oc project -q)\n' + + 'export IMG="${REG}/${PROJECT}/hello:${DATE}"\n' + + 'podman login --tls-verify=false --username ${USER} --password ${TKN} ${REG}\n' + + 'podman run --rm ${IMG}'; + + const factoryUrl: string = BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED() + ? FACTORY_TEST_CONSTANTS.TS_SELENIUM_AIRGAP_FACTORY_GIT_REPO_URL || + 'https://gh.crw-qe.com/test-automation-only/dockerfile-hello-world' + : FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL || 'https://github.com/crw-qe/dockerfile-hello-world'; + + suiteSetup(function (): void { + kubernetesCommandLineToolsExecutor.loginToOcp(); + shellExecutor.executeCommand('oc project openshift-devspaces'); + + // get current value of spec.devEnvironments.persistUserHome.enabled + const currentValue: string = shellExecutor + .executeCommand(`oc get checluster/${cheClusterName} -o "jsonpath={.spec.devEnvironments.persistUserHome.enabled}"`) + .stdout.trim(); + defaultPersistentHomeValue = currentValue === 'true'; + + // set spec.devEnvironments.persistUserHome.enabled to true + shellExecutor.executeCommand( + `oc patch checluster ${cheClusterName} --type=merge ` + + '-p \'{"spec":{"devEnvironments":{"persistUserHome":{"enabled": true}}}}\'' + ); + }); + + suiteSetup('Login', async function (): Promise { + await loginTests.loginIntoChe(); + }); + + test(`Create and open new workspace from factory:${factoryUrl}`, async function (): Promise { + await workspaceHandlingTests.createAndOpenWorkspaceFromGitRepository(factoryUrl); + }); + + test('Obtain workspace name from workspace loader page', async function (): Promise { + await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); + workspaceName = WorkspaceHandlingTests.getWorkspaceName(); + expect(workspaceName, 'Workspace name was not fetched from the loading page').not.undefined; + }); + + test('Register running workspace', function (): void { + registerRunningWorkspace(workspaceName); + }); + + test('Wait workspace readiness', async function (): Promise { + await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); + }); + + test('Check the project files were imported', async function (): Promise { + const projectSection: ViewSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, 'Dockerfile.ppc64le'), 'Files not imported').not.undefined; + }); + + test('Create and check container runs using kubedock and podman with persistUserHome', function (): void { + kubernetesCommandLineToolsExecutor.workspaceName = workspaceName; + kubernetesCommandLineToolsExecutor.loginToOcp(); + kubernetesCommandLineToolsExecutor.getPodAndContainerNames(); + const output: ShellString = kubernetesCommandLineToolsExecutor.execInContainerCommand(testScript); + expect(output, 'Podman test script failed').contains('Successfully tagged'); + const runOutput: ShellString = kubernetesCommandLineToolsExecutor.execInContainerCommand(runTestScript); + expect(runOutput, 'Podman test script failed').contains('Hello from Kubedock!'); + }); + + suiteTeardown(function (): void { + // restore spec.devEnvironments.persistUserHome.enabled to original value + shellExecutor.executeCommand( + `oc patch checluster ${cheClusterName} --type=merge ` + + `-p '{"spec":{"devEnvironments":{"persistUserHome":{"enabled": ${defaultPersistentHomeValue}}}}}'` + ); + }); + + suiteTeardown('Stop and delete the workspace by API', async function (): Promise { + await dashboard.openDashboard(); + await browserTabsUtil.closeAllTabsExceptCurrent(); + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + }); + + suiteTeardown('Unregister running workspace', function (): void { + registerRunningWorkspace(''); + }); +}); From 434d9719ae05e2471e1827289465e7a43c5e1d9d Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 27 Mar 2026 12:08:48 +0200 Subject: [PATCH 2/3] update copyright --- .../KubedockPodmanPersistUserHomeTest.spec.ts | 15 ++------------- .../miscellaneous/WorkspaceIdleTimeout.spec.ts | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/tests/e2e/specs/miscellaneous/KubedockPodmanPersistUserHomeTest.spec.ts b/tests/e2e/specs/miscellaneous/KubedockPodmanPersistUserHomeTest.spec.ts index bf1f8b8a28b..8bfa2c31913 100644 --- a/tests/e2e/specs/miscellaneous/KubedockPodmanPersistUserHomeTest.spec.ts +++ b/tests/e2e/specs/miscellaneous/KubedockPodmanPersistUserHomeTest.spec.ts @@ -1,5 +1,5 @@ /** ******************************************************************* - * copyright (c) 2023 Red Hat, Inc. + * copyright (c) 2020-2026 Red Hat, Inc. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -8,17 +8,6 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ -/** - * p03 - Test image build with spec.devEnvironments.persistUserHome enabled - * - * Prerequisites: - * - Install Dev Spaces with spec.devEnvironments.persistUserHome: true in devspaces CheCluster - * - * Test flow: - * 1. Go to User Dashboard and create workspace from sample - * 2. Open workspace and test image build using kubedock and podman - */ - import { ViewSection } from 'monaco-page-objects'; import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; import { CLASSES, TYPES } from '../../configs/inversify.types'; @@ -152,7 +141,7 @@ suite(`Test image build with persistUserHome enabled (kubedock and podman) ${BAS suiteTeardown('Stop and delete the workspace by API', async function (): Promise { await dashboard.openDashboard(); - await browserTabsUtil.closeAllTabsExceptCurrent(); + await browserTabsUtil.closeAllTabsExceptCurrent(); await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); }); diff --git a/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts b/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts index 695b4455495..da79b49c094 100644 --- a/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts +++ b/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts @@ -1,5 +1,5 @@ /** ******************************************************************* - * copyright (c) 2020-2023 Red Hat, Inc. + * copyright (c) 2020-2026 Red Hat, Inc. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 From 320afb8134bb983e63a995c264b7f9117d9115d7 Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 27 Mar 2026 12:12:03 +0200 Subject: [PATCH 3/3] update copyright --- tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts b/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts index da79b49c094..695b4455495 100644 --- a/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts +++ b/tests/e2e/specs/miscellaneous/WorkspaceIdleTimeout.spec.ts @@ -1,5 +1,5 @@ /** ******************************************************************* - * copyright (c) 2020-2026 Red Hat, Inc. + * copyright (c) 2020-2023 Red Hat, Inc. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0