Repository navigation
fix(disruption): disruption run writes its JUnit report with -o json, and an SLA breach fails through Execute - #397
Merged
Conversation
… and an SLA breach fails through Execute `kates disruption run -o json --output-junit results.xml` returned from its JSON branch before the JUnit report was written, so a CI job asking for both got no file. And --fail-on-sla-breach called os.Exit(1) in the middle of RunE: no message, every defer skipped, and an in-process caller (a test) ended with it. The JUnit report is now written ahead of the JSON branch. Its note goes to stderr with -o json, so stdout stays the JSON alone, and keeps its place after the step reports in a table. checkSlaExit returns a silent error, which Execute ends with exit 1, as before, and no second message, since the verdict is already printed.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Item 1.11 of the CLI performance and stability plan (finding F14, its
disruption runrows). Independent of the other Wave 1 PRs.Why
Two
kates disruption runpaths fail a CI job, both on main (6f4cf61):-o json --output-junitwrites no JUnit file. The JSON branch returns atcli/cmd/disruption.go:71-75, and the JUnit report is written only at:115, after the table. A pipeline that wants both the JSON and the JUnit report gets no report.--fail-on-sla-breachcallsos.Exit(1)insideRunE(checkSlaExit,:241,244). It prints no message and skips every defer, and an in-process caller ends with it: a test of this path ended the whole test binary.Changes
cli/cmd/disruption.go:-o jsonbranch.-o json, its note ("JUnit XML written to …" or the write failure) goes to stderr, so stdout stays the JSON alone.checkSlaExitreturns asilentErron a breached SLA.Executeends it with exit 1, as before, and prints nothing more, since the SLA verdict is already on screen or in the JSON.Tests
Added:
TestDisruptionRun_JSONWritesJUnit:-o json --output-junitleaves stdout parseable as the run result, writes a<testsuite>file, and names it on stderr.TestDisruptionRun_SLABreachFailsThroughExecute: with a report whoseslaVerdict.violatedis true and--fail-on-sla-breach, the command returns the silent error, both with-o tableand-o json.The test backend's report is now a
playbookBackendfield, and its reset clears--output-junitand--fail-on-sla-breach.On main's
disruption.go, the first test finds no JUnit file, and the second ends the test binary withexit status 1.Run locally, passing:
cd cli && go test ./...,go test -race ./cmd,go vet ./....golangci-lint run --new-from-rev=origin/main ./...: 0 issues.scripts/check-cli-style.shandscripts/check-cli-compat.sh: OK.cli/**triggers (Build & Test): this PR touches nothing underkates/../mvnw teston main'skates/tree ran 1,254 tests with 0 failures and 0 errors, once for all of Wave 1.Skipped locally:
govulncheck, asgo.modis unchanged.CI only:
./mvnw verifywith the*ITtests, the Kind and Docker jobs, CodeQL and Trivy.