Skip to content

Commit 8c29d8c

Browse files
Kazuyoshi Katoxibz
authored andcommitted
Verify that the shim is correctly killed
Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent c9d7f20 commit 8c29d8c

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

runtime/service_integ_test.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,7 @@ func TestShimExitsUponContainerDelete_Isolated(t *testing.T) {
140140
err = task.Start(testCtx)
141141
require.NoError(t, err, "failed to start task for container %s", containerName)
142142

143-
shimProcesses, err := internal.WaitForProcessToExist(testCtx, time.Second,
144-
func(ctx context.Context, p *process.Process) (bool, error) {
145-
processExecutable, err := p.ExeWithContext(ctx)
146-
if err != nil {
147-
return false, err
148-
}
149-
150-
return filepath.Base(processExecutable) == shimProcessName, nil
151-
},
152-
)
143+
shimProcesses, err := internal.WaitForProcessToExist(testCtx, time.Second, findShim)
153144
require.NoError(t, err, "failed waiting for expected shim process %q to come up", shimProcessName)
154145
require.Len(t, shimProcesses, 1, "expected only one shim process to exist")
155146
shimProcess := shimProcesses[0]
@@ -1264,6 +1255,22 @@ func TestStopVM_Isolated(t *testing.T) {
12641255
stdout := startAndWaitTask(ctx, t, c)
12651256
require.Equal("hello", stdout)
12661257

1258+
shimProcesses, err := internal.WaitForProcessToExist(ctx, time.Second, findShim)
1259+
require.NoError(err, "failed waiting for expected shim process %q to come up", shimProcessName)
1260+
require.Len(shimProcesses, 1, "expected only one shim process to exist")
1261+
12671262
_, err = fcClient.StopVM(ctx, &proto.StopVMRequest{VMID: vmID})
12681263
require.NoError(err)
1264+
1265+
err = internal.WaitForPidToExit(ctx, time.Second, shimProcesses[0].Pid)
1266+
require.NoError(err, "shim hasn't been terminated")
1267+
}
1268+
1269+
func findShim(ctx context.Context, p *process.Process) (bool, error) {
1270+
processExecutable, err := p.ExeWithContext(ctx)
1271+
if err != nil {
1272+
return false, err
1273+
}
1274+
1275+
return filepath.Base(processExecutable) == shimProcessName, nil
12691276
}

0 commit comments

Comments
 (0)