MCPcopy Create free account
hub / github.com/Mirantis/cri-dockerd / TestNetworkPluginInvocation

Function TestNetworkPluginInvocation

core/sandbox_helpers_test.go:264–293  ·  view source on GitHub ↗

TestNetworkPluginInvocation checks that the right SetUpPod and TearDownPod calls are made when we run/stop a sandbox.

(t *testing.T)

Source from the content-addressed store, hash-verified

262// TestNetworkPluginInvocation checks that the right SetUpPod and TearDownPod
263// calls are made when we run/stop a sandbox.
264func TestNetworkPluginInvocation(t *testing.T) {
265 ds, _, _ := newTestDockerService()
266 mockPlugin := newTestNetworkPlugin(t)
267 ds.network = network.NewPluginManager(mockPlugin)
268 defer mockPlugin.Finish()
269
270 name := "foo0"
271 ns := "bar0"
272 c := makeSandboxConfigWithLabelsAndAnnotations(
273 name, ns, "0", 0,
274 map[string]string{"label": name},
275 map[string]string{"annotation": ns},
276 )
277 cID := config.ContainerID{
278 Type: runtimeName,
279 ID: libdocker.GetFakeContainerID(fmt.Sprintf("/%v", makeSandboxName(c))),
280 }
281
282 mockPlugin.EXPECT().Name().Return("mockNetworkPlugin").AnyTimes()
283 setup := mockPlugin.EXPECT().SetUpPod(ns, name, cID)
284 mockPlugin.EXPECT().TearDownPod(ns, name, cID).After(setup)
285
286 _, err := ds.RunPodSandbox(getTestCTX(), &runtimeapi.RunPodSandboxRequest{Config: c})
287 require.NoError(t, err)
288 _, err = ds.StopPodSandbox(
289 getTestCTX(),
290 &runtimeapi.StopPodSandboxRequest{PodSandboxId: cID.ID},
291 )
292 require.NoError(t, err)
293}
294
295// TestHostNetworkPluginInvocation checks that *no* SetUp/TearDown calls happen
296// for host network sandboxes.

Callers

nothing calls this directly

Calls 14

NewPluginManagerFunction · 0.92
GetFakeContainerIDFunction · 0.92
newTestDockerServiceFunction · 0.85
newTestNetworkPluginFunction · 0.85
makeSandboxNameFunction · 0.85
getTestCTXFunction · 0.85
FinishMethod · 0.80
RunPodSandboxMethod · 0.80
StopPodSandboxMethod · 0.80
NameMethod · 0.65
SetUpPodMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…