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

Function TestTransformMigManager

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

Source from the content-addressed store, hash-verified

1766}
1767
1768func TestTransformMigManager(t *testing.T) {
1769 testCases := []struct {
1770 description string
1771 ds Daemonset
1772 cpSpec *gpuv1.ClusterPolicySpec
1773 expectedDs Daemonset
1774 }{
1775 {
1776 description: "transform mig manager",
1777 ds: NewDaemonset().WithContainer(corev1.Container{Name: "mig-manager"}).WithVolume(corev1.Volume{
1778 Name: "mig-parted-config",
1779 VolumeSource: corev1.VolumeSource{ConfigMap: &corev1.ConfigMapVolumeSource{}},
1780 }),
1781 cpSpec: &gpuv1.ClusterPolicySpec{
1782 MIGManager: gpuv1.MIGManagerSpec{
1783 Repository: "nvcr.io/nvidia/cloud-native",
1784 Image: "mig-manager",
1785 Version: "v1.0.0",
1786 ImagePullPolicy: "IfNotPresent",
1787 ImagePullSecrets: []string{"pull-secret"},
1788 Args: []string{"--test-flag"},
1789 Env: []gpuv1.EnvVar{
1790 {Name: "foo", Value: "bar"},
1791 },
1792 },
1793 Toolkit: gpuv1.ToolkitSpec{
1794 Enabled: newBoolPtr(true),
1795 InstallDir: "/path/to/install",
1796 },
1797 },
1798 expectedDs: NewDaemonset().WithContainer(corev1.Container{
1799 Name: "mig-manager",
1800 Image: "nvcr.io/nvidia/cloud-native/mig-manager:v1.0.0",
1801 ImagePullPolicy: corev1.PullIfNotPresent,
1802 Args: []string{"--test-flag"},
1803 Env: []corev1.EnvVar{
1804 {Name: "DEFAULT_CONFIG_FILE", Value: "/mig-parted-config/config-default.yaml"},
1805 {Name: CDIEnabledEnvName, Value: "true"},
1806 {Name: NvidiaCDIHookPathEnvName, Value: "/path/to/install/toolkit/nvidia-cdi-hook"},
1807 {Name: "foo", Value: "bar"},
1808 },
1809 }).WithPullSecret("pull-secret").WithRuntimeClassName("nvidia").WithVolume(corev1.Volume{
1810 Name: "mig-parted-config",
1811 VolumeSource: corev1.VolumeSource{ConfigMap: &corev1.ConfigMapVolumeSource{
1812 LocalObjectReference: corev1.LocalObjectReference{Name: MigPartedDefaultConfigMapName},
1813 Items: []corev1.KeyToPath{{Key: "config.yaml", Path: "config-default.yaml"}},
1814 }},
1815 }),
1816 },
1817 {
1818 description: "mig manager with custom config",
1819 ds: NewDaemonset().WithContainer(corev1.Container{
1820 Name: "mig-manager",
1821 VolumeMounts: []corev1.VolumeMount{
1822 {Name: "mig-parted-config", MountPath: "/mig-parted-config", ReadOnly: true},
1823 },
1824 }).WithVolume(corev1.Volume{
1825 Name: "mig-parted-config",

Callers

nothing calls this directly

Calls 9

NewDaemonsetFunction · 0.85
newBoolPtrFunction · 0.85
TransformMIGManagerFunction · 0.85
WithVolumeMethod · 0.80
WithContainerMethod · 0.80
WithPullSecretMethod · 0.80
RunMethod · 0.80
WithNameMethod · 0.80
WithRuntimeClassNameMethod · 0.45

Tested by

no test coverage detected