test: harden harness reproducibility and cleanup
This commit is contained in:
@@ -36,6 +36,9 @@ func TestSampleRunLifecycle_HP_CFG_01(t *testing.T) {
|
||||
if _, err := os.Stat(filepath.Join(root, "sample-run", "artifacts", "report.json")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(root, "sample-run", "artifacts", "junit.xml")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := h.transition(loaded, "reset", "reset", "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -59,6 +62,9 @@ func TestRunIsolationAndManifestIdentity_HP_CFG_01(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := h.transition(first, "reset", "reset", "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := h.purge(first); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -81,6 +87,63 @@ func TestRunIsolationAndManifestIdentity_HP_CFG_01(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPurgeRequiresExplicitExecution_HP_CFG_01(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var output bytes.Buffer
|
||||
h := &harness{root: t.TempDir(), now: time.Now, out: &output}
|
||||
current, err := h.create("safe-purge", "integration", "sample")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := h.transition(current, "reset", "reset", "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := h.environmentCommand("purge", []string{"--run-id", current.RunID}); err != nil {
|
||||
t.Fatalf("purge dry run: %v", err)
|
||||
}
|
||||
if _, err := h.load(current.RunID); err != nil {
|
||||
t.Fatalf("dry-run purge removed run: %v", err)
|
||||
}
|
||||
if err := h.environmentCommand("purge", []string{"--run-id", current.RunID, "--execute"}); err == nil {
|
||||
t.Fatal("unconfirmed purge execution succeeded")
|
||||
}
|
||||
if err := h.environmentCommand("purge", []string{"--run-id", current.RunID, "--execute", "--yes"}); err != nil {
|
||||
t.Fatalf("confirmed purge: %v", err)
|
||||
}
|
||||
if _, err := os.Stat(h.runDir(current.RunID)); !os.IsNotExist(err) {
|
||||
t.Fatalf("confirmed purge retained run: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGCOnlyRemovesEligibleOldRuns_HP_CFG_01(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
now := time.Date(2026, time.September, 11, 6, 0, 0, 0, time.UTC)
|
||||
h := &harness{root: t.TempDir(), now: func() time.Time { return now }, out: &bytes.Buffer{}}
|
||||
old, err := h.create("old-reset", "integration", "sample")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := h.transition(old, "reset", "reset", "test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
now = now.Add(2 * time.Hour)
|
||||
active, err := h.create("active-run", "integration", "sample")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := h.gc([]string{"--older-than", "1h", "--execute", "--yes"}); err != nil {
|
||||
t.Fatalf("gc: %v", err)
|
||||
}
|
||||
if _, err := os.Stat(h.runDir(old.RunID)); !os.IsNotExist(err) {
|
||||
t.Fatalf("gc retained old reset run: %v", err)
|
||||
}
|
||||
if _, err := h.load(active.RunID); err != nil {
|
||||
t.Fatalf("gc affected active run: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunIDTraversalAndSymlinkPurgeRejected_HP_CFG_01(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -131,7 +194,7 @@ func TestStableSuiteAndScenarioListing_HP_CFG_01(t *testing.T) {
|
||||
if err := h.integration(context.Background(), []string{"--list"}); err != nil {
|
||||
t.Fatalf("list integration suites: %v", err)
|
||||
}
|
||||
if got, want := output.String(), "integration suites:\nsample\nstore\nserver-session\ncontrol\nclient-agent\n"; got != want {
|
||||
if got, want := output.String(), "integration suites:\nsample\nstore\nserver-session\ncontrol\nclient-agent\nall\n"; got != want {
|
||||
t.Fatalf("integration list = %q, want %q", got, want)
|
||||
}
|
||||
output.Reset()
|
||||
@@ -149,6 +212,28 @@ func TestStableSuiteAndScenarioListing_HP_CFG_01(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHarnessDefaultsAndResumeIdentity_HP_CFG_01(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
defaults, err := loadHarnessDefaults("defaults.toml")
|
||||
if err != nil {
|
||||
t.Fatalf("load defaults: %v", err)
|
||||
}
|
||||
if defaults.Limits.MaxConcurrentRuns != 1 || defaults.Limits.FreeSpaceFloorBytes == 0 {
|
||||
t.Fatalf("defaults = %#v", defaults)
|
||||
}
|
||||
|
||||
h := &harness{root: t.TempDir(), now: time.Now, out: &bytes.Buffer{}}
|
||||
current, err := h.create("resume-identity", "integration", "sample")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
current.GitCommit = "different-commit"
|
||||
if err := h.verifyResume(current); err == nil || !strings.Contains(err.Error(), "commit") {
|
||||
t.Fatalf("verifyResume mismatched commit = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBoundedSuiteLogAndFailedRunRecovery_BH_STORE_03(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user