Skip to content

Commit 0b71a80

Browse files
Merge pull request #672 from austinvazquez/remote-snapshotter-integ-test
fix: do not pass testing.T to goroutines in remote snapshotter tests
2 parents 47ceb62 + 3ff649d commit 0b71a80

File tree

2 files changed

+54
-25
lines changed

2 files changed

+54
-25
lines changed

.buildkite/pipeline.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ steps:
7373
- make test-in-docker
7474
timeout_in_minutes: 10
7575

76-
- label: ":running: snapshotter isolated tests"
76+
- label: ":running: runtime isolated tests"
7777
agents:
7878
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
7979
distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"
@@ -82,12 +82,17 @@ steps:
8282
DOCKER_IMAGE_TAG: "$BUILDKITE_BUILD_NUMBER"
8383
NUMBER_OF_VMS: 10
8484
EXTRAGOARGS: "-v -count=1 -race"
85+
FICD_DM_VOLUME_GROUP: fcci-vg
8586
artifact_paths:
86-
- "snapshotter/logs/*"
87+
- "runtime/logs/*"
8788
command:
88-
- make -C snapshotter integ-test
89+
- make -C runtime integ-test FICD_DM_POOL=build_${BUILDKITE_BUILD_NUMBER}_runtime
8990

90-
- label: ":running: runtime isolated tests"
91+
- wait
92+
93+
# Let's isolate the remote snapshotter integration tests.
94+
# See https://github.com/firecracker-microvm/firecracker-containerd/issues/673
95+
- label: ":running: snapshotter isolated tests"
9196
agents:
9297
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
9398
distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"
@@ -96,11 +101,12 @@ steps:
96101
DOCKER_IMAGE_TAG: "$BUILDKITE_BUILD_NUMBER"
97102
NUMBER_OF_VMS: 10
98103
EXTRAGOARGS: "-v -count=1 -race"
99-
FICD_DM_VOLUME_GROUP: fcci-vg
100104
artifact_paths:
101-
- "runtime/logs/*"
105+
- "snapshotter/logs/*"
102106
command:
103-
- make -C runtime integ-test FICD_DM_POOL=build_${BUILDKITE_BUILD_NUMBER}_runtime
107+
- make -C snapshotter integ-test
108+
109+
- wait
104110

105111
- label: ":weight_lifter: stress tests"
106112
concurrency_group: stress

snapshotter/service_integ_test.go

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"context"
1818
"fmt"
1919
"strconv"
20-
"sync"
2120
"testing"
2221
"time"
2322

@@ -29,6 +28,7 @@ import (
2928
"github.com/firecracker-microvm/firecracker-containerd/runtime/firecrackeroci"
3029
"github.com/firecracker-microvm/firecracker-containerd/snapshotter/internal/integtest/stargz/fs/source"
3130
"github.com/stretchr/testify/require"
31+
"golang.org/x/sync/errgroup"
3232
)
3333

