Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRW-4656 Create automated test for the podman run scenario #22541

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions tests/e2e/specs/dashboard-samples/Documentation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,26 @@ 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();
kubernetesCommandLineToolsExecutor.applyYamlConfigurationAsFile(pathToSampleFile);
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();
});
Expand Down
92 changes: 92 additions & 0 deletions tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
await workspaceHandlingTests.createAndOpenWorkspaceFromGitRepository(factoryUrl);
});

test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
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<void> {
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
});

test('Check the project files were imported', async function (): Promise<void> {
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!');
dmytro-ndp marked this conversation as resolved.
Show resolved Hide resolved
});

test('Stop the workspace', async function (): Promise<void> {
await workspaceHandlingTests.stopWorkspace(workspaceName);
await browserTabsUtil.closeAllTabsExceptCurrent();
});

test('Delete the workspace', async function (): Promise<void> {
await workspaceHandlingTests.removeWorkspace(workspaceName);
});

loginTests.logoutFromChe();
});
Loading