microcks test exits with code 1 (contract failure) instead of code 11 (connection) when polling loop times out
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Anfängerfreundlichkeit
- 88/100
Rechercherichtung
Beginne in cmd/testExecutor.go bei runTestAndWait: Die Polling-Schleife kann mit inProgress immer noch true enden und gibt einen nil-Fehler zurück, daher behandelt cmd/test.go dies als errors.ErrTestFailed und cmd/exit.go bildet es auf Exit-Code 1 ab. Füge eine Prüfung nach der Schleife für inProgress hinzu, die einen Timeout-Fehler als errors.KindConnection wrapt, und überprüfe anschließend mit dem Python-Mock-Server aus dem Issue plus go run main.go test ... --waitFor=100milli, dass die CLI nun mit 11 statt 1 beendet. Gleiche die erwarteten Codes mit documentation/error-handling.md ab und führe die vorhandenen Go-Tests aus.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
While going through the changes in PR #540 and the new documentation/error-handling.md, I noticed a gap in how the test polling loop handles timeouts.
In cmd/testExecutor.go, runTestAndWait polls the server in a loop until the test finishes or the deadline passes:
for nowInMilliseconds() < future {
testResultSummary, err := mc.GetTestResult(testResultID)
if err != nil {
return false, "", fmt.Errorf("checking test result: %w", err)
}
success = testResultSummary.Success
inProgress := testResultSummary.InProgress
if !inProgress {
break
}
time.Sleep(2 * time.Second)
}
return success, testResultID, nil
If the server hasn't finished by the time the deadline runs out, the loop exits with inProgress still true, but the function returns nil for the error. No timeout is ever flagged.
Back in cmd/test.go, the caller sees err == nil and !success, so it returns errors.ErrTestFailed:
success, testResultID, err := runTestAndWait(mc, params)
if err != nil {
return err
}
if !success {
return errors.ErrTestFailed // exit code 1
}
And cmd/exit.go maps that to exit code 1:
case stderrors.Is(err, errors.ErrTestFailed):
// A clean run with a non-conforming result — pytest-style exit 1.
return 1
The problem is that a polling timeout is not a contract conformance failure, it's an infrastructure/connection issue. According to error-handling.md, exit code 1 is strictly for "a clean run whose result did not conform". A timeout means the CLI never got a final result at all.
Expected behavior
When the polling loop runs out of time with inProgress still true, it should return a proper timeout error wrapped as KindConnection, something like:
if inProgress {
return false, testResultID, errors.Wrap(errors.KindConnection,
fmt.Errorf("test polling timed out after %dms waiting for result %s",
params.waitForMillis+10000, testResultID))
}
This would cause ExitCodeFor to return 11 and Handle to print a clear error to stderr, so CI/CD pipelines can tell apart "API contract broken" (exit 1) from "server was too slow or unreachable" (exit 11).
Actual behavior
MicrocksClient got status for test "test-hanging-1" - success: false, inProgress: true
MicrocksTester waiting for 2 seconds before checking again or exiting.
MicrocksClient got status for test "test-hanging-1" - success: false, inProgress: true
MicrocksTester waiting for 2 seconds before checking again or exiting.
... repeats until deadline ...
Test test-hanging-1: FAILURE (0ms)
Full TestResult details are available here: http://127.0.0.1:8888/#/tests/test-hanging-1
exit status 1
$ echo $?
1
The CLI exits with code 1 and falsely reports a contract test failure (FAILURE 0ms), with no error indicating that the run actually timed out.
How to Reproduce?
- Start a mock server simulating a test that remains in progress:
python3 -c '
from http.server import HTTPServer, BaseHTTPRequestHandler
class MockServer(BaseHTTPRequestHandler):
def do_POST(self):
self.send_response(201)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(b"{\"id\":\"test-hanging-1\"}")
def do_GET(self):
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(b"{\"id\":\"test-hanging-1\",\"success\":false,\"inProgress\":true}")
def log_message(self, *args): pass
HTTPServer(("127.0.0.1", 8888), MockServer).serve_forever()
'
-
Run the test command with a short wait deadline:
go run main.go test "MyAPI:1.0" "http://localhost:8080" HTTP --microcksURL=http://127.0.0.1:8888 --waitFor=100milli -
Check the exit status: It returns 1 instead of 11.
Root cause: in cmd/testExecutor.go (lines 76–103), the loop ends when nowInMilliseconds() >= future, but falls through to return success, testResultID, nil without verifying if inProgress was still true.
Microcks version or git rev
main
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
CLI
Additional information
The fix is small and self-contained, only cmd/testExecutor.go needs to change (add a post-loop inProgress check). All three callers of runTestAndWait (cmd/test.go, and two places in cmd/testDryRun.go) already have if err != nil { return err } guards, so they'll handle the new error correctly without any changes.
- Vorherrschende Sprache
- Go
- Sterne
- 58
- Forks
- 72
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 27
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microcks/microcks-cli
-
Default configuration path falls back to the current directory when the home directory cannot be determinedEvtl. vergeben @Sarthak-Shreshtha01 hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microcks/microcks-cli#583 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug: YAML parse error in config is silently swallowed, login overwrites all other contextsEvtl. vergeben @Sarthak-Shreshtha01 hat das vor 7 Tagen übernommen. Offencomponent/cli kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microcks/microcks-cli#572 · 6 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
import-dir uploads secondary artifacts before their primary API definitionEvtl. vergeben @doraem-on hat das vor 14 Tagen übernommen. Offencomponent/cli kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
microcks/microcks-cli#561 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
TEST: `ConnectAndGetToken` Returns Error on Non-200 ResponseEvtl. vergeben @aniket866 hat das vor 16 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
microcks/microcks-cli#554 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Empty `AuthToken` Causes Cryptic JWT Parse ErrorEvtl. vergeben @aniket866 hat das vor 17 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
microcks/microcks-cli#551 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microcks/microcks-cli
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
copilot-api domain:platform go
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
docs: clarify gh api -f vs -F and @-file expansion in the gh skillEvtl. vergeben @MatiasOlivera hat das heute übernommen. Offenenhancement
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 62/100
cli/cli#14701 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
aws/aws-advanced-go-wrapper#612 ·
-
Say in the changelog that the text-index update cannot be rolled backEvtl. vergeben @praetorianer777 hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
praetorianer777/GoTome#275 ·
Maintainer antworten meist innerhalb von 1 Tag