@@ -726,6 +726,68 @@ var _ = Describe("OVNController controller", func() {
726726 })
727727 })
728728
729+ When ("OVNController is created with invalid nic mappings" , func () {
730+ var OVNControllerName types.NamespacedName
731+ BeforeEach (func () {
732+ dbs := CreateOVNDBClusters (namespace , map [string ][]string {}, 1 )
733+ DeferCleanup (DeleteOVNDBClusters , dbs )
734+ spec := GetDefaultOVNControllerSpec ()
735+ spec .NicMappings = map [string ]string {
736+ "<invalid>" : "<nic>" ,
737+ }
738+ instance := CreateOVNController (namespace , spec )
739+ OVNControllerName = types.NamespacedName {Name : instance .GetName (), Namespace : instance .GetNamespace ()}
740+ DeferCleanup (th .DeleteInstance , instance )
741+ })
742+
743+ It ("reports error for invalid nicMappings" , func () {
744+ Eventually (func (g Gomega ) {
745+ getter := ConditionGetterFunc (OVNControllerConditionGetter )
746+ conditions := getter .GetConditions (OVNControllerName )
747+ g .Expect (conditions ).NotTo (
748+ BeNil (), "Status.Conditions in nil" )
749+ netCondition := conditions .Get (condition .NetworkAttachmentsReadyCondition )
750+ g .Expect (netCondition .Message ).Should (
751+ ContainSubstring ("a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.'" ))
752+ }, timeout , interval ).Should (Succeed ())
753+ })
754+
755+ It ("reports success when nicMappings updated to valid value" , func () {
756+ // Update Interface in NicMappings
757+ Eventually (func (g Gomega ) {
758+ ovnController := GetOVNController (OVNControllerName )
759+ ovnController .Spec .NicMappings = map [string ]string {
760+ "validnet" : "enp3s0.100" ,
761+ }
762+ g .Expect (k8sClient .Update (ctx , ovnController )).Should (Succeed ())
763+ }, timeout , interval ).Should (Succeed ())
764+
765+ nad := types.NamespacedName {
766+ Namespace : OVNControllerName .Namespace ,
767+ Name : "validnet" ,
768+ }
769+
770+ // Ensure OwnerReferences set correctly for the updated Network Attachment
771+ Eventually (func (g Gomega ) {
772+ g .Expect (GetNAD (nad ).ObjectMeta .OwnerReferences [0 ].Name ).To (Equal (
773+ OVNControllerName .Name ))
774+ }, timeout , interval ).Should (Succeed ())
775+
776+ // Ensure NetworkCondition ready
777+ th .ExpectCondition (
778+ OVNControllerName ,
779+ ConditionGetterFunc (OVNControllerConditionGetter ),
780+ condition .NetworkAttachmentsReadyCondition ,
781+ corev1 .ConditionTrue ,
782+ )
783+ // Ensure Interface updated in the Network Attachment
784+ Eventually (func (g Gomega ) {
785+ g .Expect (GetNAD (nad ).Spec .Config ).Should (
786+ ContainSubstring ("enp3s0.100" ))
787+ }, timeout , interval ).Should (Succeed ())
788+ })
789+ })
790+
729791 When ("OVNController is created with networkAttachment and nic configs" , func () {
730792 BeforeEach (func () {
731793 dbs := CreateOVNDBClusters (namespace , map [string ][]string {}, 1 )
0 commit comments