Skip to content

Commit 3dc480c

Browse files
[no-relnote] add e2e for containerd
Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
1 parent 3335b5d commit 3dc480c

File tree

6 files changed

+522
-4
lines changed

6 files changed

+522
-4
lines changed

tests/e2e/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ GINKGO_BIN := $(CURDIR)/bin/ginkgo
2525
# - nvidia-container-cli
2626
# - docker
2727
# - nvidia-cdi-refresh
28+
# - containerd
2829
GINKGO_FOCUS ?=
2930

3031
test: $(GINKGO_BIN)

tests/e2e/installer.go

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,49 @@ docker run --pid=host --rm -i --privileged \
6262
--restart-mode=systemd
6363
`
6464

65+
// containerdInstallTemplate is a template for installing the NVIDIA Container Toolkit
66+
// on a host using containerd with drop-in configuration support.
67+
var containerdInstallTemplate = `
68+
set -xe
69+
70+
# if the TEMP_DIR is already set, use it
71+
if [ -f /tmp/ctk_e2e_temp_dir.txt ]; then
72+
TEMP_DIR=$(cat /tmp/ctk_e2e_temp_dir.txt)
73+
else
74+
TEMP_DIR="/tmp/ctk_e2e.$(date +%s)_$RANDOM"
75+
echo "$TEMP_DIR" > /tmp/ctk_e2e_temp_dir.txt
76+
fi
77+
78+
# if TEMP_DIR does not exist, create it
79+
if [ ! -d "$TEMP_DIR" ]; then
80+
mkdir -p "$TEMP_DIR"
81+
fi
82+
83+
# Create the drop-in config directory if it doesn't exist
84+
mkdir -p /etc/containerd/conf.d || true
85+
86+
docker run --pid=host --rm -i --privileged \
87+
-v /:/host \
88+
-v "$TEMP_DIR:$TEMP_DIR" \
89+
-v /etc/containerd:/config-root \
90+
{{.Image}} \
91+
--root "$TEMP_DIR/toolkit" \
92+
--runtime=containerd \
93+
--config=/config-root/config.toml \
94+
--drop-in-config=/config-root/conf.d/99-nvidia.toml \
95+
--drop-in-config-host-path=/etc/containerd/conf.d/99-nvidia.toml \
96+
--driver-root=/ \
97+
--no-daemon \
98+
--restart-mode=none{{if .AdditionalFlags}} \
99+
{{.AdditionalFlags}}{{end}}
100+
`
101+
65102
type ToolkitInstaller struct {
66103
runner Runner
67104
template string
68105

69-
Image string
106+
Image string
107+
AdditionalFlags string
70108
}
71109

72110
type installerOption func(*ToolkitInstaller)
@@ -89,6 +127,12 @@ func WithTemplate(template string) installerOption {
89127
}
90128
}
91129

130+
func WithAdditionalFlags(flags string) installerOption {
131+
return func(i *ToolkitInstaller) {
132+
i.AdditionalFlags = flags
133+
}
134+
}
135+
92136
func NewToolkitInstaller(opts ...installerOption) (*ToolkitInstaller, error) {
93137
i := &ToolkitInstaller{
94138
runner: localRunner{},

tests/e2e/nvidia-container-cli_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ curl -fsSL http://cdimage.ubuntu.com/ubuntu-base/releases/22.04/release/ubuntu-b
4242
}
4343
4444
# Enter a new mount + PID namespace so we can pivot_root without touching the
45-
# container'\''s original filesystem.
46-
unshare --mount --pid --fork --propagation private -- sh -eux <<'\''IN_NS'\''
45+
# container's original filesystem.
46+
unshare --mount --pid --fork --propagation private -- sh -eux <<'IN_NS'
4747
: "${ROOTFS:?}"
4848
4949
# 1 Bind-mount the new root and make the mount private

0 commit comments

Comments
 (0)