Skip to content

Commit

Permalink
fix: update utils
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <[email protected]>

Signed-off-by: mdolhalo <[email protected]>
  • Loading branch information
mdolhalo committed Oct 30, 2023
1 parent bd87e08 commit f2e5273
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 9 deletions.
7 changes: 5 additions & 2 deletions tests/e2e/configs/sh-scripts/runFunctionalTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ launchAllTests() {
echo ""
echo "Launching all tests for $TEST_ENVIRONMENT"
echo ""
launchDynamicallyGeneratingAPITests
launchAPITests
# launchDynamicallyGeneratingAPITests
# launchAPITests
launchUITests
}

Expand All @@ -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'}
Expand All @@ -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}"
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/constants/BASE_TEST_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/specs/MochaHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
if (!BASE_TEST_CONSTANTS.TS_DEBUG_MODE && CHROME_DRIVER_CONSTANTS.TS_USE_WEB_DRIVER_FOR_TEST) {
// ensure that fired events done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -73,7 +74,11 @@ suite(`DevConsole Integration ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function
});

test('Login', async function (): Promise<void> {
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<void> {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/utils/workspace/ITestWorkspaceUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

0 comments on commit f2e5273

Please sign in to comment.