Browse Source

Modify Member tests for Provider Drivers

There is a possibility that the provider drivers may not support some
functionality. Member API tests are very closely coupled with Monitors,
so in case if a provider driver doesnt support monitors, the Octavia
API tests may not give the correct response. The following patch
attempts to split the same.

Change-Id: Idc0965550a57d4424a7d4f27525bf345324bd68a
Reedip 7 months ago
parent
commit
9169029d1a
1 changed files with 55 additions and 31 deletions
  1. 55
    31
      octavia_tempest_plugin/tests/api/v2/test_member.py

+ 55
- 31
octavia_tempest_plugin/tests/api/v2/test_member.py View File

@@ -99,6 +99,14 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
99 99
                                 CONF.load_balancer.build_interval,
100 100
                                 CONF.load_balancer.build_timeout)
101 101
 
102
+    def _create_member_and_get_monitor_status(self, **member_kwargs):
103
+        monitor = CONF.loadbalancer_feature_enabled.health_monitor_enabled
104
+        if not monitor:
105
+            del member_kwargs[const.MONITOR_ADDRESS]
106
+            del member_kwargs[const.MONITOR_PORT]
107
+        member = self.mem_member_client.create_member(**member_kwargs)
108
+        return member, monitor
109
+
102 110
     # Note: This test also covers basic member show API
103 111
     @decorators.idempotent_id('0623aa1f-753d-44e7-afa1-017d274eace7')
104 112
     def test_member_ipv4_create(self):
@@ -117,6 +125,7 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
117 125
         * Tests that users without the loadbalancer member role cannot
118 126
           create members.
119 127
         * Create a fully populated member.
128
+        * If driver doesnt support Monitors, allow to create without monitor
120 129
         * Show member details.
121 130
         * Validate the show reflects the requested values.
