Skip to content

Commit ed9cd95

Browse files
committed
Use testdata/firecracker when it can
The new CI instance doesn't have /usr/local/bin/firecracker. Since other tests already use testdata/firecracker, using the binary from these tests is better than having the binary on /usr/local. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 7089a4e commit ed9cd95

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

machine_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,12 +909,19 @@ func TestPID(t *testing.T) {
909909
DisableValidation: true,
910910
}
911911

912-
m, err = NewMachine(context.Background(), cfg, WithLogger(fctesting.NewLogEntry(t)))
912+
ctx := context.Background()
913+
914+
cmd := VMCommandBuilder{}.
915+
WithSocketPath(cfg.SocketPath).
916+
WithBin(getFirecrackerBinaryPath()).
917+
Build(ctx)
918+
919+
m, err = NewMachine(ctx, cfg, WithProcessRunner(cmd), WithLogger(fctesting.NewLogEntry(t)))
913920
if err != nil {
914921
t.Errorf("expected no error during create machine, but received %v", err)
915922
}
916923

917-
if err := m.Start(context.Background()); err != nil {
924+
if err := m.Start(ctx); err != nil {
918925
t.Errorf("expected no error during Start, but received %v", err)
919926
}
920927
defer m.StopVMM()
@@ -932,7 +939,7 @@ func TestPID(t *testing.T) {
932939
t.Errorf("expected clean kill, but received %v", err)
933940
}
934941

935-
m.Wait(context.Background())
942+
m.Wait(ctx)
936943

937944
if _, err := m.PID(); err == nil {
938945
t.Errorf("expected an error, but received none")

network_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ func startCNIMachine(t *testing.T,
353353
err = ioutil.WriteFile(rootfsPath, rootfsBytes, 0666)
354354
require.NoError(t, err, "failed to copy vm rootfs to %s", rootfsPath)
355355

356+
cmd := VMCommandBuilder{}.
357+
WithSocketPath(firecrackerSockPath).
358+
WithBin(getFirecrackerBinaryPath()).
359+
Build(ctx)
360+
356361
m, err := NewMachine(ctx, Config{
357362
SocketPath: firecrackerSockPath,
358363
KernelImagePath: getVmlinuxPath(t),
@@ -379,7 +384,7 @@ func startCNIMachine(t *testing.T,
379384
},
380385
}},
381386
VMID: vmID,
382-
})
387+
}, WithProcessRunner(cmd))
383388
require.NoError(t, err, "failed to create machine with CNI network interface")
384389

385390
err = m.Start(context.Background())

0 commit comments

Comments
 (0)