TestNetworkPluginInvocation checks that the right SetUpPod and TearDownPod calls are made when we run/stop a sandbox.
(t *testing.T)
| 262 | // TestNetworkPluginInvocation checks that the right SetUpPod and TearDownPod |
| 263 | // calls are made when we run/stop a sandbox. |
| 264 | func 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…