Skip to content

Commit 66f4d23

Browse files
authored
Merge pull request #640 from kzys/root
Reduce "isolated" tests to speed up runtime tests
2 parents 2637d9a + 75faa42 commit 66f4d23

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ steps:
6767
hostname: "${BUILDKITE_AGENT_META_DATA_HOSTNAME}"
6868
env:
6969
EXTRAGOARGS: "-v -count=1 -race"
70+
DISABLE_ROOT_TESTS: 1
7071
command:
7172
- cp "/local/artifacts/$BUILDKITE_BUILD_NUMBER/rootfs.img" tools/image-builder/rootfs.img
7273
- make test-in-docker

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ test-in-docker:
171171
--env HOME=/tmp \
172172
--env GOPATH=/go \
173173
--env EXTRAGOARGS="$(EXTRAGOARGS)" \
174+
--env DISABLE_ROOT_TESTS=$(DISABLE_ROOT_TESTS) \
174175
--entrypoint=/bin/bash \
175176
--workdir /src \
176177
$(FIRECRACKER_CONTAINERD_BUILDER_IMAGE) \

runtime/runc_jailer_test.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ import (
3333
"github.com/firecracker-microvm/firecracker-containerd/internal"
3434
)
3535

36-
func TestBuildJailedRootHandler_Isolated(t *testing.T) {
37-
internal.RequiresIsolation(t)
36+
func TestBuildJailedRootHandler(t *testing.T) {
37+
internal.RequiresRoot(t)
3838
dir := t.TempDir()
39+
ctx := context.Background()
3940

4041
kernelImagePath := filepath.Join(dir, "kernel-image")
4142
kernelImageFd, err := os.OpenFile(kernelImagePath, os.O_CREATE, 0600)
@@ -61,7 +62,7 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
6162
GID: 456,
6263
}
6364
vmID := "foo"
64-
jailer, err := newRuncJailer(context.Background(), l, vmID, runcConfig, []*proto.FirecrackerDriveMount{})
65+
jailer, err := newRuncJailer(ctx, l, vmID, runcConfig, []*proto.FirecrackerDriveMount{})
6566
require.NoError(t, err, "failed to create runc jailer")
6667

6768
cfg := config.Config{
@@ -85,7 +86,7 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
8586
machine := firecracker.Machine{
8687
Cfg: machineConfig,
8788
}
88-
err = handler.Fn(context.Background(), &machine)
89+
err = handler.Fn(ctx, &machine)
8990
assert.NoError(t, err, "jailed handler failed to run")
9091

9192
_, err = os.Stat(filepath.Join(dir, "config.json"))
@@ -101,9 +102,9 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) {
101102
assert.NoError(t, err, "failed to create root drive")
102103
}
103104

104-
func TestMkdirAllWithPermissions_Isolated(t *testing.T) {
105+
func TestMkdirAllWithPermissions(t *testing.T) {
105106
// requires isolation so we can change uid/gid of files
106-
internal.RequiresIsolation(t)
107+
internal.RequiresRoot(t)
107108

108109
tmpdir := t.TempDir()
109110

@@ -132,9 +133,9 @@ func TestMkdirAllWithPermissions_Isolated(t *testing.T) {
132133
assert.Equal(t, newgid, newlyCreatedPathStat.Sys().(*syscall.Stat_t).Gid)
133134
}
134135

135-
func TestBindMountToJail_Isolated(t *testing.T) {
136+
func TestBindMountToJail(t *testing.T) {
136137
// The user must be root to call chown.
137-
internal.RequiresIsolation(t)
138+
internal.RequiresRoot(t)
138139

139140
dir := t.TempDir()
140141

@@ -167,9 +168,10 @@ func TestBindMountToJail_Isolated(t *testing.T) {
167168
require.Error(t, err)
168169
}
169170

170-
func TestFifoHandler_Isolated(t *testing.T) {
171+
func TestFifoHandler(t *testing.T) {
171172
// Because of chown(2).
172-
internal.RequiresIsolation(t)
173+
internal.RequiresRoot(t)
174+
ctx := context.Background()
173175

174176
testcases := []struct {
175177
name string
@@ -215,15 +217,8 @@ func TestFifoHandler_Isolated(t *testing.T) {
215217
require.NoError(t, err)
216218

217219
handler := j.BuildLinkFifoHandler()
218-
err = handler.Fn(
219-
context.Background(),
220-
&firecracker.Machine{
221-
Cfg: firecracker.Config{
222-
LogPath: logPath,
223-
MetricsPath: metricsPath,
224-
},
225-
},
226-
)
220+
machine := firecracker.Machine{Cfg: firecracker.Config{LogPath: logPath, MetricsPath: metricsPath}}
221+
err = handler.Fn(ctx, &machine)
227222
require.NoError(t, err)
228223
})
229224
}

0 commit comments

Comments
 (0)