test(worker): add retry and persistence checks and adapt attachment tests for async processing

This commit is contained in:
kk10
2026-11-16 12:41:11 +03:00
parent 4a6176fe81
commit eafc437933
9 changed files with 345 additions and 70 deletions
+47
View File
@@ -0,0 +1,47 @@
//go:build failure || worker
package studenttests_test
import (
"net/http"
"os/exec"
"testing"
"time"
)
func compose(t *testing.T, args ...string) {
t.Helper()
cmd := exec.Command("docker", append([]string{"compose"}, args...)...)
cmd.Dir = ".."
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("docker compose %v: %v\n%s", args, err, out)
}
}
func stopService(t *testing.T, name string) {
t.Helper()
compose(t, "stop", name)
t.Cleanup(func() {
compose(t, "start", name)
waitReady(t)
})
}
func waitReady(t *testing.T) {
t.Helper()
deadline := time.Now().Add(60 * time.Second)
for time.Now().Before(deadline) {
resp, err := httpClient.Get(*baseURL + "/health/ready")
if err == nil {
resp.Body.Close()
if resp.StatusCode == http.StatusOK {
return
}
}
time.Sleep(500 * time.Millisecond)
}
t.Fatal("service did not become ready in 60s")
}