@@ -145,6 +145,7 @@ var _ = Describe("NIMServiceReconciler for a standalone platform", func() {
145
145
Expect (monitoringv1 .AddToScheme (scheme )).To (Succeed ())
146
146
Expect (lwsv1 .AddToScheme (scheme )).To (Succeed ())
147
147
Expect (gatewayv1 .Install (scheme )).To (Succeed ())
148
+ Expect (resourcev1beta2 .AddToScheme (scheme )).To (Succeed ())
148
149
149
150
client = fake .NewClientBuilder ().WithScheme (scheme ).
150
151
WithStatusSubresource (& appsv1alpha1.NIMService {}).
@@ -756,6 +757,87 @@ var _ = Describe("NIMServiceReconciler for a standalone platform", func() {
756
757
Expect (failedCondition .Reason ).To (Equal (conditions .ReasonDRAResourcesUnsupported ))
757
758
Expect (failedCondition .Message ).To (Equal ("spec.draResources[1].resourceClaimName: duplicate resource claim name: 'test-resource-claim'" ))
758
759
})
760
+
761
+ It ("should mark NIMService as failed when ClaimCreationSpec.Devices[].AttributeSelectors version value is invalid" , func () {
762
+ nimService .Spec .DRAResources = []appsv1alpha1.DRAResource {
763
+ {
764
+ ClaimCreationSpec : & appsv1alpha1.DRAClaimCreationSpec {
765
+ Devices : []appsv1alpha1.DRADeviceSpec {
766
+ {
767
+ Name : "test-device" ,
768
+ Count : 1 ,
769
+ DriverName : "gpu.nvidia.com" ,
770
+ DeviceClassName : "gpu.nvidia.com" ,
771
+ AttributeSelectors : []appsv1alpha1.DRADeviceAttributeSelector {
772
+ {
773
+ Key : "testKey" ,
774
+ Op : "GreaterThan" ,
775
+ Value : & appsv1alpha1.DRADeviceAttributeSelectorValue {
776
+ VersionValue : ptr .To ("550.127.08" ),
777
+ },
778
+ },
779
+ },
780
+ },
781
+ },
782
+ },
783
+ },
784
+ }
785
+ nimServiceKey := types.NamespacedName {Name : nimService .Name , Namespace : nimService .Namespace }
786
+ err := client .Create (context .TODO (), nimService )
787
+ Expect (err ).NotTo (HaveOccurred ())
788
+
789
+ _ , err = reconciler .reconcileNIMService (context .TODO (), nimService )
790
+ Expect (err ).NotTo (HaveOccurred ())
791
+
792
+ obj := & appsv1alpha1.NIMService {}
793
+ err = client .Get (context .TODO (), nimServiceKey , obj )
794
+ Expect (err ).NotTo (HaveOccurred ())
795
+ Expect (obj .Status .State ).To (Equal (appsv1alpha1 .NIMServiceStatusFailed ))
796
+ failedCondition := getCondition (obj , conditions .Failed )
797
+ Expect (failedCondition ).NotTo (BeNil ())
798
+ Expect (failedCondition .Status ).To (Equal (metav1 .ConditionTrue ))
799
+ Expect (failedCondition .Reason ).To (Equal (conditions .ReasonDRAResourcesUnsupported ))
800
+ Expect (failedCondition .Message ).To (ContainSubstring ("spec.draResources[0].claimCreationSpec.devices[0].attributeSelectors[0].value.versionValue.version: invalid version \" 550.127.08\" :" ))
801
+ })
802
+
803
+ It ("should succeed with valid ClaimCreationSpec" , func () {
804
+ nimService .Spec .DRAResources = []appsv1alpha1.DRAResource {
805
+ {
806
+ ClaimCreationSpec : & appsv1alpha1.DRAClaimCreationSpec {
807
+ Devices : []appsv1alpha1.DRADeviceSpec {
808
+ {
809
+ Name : "test-device" ,
810
+ Count : 1 ,
811
+ DriverName : "gpu.nvidia.com" ,
812
+ DeviceClassName : "gpu.nvidia.com" ,
813
+ AttributeSelectors : []appsv1alpha1.DRADeviceAttributeSelector {
814
+ {
815
+ Key : "testKey" ,
816
+ Op : "GreaterThan" ,
817
+ Value : & appsv1alpha1.DRADeviceAttributeSelectorValue {
818
+ VersionValue : ptr .To ("550.127.8" ),
819
+ },
820
+ },
821
+ },
822
+ },
823
+ },
824
+ },
825
+ },
826
+ }
827
+ nimServiceKey := types.NamespacedName {Name : nimService .Name , Namespace : nimService .Namespace }
828
+ err := client .Create (context .TODO (), nimService )
829
+ Expect (err ).NotTo (HaveOccurred ())
830
+
831
+ _ , err = reconciler .reconcileNIMService (context .TODO (), nimService )
832
+ Expect (err ).NotTo (HaveOccurred ())
833
+
834
+ obj := & appsv1alpha1.NIMService {}
835
+ err = client .Get (context .TODO (), nimServiceKey , obj )
836
+ Expect (err ).NotTo (HaveOccurred ())
837
+ Expect (obj .Status .State ).NotTo (Equal (appsv1alpha1 .NIMServiceStatusFailed ))
838
+ failedCondition := getCondition (obj , conditions .Failed )
839
+ Expect (failedCondition .Status ).To (Equal (metav1 .ConditionFalse ))
840
+ })
759
841
})
760
842
761
843
It ("should delete Deployment when the NIMService is deleted" , func () {
0 commit comments