From 7e7fc8534bda9583dfd21a4552cea10186e1e278 Mon Sep 17 00:00:00 2001 From: Vu Tong <129731357+tphvu-axonivy@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:50:11 +0700 Subject: [PATCH] Ivyportal -17687-showing-flaky-test-on-result-LE (#1095) - implement shell script to extract flaky result --- .../resources/extractFlakyTests.sh | 8 ++++++++ build/gui-test-new-dashboard/Jenkinsfile | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 AxonIvyPortal/portal-selenium-test/resources/extractFlakyTests.sh diff --git a/AxonIvyPortal/portal-selenium-test/resources/extractFlakyTests.sh b/AxonIvyPortal/portal-selenium-test/resources/extractFlakyTests.sh new file mode 100644 index 00000000000..65c37465c57 --- /dev/null +++ b/AxonIvyPortal/portal-selenium-test/resources/extractFlakyTests.sh @@ -0,0 +1,8 @@ +if grep -q "\[WARNING\] Flakes:" logText.txt; then + + awk '/^\[WARNING\] Flakes:.*$/{flag=1}/^\[ERROR\] Tests run:.*Flakes: [0-9]*$/{print;flag=0}flag' logText.txt > flaky-tests-log.txt + + grep "\[WARNING\]" flaky-tests-log.txt | awk '{print}' > testReport.txt + + exit 0 +fi \ No newline at end of file diff --git a/build/gui-test-new-dashboard/Jenkinsfile b/build/gui-test-new-dashboard/Jenkinsfile index 84f89af3788..df4edc6bcd1 100644 --- a/build/gui-test-new-dashboard/Jenkinsfile +++ b/build/gui-test-new-dashboard/Jenkinsfile @@ -58,6 +58,16 @@ pipeline { echo '====================Execute maven for testing====================' bat "mvn clean test -f AxonIvyPortal/portal-selenium-test/customized_pom.xml %engineDownloadURL% -Dtest=${params.testPatternToRun} -DbrowserType=FIREFOX -DtrimStackTrace=false -Divy.engine.directory=%engineDir% -Divy.deploy.timeout.seconds=60 -Divy.engine.start.timeout.seconds=500 -Dsurefire.rerunFailingTestsCount=2" utils.cleanDisk() + + echo '====================Archive consoleText file====================' + withCredentials([usernameColonPassword(credentialsId: 'wawa-jenkins', variable: 'credentials')]) { + def branchName = env.BRANCH_NAME.replaceAll("/", "%%2F") + bat """ + curl --user ${credentials} ${env.JENKINS_URL}job/portal-selenium-test/job/${branchName}/${env.BUILD_NUMBER}/consoleText --output logText.txt + mv AxonIvyPortal/portal-selenium-test/resources/extractFlakyTests.sh . + sh extractFlakyTests.sh + """ + } } } } @@ -65,7 +75,7 @@ pipeline { post { always { - archiveArtifacts artifacts: 'AxonIvyPortal/portal-selenium-test/target/selenide/reports/**/*.*, AxonIvyPortal/portal-selenium-test/target/testEngineOut.log', allowEmptyArchive: true + archiveArtifacts artifacts: 'AxonIvyPortal/portal-selenium-test/target/selenide/reports/**/*.*, AxonIvyPortal/portal-selenium-test/target/testEngineOut.log, testReport.txt, logText.txt', allowEmptyArchive: true junit allowEmptyResults: true, testResults: '**/surefire-reports/TEST-*.xml' } }