MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / TestTransformKataManager

Function TestTransformKataManager

controllers/transforms_test.go:1949–2065  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1947}
1948
1949func TestTransformKataManager(t *testing.T) {
1950 testCases := []struct {
1951 description string
1952 ds Daemonset
1953 cpSpec *gpuv1.ClusterPolicySpec
1954 expectedDs Daemonset
1955 }{
1956 {
1957 description: "transform kata manager",
1958 ds: NewDaemonset().WithContainer(corev1.Container{Name: "nvidia-kata-manager"}),
1959 cpSpec: &gpuv1.ClusterPolicySpec{
1960 KataManager: gpuv1.KataManagerSpec{
1961 Repository: "nvcr.io/nvidia/cloud-native",
1962 Image: "kata-manager",
1963 Version: "v1.0.0",
1964 ImagePullPolicy: "IfNotPresent",
1965 ImagePullSecrets: []string{"pull-secret"},
1966 Args: []string{"--test-flag"},
1967 Config: &kata_v1alpha1.Config{
1968 ArtifactsDir: "/var/lib/kata",
1969 },
1970 Env: []gpuv1.EnvVar{
1971 {Name: "foo", Value: "bar"},
1972 },
1973 },
1974 },
1975 expectedDs: NewDaemonset().WithContainer(corev1.Container{
1976 Name: "nvidia-kata-manager",
1977 Image: "nvcr.io/nvidia/cloud-native/kata-manager:v1.0.0",
1978 ImagePullPolicy: corev1.PullIfNotPresent,
1979 Args: []string{"--test-flag"},
1980 Env: []corev1.EnvVar{
1981 {Name: "KATA_ARTIFACTS_DIR", Value: "/var/lib/kata"},
1982 {Name: "foo", Value: "bar"},
1983 {Name: "RUNTIME", Value: "containerd"},
1984 {Name: "CONTAINERD_RUNTIME_CLASS", Value: "nvidia"},
1985 {Name: "RUNTIME_CONFIG", Value: "/runtime/config-dir/config.toml"},
1986 {Name: "CONTAINERD_CONFIG", Value: "/runtime/config-dir/config.toml"},
1987 {Name: "RUNTIME_SOCKET", Value: "/runtime/sock-dir/containerd.sock"},
1988 {Name: "CONTAINERD_SOCKET", Value: "/runtime/sock-dir/containerd.sock"},
1989 },
1990 VolumeMounts: []corev1.VolumeMount{
1991 {Name: "kata-artifacts", MountPath: "/var/lib/kata"},
1992 {Name: "containerd-config", MountPath: "/runtime/config-dir/"},
1993 {Name: "containerd-socket", MountPath: "/runtime/sock-dir/"},
1994 },
1995 }).WithPullSecret("pull-secret").WithPodAnnotations(map[string]string{"nvidia.com/kata-manager.last-applied-hash": "1929911998"}).WithHostPathVolume("kata-artifacts", "/var/lib/kata", ptr.To(corev1.HostPathDirectoryOrCreate)).WithHostPathVolume("containerd-config", "/etc/containerd", ptr.To(corev1.HostPathDirectoryOrCreate)).WithHostPathVolume("containerd-socket", "/run/containerd", nil),
1996 },
1997 {
1998 description: "transform kata manager with custom container runtime socket",
1999 ds: NewDaemonset().WithContainer(corev1.Container{Name: "nvidia-kata-manager"}),
2000 cpSpec: &gpuv1.ClusterPolicySpec{
2001 KataManager: gpuv1.KataManagerSpec{
2002 Repository: "nvcr.io/nvidia/cloud-native",
2003 Image: "kata-manager",
2004 Version: "v1.0.0",
2005 ImagePullPolicy: "IfNotPresent",
2006 ImagePullSecrets: []string{"pull-secret"},

Callers

nothing calls this directly

Calls 8

NewDaemonsetFunction · 0.85
TransformKataManagerFunction · 0.85
WithContainerMethod · 0.80
WithHostPathVolumeMethod · 0.80
WithPodAnnotationsMethod · 0.80
WithPullSecretMethod · 0.80
RunMethod · 0.80
WithNameMethod · 0.80

Tested by

no test coverage detected