122 131
         """
@@ -156,7 +165,9 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
156 165
                 self.os_primary.member_client.create_member,
157 166
                 **member_kwargs)
158 167
 
159
-        member = self.mem_member_client.create_member(**member_kwargs)
168
+        member, monitor = self._create_member_and_get_monitor_status(
169
+            **member_kwargs)
170
+
160 171
         self.addClassResourceCleanup(
161 172
             self.mem_member_client.cleanup_member,
162 173
             member[const.ID], pool_id=self.pool_id,
@@ -181,13 +192,13 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
181 192
         self.assertEqual(const.NO_MONITOR, member[const.OPERATING_STATUS])
182 193
 
183 194
         equal_items = [const.NAME, const.ADMIN_STATE_UP, const.ADDRESS,
184
-                       const.PROTOCOL_PORT, const.WEIGHT,
185
-                       const.MONITOR_ADDRESS, const.MONITOR_PORT]
186
-
195
+                       const.PROTOCOL_PORT, const.WEIGHT]
187 196
         if self.mem_member_client.is_version_supported(
188 197
                 self.api_version, '2.1'):
189 198
             equal_items.append(const.BACKUP)
190 199
 
200
+        if monitor:
201
+            equal_items += [const.MONITOR_ADDRESS, const.MONITOR_PORT]
191 202
         if const.SUBNET_ID in member_kwargs:
192 203
             equal_items.append(const.SUBNET_ID)
193 204
         else:
@@ -451,7 +462,9 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
451 462
             member_kwargs[const.SUBNET_ID] = self.lb_member_vip_subnet[
452 463
                 const.ID]
453 464
 
454
-        member = self.mem_member_client.create_member(**member_kwargs)
465
+        member, monitor = self._create_member_and_get_monitor_status(
466
+            **member_kwargs)
467
+
455 468
         self.addClassResourceCleanup(
456 469
             self.mem_member_client.cleanup_member,
457 470
             member[const.ID], pool_id=self.pool_id,
@@ -476,13 +489,14 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
476 489
         self.assertEqual(const.NO_MONITOR, member[const.OPERATING_STATUS])
477 490
 
478 491
         equal_items = [const.NAME, const.ADMIN_STATE_UP, const.ADDRESS,
479
-                       const.PROTOCOL_PORT, const.WEIGHT,
480
-                       const.MONITOR_ADDRESS, const.MONITOR_PORT]
492
+                       const.PROTOCOL_PORT, const.WEIGHT]
481 493
 
482 494
         if self.mem_member_client.is_version_supported(
483 495
                 self.api_version, '2.1'):
484 496
             equal_items.append(const.BACKUP)
485 497
 
498
+        if monitor:
499
+            equal_items += [const.MONITOR_ADDRESS, const.MONITOR_PORT]
486 500
         if const.SUBNET_ID in member_kwargs:
487 501
             equal_items.append(const.SUBNET_ID)
488 502
         else:
@@ -553,7 +567,9 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
553 567
             member_kwargs[const.SUBNET_ID] = self.lb_member_vip_subnet[
554 568
                 const.ID]
555 569
 
556
-        member = self.mem_member_client.create_member(**member_kwargs)
570
+        member, monitor = self._create_member_and_get_monitor_status(
571
+            **member_kwargs)
572
+
557 573
         self.addClassResourceCleanup(
558 574
             self.mem_member_client.cleanup_member,
559 575
             member[const.ID], pool_id=self.pool_id,
@@ -571,27 +587,30 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
571 587
             CONF.load_balancer.build_interval,
572 588
             CONF.load_balancer.build_timeout,
573 589
             pool_id=self.pool_id)
574
-        if not CONF.load_balancer.test_with_noop:
575
-            member = waiters.wait_for_status(
576
-                self.mem_member_client.show_member,
577
-                member[const.ID], const.OPERATING_STATUS,
578
-                const.OFFLINE,
579
-                CONF.load_balancer.build_interval,
580
-                CONF.load_balancer.build_timeout,
581
-                pool_id=self.pool_id)
590
+        status = const.OFFLINE
591
+        if not monitor or CONF.load_balancer.test_with_noop:
592
+            status = const.NO_MONITOR
593
+        member = waiters.wait_for_status(
594
+            self.mem_member_client.show_member,
595
+            member[const.ID], const.OPERATING_STATUS,
596
+            status,
597
+            CONF.load_balancer.build_interval,
598
+            CONF.load_balancer.build_timeout,
599
+            pool_id=self.pool_id)
582 600
 
583 601
         parser.parse(member[const.CREATED_AT])
584 602
         parser.parse(member[const.UPDATED_AT])
585 603
         UUID(member[const.ID])
586 604
 
587 605
         equal_items = [const.NAME, const.ADMIN_STATE_UP, const.ADDRESS,
588
-                       const.PROTOCOL_PORT, const.WEIGHT,
589
-                       const.MONITOR_ADDRESS, const.MONITOR_PORT]
606
+                       const.PROTOCOL_PORT, const.WEIGHT]
590 607
 
591 608
         if self.mem_member_client.is_version_supported(
592 609
                 self.api_version, '2.1'):
593 610
             equal_items.append(const.BACKUP)
594 611
 
612
+        if monitor:
613
+            equal_items += [const.MONITOR_ADDRESS, const.MONITOR_PORT]
595 614
         if const.SUBNET_ID in member_kwargs:
596 615
             equal_items.append(const.SUBNET_ID)
597 616
         else:
@@ -600,8 +619,9 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
600 619
         for item in equal_items:
601 620
             self.assertEqual(member_kwargs[item], member[item])
602 621
 
603
-        if CONF.load_balancer.test_with_noop:
604
-            # Operating status with noop will stay in NO_MONITOR
622
+        if CONF.load_balancer.test_with_noop or not monitor:
623
+            # Operating status with noop or Driver not supporting Monitors
624
+            # will stay in NO_MONITOR
605 625
             self.assertEqual(const.NO_MONITOR, member[const.OPERATING_STATUS])
606 626
         else:
607 627
             # Operating status will be OFFLINE while admin_state_up = False
@@ -646,18 +666,18 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
646 666
             const.NAME: new_name,
647 667
             const.ADMIN_STATE_UP: not member[const.ADMIN_STATE_UP],
648 668
             const.WEIGHT: member[const.WEIGHT] + 1,
649
-            const.MONITOR_ADDRESS: '192.0.2.3',
650
-            const.MONITOR_PORT: member[const.MONITOR_PORT] + 1,
651 669
         }
652 670
         if self.mem_member_client.is_version_supported(
653 671
                 self.api_version, '2.1'):
654 672
             member_update_kwargs.update({
655 673
                 const.BACKUP: not member[const.BACKUP]
656 674
             })
657
-
675
+        if monitor:
676
+            member_update_kwargs[const.MONITOR_ADDRESS] = '192.0.2.3'
677
+            member_update_kwargs[const.MONITOR_PORT] = member[
678
+                const.MONITOR_PORT] + 1
658 679
         member = self.mem_member_client.update_member(
659 680
             member[const.ID], **member_update_kwargs)
660
-
661 681
         waiters.wait_for_status(
662 682
             self.mem_lb_client.show_loadbalancer, self.lb_id,
663 683
             const.PROVISIONING_STATUS, const.ACTIVE,
@@ -683,13 +703,14 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
683 703
         self.assertEqual(const.NO_MONITOR, member[const.OPERATING_STATUS])
684 704
 
685 705
         # Test changed items
686
-        equal_items = [const.NAME, const.ADMIN_STATE_UP, const.WEIGHT,
687
-                       const.MONITOR_ADDRESS, const.MONITOR_PORT]
706
+        equal_items = [const.NAME, const.ADMIN_STATE_UP, const.WEIGHT]
688 707
 
689 708
         if self.mem_member_client.is_version_supported(
690 709
                 self.api_version, '2.1'):
691 710
             equal_items.append(const.BACKUP)
692 711
 
712
+        if monitor:
713
+            equal_items += [const.MONITOR_ADDRESS, const.MONITOR_PORT]
693 714
         for item in equal_items:
694 715
             self.assertEqual(member_update_kwargs[item], member[item])
695 716
 
@@ -748,8 +769,9 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
748 769
         if self.lb_member_vip_subnet:
749 770
             member1_kwargs[const.SUBNET_ID] = self.lb_member_vip_subnet[
750 771
                 const.ID]
772
+        member1, monitor = self._create_member_and_get_monitor_status(
773
+            **member1_kwargs)
751 774
 
752
-        member1 = self.mem_member_client.create_member(**member1_kwargs)
753 775
         self.addClassResourceCleanup(
754 776
             self.mem_member_client.cleanup_member,
755 777
             member1[const.ID], pool_id=pool_id,
@@ -770,8 +792,6 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
770 792
             const.ADDRESS: '192.0.2.3',
771 793
             const.PROTOCOL_PORT: 81,
772 794
             const.WEIGHT: 51,
773
-            const.MONITOR_ADDRESS: '192.0.2.4',
774
-            const.MONITOR_PORT: 8081,
775 795
         }
776 796
         if self.mem_member_client.is_version_supported(
777 797
                 self.api_version, '2.1'):
@@ -779,6 +799,9 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
779 799
                 const.BACKUP: True,
780 800
             })
781 801
 
802
+        if monitor:
803
+            member2_kwargs[const.MONITOR_ADDRESS] = '192.0.2.4'
804
+            member2_kwargs[const.MONITOR_PORT] = 8081
782 805
         if self.lb_member_vip_subnet:
783 806
             member2_kwargs[const.SUBNET_ID] = self.lb_member_vip_subnet[
784 807
                 const.ID]
@@ -803,8 +826,6 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
803 826
             const.ADDRESS: '192.0.2.5',
804 827
             const.PROTOCOL_PORT: 82,
805 828
             const.WEIGHT: 52,
806
-            const.MONITOR_ADDRESS: '192.0.2.6',
807
-            const.MONITOR_PORT: 8082,
808 829
         }
809 830
         if self.mem_member_client.is_version_supported(
810 831
                 self.api_version, '2.1'):
@@ -812,6 +833,9 @@ class MemberAPITest(test_base.LoadBalancerBaseTest):
812 833
                 const.BACKUP: True,
813 834
             })
814 835
 
836
+        if monitor:
837
+            member2_kwargs[const.MONITOR_ADDRESS] = '192.0.2.6'
838
+            member2_kwargs[const.MONITOR_PORT] = 8082
815 839
         if self.lb_member_vip_subnet:
816 840
             member3_kwargs[const.SUBNET_ID] = self.lb_member_vip_subnet[
817 841
                 const.ID]

Loading…
Cancel
Save