Browse Source

Add test with secure connection for dvs agent

Change-Id: I99b1316a9ba7d8ddf76c71c31ff61f70f6a4be94
ibumarskov 2 years ago
parent
commit
8cf72614e8
1 changed files with 130 additions and 6 deletions
  1. 130
    6
      plugin_test/tests/test_plugin_vmware_dvs_system.py

+ 130
- 6
plugin_test/tests/test_plugin_vmware_dvs_system.py View File

@@ -13,6 +13,8 @@ License for the specific language governing permissions and limitations
13 13
 under the License.
14 14
 """
15 15
 
16
+import os
17
+import requests
16 18
 import time
17 19
 
18 20
 from devops.error import TimeoutError
@@ -22,14 +24,17 @@ from proboscis.asserts import assert_true
22 24
 
23 25
 import fuelweb_test.tests.base_test_case
24 26
 from fuelweb_test import logger
25
-from fuelweb_test.helpers.utils import pretty_log
26 27
 from fuelweb_test.helpers import os_actions
27 28
 from fuelweb_test.helpers.decorators import log_snapshot_after_test
29
+from fuelweb_test.helpers.ssh_manager import SSHManager
30
+from fuelweb_test.helpers.utils import pretty_log
28 31
 from fuelweb_test.settings import DEPLOYMENT_MODE
29 32
 from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE
30 33
 from fuelweb_test.settings import SERVTEST_PASSWORD
31 34
 from fuelweb_test.settings import SERVTEST_TENANT
32 35
 from fuelweb_test.settings import SERVTEST_USERNAME
36
+from fuelweb_test.settings import VCENTER_CERT_BYPASS
37
+from fuelweb_test.settings import VCENTER_CERT_URL
33 38
 from helpers import openstack
34 39
 from helpers import plugin
35 40
 
@@ -81,6 +86,19 @@ class TestDVSSystem(TestBasic):
81 86
              "remote_group_id": None,
82 87
              "remote_ip_prefix": None}}
83 88
 
89
+    def check_config(self, host, path, settings):
90
+        """Return vmware glance backend conf_dict.
91
+
92
+        :param host:     host url or ip, string
93
+        :param path:     config path, string
94
+        :param settings: settings, dict
95
+        """
96
+        for key in settings.keys():
97
+            cmd = 'grep {1} {0} | grep -i "{2}"'.format(path, key,
98
+                                                        settings[key])
99
+            logger.debug('CMD: {}'.format(cmd))
100
+            SSHManager().check_call(host, cmd)
101
+
84 102
     @test(depends_on=[SetupEnvironment.prepare_slaves_5],
85 103
           groups=["dvs_vcenter_systest_setup"])
86 104
     @log_snapshot_after_test
@@ -88,7 +106,7 @@ class TestDVSSystem(TestBasic):
88 106
         """Deploy cluster with plugin and vmware datastore backend.
89 107
 
90 108
         Scenario:
91
-            1. Upload plugins to the master node.
109
+            1. Upload plugin to the master node.
92 110
             2. Install plugin.
93 111
             3. Create cluster with vcenter.
94 112
             4. Add 1 node with controller role.
