-
Notifications
You must be signed in to change notification settings - Fork 27
MDBF-991 - Obtain failed test results and the associated output from MTR #816
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
783ddaf
Save MTR output as JUnit formatted XML
RazvanLiviuVarzaru 2f4934d
Failed ShellStep can be marked as warning
RazvanLiviuVarzaru e1ce61a
Framework fix of BashScriptCommand
RazvanLiviuVarzaru 2de936e
Define an MTR JUnit reporter (client)
RazvanLiviuVarzaru 616a9bb
bash review
RazvanLiviuVarzaru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Input variables | ||
| BASE_URL="$1" # e.g., 100.64.101.1:9990 | ||
| BRANCH="$2" | ||
| REVISION="$3" | ||
| PLATFORM="$4" | ||
| BBNUM="$5" | ||
| DIR="$6" # Directory containing .xml files | ||
|
|
||
| err() { | ||
| set +x | ||
| echo >&2 "ERROR: $*" | ||
| exit 1 | ||
| } | ||
|
|
||
| bb_log_info() { | ||
| set +x | ||
| echo >&1 "INFO: $*" | ||
| set -x | ||
| } | ||
|
|
||
| UPLOAD_URL="${BASE_URL}/upload-test-results/" | ||
| HEALTH_URL="${BASE_URL}/health" | ||
|
|
||
| # Step 1: Health check before uploads | ||
| command -v curl >/dev/null || err "curl not found" | ||
| bb_log_info "Checking service health at $HEALTH_URL..." | ||
| if ! curl "$HEALTH_URL" \ | ||
| --max-time 5 \ | ||
| --retry 3 \ | ||
| --retry-max-time 0 \ | ||
| --retry-delay 5 \ | ||
| --retry-connrefused \ | ||
| --fail-with-body; then | ||
| err "Service health check failed. Aborting uploads." | ||
| fi | ||
| bb_log_info "Service is healthy. Proceeding with uploads." | ||
|
|
||
| # Step 2: Validate directory | ||
| if [[ ! -d "$DIR" ]]; then | ||
| err "Error: directory '$DIR' does not exist" | ||
| fi | ||
|
|
||
| # Step 3: Find XML files | ||
| shopt -s nullglob | ||
| XML_FILES=("$DIR"/*.xml) | ||
| shopt -u nullglob | ||
|
|
||
| if (( ${#XML_FILES[@]} == 0 )); then | ||
| err "Error: no .xml files found in directory '$DIR'" | ||
| fi | ||
|
|
||
| # Step 4: Upload files and track failures | ||
| ANY_FAILED=0 | ||
|
|
||
| for FILE in "${XML_FILES[@]}"; do | ||
| # Extract filename without extension for 'typ' | ||
| BASENAME="$(basename "$FILE" .xml)" | ||
| bb_log_info "Uploading $FILE (typ=$BASENAME)..." | ||
|
|
||
| if ! curl --max-time 120 --connect-timeout 10 --fail-with-body \ | ||
| -X POST "$UPLOAD_URL" \ | ||
| -F "branch=${BRANCH}" \ | ||
| -F "revision=${REVISION}" \ | ||
| -F "platform=${PLATFORM}" \ | ||
| -F "bbnum=${BBNUM}" \ | ||
| -F "typ=${BASENAME}" \ | ||
| -F "file=@${FILE};type=application/xml"; then | ||
| bb_log_info "Upload failed for $FILE" | ||
| ANY_FAILED=1 | ||
| else | ||
| bb_log_info "Upload succeeded for $FILE" | ||
| fi | ||
| done | ||
|
|
||
| # Step 5: Final result | ||
| if ((ANY_FAILED != 0 )); then | ||
| err "One or more uploads failed." | ||
| else | ||
| bb_log_info "All uploads succeeded." | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.