MCPcopy
hub / github.com/containerd/containerd / TestNriAnnotationInjection

Function TestNriAnnotationInjection

integration/nri_test.go:227–256  ·  view source on GitHub ↗

Test annotation injection by NRI plugins.

(t *testing.T)

Source from the content-addressed store, hash-verified

225
226// Test annotation injection by NRI plugins.
227func TestNriAnnotationInjection(t *testing.T) {
228 skipNriTestIfNecessary(t)
229
230 t.Log("Test that NRI plugins can inject annotations into containers.")
231
232 var (
233 key = "TEST_ANNOTATION_KEY"
234 value = "TEST_ANNOTATION_VALUE"
235 tc = &nriTest{
236 t: t,
237 plugins: []*mockPlugin{{}},
238 }
239 injectAnnotation = func(p *mockPlugin, pod *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
240 adjust := &api.ContainerAdjustment{}
241 adjust.AddAnnotation(key, value)
242 return adjust, nil, nil
243 }
244 )
245
246 tc.plugins[0].createContainer = injectAnnotation
247 tc.setup()
248
249 podID := tc.runPod("pod0")
250 id := tc.startContainer(podID, "ctr0")
251
252 timeout := time.After(pluginSyncTimeout)
253 err := tc.plugins[0].Wait(ContainerEvent(tc.plugins[0].ctrs[id], PostCreateContainer), timeout)
254 require.NoError(t, err, "wait for container post-create event")
255 require.Equal(t, value, tc.plugins[0].ctrs[id].Annotations[key], "updated annotations")
256}
257
258// Test linux device injection by NRI plugins.
259func TestNriLinuxDeviceInjection(t *testing.T) {

Callers

nothing calls this directly

Calls 7

skipNriTestIfNecessaryFunction · 0.85
ContainerEventFunction · 0.85
LogMethod · 0.80
setupMethod · 0.80
runPodMethod · 0.80
startContainerMethod · 0.80
WaitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…