test: add server session integration harness
This commit is contained in:
+41
-5
@@ -126,8 +126,8 @@ func (h *harness) integration(ctx context.Context, args []string) error {
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
if *suite != "sample" && *suite != "store" {
|
||||
return fmt.Errorf("suite %q is not implemented yet; available: sample, store", *suite)
|
||||
if *suite != "sample" && *suite != "store" && *suite != "server-session" {
|
||||
return fmt.Errorf("suite %q is not implemented yet; available: sample, store, server-session", *suite)
|
||||
}
|
||||
|
||||
var current *manifest
|
||||
@@ -166,9 +166,18 @@ func (h *harness) integration(ctx context.Context, args []string) error {
|
||||
if err := h.appendJournal(current.RunID, journalEntry{At: h.now(), Step: "invariant", Status: "passed", Detail: "manifest ownership and journal durability verified"}); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err := h.runStoreSuite(ctx, current); err != nil {
|
||||
_ = h.transition(current, "failed", "store-failed", err.Error())
|
||||
return err
|
||||
} else {
|
||||
var suiteErr error
|
||||
switch *suite {
|
||||
case "store":
|
||||
suiteErr = h.runStoreSuite(ctx, current)
|
||||
case "server-session":
|
||||
suiteErr = h.runServerSessionSuite(ctx, current)
|
||||
}
|
||||
if suiteErr != nil {
|
||||
_ = h.transition(current, "failed", *suite+"-failed", suiteErr.Error())
|
||||
return suiteErr
|
||||
}
|
||||
}
|
||||
return h.transition(current, "completed", *suite+"-complete", *suite+" integration run completed")
|
||||
}
|
||||
@@ -196,6 +205,33 @@ func (h *harness) runStoreSuite(ctx context.Context, current *manifest) error {
|
||||
return h.appendJournal(current.RunID, journalEntry{At: h.now(), Step: "store-real-sqlite", Status: "passed", Detail: "real SQLite/WAL and filesystem cases passed"})
|
||||
}
|
||||
|
||||
func (h *harness) runServerSessionSuite(ctx context.Context, current *manifest) error {
|
||||
return h.runGoSuite(ctx, current, "server-session-real-websocket", "running real HTTP/WebSocket, protobuf, SQLite, and fencing cases", "./internal/server/session")
|
||||
}
|
||||
|
||||
func (h *harness) runGoSuite(ctx context.Context, current *manifest, step, detail, packagePath string) error {
|
||||
if err := h.appendJournal(current.RunID, journalEntry{At: h.now(), Step: step, Status: "running", Detail: detail}); err != nil {
|
||||
return err
|
||||
}
|
||||
artifactDir := filepath.Join(h.runDir(current.RunID), "artifacts")
|
||||
if err := os.MkdirAll(artifactDir, 0o700); err != nil {
|
||||
return err
|
||||
}
|
||||
capture := &limitedCapture{limit: maxSuiteLogSize}
|
||||
command := exec.CommandContext(ctx, "go", "test", "-race", "-count=1", "-shuffle="+strconv.FormatInt(current.Seed, 10), "-timeout=2m", packagePath)
|
||||
command.Stdout = capture
|
||||
command.Stderr = capture
|
||||
err := command.Run()
|
||||
logPath := filepath.Join(artifactDir, "suite.log")
|
||||
if writeErr := atomicWrite(logPath, capture.Bytes(), 0o600); writeErr != nil {
|
||||
return writeErr
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s suite failed (bounded log %s): %w", current.Suite, logPath, err)
|
||||
}
|
||||
return h.appendJournal(current.RunID, journalEntry{At: h.now(), Step: step, Status: "passed", Detail: detail + " passed"})
|
||||
}
|
||||
|
||||
func (h *harness) environmentCommand(command string, args []string) error {
|
||||
flags := flag.NewFlagSet(command, flag.ContinueOnError)
|
||||
flags.SetOutput(io.Discard)
|
||||
|
||||
Reference in New Issue
Block a user