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

Function TestTransformDCGM

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

Source from the content-addressed store, hash-verified

1661}
1662
1663func TestTransformDCGM(t *testing.T) {
1664 limits := corev1.ResourceList{
1665 corev1.ResourceCPU: resource.MustParse("100m"),
1666 corev1.ResourceMemory: resource.MustParse("128Mi"),
1667 }
1668 requests := corev1.ResourceList{
1669 corev1.ResourceCPU: resource.MustParse("50m"),
1670 corev1.ResourceMemory: resource.MustParse("64Mi"),
1671 }
1672
1673 testCases := []struct {
1674 description string
1675 daemonset Daemonset
1676 clusterPolicySpec *gpuv1.ClusterPolicySpec
1677 expectedDaemonset Daemonset
1678 }{
1679 {
1680 description: "transform dcgm fully configured",
1681 daemonset: NewDaemonset().
1682 WithContainer(corev1.Container{Name: "dcgm"}).
1683 WithContainer(corev1.Container{Name: "sidecar"}),
1684 clusterPolicySpec: &gpuv1.ClusterPolicySpec{
1685 DCGM: gpuv1.DCGMSpec{
1686 Repository: "nvcr.io/nvidia/cloud-native",
1687 Image: "dcgm",
1688 Version: "v1.0.0",
1689 ImagePullPolicy: "IfNotPresent",
1690 ImagePullSecrets: []string{"pull-secret"},
1691 Resources: &gpuv1.ResourceRequirements{Limits: limits, Requests: requests},
1692 Args: []string{"--foo"},
1693 Env: []gpuv1.EnvVar{{Name: "FOO", Value: "bar"}},
1694 },
1695 },
1696 expectedDaemonset: NewDaemonset().
1697 WithContainer(corev1.Container{
1698 Name: "dcgm",
1699 Image: "nvcr.io/nvidia/cloud-native/dcgm:v1.0.0",
1700 ImagePullPolicy: corev1.PullIfNotPresent,
1701 Args: []string{"--foo"},
1702 Env: []corev1.EnvVar{{Name: "FOO", Value: "bar"}},
1703 Resources: corev1.ResourceRequirements{Limits: limits, Requests: requests},
1704 }).
1705 WithContainer(corev1.Container{
1706 Name: "sidecar",
1707 Resources: corev1.ResourceRequirements{Limits: limits, Requests: requests},
1708 }).
1709 WithPullSecret("pull-secret").
1710 WithRuntimeClassName("nvidia"),
1711 },
1712 {
1713 description: "transform dcgm sets runtime class only when spec empty",
1714 daemonset: NewDaemonset().WithContainer(corev1.Container{Name: "dcgm"}),
1715 clusterPolicySpec: &gpuv1.ClusterPolicySpec{
1716 Operator: gpuv1.OperatorSpec{RuntimeClass: "nvidia"},
1717 DCGM: gpuv1.DCGMSpec{Repository: "nvcr.io/nvidia/cloud-native", Image: "dcgm", Version: "v1.0.0"},
1718 },
1719 expectedDaemonset: NewDaemonset().
1720 WithContainer(corev1.Container{

Callers

nothing calls this directly

Calls 7

NewDaemonsetFunction · 0.85
TransformDCGMFunction · 0.85
WithContainerMethod · 0.80
WithPullSecretMethod · 0.80
RunMethod · 0.80
WithNameMethod · 0.80
WithRuntimeClassNameMethod · 0.45

Tested by

no test coverage detected