run a single test before running multiple tests
parent
b93845f9d4
commit
d8f53e4bd2
|
@ -67,37 +67,31 @@ func TestGeneratedLogs(t *testing.T) {
|
||||||
logTests := []struct {
|
logTests := []struct {
|
||||||
command string
|
command string
|
||||||
args []string
|
args []string
|
||||||
runCount int // number of times to run command
|
runCount int // number of times to run command
|
||||||
expectedLogFiles int // number of logfiles expected after running command runCount times
|
expectedLogFiles int // number of logfiles expected after running command runCount times
|
||||||
checkReverse bool // the subcommand can be in the middle, before or after the flags
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
command: "start",
|
command: "start",
|
||||||
args: []string{"--dry-run"},
|
args: []string{"--dry-run"},
|
||||||
runCount: 175, // calling this 175 times should create 2 files with 1 greater than 1M
|
runCount: 175, // calling this 175 times should create 2 files with 1 greater than 1M
|
||||||
expectedLogFiles: 2,
|
expectedLogFiles: 2,
|
||||||
checkReverse: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: "status",
|
command: "status",
|
||||||
runCount: 100,
|
runCount: 100,
|
||||||
expectedLogFiles: 1,
|
expectedLogFiles: 1,
|
||||||
checkReverse: false,
|
|
||||||
}, {
|
}, {
|
||||||
command: "pause",
|
command: "pause",
|
||||||
runCount: 5,
|
runCount: 5,
|
||||||
expectedLogFiles: 1,
|
expectedLogFiles: 1,
|
||||||
checkReverse: false,
|
|
||||||
}, {
|
}, {
|
||||||
command: "unpause",
|
command: "unpause",
|
||||||
runCount: 1,
|
runCount: 1,
|
||||||
expectedLogFiles: 1,
|
expectedLogFiles: 1,
|
||||||
checkReverse: false,
|
|
||||||
}, {
|
}, {
|
||||||
command: "stop",
|
command: "stop",
|
||||||
runCount: 1,
|
runCount: 1,
|
||||||
expectedLogFiles: 1,
|
expectedLogFiles: 1,
|
||||||
checkReverse: false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +105,21 @@ func TestGeneratedLogs(t *testing.T) {
|
||||||
}
|
}
|
||||||
cleanupLogFiles(t, logFiles)
|
cleanupLogFiles(t, logFiles)
|
||||||
|
|
||||||
|
args := []string{"-p", profile, "--log_dir", logDir, test.command}
|
||||||
|
args = append(args, test.args...)
|
||||||
|
|
||||||
|
singleRun, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%q failed: %v", singleRun.Command(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// get log files generated above for a single run
|
||||||
|
logFiles, err = filepath.Glob(filepath.Join(logDir, fmt.Sprintf("minikube_%s*", test.command)))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed to get new log files for command %s : %v", test.command, err)
|
||||||
|
}
|
||||||
|
cleanupLogFiles(t, logFiles)
|
||||||
|
|
||||||
// run command runCount times
|
// run command runCount times
|
||||||
for i := 0; i < test.runCount; i++ {
|
for i := 0; i < test.runCount; i++ {
|
||||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
||||||
|
|
Loading…
Reference in New Issue