3434
const (
@@ -58,7 +58,8 @@ func TestLaunchContainerWithRemoteSnapshotter_Isolated(t *testing.T) {
5858
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
5959
defer cancel()
6060

61-
launchContainerWithRemoteSnapshotterInVM(ctx, t, strconv.Itoa(vmID))
61+
err := launchContainerWithRemoteSnapshotterInVM(ctx, strconv.Itoa(vmID))
62+
require.NoError(t, err)
6263
}
6364

6465
func TestLaunchMultipleContainersWithRemoteSnapshotter_Isolated(t *testing.T) {
@@ -68,33 +69,43 @@ func TestLaunchMultipleContainersWithRemoteSnapshotter_Isolated(t *testing.T) {
6869
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
6970
defer cancel()
7071

71-
var wg sync.WaitGroup
72+
eg, ctx := errgroup.WithContext(ctx)
7273

7374
numberOfVms := integtest.NumberOfVms
7475
for vmID := 0; vmID < numberOfVms; vmID++ {
75-
wg.Add(1)
76-
go func(id int) {
77-
defer wg.Done()
78-
launchContainerWithRemoteSnapshotterInVM(ctx, t, strconv.Itoa(id))
79-
}(vmID)
76+
ctx := ctx
77+
id := vmID
78+
eg.Go(func() error {
79+
return launchContainerWithRemoteSnapshotterInVM(ctx, strconv.Itoa(id))
80+
})
8081
}
81-
wg.Wait()
82+
err := eg.Wait()
83+
require.NoError(t, err)
8284
}
8385

84-
func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, t *testing.T, vmID string) {
86+
func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, vmID string) error {
8587
// For integration testing, assume the namespace is same as the VM ID.
8688
namespace := vmID
8789

8890
ctx = namespaces.WithNamespace(ctx, namespace)
8991

9092
client, err := containerd.New(integtest.ContainerdSockPath, containerd.WithDefaultRuntime(integtest.FirecrackerRuntime))
91-
require.NoError(t, err, "Unable to create client to containerd service at %s, is containerd running?", integtest.ContainerdSockPath)
93+
if err != nil {
94+
return fmt.Errorf("Unable to create client to containerd service at %s, is containerd running? [%v]", integtest.ContainerdSockPath, err)
95+
}
9296

9397
fcClient, err := integtest.NewFCControlClient(integtest.ContainerdSockPath)
94-
require.NoError(t, err, "Failed to create fccontrol client")
98+
if err != nil {
99+
return fmt.Errorf("Failed to create fccontrol client. [%v]", err)
100+
}
101+
102+
// Disable 8250 serial device and lessen the number of log messages written to the serial console.
103+
// https://github.com/firecracker-microvm/firecracker/blob/v1.1.0/docs/prod-host-setup.md
104+
kernelArgs := integtest.DefaultRuntimeConfig.KernelArgs + " 8250.nr_uarts=0 quiet loglevel=1"
95105

96106
_, err = fcClient.CreateVM(ctx, &proto.CreateVMRequest{
97-
VMID: vmID,
107+
VMID: vmID,
108+
KernelArgs: kernelArgs,
98109
RootDrive: &proto.FirecrackerRootDrive{
99110
HostPath: "/var/lib/firecracker-containerd/runtime/rootfs-stargz.img",
100111
},
@@ -111,23 +122,30 @@ func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, t *testing.T,
111122
VcpuCount: 1,
112123
MemSizeMib: 1024,
113124
},
125+
TimeoutSeconds: 60,
114126
ContainerCount: 1,
115127
})
116-
require.NoErrorf(t, err, "Failed to create microVM[%s]", vmID)
128+
if err != nil {
129+
return fmt.Errorf("Failed to create microVM[%s] [%v]", vmID, err)
130+
}
117131
defer fcClient.StopVM(ctx, &proto.StopVMRequest{VMID: vmID})
118132

119133
_, err = fcClient.SetVMMetadata(ctx, &proto.SetVMMetadataRequest{
120134
VMID: vmID,
121135
Metadata: fmt.Sprintf(dockerMetadataTemplate, "ghcr.io", noAuth, noAuth),
122136
})
123-
require.NoError(t, err, "Failed to configure VM metadata for registry resolution")
137+
if err != nil {
138+
return fmt.Errorf("Failed to configure VM metadata for registry resolution [%v]", err)
139+
}
124140

125141
image, err := client.Pull(ctx, imageRef,
126142
containerd.WithPullUnpack,
127143
containerd.WithPullSnapshotter(snapshotterName),
128144
containerd.WithImageHandlerWrapper(source.AppendDefaultLabelsHandlerWrapper(imageRef, 10*1024*1024)),
129145
)
130-
require.NoError(t, err, "Failed to pull image for VM: %s", vmID)
146+
if err != nil {
147+
return fmt.Errorf("Failed to pull image for VM: %s [%v]", vmID, err)
148+
}
131149
defer client.ImageService().Delete(ctx, image.Name())
132150

133151
container, err := client.NewContainer(ctx, fmt.Sprintf("container-%s", vmID),
@@ -141,9 +159,14 @@ func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, t *testing.T,
141159
firecrackeroci.WithVMNetwork,
142160
),
143161
)
144-
require.NoError(t, err, "Failed to create container in VM: %s", vmID)
162+
if err != nil {
163+
return fmt.Errorf("Failed to create container in VM: %s, [%v]", vmID, err)
164+
}
145165
defer container.Delete(ctx, containerd.WithSnapshotCleanup)
146166

147167
_, err = integtest.RunTask(ctx, container)
148-
require.NoError(t, err, "Failed to run task in VM: %s", vmID)
168+
if err != nil {
169+
return fmt.Errorf("Failed to run task in VM: %s [%v]", vmID, err)
170+
}
171+
return nil
149172
}

0 commit comments

Comments
 (0)