@@ -803,7 +803,7 @@ func TestTransformDCGMExporter(t *testing.T) {
803803 expectedDs Daemonset // Expected output DaemonSet
804804 }{
805805 {
806- description : "transform dcgm exporter" ,
806+ description : "transform dcgm exporter without annotations " ,
807807 ds : NewDaemonset ().
808808 WithContainer (corev1.Container {Name : "dcgm-exporter" }).
809809 WithContainer (corev1.Container {Name : "dummy" }),
@@ -833,6 +833,122 @@ func TestTransformDCGMExporter(t *testing.T) {
833833 },
834834 }).WithContainer (corev1.Container {Name : "dummy" }).WithPullSecret ("pull-secret" ).WithRuntimeClassName ("nvidia" ),
835835 },
836+ {
837+ description : "transform dcgm exporter with annotations" ,
838+ ds : NewDaemonset ().
839+ WithContainer (corev1.Container {Name : "dcgm-exporter" }).
840+ WithContainer (corev1.Container {Name : "dummy" }),
841+ cpSpec : & gpuv1.ClusterPolicySpec {
842+ DCGMExporter : gpuv1.DCGMExporterSpec {
843+ Repository : "nvcr.io/nvidia/cloud-native" ,
844+ Image : "dcgm-exporter" ,
845+ Version : "v1.0.0" ,
846+ ImagePullPolicy : "IfNotPresent" ,
847+ ImagePullSecrets : []string {"pull-secret" },
848+ Args : []string {"--fail-on-init-error=false" },
849+ Annotations : map [string ]string {"dcgm-exporter" : "test" },
850+ Env : []gpuv1.EnvVar {
851+ {Name : "foo" , Value : "bar" },
852+ },
853+ },
854+ DCGM : gpuv1.DCGMSpec {
855+ Enabled : newBoolPtr (true ),
856+ },
857+ },
858+ expectedDs : NewDaemonset ().WithContainer (corev1.Container {
859+ Name : "dcgm-exporter" ,
860+ Image : "nvcr.io/nvidia/cloud-native/dcgm-exporter:v1.0.0" ,
861+ ImagePullPolicy : corev1 .PullIfNotPresent ,
862+ Args : []string {"--fail-on-init-error=false" },
863+ Env : []corev1.EnvVar {
864+ {Name : "DCGM_REMOTE_HOSTENGINE_INFO" , Value : "nvidia-dcgm:5555" },
865+ },
866+ }).WithContainer (corev1.Container {Name : "dummy" }).WithPullSecret ("pull-secret" ).WithRuntimeClassName ("nvidia" ).WithPodAnnotations (map [string ]string {"dcgm-exporter" : "test" }),
867+ },
868+ {
869+ description : "transform dcgm exporter with annotations and common annotations" ,
870+ ds : NewDaemonset ().
871+ WithContainer (corev1.Container {Name : "dcgm-exporter" }).
872+ WithContainer (corev1.Container {Name : "dummy" }),
873+ cpSpec : & gpuv1.ClusterPolicySpec {
874+ Daemonsets : gpuv1.DaemonsetsSpec {Annotations : map [string ]string {
875+ "key" : "value" ,
876+ "app" : "value" ,
877+ "app.kubernetes.io/part-of" : "value" ,
878+ }},
879+ DCGMExporter : gpuv1.DCGMExporterSpec {
880+ Repository : "nvcr.io/nvidia/cloud-native" ,
881+ Image : "dcgm-exporter" ,
882+ Version : "v1.0.0" ,
883+ ImagePullPolicy : "IfNotPresent" ,
884+ ImagePullSecrets : []string {"pull-secret" },
885+ Args : []string {"--fail-on-init-error=false" },
886+ Annotations : map [string ]string {"dcgm-exporter" : "test" },
887+ Env : []gpuv1.EnvVar {
888+ {Name : "foo" , Value : "bar" },
889+ },
890+ },
891+ DCGM : gpuv1.DCGMSpec {
892+ Enabled : newBoolPtr (true ),
893+ },
894+ },
895+ expectedDs : NewDaemonset ().WithContainer (corev1.Container {
896+ Name : "dcgm-exporter" ,
897+ Image : "nvcr.io/nvidia/cloud-native/dcgm-exporter:v1.0.0" ,
898+ ImagePullPolicy : corev1 .PullIfNotPresent ,
899+ Args : []string {"--fail-on-init-error=false" },
900+ Env : []corev1.EnvVar {
901+ {Name : "DCGM_REMOTE_HOSTENGINE_INFO" , Value : "nvidia-dcgm:5555" },
902+ },
903+ }).WithContainer (corev1.Container {Name : "dummy" }).WithPullSecret ("pull-secret" ).WithRuntimeClassName ("nvidia" ).
904+ WithPodAnnotations (map [string ]string {
905+ "dcgm-exporter" : "test" ,
906+ "key" : "value" ,
907+ "app" : "value" ,
908+ "app.kubernetes.io/part-of" : "value" ,
909+ }),
910+ },
911+ {
912+ description : "transform dcgm exporter only with common annotations" ,
913+ ds : NewDaemonset ().
914+ WithContainer (corev1.Container {Name : "dcgm-exporter" }).
915+ WithContainer (corev1.Container {Name : "dummy" }),
916+ cpSpec : & gpuv1.ClusterPolicySpec {
917+ Daemonsets : gpuv1.DaemonsetsSpec {Annotations : map [string ]string {
918+ "key" : "value" ,
919+ "app" : "value" ,
920+ "app.kubernetes.io/part-of" : "value" ,
921+ }},
922+ DCGMExporter : gpuv1.DCGMExporterSpec {
923+ Repository : "nvcr.io/nvidia/cloud-native" ,
924+ Image : "dcgm-exporter" ,
925+ Version : "v1.0.0" ,
926+ ImagePullPolicy : "IfNotPresent" ,
927+ ImagePullSecrets : []string {"pull-secret" },
928+ Args : []string {"--fail-on-init-error=false" },
929+ Env : []gpuv1.EnvVar {
930+ {Name : "foo" , Value : "bar" },
931+ },
932+ },
933+ DCGM : gpuv1.DCGMSpec {
934+ Enabled : newBoolPtr (true ),
935+ },
936+ },
937+ expectedDs : NewDaemonset ().WithContainer (corev1.Container {
938+ Name : "dcgm-exporter" ,
939+ Image : "nvcr.io/nvidia/cloud-native/dcgm-exporter:v1.0.0" ,
940+ ImagePullPolicy : corev1 .PullIfNotPresent ,
941+ Args : []string {"--fail-on-init-error=false" },
942+ Env : []corev1.EnvVar {
943+ {Name : "DCGM_REMOTE_HOSTENGINE_INFO" , Value : "nvidia-dcgm:5555" },
944+ },
945+ }).WithContainer (corev1.Container {Name : "dummy" }).WithPullSecret ("pull-secret" ).WithRuntimeClassName ("nvidia" ).
946+ WithPodAnnotations (map [string ]string {
947+ "key" : "value" ,
948+ "app" : "value" ,
949+ "app.kubernetes.io/part-of" : "value" ,
950+ }),
951+ },
836952 }
837953
838954 for _ , tc := range testCases {
0 commit comments