Skip to content

Commit 13ca3e3

Browse files
[no-relnote] Add test to check CDI injection by default
Now that the NVIDIA Container Toolkit uses CDI injection by default. This does not trigger the code in the nvidia-container-cli that creates the empty files on the host. Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent b442fe8 commit 13ca3e3

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/e2e/nvidia-container-toolkit_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,22 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
240240
BeforeAll(func(ctx context.Context) {
241241
_, _, err := runner.Run("docker pull ubuntu")
242242
Expect(err).ToNot(HaveOccurred())
243+
244+
err = buildDockerImage(
245+
runner,
246+
"firmware-test",
247+
map[string]string{
248+
"RM_VERSION": "$(basename $(ls -d /lib/firmware/nvidia/*.*))",
249+
"CURRENT_DIR": "$(pwd)",
250+
}, `
251+
FROM ubuntu
252+
RUN mkdir -p /lib/firmware/nvidia/
253+
ARG RM_VERSION
254+
ARG CURRENT_DIR
255+
RUN ln -s /../../../../../../../../$CURRENT_DIR /lib/firmware/nvidia/$RM_VERSION
256+
`,
257+
)
258+
Expect(err).ToNot(HaveOccurred())
243259
})
244260

245261
It("should include libcuda.so in the ldcache", func(ctx context.Context) {
@@ -256,5 +272,14 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
256272

257273
Expect(libs).To(ContainElements([]string{"libcuda.so", "libcuda.so.1"}))
258274
})
275+
276+
It("should not attempt to create empty firmware files", func(ctx context.Context) {
277+
_, _, err := runner.Run("docker run --rm --runtime=nvidia --gpus=all firmware-test")
278+
Expect(err).To(HaveOccurred())
279+
280+
containerOutput, _, err := runner.Run("docker run --rm --runtime=runc --gpus=all firmware-test")
281+
Expect(err).ToNot(HaveOccurred())
282+
Expect(containerOutput).To(BeEmpty())
283+
})
259284
})
260285
})

tests/e2e/runner.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,15 @@ func connectOrDie(sshKey, sshUser, host, port string) (*ssh.Client, error) {
169169

170170
return client, nil
171171
}
172+
173+
func buildDockerImage(runner Runner, tag string, args map[string]string, dockerfile string) error {
174+
var buildArgs string
175+
for k, v := range args {
176+
buildArgs += fmt.Sprintf("--build-arg %s=%q ", k, v)
177+
}
178+
179+
command := fmt.Sprintf("docker build -t %s %s - <<EOF\n%s\nEOF", tag, buildArgs, dockerfile)
180+
181+
_, _, err := runner.Run(command)
182+
return err
183+
}

0 commit comments

Comments
 (0)