diff --git a/tests/e2e/specs/dashboard-samples/Documentation.spec.ts b/tests/e2e/specs/dashboard-samples/Documentation.spec.ts index ee292976ae1..a256474cc49 100644 --- a/tests/e2e/specs/dashboard-samples/Documentation.spec.ts +++ b/tests/e2e/specs/dashboard-samples/Documentation.spec.ts @@ -38,17 +38,10 @@ suite('Check links to documentation page in Dashboard.', function (): void { const workspaceDetails: WorkspaceDetails = e2eContainer.get(CLASSES.WorkspaceDetails); const shellExecutor: ShellExecutor = e2eContainer.get(CLASSES.ShellExecutor); const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); - const testingVersion: string = BASE_TEST_CONSTANTS.TESTING_APPLICATION_VERSION; let parentGUID: string = ''; - - // get links from product version github branch - const { docs, links, productVersion }: any = JSON.parse( - shellExecutor.curl( - `https://raw.githubusercontent.com/redhat-developer/devspaces-images/devspaces-${testingVersion}-rhel-8/devspaces-dashboard/packages/dashboard-frontend/assets/branding/product.json` - ) - ); - const { webSocketTroubleshooting, workspace, devfile, general, storageTypes } = docs; + let docs: any, links: any, productVersion: any; + let webSocketTroubleshooting: any, workspace: any, devfile: any, general: any, storageTypes: any; suiteSetup('Login into OC client and apply default DevFile', function (): void { kubernetesCommandLineToolsExecutor.loginToOcp(); @@ -56,6 +49,15 @@ suite('Check links to documentation page in Dashboard.', function (): void { shellExecutor.wait(5); }); + suiteSetup('Get links from product version github branch', function (): void { + ({ docs, links, productVersion } = JSON.parse( + shellExecutor.curl( + `https://raw.githubusercontent.com/redhat-developer/devspaces-images/devspaces-${testingVersion}-rhel-8/devspaces-dashboard/packages/dashboard-frontend/assets/branding/product.json` + ) + )); + ({ webSocketTroubleshooting, workspace, devfile, general, storageTypes } = docs); + }); + suiteTeardown('Delete default DevWorkspace', function (): void { kubernetesCommandLineToolsExecutor.deleteDevWorkspace(); }); diff --git a/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts b/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts new file mode 100644 index 00000000000..6da46f31dc7 --- /dev/null +++ b/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts @@ -0,0 +1,92 @@ +/** ******************************************************************* + * 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 + **********************************************************************/ +import { SideBarView, ViewSection } from 'monaco-page-objects'; +import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; +import { CLASSES } 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'; + +suite('Check possibility to manage containers within a workspace with kubedock and podman', 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); + let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor; + let workspaceName: string = ''; + + const testScript: string = + '# Enable Kubedock\n' + + 'export KUBEDOCK_ENABLED=true\n' + + 'echo KUBEDOCK_ENABLED\n' + + '/entrypoint.sh\n' + + 'cd $PROJECT_SOURCE\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"\n' + + 'podman login --tls-verify=false --username ${USER} --password ${TKN} ${REG}\n' + + 'podman build -t ${IMG} .\n' + + 'podman push --tls-verify=false ${IMG}\n' + + 'podman run --rm ${IMG}'; + + const factoryUrl: string = 'https://github.com/l0rd/dockerfile-hello-world'; + + 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 new SideBarView().getContent().getSections(); + expect(await projectSection.findItem('Dockerfile'), 'Files not imported').not.undefined; + }); + + test('Create and check container runs using kubedock and podman', function (): void { + kubernetesCommandLineToolsExecutor = e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor); + kubernetesCommandLineToolsExecutor.workspaceName = workspaceName; + kubernetesCommandLineToolsExecutor.loginToOcp(); + kubernetesCommandLineToolsExecutor.getPodAndContainerNames(); + const output: ShellString = kubernetesCommandLineToolsExecutor.executeCommand(testScript); + expect(output, 'Podman test script failed').contains('Hello from Kubedock!'); + }); + + test('Stop the workspace', async function (): Promise { + await workspaceHandlingTests.stopWorkspace(workspaceName); + await browserTabsUtil.closeAllTabsExceptCurrent(); + }); + + test('Delete the workspace', async function (): Promise { + await workspaceHandlingTests.removeWorkspace(workspaceName); + }); + + loginTests.logoutFromChe(); +});