Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to re-run failed tests and merge the output files post re-run #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

harshkumarRH
Copy link
Collaborator

@harshkumarRH harshkumarRH commented Jun 12, 2022

With this PR, the below changes were made to run_robot_test.sh

  1. Ability to re-run failed tests
  2. Ability to merge the output files post re-run of failures
  3. Creation of unique results output directory for each run

Marks tentative completion of DBAAS-544
Logs for reference: PR35.zip
Complete Test Result directory: rhoda--2022-06-13-3249.zip

Signed-off-by: Harsh Kumar [email protected]

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -eux
set -x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional change? IMHO "-eu" wont harm anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they both had to be removed due to requirement changes
-e was removed because it causes the shell script to exit when there is robot test failure, as the exit status of robot command is 1
So if a test case fails, the bash script will exit right away and won't execute the code for re-run failed tests
-u was removed as it requires that every variable used should already be set, and we are using a Jenkins Environment Variable which outside of Jenkins run will be empty/un-set

;;
Linux)
TEST_ARTIFACT_DIR=$(mktemp -d -p ${TEST_ARTIFACT_DIR} -t rhoda-ci-$(date +%Y-%m-%d-%H-%M)-XXXXXXXXXX)
TEST_ARTIFACT_DIR="${TEST_ARTIFACT_DIR}/rhoda-${BUILD_NUMBER}-$(date +%Y-%m-%d-%M%S)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${BUILD_NUMBER} I dont see the declaration for this variable, is this expected to be passed as CLI argument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${BUILD_NUMBER} is a Jenkins Environment variable, it will automatically get picked up once a Job is kicked off
https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-belowJenkinsSetEnvironmentVariables
When running manually, the variable will be empty, so won't be included in the directory name

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure Jenkins environment variables can be called this way, I use ${env.BUILD_NUMBER} to access the variable.
Can you please attach the test results from local jenkins setup?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't run this from local jenkins setup
${BUILD_NUMBER} should also work the same theoretically - https://www.lambdatest.com/blog/set-jenkins-pipeline-environment-variables-list/#Reading

I can change it to ${env.BUILD_NUMBER} if it makes more sense, please suggest

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure too. So please setup the local jenkins and give it a try

@@ -168,6 +168,13 @@ case "$(uname -s)" in
esac


./venv/bin/robot -d "${TEST_ARTIFACT_DIR}" -x xunit_test_result.xml -r test_report.html ${TEST_VARIABLES} --variablefile ${TEST_VARIABLES_FILE} ${EXTRA_ROBOT_ARGS} ${TEST_CASE_FILE}
./venv/bin/robot ${EXTRA_ROBOT_ARGS} -d ${TEST_ARTIFACT_DIR} -x xunit_test_result.xml -r test_report.html ${TEST_VARIABLES} --variablefile "${TEST_VARIABLES_FILE}" "${TEST_CASE_FILE}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the variable expansion, shall we follow same format everywhere without using double quotes around the variable? LMKWYT

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the standard and best way to use variables is inside double quotes to avoid incorrect expansion. In our case though, problem is that it can only be used for non-empty variables
If empty string variables are put inside double quote, robot tries to interpret them as command line input and fails to run.

I should, however, add the double quotes for ${TEST_ARTIFACT_DIR}
Thank you!

if [[ $? -ne 0 ]] && [[ -f "${TEST_ARTIFACT_DIR}/output.xml" ]]; then
./venv/bin/robot ${EXTRA_ROBOT_ARGS} -d ${TEST_ARTIFACT_DIR} -x xunit_test_result.xml -r test_report.html ${TEST_VARIABLES} --variablefile "${TEST_VARIABLES_FILE}" --rerunfailed "${TEST_ARTIFACT_DIR}/output.xml" --output "output_rerun.xml" "${TEST_CASE_FILE}"

./venv/bin/rebot -d ${TEST_ARTIFACT_DIR} -o "output.xml" -x xunit_test_result.xml -r test_report.html --merge "${TEST_ARTIFACT_DIR}/output.xml" "${TEST_ARTIFACT_DIR}/output_rerun.xml"
Copy link
Collaborator

@mrrajan mrrajan Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please attach the test results for the successful execution of rerun passed cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logs are already attached, did I miss something in there?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am good with logs. I was looking for report, xunit and output xml files

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Rajan, attached the complete results directory

@harshkumarRH harshkumarRH force-pushed the run-script branch 2 times, most recently from 5a5e1ed to 8f83c7a Compare June 13, 2022 10:17
@harshkumarRH harshkumarRH added the DNM Do not merge the pull request label Jun 13, 2022
@mergify
Copy link
Contributor

mergify bot commented Jun 30, 2022

"This pull request now has conflicts with the target branch.
Please resolve conflicts."

@mergify
Copy link
Contributor

mergify bot commented Sep 28, 2022

This pull request now has conflicts with the target branch. Please resolve conflicts.

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented May 8, 2023

This pull request now has conflicts with the target branch. Please resolve conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DNM Do not merge the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants