Skip to content

Commit 36ecc36

Browse files
authored
[Test] Adapt Podman tests to airgap disconnected cluster (#23407)
BuildPushRunPodmanContainerAPI & KubedockPodmanTest now use dockerfile-hello-world from internal and public github repositories Added TS_SELENIUM_AIRGAP_FACTORY_GIT_REPO_URL environment variable to support factory URLs specifically for disconnected environments Signed-off-by: Martin Szuc <mszuc@redhat.com>
1 parent fd9242b commit 36ecc36

3 files changed

Lines changed: 47 additions & 15 deletions

File tree

tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export enum GitProviderType {
2020

2121
export const FACTORY_TEST_CONSTANTS: {
2222
TS_SELENIUM_FACTORY_GIT_REPO_URL: string;
23+
TS_SELENIUM_AIRGAP_FACTORY_GIT_REPO_URL: string;
2324
TS_SELENIUM_PROJECT_NAME: string;
2425
TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO: boolean;
2526
TS_SELENIUM_FACTORY_GIT_PROVIDER: string;
@@ -36,6 +37,11 @@ export const FACTORY_TEST_CONSTANTS: {
3637
*/
3738
TS_SELENIUM_FACTORY_GIT_REPO_URL: process.env.TS_SELENIUM_FACTORY_GIT_REPO_URL || '',
3839

40+
/**
41+
* url to create factory for airgap/disconnected environments
42+
*/
43+
TS_SELENIUM_AIRGAP_FACTORY_GIT_REPO_URL: process.env.TS_SELENIUM_AIRGAP_FACTORY_GIT_REPO_URL || '',
44+
3945
/**
4046
* git repository name
4147
*/

tests/e2e/specs/api/BuildPushRunPodmanContainerAPI.spec.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { ShellString } from 'shelljs';
2121
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
2222
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
2323
import { ShellExecutor } from '../../utils/ShellExecutor';
24+
import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
25+
import { ViewSection } from 'monaco-page-objects';
2426

2527
suite(`Test podman build container functionality ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
2628
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
@@ -37,6 +39,16 @@ suite(`Test podman build container functionality ${BASE_TEST_CONSTANTS.TEST_ENVI
3739
let devSpacesNamespace: string = '';
3840
let cheClusterName: string = '';
3941

42+
/**
43+
* test requires the following files to be present in the workspace root:
44+
* - A Dockerfile named Dockerfile.${ARCH} with content:
45+
* FROM scratch
46+
* COPY hello /hello
47+
* CMD ["/hello"]
48+
* - A compiled 'hello' binary, that prints "Hello from Kubedock!" to output.
49+
*
50+
* Used to build and run a container in a pod for verifying Podman functionality.
51+
*/
4052
const buildPushScript: string = `
4153
export ARCH=$(uname -m)
4254
export DATE=$(date +"%m%d%y")
@@ -45,19 +57,10 @@ export TKN=$(oc whoami -t)
4557
export REG="image-registry.openshift-image-registry.svc:5000"
4658
export PROJECT=$(oc project -q)
4759
export IMG="\${REG}/\${PROJECT}/hello:\${DATE}"
48-
49-
# Create test directory and Dockerfile
50-
mkdir -p /projects/dockerfile-test
51-
cd /projects/dockerfile-test
52-
53-
cat > Dockerfile << EOF
54-
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
55-
RUN echo "Hello from Kubedock!" > /hello.txt
56-
CMD ["cat", "/hello.txt"]
57-
EOF
60+
cd $PROJECT_SOURCE
5861
5962
podman login --tls-verify=false --username "\${USER}" --password "\${TKN}" "\${REG}"
60-
podman build -t "\${IMG}" .
63+
podman build -t "\${IMG}" -f Dockerfile.\${ARCH} .
6164
podman push --tls-verify=false "\${IMG}"
6265
`;
6366

@@ -81,6 +84,11 @@ fi
8184
oc logs test-hello-pod
8285
`;
8386

87+
const factoryUrl: string = BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()
88+
? FACTORY_TEST_CONSTANTS.TS_SELENIUM_AIRGAP_FACTORY_GIT_REPO_URL ||
89+
'https://gh.crw-qe.com/test-automation-only/dockerfile-hello-world'
90+
: FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL || 'https://github.com/crw-qe/dockerfile-hello-world';
91+
8492
suiteSetup('Setup DevSpaces with container build capabilities enabled', function (): void {
8593
kubernetesCommandLineToolsExecutor = e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor);
8694
kubernetesCommandLineToolsExecutor.loginToOcp();
@@ -108,9 +116,8 @@ oc logs test-hello-pod
108116
await loginTests.loginIntoChe();
109117
});
110118

111-
test('Create and open new Empty Workspace', async function (): Promise<void> {
112-
await dashboard.waitPage();
113-
await workspaceHandlingTests.createAndOpenWorkspace('Empty Workspace');
119+
test(`Create and open new workspace from: ${factoryUrl}`, async function (): Promise<void> {
120+
await workspaceHandlingTests.createAndOpenWorkspaceFromGitRepository(factoryUrl);
114121
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
115122
workspaceName = WorkspaceHandlingTests.getWorkspaceName();
116123
expect(workspaceName, 'Workspace name was not detected').not.empty;
@@ -121,6 +128,11 @@ oc logs test-hello-pod
121128
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
122129
});
123130

131+
test('Check the project files were imported', async function (): Promise<void> {
132+
const projectSection: ViewSection = await projectAndFileTests.getProjectViewSession();
133+
expect(await projectAndFileTests.getProjectTreeItem(projectSection, 'Dockerfile.x86_64'), 'Dockerfile not found in the project tree').not.undefined;
134+
});
135+
124136
test('Build and push container image from workspace', function (): void {
125137
kubernetesCommandLineToolsExecutor = e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor);
126138
kubernetesCommandLineToolsExecutor.workspaceName = workspaceName;

tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ShellString } from 'shelljs';
2121
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
2222
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
2323
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
24+
import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
2425

2526
suite(
2627
`Check possibility to manage containers within a workspace with kubedock and podman ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
@@ -35,6 +36,16 @@ suite(
3536
let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor;
3637
let workspaceName: string = '';
3738

39+
/**
40+
* test requires the following files to be present in the workspace root:
41+
* - A Dockerfile named Dockerfile.${ARCH} with content:
42+
* FROM scratch
43+
* COPY hello /hello
44+
* CMD ["/hello"]
45+
* - A compiled 'hello' binary, that prints "Hello from Kubedock!" to output.
46+
*
47+
* Used to build and run a container in a pod for verifying Podman functionality.
48+
*/
3849
const testScript: string =
3950
'# Enable Kubedock\n' +
4051
'export KUBEDOCK_ENABLED=true\n' +
@@ -66,7 +77,10 @@ suite(
6677
'podman login --tls-verify=false --username ${USER} --password ${TKN} ${REG}\n' +
6778
'podman run --rm ${IMG}';
6879

69-
const factoryUrl: string = 'https://github.com/crw-qe/dockerfile-hello-world';
80+
const factoryUrl: string = BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()
81+
? FACTORY_TEST_CONSTANTS.TS_SELENIUM_AIRGAP_FACTORY_GIT_REPO_URL ||
82+
'https://gh.crw-qe.com/test-automation-only/dockerfile-hello-world'
83+
: FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL || 'https://github.com/crw-qe/dockerfile-hello-world';
7084

7185
suiteSetup('Login', async function (): Promise<void> {
7286
await loginTests.loginIntoChe();

0 commit comments

Comments
 (0)