Skip to content

Commit 6e994af

Browse files
authored
Merge pull request firecracker-microvm#486 from kzys/fast-test
Run some subtests in parallel to make integ-test faster
2 parents 4e4c907 + a011813 commit 6e994af

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

runtime/jailer_integ_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,18 @@ import (
4040
func TestJailer_Isolated(t *testing.T) {
4141
prepareIntegTest(t)
4242
t.Run("Without Jailer", func(t *testing.T) {
43+
t.Parallel()
4344
testJailer(t, nil)
4445
})
4546
t.Run("With Jailer", func(t *testing.T) {
47+
t.Parallel()
4648
testJailer(t, &proto.JailerConfig{
4749
UID: 300001,
4850
GID: 300001,
4951
})
5052
})
5153
t.Run("With Jailer and bind-mount", func(t *testing.T) {
54+
t.Parallel()
5255
testJailer(t, &proto.JailerConfig{
5356
UID: 300001,
5457
GID: 300001,
@@ -118,9 +121,9 @@ func testJailer(t *testing.T, jailerConfig *proto.JailerConfig) {
118121
require.NoError(err)
119122

120123
c, err := client.NewContainer(ctx,
121-
"container",
124+
vmID+"-container",
122125
containerd.WithSnapshotter(defaultSnapshotterName),
123-
containerd.WithNewSnapshot("snapshot", image),
126+
containerd.WithNewSnapshot(vmID+"-snapshot", image),
124127
containerd.WithNewSpec(
125128
oci.WithProcessArgs(
126129
"/bin/sh", "-c", "echo hello && cat /mnt/in-container/dir/hello",

runtime/service_integ_test.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,10 +1921,11 @@ func TestCreateVM_Isolated(t *testing.T) {
19211921
fcClient := fccontrol.NewFirecrackerClient(pluginClient.Client())
19221922

19231923
type subtest struct {
1924-
name string
1925-
request proto.CreateVMRequest
1926-
validate func(*testing.T, error)
1927-
stopVM bool
1924+
name string
1925+
request proto.CreateVMRequest
1926+
validate func(*testing.T, error)
1927+
validateUsesFindProcess bool
1928+
stopVM bool
19281929
}
19291930

19301931
subtests := []subtest{
@@ -1951,7 +1952,8 @@ func TestCreateVM_Isolated(t *testing.T) {
19511952
require.NoError(t, err, "failed waiting for expected firecracker process %q to come up", firecrackerProcessName)
19521953
require.Len(t, firecrackerProcesses, 0, "expected only no firecracker processes to exist")
19531954
},
1954-
stopVM: false,
1955+
validateUsesFindProcess: true,
1956+
stopVM: false,
19551957
},
19561958
{
19571959
name: "Slow Root FS",
@@ -1983,6 +1985,12 @@ func TestCreateVM_Isolated(t *testing.T) {
19831985
}
19841986

19851987
runTest := func(t *testing.T, request proto.CreateVMRequest, s subtest) {
1988+
// If this test checks the number of the processes on the host
1989+
// (e.g. the number of Firecracker processes), running the test with
1990+
// others in parallel messes up the result.
1991+
if !s.validateUsesFindProcess {
1992+
t.Parallel()
1993+
}
19861994
vmID := testNameToVMID(t.Name())
19871995

19881996
tempDir, err := ioutil.TempDir("", vmID)

0 commit comments

Comments
 (0)