Skip to content

Commit

Permalink
feat: reportportal integration
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <[email protected]>
  • Loading branch information
mdolhalo committed Oct 18, 2023
1 parent a90153c commit bf06c39
Show file tree
Hide file tree
Showing 15 changed files with 437 additions and 60 deletions.
3 changes: 2 additions & 1 deletion tests/e2e/configs/mocharc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ module.exports = {
timeout: MOCHA_CONSTANTS.MOCHA_DEFAULT_TIMEOUT,
slow: 60000,
reporter: 'mocha-multi-reporters',
reporterOptions: 'configFile=configs/reporters-config.json',
reporterOptions: 'configFile=configs/reporters.config.js',
ui: 'tdd',
extension: ['js', 'cjs', 'mjs'],
require: ['dist/specs/MochaHooks.js', 'ts-node/register'],
bail: MOCHA_CONSTANTS.MOCHA_BAIL,
'full-trace': true,
Expand Down
6 changes: 0 additions & 6 deletions tests/e2e/configs/reporters-config.json

This file was deleted.

42 changes: 42 additions & 0 deletions tests/e2e/configs/reporters.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** *******************************************************************
* 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
**********************************************************************/
const { REPORTER_CONSTANTS } = require('../constants/REPORTER_CONSTANTS');
const { BASE_TEST_CONSTANTS } = require('../constants/BASE_TEST_CONSTANTS');

module.exports = {
reporterEnabled: REPORTER_CONSTANTS.REPORTERS_ENABLED(),
allureMochaReporterOptions: {
resultsDir: '.allure-results'
},
reportportalAgentJsMochaReporterOptions: {
apiKey: REPORTER_CONSTANTS.RP_API_KEY,
endpoint: REPORTER_CONSTANTS.PR_ENDPOINT(),
project: REPORTER_CONSTANTS.RP_PROJECT(),
launch: `${REPORTER_CONSTANTS.RP_LAUNCH_NAME}`,
attributes: [
{
key: 'build',
value: `${BASE_TEST_CONSTANTS.TESTING_APPLICATION_VERSION}`
},
{
value: BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME()
},
{
key: 'url',
value: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL
}
],
rerun: REPORTER_CONSTANTS.RP_RERUN(),
rerunOf: REPORTER_CONSTANTS.RP_RERUN_UUID,
restClientConfig: {
timeout: 1200000
}
}
};
12 changes: 12 additions & 0 deletions tests/e2e/constants/BASE_TEST_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const BASE_TEST_CONSTANTS: {
TS_SELENIUM_PROJECT_ROOT_FILE_NAME: string;
TS_SELENIUM_REQUEST_INTERCEPTOR: boolean;
TS_SELENIUM_RESPONSE_INTERCEPTOR: boolean;
TESTING_APPLICATION_NAME: () => string;
} = {
/**
* base URL of the application which should be checked
Expand All @@ -51,6 +52,17 @@ export const BASE_TEST_CONSTANTS: {
*/
TEST_ENVIRONMENT: process.env.TEST_ENVIRONMENT || '',

/**
* application name (DevSpaces or Che)
*/
TESTING_APPLICATION_NAME: (): string => {
return BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces')
? 'devspaces'
: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che')
? 'che'
: 'default';
},

/**
* testing application version
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/constants/MOCHA_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const MOCHA_CONSTANTS: {

MOCHA_DELAYED_SUITE: process.env.MOCHA_DELAYED_SUITE === 'true',

MOCHA_DEFAULT_TIMEOUT: process.env.MOCHA_DEFAULT_TIMEOUT || 420000,
MOCHA_DEFAULT_TIMEOUT: Number(process.env.MOCHA_DEFAULT_TIMEOUT) || 420000,

MOCHA_RETRIES: process.env.MOCHA_RETRIES || BASE_TEST_CONSTANTS.TEST_ENVIRONMENT === '' ? 0 : 2,

Expand Down
103 changes: 98 additions & 5 deletions tests/e2e/constants/REPORTER_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,28 @@
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { BASE_TEST_CONSTANTS } from './BASE_TEST_CONSTANTS';

export const REPORTER_CONSTANTS: {
DELETE_SCREENCAST_IF_TEST_PASS: boolean;
RP_ENDPOINT(): string;
RP_IS_LOCAL_SERVER: boolean;
REPORTERS_ENABLED(): string;
RP_API_KEY: string;
RP_PROJECT(): string;
RP_RERUN(): boolean;
RP_RERUN_UUID: string | undefined;
RP_LAUNCH_NAME: string;
RP_USER: string;
RP_USE_PERSONAL: boolean;
SAVE_ALLURE_REPORT_DATA: boolean;
SAVE_RP_REPORT_DATA: boolean;
TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS: number;
TS_SELENIUM_REPORT_FOLDER: string;
TS_SELENIUM_EXECUTION_SCREENCAST: boolean;
TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: string | boolean;
TS_SELENIUM_LOAD_TEST_REPORT_FOLDER: string;
TS_SELENIUM_LOG_LEVEL: string;
DELETE_SCREENCAST_IF_TEST_PASS: boolean;
TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: string | boolean;
TS_SELENIUM_REPORT_FOLDER: string;
} = {
/**
* path to folder with load tests execution report.
Expand Down Expand Up @@ -44,10 +58,89 @@ export const REPORTER_CONSTANTS: {
/**
* log level settings, possible variants: 'INFO' (by default), 'DEBUG', 'TRACE'.
*/
TS_SELENIUM_LOG_LEVEL: process.env.TS_SELENIUM_LOG_LEVEL || 'INFO',
TS_SELENIUM_LOG_LEVEL: process.env.TS_SELENIUM_LOG_LEVEL || 'TRACE',

/**
* print all timeout variables when tests launch, default to false
*/
TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: process.env.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES || false
TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: process.env.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES === 'true',

/**
* use local Allure reporter, default to false
*/
SAVE_ALLURE_REPORT_DATA: process.env.SAVE_ALLURE_REPORT_DATA === 'true',

/**
* use ReportPortal reporter, default to true
*/
SAVE_RP_REPORT_DATA: process.env.SAVE_RP_REPORT_DATA === 'true',

/**
* list of enabler reporters
*/
REPORTERS_ENABLED: (): string => {
let reporters: string = 'dist/utils/CheReporter.js';
if (REPORTER_CONSTANTS.SAVE_ALLURE_REPORT_DATA) {
reporters += ',allure-mocha';
}
if (REPORTER_CONSTANTS.SAVE_RP_REPORT_DATA) {
reporters += ',@reportportal/agent-js-mocha';
}
return reporters;
},

/**
* reportPortal app key or user token
*/
RP_API_KEY: process.env.RP_API_KEY || '',

/**
* user name on ReportPortal
*/
RP_USER: process.env.RP_USER || process.env.USER || 'superadmin',

/**
* launch name to save report
*/
RP_LAUNCH_NAME: process.env.RP_LAUNCH_NAME || 'Test run',

/**
* launch name to save report
*/
RP_RERUN_UUID: process.env.RP_RERUN_UUID || undefined,

/**
* is launch rerun
*/
RP_RERUN: (): boolean => !!REPORTER_CONSTANTS.RP_RERUN_UUID,

/**
* is local or online server to use
*/
RP_IS_LOCAL_SERVER: process.env.RP_IS_LOCAL_SERVER !== 'false',

/**
* url with endpoints where ReportPortal is
*/
RP_ENDPOINT: (): string => {
return process.env.RP_ENDPOINT || REPORTER_CONSTANTS.RP_IS_LOCAL_SERVER
? 'http://localhost:8080/api/v1'
: 'https://reportportal-crw.apps.ocp-c1.prod.psi.redhat.com/api/v1';
},

/**
* use personal project to save launch, if false launch will be send to devspaces or che project, true by default
*/
RP_USE_PERSONAL: process.env.RP_USE_PERSONAL !== 'false',

/**
* project name to save launch
*/
RP_PROJECT: (): string => {
const project: string =
BASE_TEST_CONSTANTS.TEST_ENVIRONMENT !== '' && REPORTER_CONSTANTS.RP_USE_PERSONAL
? `${REPORTER_CONSTANTS.RP_USER}_personal`
: BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME();
return process.env.RP_PROJECT || project;
}
};
32 changes: 10 additions & 22 deletions tests/e2e/constants/TIMEOUT_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
export const TIMEOUT_CONSTANTS: {
TS_FIND_EXTENSION_TEST_TIMEOUT: number;
TS_SELENIUM_WORKSPACE_STATUS_POLLING: number;
TS_CLICK_DASHBOARD_ITEM_TIMEOUT: number;
TS_COMMON_DASHBOARD_WAIT_TIMEOUT: number;
TS_EXPAND_PROJECT_TREE_ITEM_TIMEOUT: number;
TS_DIALOG_WINDOW_DEFAULT_TIMEOUT: number;
TS_COMMON_PLUGIN_TEST_TIMEOUT: number;
TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT: number;
TS_DIALOG_WINDOW_DEFAULT_TIMEOUT: number;
TS_EDITOR_TAB_INTERACTION_TIMEOUT: number;
TS_EXPAND_PROJECT_TREE_ITEM_TIMEOUT: number;
TS_FIND_EXTENSION_TEST_TIMEOUT: number;
TS_IDE_LOAD_TIMEOUT: number;
TS_SELENIUM_CLICK_ON_VISIBLE_ITEM: number;
TS_SELENIUM_DEFAULT_ATTEMPTS: number;
TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS: number;
TS_SELENIUM_WAIT_FOR_URL: number;
TS_SELENIUM_DEFAULT_POLLING: number;
TS_IDE_LOAD_TIMEOUT: number;
TS_SELENIUM_LOAD_PAGE_TIMEOUT: number;
TS_SELENIUM_START_WORKSPACE_TIMEOUT: number;
TS_SELENIUM_WAIT_FOR_URL: number;
TS_WAIT_LOADER_ABSENCE_TIMEOUT: number;
TS_WAIT_LOADER_PRESENCE_TIMEOUT: number;
TS_SELENIUM_START_WORKSPACE_TIMEOUT: number;
TS_SELENIUM_LOAD_PAGE_TIMEOUT: number;
TS_CLICK_DASHBOARD_ITEM_TIMEOUT: number;
TS_COMMON_PLUGIN_TEST_TIMEOUT: number;
TS_EDITOR_TAB_INTERACTION_TIMEOUT: number;
} = {
/**
* default amount of tries, "5" by default.
Expand All @@ -45,16 +43,6 @@ export const TIMEOUT_CONSTANTS: {
*/
TS_SELENIUM_WAIT_FOR_URL: Number(process.env.TS_SELENIUM_WAIT_FOR_URL) || 10_000,

/**
* amount of tries for checking workspace status.
*/
TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS: Number(process.env.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS) || 90,

/**
* delay in milliseconds between checking workspace status tries.
*/
TS_SELENIUM_WORKSPACE_STATUS_POLLING: Number(process.env.TS_SELENIUM_WORKSPACE_STATUS_POLLING) || 10000,

/**
* wait between workspace started and IDE ready to be used, "20 000" by default.
*/
Expand Down
Loading

0 comments on commit bf06c39

Please sign in to comment.