refactor: enhance job status checks in worker tests
CI / changes (push) Successful in 6s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 39s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, , evobgp-web) (push) Has been skipped
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, evobgp-all, evobgp-web-all) (push) Has been skipped
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 15s
CI / docker-go-prime (push) Successful in 24s
CI / docker-go (deploy/docker/evobgp-agent/Dockerfile, , evobgp-agent) (push) Successful in 59s
CI / docker-go (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, , evobgp-all) (push) Successful in 6m8s
CI / docker-go (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, , evobgp-api) (push) Successful in 1m22s
CI / docker-go (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, , evobgp-deploy) (push) Successful in 1m21s
CI / docker-go (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, , evobgp-ingest) (push) Successful in 1m22s
CI / docker-go (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, , evobgp-node) (push) Successful in 1m6s
CI / docker-go (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, , evobgp-render) (push) Successful in 1m20s
CI / docker-go (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, , evobgp-scheduler) (push) Successful in 1m20s

Updated the worker test cases to improve the handling of job status checks. Added nil checks for job instances and refined the logic to verify job statuses directly from snapshots, ensuring more robust test coverage and preventing potential nil pointer dereferences.
This commit is contained in:
Denozordec
2026-04-09 15:14:19 +07:00
parent 3b17228ef2
commit 6107c3eb87
+10 -3
View File
@@ -58,10 +58,14 @@ func TestParallelModuleRefresh_CoalescesDeployApply(t *testing.T) {
var deferred, withDeployID int
refreshJobs, _, _ := reg.List(tenant, "", KindModuleRefresh, "", 100)
for _, j := range refreshJobs {
if j.Status != StatusSucceeded {
if j == nil {
continue
}
meta := j.Snapshot()["meta"].(map[string]any)
snap := j.Snapshot()
if st, _ := snap["status"].(string); st != StatusSucceeded {
continue
}
meta, _ := snap["meta"].(map[string]any)
if v, ok := meta["deploy_apply_deferred"].(bool); ok && v {
deferred++
}
@@ -89,10 +93,13 @@ func waitSucceededJobsByKindCount(t *testing.T, reg *Registry, tenant, kind stri
}
all, _, _ := reg.List(tenant, "", kind, "", 100)
for _, j := range all {
if j == nil || j.Status != StatusFailed {
if j == nil {
continue
}
snap := j.Snapshot()
if st, _ := snap["status"].(string); st != StatusFailed {
continue
}
t.Fatalf("%s job failed: %#v", kind, snap["error"])
}
time.Sleep(5 * time.Millisecond)