diff --git a/tests/e2e/configs/sh-scripts/runFunctionalTests.sh b/tests/e2e/configs/sh-scripts/runFunctionalTests.sh index 576424978bb4..f6cce401b254 100755 --- a/tests/e2e/configs/sh-scripts/runFunctionalTests.sh +++ b/tests/e2e/configs/sh-scripts/runFunctionalTests.sh @@ -44,8 +44,8 @@ launchAllTests() { echo "" echo "Launching all tests for $TEST_ENVIRONMENT" echo "" - launchDynamicallyGeneratingAPITests - launchAPITests + # launchDynamicallyGeneratingAPITests + # launchAPITests launchUITests } @@ -61,6 +61,7 @@ initTestValues() { export TEST_ENVIRONMENT="$OCP_INFRA $MOCHA_DIRECTORY $OCP_VERSION" export DELETE_WORKSPACE_ON_FAILED_TEST=${DELETE_WORKSPACE_ON_FAILED_TEST:-'false'} + export DELETE_ALL_WORKSPACES_ON_RUN_FINISH=${DELETE_ALL_WORKSPACES_ON_RUN_FINISH:-'true'} export DELETE_SCREENCAST_IF_TEST_PASS=${DELETE_SCREENCAST_IF_TEST_PASS:-'true'} export NODE_TLS_REJECT_UNAUTHORIZED=${NODE_TLS_REJECT_UNAUTHORIZED:-'0'} export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=${TS_OCP_LOGIN_PAGE_PROVIDER_TITLE:-'htpasswd'} @@ -77,9 +78,11 @@ initTestValues() { export MOCHA_BAIL=${MOCHA_BAIL:-'false'} export MOCHA_RETRIES=${MOCHA_RETRIES:-'1'} + echo "TS_SELENIUM_BASE_URL=${TS_SELENIUM_BASE_URL}" echo "TEST_ENVIRONMENT=${TEST_ENVIRONMENT}" echo "DELETE_WORKSPACE_ON_FAILED_TEST=${DELETE_WORKSPACE_ON_FAILED_TEST}" + echo "DELETE_ALL_WORKSPACES_ON_RUN_FINISH=${DELETE_ALL_WORKSPACES_ON_RUN_FINISH}" echo "DELETE_SCREENCAST_IF_TEST_PASS=${DELETE_SCREENCAST_IF_TEST_PASS}" echo "NODE_TLS_REJECT_UNAUTHORIZED=${NODE_TLS_REJECT_UNAUTHORIZED}" echo "TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=${TS_OCP_LOGIN_PAGE_PROVIDER_TITLE}" diff --git a/tests/e2e/constants/BASE_TEST_CONSTANTS.ts b/tests/e2e/constants/BASE_TEST_CONSTANTS.ts index 8ab1ceb44418..585fd80b7da4 100644 --- a/tests/e2e/constants/BASE_TEST_CONSTANTS.ts +++ b/tests/e2e/constants/BASE_TEST_CONSTANTS.ts @@ -13,6 +13,7 @@ export enum Platform { } export const BASE_TEST_CONSTANTS: { + DELETE_ALL_WORKSPACES_ON_RUN_FINISH: boolean; OCP_INFRA: string; DELETE_WORKSPACE_ON_FAILED_TEST: boolean; IS_CLUSTER_DISCONNECTED: () => boolean; @@ -125,6 +126,11 @@ export const BASE_TEST_CONSTANTS: { */ DELETE_WORKSPACE_ON_FAILED_TEST: process.env.DELETE_WORKSPACE_ON_FAILED_TEST === 'true', + /** + * stop and remove all workspaces on test run finish + */ + DELETE_ALL_WORKSPACES_ON_RUN_FINISH: process.env.DELETE_WORKSPACE_ON_FAILED_TEST === 'true', + /** * constant, which prolong timeout constants for local debug. */ diff --git a/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts b/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts index 1f4be0791622..8a096148292b 100644 --- a/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +++ b/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts @@ -101,7 +101,7 @@ export class WorkspaceDetails { await this.clickOnOpenButton(timeout); await this.testProjectAndFileCheCode.waitWorkspaceReadinessForCheCodeEditor(); - this.testWorkspaceUtil.waitWorkspaceStatus(namespace, workspaceName, WorkspaceStatus.STARTING); + this.testWorkspaceUtil.waitWorkspaceStatus(workspaceName, WorkspaceStatus.STARTING); } async waitTabsPresence(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { diff --git a/tests/e2e/specs/MochaHooks.ts b/tests/e2e/specs/MochaHooks.ts index e16d597c6156..82c088150262 100644 --- a/tests/e2e/specs/MochaHooks.ts +++ b/tests/e2e/specs/MochaHooks.ts @@ -126,6 +126,19 @@ exports.mochaHooks = { ], afterAll: [ // stop and remove running workspace + function deleteAllWorkspacesOnFinish(): void { + if (BASE_TEST_CONSTANTS.DELETE_ALL_WORKSPACES_ON_RUN_FINISH) { + Logger.info( + 'Property DELETE_WORKSPACE_ON_FAILED_TEST is true - trying to stop and delete all running workspace after test run with API.' + ); + const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); + try { + testWorkspaceUtil.stopAndDeleteAllRunningWorkspaces(); + } catch (e) { + Logger.trace('Running workspaces not found'); + } + } + }, async function stopTheDriver(): Promise { if (!BASE_TEST_CONSTANTS.TS_DEBUG_MODE && CHROME_DRIVER_CONSTANTS.TS_USE_WEB_DRIVER_FOR_TEST) { // ensure that fired events done diff --git a/tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts b/tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts index 6e3f3c17a16c..856c1797d90f 100644 --- a/tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +++ b/tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts @@ -24,6 +24,7 @@ import { OcpApplicationPage } from '../../pageobjects/openshift/OcpApplicationPa import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; +import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS'; suite(`DevConsole Integration ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void { let ocpImportPage: OcpImportFromGitPage; @@ -73,7 +74,11 @@ suite(`DevConsole Integration ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function }); test('Login', async function (): Promise { - await loginTests.loginIntoChe(); + try { + await dashboard.waitLoader(TIMEOUT_CONSTANTS.TS_WAIT_LOADER_PRESENCE_TIMEOUT); + } catch (e) { + await loginTests.loginIntoChe(); + } }); test('Obtain workspace name from workspace loader page', async function (): Promise { diff --git a/tests/e2e/utils/Logger.ts b/tests/e2e/utils/Logger.ts index 1431dadcf148..36d1c302820d 100644 --- a/tests/e2e/utils/Logger.ts +++ b/tests/e2e/utils/Logger.ts @@ -150,7 +150,7 @@ export class Logger { private static isRootCaller(traceLevel: number = 6): boolean { return this.getCallStackArray() - .slice(traceLevel, traceLevel + 2) + .slice(traceLevel, traceLevel + 3) .reduce((acc, e): boolean => { return acc || /MochaHooks|CheReporter/.test(e); }, false); diff --git a/tests/e2e/utils/workspace/ITestWorkspaceUtil.ts b/tests/e2e/utils/workspace/ITestWorkspaceUtil.ts index 676bc71f823c..533192c2a99f 100644 --- a/tests/e2e/utils/workspace/ITestWorkspaceUtil.ts +++ b/tests/e2e/utils/workspace/ITestWorkspaceUtil.ts @@ -11,7 +11,7 @@ import { WorkspaceStatus } from './WorkspaceStatus'; export interface ITestWorkspaceUtil { - waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus): void; + waitWorkspaceStatus(workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus): void; stopWorkspaceByName(workspaceName: string): void; @@ -28,16 +28,16 @@ export interface ITestWorkspaceUtil { /** * stop all run workspaces in the namespace */ - stopAllRunningWorkspaces(namespace: string): void; + stopAllRunningWorkspaces(): void; /** * stop all run workspaces, check statused and remove the workspaces */ - stopAndDeleteAllRunningWorkspaces(namespace: string): void; + stopAndDeleteAllRunningWorkspaces(): void; /** * stop all run workspaces without stopping and waiting for of 'Stopped' phase * Similar with 'force' deleting */ - deleteAllWorkspaces(namespace: string): void; + deleteAllWorkspaces(): void; }