diff --git a/Makefile b/Makefile index 20ab5ac9c5..b6463d952a 100644 --- a/Makefile +++ b/Makefile @@ -848,4 +848,4 @@ endif .PHONY: stress stress: - go test -test.v -test.timeout=2h ./test/stress -loops=10 + go test -test.v -test.timeout=2h ./test/stress -loops=10 | tee "./out/testout_$(COMMIT_SHORT).txt" diff --git a/test/stress/stress_test.go b/test/stress/stress_test.go index 523109c0d6..e7a4791fd6 100644 --- a/test/stress/stress_test.go +++ b/test/stress/stress_test.go @@ -65,39 +65,62 @@ func TestStress(t *testing.T) { for i := 1; i <= *loops; i++ { t.Logf("Loop %d of %d: %s to HEAD", i, *loops, *upgradeFrom) runStress(t, oldPath, profile, i) + t.Logf("Loop %d of %d done.", i, *loops) } } +type stressFunc func(*testing.T, string, string, int) + // This run the guts of the actual test -func runStress(t *testing.T, oldPath string, profile string, i int) { +func runStress(t *testing.T, oldPath string, profile string, loop int) { // Cleanup old runs runCommand(t, false, newPath, "delete", "-p", profile) + t.Run("stress", func(t *testing.T) { + tests := []struct { + name string + validator stressFunc + }{ + {"HotOldToNewUpgrade", validHotOldToNewUpgrade}, + {"ColdOldToNewUpgrade", validColdOldToNewUpgrade}, + {"HotHeadRestart", validHotHeadRestart}, + {"ColdHeadRestart", validColdHeadRestart}, + } + for _, tc := range tests { + tc := tc + t.Run(tc.name, func(t *testing.T) { + tc.validator(t, oldPath, profile, loop) + }) + } + }) +} + +func validHotOldToNewUpgrade(t *testing.T, oldPath string, profile string, i int) { t.Logf("Hot upgrade from %s to HEAD", *upgradeFrom) runCommand(t, true, oldPath, "start", "-p", profile, *startArgs, "--alsologtostderr") - runCommand(t, true, newPath, "start", "-p", profile, *startArgs, "--alsologtostderr") - runCommand(t, false, newPath, "delete", "-p", profile) +} +func validColdOldToNewUpgrade(t *testing.T, oldPath string, profile string, i int) { t.Logf("Cold upgrade from %s to HEAD", *upgradeFrom) runCommand(t, false, oldPath, "start", "-p", profile, *startArgs, "--alsologtostderr") runCommand(t, false, oldPath, "stop", "-p", profile) runCommand(t, true, newPath, "start", "-p", profile, *startArgs, "--alsologtostderr") +} +func validHotHeadRestart(t *testing.T, oldPath string, profile string, i int) { t.Logf("Restart HEAD test") runCommand(t, true, newPath, "start", "-p", profile, *startArgs, "--alsologtostderr") +} +func validColdHeadRestart(t *testing.T, oldPath string, profile string, i int) { t.Logf("Cold HEAD restart") runCommand(t, false, newPath, "stop", "-p", profile) - runCommand(t, true, newPath, "start", "-p", profile, *startArgs, "--alsologtostderr") - runCommand(t, false, newPath, "delete", "-p", profile) - - t.Logf("Loop %d of %d done.", i, *loops) } func runCommand(t *testing.T, errorOut bool, mkPath string, args ...string) {