@@ -779,7 +797,7 @@ class TestDVSSystem(TestBasic):
779 797
         """Deploy cluster with plugin and vmware datastore backend.
780 798
 
781 799
         Scenario:
782
-            1. Upload plugins to the master node
800
+            1. Upload plugin to the master node
783 801
             2. Install plugin on master node.
784 802
             3. Create a new environment with following parameters:
785 803
                     * Compute: KVM/QEMU with vCenter
@@ -787,7 +805,7 @@ class TestDVSSystem(TestBasic):
787 805
                     * Storage: default
788 806
                     * Additional services: default
789 807
             4. Enable and configure DVS plugin.
790
-            5. Add nodes with following roles:
808
+            5. Add nodes with the following roles:
791 809
                     * Controller
792 810
                     * Compute
793 811
                     * Cinder
@@ -2239,7 +2257,7 @@ class TestDVSSystem(TestBasic):
2239 2257
                 * Networking: Neutron with VLAN segmentation
2240 2258
                 * Storage: default
2241 2259
                 * Additional services: default
2242
-            5. Add nodes with following roles:
2260
+            5. Add nodes with the following roles:
2243 2261
                 * Controller
2244 2262
                 * Compute
2245 2263
                 * Compute
@@ -2318,7 +2336,7 @@ class TestDVSSystem(TestBasic):
2318 2336
                 * Networking: Neutron with VLAN segmentation
2319 2337
                 * Storage: default
2320 2338
                 * Additional services: default
2321
-            5. Add nodes with following roles:
2339
+            5. Add nodes with the following roles:
2322 2340
                 * Controller
2323 2341
                 * Compute
2324 2342
                 * Compute
@@ -2381,3 +2399,109 @@ class TestDVSSystem(TestBasic):
2381 2399
 
2382 2400
         self.show_step(13)
2383 2401
         self.fuel_web.run_ostf(cluster_id=cluster_id, test_sets=['smoke'])
2402
+
2403
+    @test(depends_on=[SetupEnvironment.prepare_slaves_5],
2404
+          groups=["dvs_secure"])
2405
+    @log_snapshot_after_test
2406
+    def dvs_secure(self):
2407
+        """Deploy cluster with plugin and upload CA file certificate for
2408
+        vCenter.
2409
+
2410
+        Scenario:
2411
+            1. Upload plugin to the master node.
2412
+            2. Install plugin.
2413
+            3. Create cluster with vcenter.
2414
+            4. Add nodes with the following roles:
2415
+               * controller
2416
+               * compute-vmware, cinder-vmware
2417
+            5. Disable "Bypass vCenter certificate verification" option for
2418
+               vCenter and upload CA file certificate.
2419
+            6. Deploy the cluster.
2420
+            7. Check dvs agent configuration files.
2421
+            8. Run OSTF.
2422
+
2423
+        Duration: 1.8 hours
2424
+
2425
+        """
2426
+        self.env.revert_snapshot("ready_with_5_slaves")
2427
+
2428
+        self.show_step(1)
2429
+        self.show_step(2)
2430
+        plugin.install_dvs_plugin(self.ssh_manager.admin_ip)
2431
+
2432
+        self.show_step(3)
2433
+        cluster_id = self.fuel_web.create_cluster(
2434
+            name=self.__class__.__name__,
2435
+            mode=DEPLOYMENT_MODE,
2436
+            settings={
2437
+                "net_provider": 'neutron',
2438
+                "net_segment_type": NEUTRON_SEGMENT_TYPE
2439
+            }
2440
+        )
2441
+        plugin.enable_plugin(cluster_id, self.fuel_web)
2442
+
2443
+        self.show_step(4)
2444
+        self.fuel_web.update_nodes(cluster_id,
2445
+                                   {'slave-01': ['controller'],
2446
+                                    'slave-02': ['compute-vmware',
2447
+                                                 'cinder-vmware']})
2448
+
2449
+        # Configure VMWare vCenter settings
2450
+        target_node_2 = self.node_name('slave-02')
2451
+        self.fuel_web.vcenter_configure(cluster_id,
2452
+                                        target_node_2=target_node_2,
2453
+                                        multiclusters=True)
2454
+
2455
+        self.show_step(5)
2456
+        file_url = VCENTER_CERT_URL
2457
+        r = requests.get(file_url)
2458
+        cert_data = {'content': r.text, 'name': file_url.split('/')[-1]}
2459
+        vmware_attr = self.fuel_web.client.get_cluster_vmware_attributes(
2460
+            cluster_id)
2461
+        vc_values = vmware_attr['editable']['value']['availability_zones'][0]
2462
+        vc_values['vcenter_insecure'] = VCENTER_CERT_BYPASS
2463
+        vc_values['vcenter_ca_file'] = cert_data
2464
+        self.fuel_web.client.update_cluster_vmware_attributes(cluster_id,
2465
+                                                              vmware_attr)
2466
+
2467
+        self.show_step(6)
2468
+        self.fuel_web.deploy_cluster_wait(cluster_id)
2469
+
2470
+        self.show_step(7)
2471
+        nodes = self.fuel_web.client.list_cluster_nodes(cluster_id)
2472
+        vmware_attr = self.fuel_web.client.get_cluster_vmware_attributes(
2473
+            cluster_id)
2474
+        az = vmware_attr['editable']['value']['availability_zones'][0]
2475
+        nova_computes = az['nova_computes']
2476
+
2477
+        data = []
2478
+        ctrl_nodes = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
2479
+            cluster_id, ["controller"])
2480
+        for nova in nova_computes:
2481
+            target_node = nova['target_node']['current']['id']
2482
+            conf_path = '/etc/neutron/plugins/ml2/vmware_dvs-vcenter-{0}' \
2483
+                        '.ini'.format(nova['service_name'])
2484
+            ca_path = '/etc/neutron/vmware-vcenter-{0}-ca.pem'.format(
2485
+                nova['service_name'])
2486
+            conf_dict = {
2487
+                'insecure': False,
2488
+                'ca_file': ca_path
2489
+            }
2490
+            if target_node == 'controllers':
2491
+                for node in ctrl_nodes:
2492
+                    params = (node['hostname'], node['ip'], conf_path,
2493
+                              conf_dict)
2494
+                    data.append(params)
2495
+            else:
2496
+                for node in nodes:
2497
+                    if node['hostname'] == target_node:
2498
+                        params = (node['hostname'], node['ip'], conf_path,
2499
+                                  conf_dict)
2500
+                        data.append(params)
2501
+
2502
+        for hostname, ip, conf_path, conf_dict in data:
2503
+            logger.info("Check dvs agent conf of {0}".format(hostname))
2504
+            self.check_config(ip, conf_path, conf_dict)
2505
+
2506
+        self.show_step(8)
2507
+        self.fuel_web.run_ostf(cluster_id=cluster_id, test_sets=['smoke'])

Loading…
Cancel
Save