tests/image: run the tests in parallel (somewhat)
This commits enables the parallelism for the image tests. However, there's a catch. Osbuild cannot be reliably run in parallel, so the code uses a mutex to ensure there's always only one osbuild instance for now. Even with this limitation, there's a significant speed-up of the tests: Prior this commit, the image tests run in 40 minutes on Travis. After this commit, the time is reduced to 32 minutes. The speed-up will have an even bigger effect when more cloud-upload tests are added to the test suite.
This commit is contained in:
parent
c4d40b4b0f
commit
e890e03d68
1 changed files with 17 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -37,8 +38,17 @@ type testcaseStruct struct {
|
|||
}
|
||||
}
|
||||
|
||||
// mutex to enforce only one osbuild instance run at a time, see below
|
||||
var osbuildMutex sync.Mutex
|
||||
|
||||
// runOsbuild runs osbuild with the specified manifest and store.
|
||||
func runOsbuild(manifest []byte, store string) (string, error) {
|
||||
// Osbuild crashes when multiple instances are run at a time.
|
||||
// This mutex enforces that there's always just one osbuild instance.
|
||||
// This should be removed once osbuild is fixed.
|
||||
// See https://github.com/osbuild/osbuild/issues/351
|
||||
osbuildMutex.Lock()
|
||||
defer osbuildMutex.Unlock()
|
||||
cmd := getOsbuildCommand(store)
|
||||
|
||||
cmd.Stderr = os.Stderr
|
||||
|
|
@ -402,6 +412,13 @@ func runTests(t *testing.T, cases []string) {
|
|||
t.Skipf("the required arch is %s, the current arch is %s", testcase.ComposeRequest.Arch, currentArch)
|
||||
}
|
||||
|
||||
// Run the test in parallel
|
||||
// The t.Parallel() call is after the skip conditions, because
|
||||
// the skipped tests are short and there's no need to run
|
||||
// them in parallel and create more goroutines.
|
||||
// Also the output is clearer this way.
|
||||
t.Parallel()
|
||||
|
||||
runTestcase(t, testcase)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue