-
Notifications
You must be signed in to change notification settings - Fork 73
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
Core: Generate xUnit Reports for e2e tests #962
base: master
Are you sure you want to change the base?
Core: Generate xUnit Reports for e2e tests #962
Conversation
Hi @sawood14012. Thanks for your PR. I'm waiting for a codeready-toolchain member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sawood14012 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look at this 🙏
I'm not familiar with go-junit-report
but don't you need to pipe it to the go test ./...
command as explained here:
go test -v 2>&1 ./... | go-junit-report -set-exit-code > report.xml
Co-authored-by: Francisc Munteanu <[email protected]>
Co-authored-by: Francisc Munteanu <[email protected]>
make/test.mk
Outdated
@command -v ./go-junit-report >/dev/null 2>&1 || { echo "go-junit-report is not installed. Installing..."; GOBIN=$(PWD) go install github.com/jstemmer/go-junit-report/v2@latest; } | ||
@echo "go-junit-report version:" && ./go-junit-report -version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather avoid installing the binary in the folder of the repository - let's install it either in /tmp folder or somewhere else.
make/test.mk
Outdated
@@ -163,7 +165,8 @@ execute-tests: | |||
@echo "Status of ToolchainStatus" | |||
-oc get ToolchainStatus -n ${HOST_NS} -o yaml | |||
@echo "Starting test $(shell date)" | |||
MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -parallel ${E2E_PARALLELISM} -v -timeout=90m -failfast || \ | |||
$(MAKE) check-go-junit-report | |||
MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -parallel ${E2E_PARALLELISM} -v -timeout=90m -failfast 2>&1 | $(MAKE) generate-report REPORT_NAME=${REPORT_NAME} || \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot use the pipe for the whole output; otherwise, we will lose the content/output of the tests when running it locally as well as in openshift-ci
Quality Gate passedIssues Measures |
@MatousJobanek i have resolved your comments and updated my approach
|
make/test.mk
Outdated
@echo "Skipping Go Junit report check and install" | ||
endif | ||
@echo "Running tests" | ||
MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -parallel ${E2E_PARALLELISM} -v -timeout=90m -failfast 2>&1 | tee test_output.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_output.log
should be stored in a /tmp folder, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
make/test.mk
Outdated
$(MAKE) generate-report REPORT_NAME=${REPORT_NAME} || \ | ||
($(MAKE) print-logs HOST_NS=${HOST_NS} MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} && exit 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is executed as a separate command, which means that printing logs will depend on the result of the generate-report
target, not on the result of the tests.
The original way it was written printed out the logs only when the test failed and also returned the exit code 1
, so execution of the print-logs
target depended on the results of the tests - this needs to stay the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so i am now running the generate report cmd after print logs hope this works
make/test.mk
Outdated
go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -parallel ${E2E_PARALLELISM} -v -timeout=90m -failfast 2>&1 | tee /tmp/test_output.log || ( $(MAKE) print-logs && exit 1 ) | ||
$(MAKE) generate-report REPORT_NAME=${REPORT_NAME} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the test fails, then the previous line exits with exit code 1
, so the report won't be generated - see
|| ( $(MAKE) print-logs && exit 1 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that you need to do something like this:
go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -parallel ${E2E_PARALLELISM} -v -timeout=90m -failfast 2>&1 | tee /tmp/test_output.log || ( $(MAKE) print-logs && exit 1 ) | |
$(MAKE) generate-report REPORT_NAME=${REPORT_NAME} | |
MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} \ | |
(go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -parallel ${E2E_PARALLELISM} -v -timeout=90m -failfast 2>&1 | tee /tmp/test_output.log && $(MAKE) generate-report REPORT_NAME=${REPORT_NAME}) || ( $(MAKE) print-logs && $(MAKE) generate-report REPORT_NAME=${REPORT_NAME} && exit 1 ) |
but I haven't tested it.
Not sure if there is some simpler way to deal with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't work because of the pipe and the returned value from tee
:-/
MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} \ | ||
go test ${TESTS_TO_EXECUTE} -run ${TESTS_RUN_FILTER_REGEXP} -p 1 -parallel ${E2E_PARALLELISM} -v -timeout=90m -failfast 2>&1 | tee /tmp/test_output.log; \ | ||
STATUS=$$?; \ | ||
$(MAKE) generate-report REPORT_NAME=${REPORT_NAME}; \ | ||
if [ $$STATUS -ne 0 ]; then $(MAKE) print-logs && exit 1; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested it and it doesn't work as expected - if one of the test suites fails, then it keeps running with the following test suites, but it should stop instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my guess is that STATUS=$$?
takes the exit value from the tee
command that is executed "after" the test as part of the pipe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of changing to STATUS=${PIPESTATUS[0]}; \
to capture the exit status of go test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that could work, I didn't know about PIPESTATUS
👍
a Wip PR which enables generation of junit/xunit reports to connect report-portal and Quality dashboard