@@ -21,6 +21,8 @@ import { ShellString } from 'shelljs';
2121import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil' ;
2222import { Dashboard } from '../../pageobjects/dashboard/Dashboard' ;
2323import { ShellExecutor } from '../../utils/ShellExecutor' ;
24+ import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS' ;
25+ import { ViewSection } from 'monaco-page-objects' ;
2426
2527suite ( `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 = `
4153export ARCH=$(uname -m)
4254export DATE=$(date +"%m%d%y")
@@ -45,19 +57,10 @@ export TKN=$(oc whoami -t)
4557export REG="image-registry.openshift-image-registry.svc:5000"
4658export PROJECT=$(oc project -q)
4759export 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
5962podman login --tls-verify=false --username "\${USER}" --password "\${TKN}" "\${REG}"
60- podman build -t "\${IMG}" .
63+ podman build -t "\${IMG}" -f Dockerfile.\${ARCH} .
6164podman push --tls-verify=false "\${IMG}"
6265` ;
6366
8184oc 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 ;
0 commit comments