@@ -819,6 +819,82 @@ def test__get_logical_router_port_ha_chassis_group_no_hcg(self):
819
819
cprio_res = self .nbapi ._get_logical_router_port_ha_chassis_group (lrp )
820
820
self .assertEqual ([], cprio_res )
821
821
822
+ def test_create_lrp_with_ha_chassis_group_same_txn (self ):
823
+ mac = next (net_utils .random_mac_generator (['ca' , 'fe' , 'ca' , 'fe' ]))
824
+ networks = ['192.0.2.0/24' ]
825
+ lr_name = uuidutils .generate_uuid ()
826
+ lrp_name = uuidutils .generate_uuid ()
827
+ self .nbapi .lr_add (lr_name ).execute (check_error = True )
828
+
829
+ # Create the HCG and the LRP in the same transaction.
830
+ with self .nbapi .transaction (check_error = True ) as txn :
831
+ hcg_cmd = txn .add (self .nbapi .ha_chassis_group_with_hc_add (
832
+ uuidutils .generate_uuid (), {'ch1' : 1 , 'ch2' : 2 }))
833
+ txn .add (self .nbapi .add_lrouter_port (
834
+ lrp_name , lr_name , mac = mac , networks = networks ,
835
+ ha_chassis_group = hcg_cmd ))
836
+
837
+ lrp = self .nbapi .lrp_get (lrp_name ).execute (check_error = True )
838
+ self .assertEqual (hcg_cmd .result .uuid , lrp .ha_chassis_group [0 ].uuid )
839
+
840
+ def test_create_lrp_with_ha_chassis_group_different_txn (self ):
841
+ mac = next (net_utils .random_mac_generator (['ca' , 'fe' , 'ca' , 'fe' ]))
842
+ networks = ['192.0.2.0/24' ]
843
+ lr_name = uuidutils .generate_uuid ()
844
+ lrp_name = uuidutils .generate_uuid ()
845
+ self .nbapi .lr_add (lr_name ).execute (check_error = True )
846
+
847
+ # Create the HCG and the LRP in two consecutive transactions.
848
+ hcg = self .nbapi .ha_chassis_group_with_hc_add (
849
+ uuidutils .generate_uuid (), {'ch1' : 1 , 'ch2' : 2 }).execute (
850
+ check_error = True )
851
+ self .nbapi .add_lrouter_port (
852
+ lrp_name , lr_name , mac = mac , networks = networks ,
853
+ ha_chassis_group = hcg .uuid ).execute (check_error = True )
854
+
855
+ lrp = self .nbapi .lrp_get (lrp_name ).execute (check_error = True )
856
+ self .assertEqual (hcg .uuid , lrp .ha_chassis_group [0 ].uuid )
857
+
858
+ def test_update_lrp_with_ha_chassis_group_same_txn (self ):
859
+ mac = next (net_utils .random_mac_generator (['ca' , 'fe' , 'ca' , 'fe' ]))
860
+ networks = ['192.0.2.0/24' ]
861
+ lr_name = uuidutils .generate_uuid ()
862
+ lrp_name = uuidutils .generate_uuid ()
863
+ self .nbapi .lr_add (lr_name ).execute (check_error = True )
864
+ self .nbapi .add_lrouter_port (
865
+ lrp_name , lr_name , mac = mac ,
866
+ networks = networks ).execute (check_error = True )
867
+
868
+ # Create the HCG and update the LRP in the same transaction.
869
+ with self .nbapi .transaction (check_error = True ) as txn :
870
+ hcg_cmd = txn .add (self .nbapi .ha_chassis_group_with_hc_add (
871
+ uuidutils .generate_uuid (), {'ch1' : 1 , 'ch2' : 2 }))
872
+ txn .add (self .nbapi .update_lrouter_port (
873
+ lrp_name , ha_chassis_group = hcg_cmd ))
874
+
875
+ lrp = self .nbapi .lrp_get (lrp_name ).execute (check_error = True )
876
+ self .assertEqual (hcg_cmd .result .uuid , lrp .ha_chassis_group [0 ].uuid )
877
+
878
+ def test_update_lrp_with_ha_chassis_group_different_txn (self ):
879
+ mac = next (net_utils .random_mac_generator (['ca' , 'fe' , 'ca' , 'fe' ]))
880
+ networks = ['192.0.2.0/24' ]
881
+ lr_name = uuidutils .generate_uuid ()
882
+ lrp_name = uuidutils .generate_uuid ()
883
+ self .nbapi .lr_add (lr_name ).execute (check_error = True )
884
+ self .nbapi .add_lrouter_port (
885
+ lrp_name , lr_name , mac = mac ,
886
+ networks = networks ).execute (check_error = True )
887
+
888
+ # Create the HCG and update the LRP in two consecutive transactions.
889
+ hcg = self .nbapi .ha_chassis_group_with_hc_add (
890
+ uuidutils .generate_uuid (), {'ch1' : 1 , 'ch2' : 2 }).execute (
891
+ check_error = True )
892
+ self .nbapi .update_lrouter_port (
893
+ lrp_name , ha_chassis_group = hcg .uuid ).execute (check_error = True )
894
+
895
+ lrp = self .nbapi .lrp_get (lrp_name ).execute (check_error = True )
896
+ self .assertEqual (hcg .uuid , lrp .ha_chassis_group [0 ].uuid )
897
+
822
898
823
899
class TestIgnoreConnectionTimeout (BaseOvnIdlTest ):
824
900
@classmethod
0 commit comments