Test annotation injection by NRI plugins.
(t *testing.T)
| 225 | |
| 226 | // Test annotation injection by NRI plugins. |
| 227 | func 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. |
| 259 | func TestNriLinuxDeviceInjection(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…