fix: harden multi-pod delivery and load verification
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDetectCollectorPhase(t *testing.T) {
|
||||
start := StartInfo{RunID: "run1", StartAt: time.Now().Add(-time.Second)}
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{"start": start})
|
||||
}))
|
||||
defer server.Close()
|
||||
client := &http.Client{Timeout: time.Second}
|
||||
if got := detectCollectorPhase(context.Background(), client, "before", server.URL, ""); got != "during" {
|
||||
t.Fatalf("phase=%s", got)
|
||||
}
|
||||
output := filepath.Join(t.TempDir(), "coordinator.json")
|
||||
if err := os.WriteFile(output, []byte("{}"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := detectCollectorPhase(context.Background(), client, "during", server.URL, output); got != "after" {
|
||||
t.Fatalf("phase=%s", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user