Skip to content
Snippets Groups Projects
Commit 2730479d authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6592: Introduce main-tests as app-variation in admin. Generalize run-tests.sh.

parent d3e517a6
No related branches found
No related tags found
No related merge requests found
......@@ -243,7 +243,7 @@ pipeline {
// failFast false
// parallel {
stage('E2E-EA') {
stage('E2E-Alfa-EA') {
when {
expression { !SKIP_RUN }
}
......@@ -268,13 +268,13 @@ pipeline {
}
always {
script {
publishE2ETestResult("einheitlicher-ansprechpartner", "Alfa E2E-Tests EA")
publishAlfaE2ETestResult("einheitlicher-ansprechpartner", "Alfa E2E-Tests EA")
}
}
}
}
stage('E2E-Main') {
stage('E2E-Alfa-Main') {
when {
expression { !SKIP_RUN }
}
......@@ -299,7 +299,37 @@ pipeline {
}
always {
script {
publishE2ETestResult("main-tests", "Alfa E2E-Tests main")
publishAlfaE2ETestResult("main-tests", "Alfa E2E-Tests main")
}
}
}
}
stage('E2E-Admin-Main') {
when {
expression { !SKIP_RUN }
}
steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
script {
def bezeichner = env.MAIN_BEZEICHNER
Integer mongoDbPort = forwardMongoDbPort(generateNamespace(bezeichner))
runTests(bezeichner, 'main-tests', mongoDbPort, env.STAGE_NAME)
stopForwardMongoDbPort(generateNamespace(bezeichner))
}
}
}
post {
failure {
script {
FAILED_PARALLEL_STAGE += "${env.STAGE_NAME} "
}
}
always {
script {
publishAdminE2ETestResult("main-tests", "Admin E2E-Tests main")
}
}
}
......@@ -547,6 +577,8 @@ Void waitForRollout(String bezeichner) {
waitForHealthyApplication(bezeichner, 'vorgang-manager')
waitForHealthyApplication(bezeichner, 'user-manager')
waitForHealthyApplication(bezeichner, 'alfa')
waitForHealthyApplication(bezeichner, 'administration')
waitForHealthyApplication(bezeichner, 'admin-client')
}
Void waitForHealthyApplication(String bezeichner, String application) {
......@@ -580,13 +612,21 @@ Void waitForHealthyStatus(String bezeichner, String application) {
sh "kubectl wait --for=jsonpath='{.status.health.status}'=Healthy applications/by-${bezeichner}-dev-${application} -n argocd --timeout=900s"
}
Void publishE2ETestResult(String reportFolder, String reportName) {
Void publishAlfaE2ETestResult(String reportFolder, String reportName) {
publishE2ETestResult2("alfa-client/apps/alfa-e2e/reports/${reportFolder}", reportName)
}
Void publishAdminE2ETestResult(String reportFolder, String reportName) {
publishE2ETestResult2("alfa-client/apps/admin-e2e/reports/${reportFolder}", reportName)
}
Void publishE2ETestResult2(String reportDir, String reportName) {
publishHTML (
target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: "alfa-client/apps/alfa-e2e/reports/${reportFolder}",
reportDir: ${reportDir},
reportFiles: 'report.html',
reportName: reportName
]
......
......@@ -19,7 +19,7 @@
"reporterOptions": {
"html": false,
"json": true,
"reportDir": "./reports/mochawesome-report",
"reportDir": "./reports/main-tests/mochawesome-report",
"reportFilename": "report",
"overwrite": true
}
......
import { HeaderE2EComponent } from '../../page-objects/header.po';
import { MainPage } from '../../page-objects/main.po';
import { reload } from '../../support/cypress-helper';
import { exist } from '../../support/cypress.util';
import { loginByUi } from '../../support/user-util';
import { HeaderE2EComponent } from '../../../page-objects/header.po';
import { MainPage } from '../../../page-objects/main.po';
import { reload } from '../../../support/cypress-helper';
import { exist } from '../../../support/cypress.util';
import { loginByUi } from '../../../support/user-util';
describe('Login and Logout', () => {
const mainPage: MainPage = new MainPage();
......
import { HeaderE2EComponent } from '../../page-objects/header.po';
import { MainPage } from '../../page-objects/main.po';
import { exist } from '../../support/cypress.util';
import { loginAsAriane } from '../../support/user-util';
import { HeaderE2EComponent } from '../../../page-objects/header.po';
import { MainPage } from '../../../page-objects/main.po';
import { exist } from '../../../support/cypress.util';
import { loginAsAriane } from '../../../support/user-util';
const mainPage: MainPage = new MainPage();
const header: HeaderE2EComponent = mainPage.getHeader();
......
......@@ -34,7 +34,7 @@
"reporterOptions": {
"html": false,
"json": true,
"reportDir": "./reports/mochawesome-report",
"reportDir": "./reports/main-tests/mochawesome-report",
"reportFilename": "report",
"overwrite": true
}
......
#!/bin/bash
export NO_COLOR=1
REPORT_FOLDER=$1
CONFIG_FILE="${2:-cypress.config.ts}"
SUITE_NAME="${3:-alfa-e2e}"
if [ $# -eq 0 ]; then
>&2 echo "This script is for Jenkins Execution of E2E-Tests"
>&2 echo "Example: ./run-tests.sh admin-e2e main-tests cypress.config.ts"
exit 1
fi
APP_NAME="${1:-alfa-e2e}"
APP_VARIATION="${2:-main-tests}"
CONFIG_FILE="${3:-cypress.config.ts}"
if [ -z $REPORT_FOLDER ]; then echo "Report Folder not set" && exit 1; fi
if [ -z $APP_NAME ]; then echo "App Folder not set" && exit 1; fi
if [ -z $APP_VARIATION ]; then echo "Variation Name not set" && exit 1; fi
if [ -z $CONFIG_FILE ]; then echo "Config File not set" && exit 1; fi
if [ -z $SUITE_NAME ]; then echo "Suite Name not set" && exit 1; fi
BASE_PATH=${SUITE_NAME}
REPORT_BASE_PATH=${BASE_PATH}/reports/
FULL_REPORT_PATH=${REPORT_BASE_PATH}${REPORT_FOLDER}
MOCHA_REPORT_PATH=${FULL_REPORT_PATH}/mochawesome-report/
MOCHA_REPORT_JSONS=${MOCHA_REPORT_PATH}.jsons
MOCHA_REPORT_FILE=${MOCHA_REPORT_PATH}report.json
echo "Run E2E for ${REPORT_FOLDER} with configuration ${BASE_PATH}/$CONFIG_FILE..."
BASE_PATH=${APP_NAME}
SPEC_GROUP=${BASE_PATH}/src/e2e/${APP_VARIATION}
COMMAND="npx cypress run --project ${BASE_PATH} --spec ${SPEC_GROUP} --config-file ${CONFIG_FILE}"
REPORT_PATH=${BASE_PATH}/reports/${APP_VARIATION}
rm -rf ${FULL_REPORT_PATH}
echo "Run E2E for ${APP_NAME} with command: '$COMMAND'"
npx cypress run --project ${BASE_PATH} --spec ${BASE_PATH}/src/e2e/${REPORT_FOLDER} --config-file $CONFIG_FILE
rm -rf ${REPORT_PATH}
eval $COMMAND
TEST_RESULT=$?
if [ -d "${MOCHA_REPORT_JSONS}" ]; then
if [ -d "${REPORT_PATH}" ]; then
MOCHA_REPORT_PATH=${REPORT_PATH}/mochawesome-report/
MOCHA_REPORT_JSONS=${MOCHA_REPORT_PATH}.jsons
MOCHA_REPORT_FILE=${MOCHA_REPORT_PATH}report.json
mv ${MOCHA_REPORT_JSONS} ${MOCHA_REPORT_PATH}/jsons
npx mochawesome-merge ${MOCHA_REPORT_PATH}**/*.json > ${MOCHA_REPORT_FILE}
# Workaround: mochawesome's "screenshotsFolder" value is not added in the generated HTML file. Add "screenshots" to image paths.
sed --in-place --regexp-extended 's/"([^"]*\.png)/"screenshots\1/' ${MOCHA_REPORT_FILE}
npx marge ${MOCHA_REPORT_FILE} -f report -o ${FULL_REPORT_PATH}
npx marge ${MOCHA_REPORT_FILE} -f report -o ${REPORT_PATH}
else
echo "ERROR: Reports do not exist at ${MOCHA_REPORT_JSONS}"
echo "ERROR: Reports do not exist at ${REPORT_PATH}"
fi
exit $TEST_RESULT
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment