Browse Source

Merge "Gate API test for the lbaasv2-proxy plugin"

Zuul 7 months ago
parent
commit
0f9dc4f0a2

+ 59
- 7
neutron_lbaas/services/loadbalancer/proxy_plugin.py View File

@@ -16,6 +16,7 @@ import functools
16 16
 
17 17
 from neutron.db import servicetype_db as st_db
18 18
 from neutron.services import provider_configuration as pconf
19
+from neutron_lib import constants as n_constants
19 20
 from neutron_lib import exceptions as lib_exc
20 21
 from oslo_config import cfg
21 22
 from oslo_log import log as logging
@@ -30,8 +31,7 @@ VERSION = 'v2.0'
30 31
 OCTAVIA_PROXY_CLIENT = (
31 32
     "LBaaS V2 Octavia Proxy/{version} "
32 33
     "(https://wiki.openstack.org/wiki/Octavia)").format(version=VERSION)
33
-FILTER = ['vip_address', 'vip_network_id', 'flavor_id',
34
-          'provider', 'redirect_pool_id']
34
+FILTER = ['vip_address', 'vip_network_id', 'redirect_pool_id']
35 35
 
36 36
 LOADBALANCER = 'loadbalancer'
37 37
 LISTENER = 'listener'
@@ -171,7 +171,8 @@ class LoadBalancerProxyPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2):
171 171
         res = {}
172 172
         for k in map:
173 173
             if k not in keys:
174
-                if map[k] or map[k] == '' or isinstance(map[k], bool):
174
+                if (map[k] or map[k] == '' or isinstance(map[k], bool)
175
+                    ) and map[k] != n_constants.ATTR_NOT_SPECIFIED:
175 176
                     res[k] = map[k]
176 177
         if 'tenant_id' in res:
177 178
             res['project_id'] = res.pop('tenant_id')
@@ -270,6 +271,7 @@ class LoadBalancerProxyPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2):
270 271
                          sub_resource=None, resource_id=None):
271 272
         # clean up the map
272 273
         resource_ = resource if not sub_resource else sub_resource
274
+        LOG.debug("Resource = %s", res)
273 275
         r = self._filter(FILTER, res[resource_])
274 276
         res = self.put('{}/{}'.format(self._path(
275 277
             resource, sub_resource, resource_id), id),
@@ -322,14 +324,31 @@ class LoadBalancerProxyPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2):
322 324
     def get_pools(self, context, filters=None, fields=None):
323 325
         return self._get_resources(POOL, context, filters, fields)
324 326
 
327
+    def _clean_session_persistence(self, res):
328
+        session_persistence = res.get('session_persistence')
329
+        if session_persistence:
330
+            if 'persistence_granularity' in session_persistence:
331
+                del session_persistence['persistence_granularity']
332
+            if 'persistence_timeout' in session_persistence:
333
+                del session_persistence['persistence_timeout']
334
+
325 335
     def get_pool(self, context, id, fields=None):
326
-        return self._get_resource(POOL, context, id, fields)
336
+        res = self._get_resource(POOL, context, id, fields)
337
+        # force conformance with the old API (tests fail on additional fields)
338
+        self._clean_session_persistence(res)
339
+        return res
327 340
 
328 341
     def create_pool(self, context, pool):
329
-        return self._create_resource(POOL, context, pool)
342
+        res = self._create_resource(POOL, context, pool)
343
+        # force conformance with the old API (tests fail on additional fields)
344
+        self._clean_session_persistence(res)
345
+        return res
330 346
 
331 347
     def update_pool(self, context, id, pool):
332
-        return self._update_resource(POOL, context, id, pool)
348
+        res = self._update_resource(POOL, context, id, pool)
349
+        # force conformance with the old API (tests fail on additional fields)
350
+        self._clean_session_persistence(res)
351
+        return res
333 352
 
334 353
     def delete_pool(self, context, id):
335 354
         return self._delete_resource(POOL, context, id)
@@ -362,9 +381,43 @@ class LoadBalancerProxyPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2):
362 381
         return self._get_resource(HEALTH_MONITOR, context, id, fields)
363 382
 
364 383
     def create_healthmonitor(self, context, healthmonitor):
384
+        if healthmonitor[HEALTH_MONITOR].get(
385
+                'type') == constants.HEALTH_MONITOR_HTTPS:
386
+            # it defaults to GET which is not allowed with HTTPS
387
+            # so remove it for backwards compatibility with a lax
388
+            # validator
389
+            if healthmonitor[HEALTH_MONITOR].get('http_method') == 'GET':
390
+                healthmonitor[HEALTH_MONITOR].pop('http_method')
391
+            # it defaults to '/' which is not allowed with HTTPS
392
+            # so remove it for backwards compatibility with a lax
393
+            # validator
394
+            if healthmonitor[HEALTH_MONITOR].get('url_path') == '/':
395
+                healthmonitor[HEALTH_MONITOR].pop('url_path')
396
+            # it defaults to '200' which is not allowed with HTTPS
397
+            # so remove it for backwards compatibility with a lax
398
+            # validator
399
+            if healthmonitor[HEALTH_MONITOR].get('expected_codes') == '200':
400
+                healthmonitor[HEALTH_MONITOR].pop('expected_codes')
365 401
         return self._create_resource(HEALTH_MONITOR, context, healthmonitor)
366 402
 
367 403
     def update_healthmonitor(self, context, id, healthmonitor):
404
+        if healthmonitor[HEALTH_MONITOR].get(
405
+                'type') == constants.HEALTH_MONITOR_HTTPS:
406
+            # it defaults to GET which is not allowed with HTTPS
407
+            # so remove it for backwards compatibility with a lax
408
+            # validator
409
+            if healthmonitor[HEALTH_MONITOR].get('http_method') == 'GET':
410
+                healthmonitor[HEALTH_MONITOR].pop('http_method')
411
+            # it defaults to '/' which is not allowed with HTTPS
412
+            # so remove it for backwards compatibility with a lax
413
+            # validator
414
+            if healthmonitor[HEALTH_MONITOR].get('url_path') == '/':
415
+                healthmonitor[HEALTH_MONITOR].pop('url_path')
416
+            # it defaults to '200' which is not allowed with HTTPS
417
+            # so remove it for backwards compatibility with a lax
418
+            # validator
419
+            if healthmonitor[HEALTH_MONITOR].get('expected_codes') == '200':
420
+                healthmonitor[HEALTH_MONITOR].pop('expected_codes')
368 421
         return self._update_resource(HEALTH_MONITOR, context,
369 422
                                      id, healthmonitor)
370 423
 
@@ -378,7 +431,6 @@ class LoadBalancerProxyPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2):
378 431
         pass
379 432
 
380 433
     def statuses(self, context, loadbalancer_id):
381
-        LOG.debug("Statuses called!")
382 434
         return self._get_resources(LOADBALANCER, context, sub_resource=STATUS,
383 435
                                    resource_id=loadbalancer_id,
384 436
                                    pass_through=True)

+ 1
- 1
neutron_lbaas/tests/contrib/decode_args.sh View File

@@ -47,7 +47,7 @@ case $testtype in
47 47
 
48 48
         if [ "$lbaasversion" = "lbaasv2" ]; then
49 49
             case "$lbaasenv" in
50
-                "api"|"healthmonitor"|"listener"|"loadbalancer"|"member"|"minimal"|"pool"|"proxy_octavia")
50
+                "api"|"healthmonitor"|"listener"|"loadbalancer"|"member"|"minimal"|"pool"|"proxy_octavia"|"lbaasv2_proxy")
51 51
                     testenv="apiv2"
52 52
                     ;;
53 53
                 "scenario")

+ 6
- 0
neutron_lbaas/tests/contrib/gate_hook.sh View File

@@ -46,6 +46,12 @@ function _setup_octavia {
46 46
             export OCTAVIA_USE_LEGACY_RBAC=True
47 47
             "
48 48
     fi
49
+    if [[ "$lbaasenv" == "lbaasv2_proxy" ]]; then
50
+        export DEVSTACK_LOCAL_CONFIG+="
51
+            export OCTAVIA_USE_LEGACY_RBAC=True
52
+            export LBAASV2_PLUGIN=lbaasv2-proxy
53
+            "
54
+    fi
49 55
     # Use infra's cached version of the file
50 56
     if [ -f /opt/stack/new/devstack/files/get-pip.py ]; then
51 57
             export DEVSTACK_LOCAL_CONFIG+="

+ 2
- 0
neutron_lbaas/tests/tempest/v2/api/base.py View File

@@ -339,6 +339,8 @@ class BaseTestCase(base.BaseNetworkTest):
339 339
         if wait:
340 340
             self._wait_for_load_balancer_status(
341 341
                 self.load_balancer.get('id'))
342
+            health_monitor = self.health_monitors_client.get_health_monitor(
343
+                health_monitor_id)
342 344
         return health_monitor
343 345
 
344 346
     @classmethod

+ 15
- 0
playbooks/legacy/neutron-lbaasv2-dsvm-api-proxy/post.yaml View File

@@ -0,0 +1,15 @@
1
+- hosts: primary
2
+  tasks:
3
+
4
+    - name: Copy files from {{ ansible_user_dir }}/workspace/ on node
5
+      synchronize:
6
+        src: '{{ ansible_user_dir }}/workspace/'
7
+        dest: '{{ zuul.executor.log_root }}'
8
+        mode: pull
9
+        copy_links: true
10
+        verify_host: true
11
+        rsync_opts:
12
+          - --include=/logs/**
13
+          - --include=*/
14
+          - --exclude=*
15
+          - --prune-empty-dirs

+ 60
- 0
playbooks/legacy/neutron-lbaasv2-dsvm-api-proxy/run.yaml View File

@@ -0,0 +1,60 @@
1
+- hosts: all
2
+  name: Autoconverted job legacy-neutron-lbaasv2-dsvm-api from old job gate-neutron-lbaasv2-dsvm-api-ubuntu-xenial
3
+  tasks:
4
+
5
+    - name: Ensure legacy workspace directory
6
+      file:
7
+        path: '{{ ansible_user_dir }}/workspace'
8
+        state: directory
9
+
10
+    - shell:
11
+        cmd: |
12
+          set -e
13
+          set -x
14
+          cat > clonemap.yaml << EOF
15
+          clonemap:
16
+            - name: openstack-infra/devstack-gate
17
+              dest: devstack-gate
18
+          EOF
19
+          /usr/zuul-env/bin/zuul-cloner -m clonemap.yaml --cache-dir /opt/git \
20
+              git://git.openstack.org \
21
+              openstack-infra/devstack-gate
22
+        executable: /bin/bash
23
+        chdir: '{{ ansible_user_dir }}/workspace'
24
+      environment: '{{ zuul | zuul_legacy_vars }}'
25
+
26
+    - shell:
27
+        cmd: |
28
+          set -e
29
+          set -x
30
+          export PYTHONUNBUFFERED=true
31
+          export DEVSTACK_GATE_TEMPEST=1
32
+          export DEVSTACK_GATE_TEMPEST_NOTESTS=1
33
+          export DEVSTACK_GATE_EXERCISES=0
34
+          export DEVSTACK_GATE_NEUTRON=1
35
+          export DEVSTACK_GATE_INSTALL_TESTONLY=1
36
+          export BRANCH_OVERRIDE=default
37
+          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
38
+              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
39
+          fi
40
+          export PROJECTS="openstack/barbican $PROJECTS"
41
+          export PROJECTS="openstack/python-barbicanclient $PROJECTS"
42
+          export PROJECTS="openstack/diskimage-builder $PROJECTS"
43
+          export PROJECTS="openstack/neutron-lbaas $PROJECTS"
44
+          export PROJECTS="openstack/octavia $PROJECTS"
45
+
46
+          function gate_hook {
47
+              $BASE/new/neutron-lbaas/neutron_lbaas/tests/contrib/gate_hook.sh tempest lbaasv2 lbaasv2_proxy
48
+          }
49
+          export -f gate_hook
50
+
51
+          function post_test_hook {
52
+              $BASE/new/neutron-lbaas/neutron_lbaas/tests/contrib/post_test_hook.sh tempest lbaasv2 lbaasv2_proxy
53
+          }
54
+          export -f post_test_hook
55
+
56
+          cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
57
+          ./safe-devstack-vm-gate-wrap.sh
58
+        executable: /bin/bash
59
+        chdir: '{{ ansible_user_dir }}/workspace'
60
+      environment: '{{ zuul | zuul_legacy_vars }}'

+ 7
- 0
zuul.d/jobs.yaml View File

@@ -24,6 +24,13 @@
24 24
     run: playbooks/legacy/neutron-lbaasv2-dsvm-api/run.yaml
25 25
     post-run: playbooks/legacy/neutron-lbaasv2-dsvm-api/post.yaml
26 26
 
27
+- job:
28
+    name: neutron-lbaasv2-dsvm-api-proxy
29
+    parent:  nlbaas-legacy-dsvm-base
30
+    run: playbooks/legacy/neutron-lbaasv2-dsvm-api-proxy/run.yaml
31
+    post-run: playbooks/legacy/neutron-lbaasv2-dsvm-api-proxy/post.yaml
32
+
33
+
27 34
 - job:
28 35
     name: neutron-lbaasv2-dsvm-py3x-api
29 36
     parent: nlbaas-legacy-dsvm-base

+ 2
- 0
zuul.d/projects.yaml View File

@@ -9,6 +9,7 @@
9 9
       jobs:
10 10
         - lbaas-tox-lower-constraints
11 11
         - neutron-lbaasv2-dsvm-api
12
+        - neutron-lbaasv2-dsvm-api-proxy
12 13
         - neutron-lbaasv2-dsvm-py3x-api:
13 14
             branches: ^(?!stable/ocata).*$
14 15
         - neutron-lbaasv2-dsvm-api-namespace
@@ -27,6 +28,7 @@
27 28
       jobs:
28 29
         - lbaas-tox-lower-constraints
29 30
         - neutron-lbaasv2-dsvm-api
31
+        - neutron-lbaasv2-dsvm-api-proxy
30 32
         - neutron-lbaasv2-dsvm-py3x-api:
31 33
             branches: ^(?!stable/ocata).*$
32 34
         - neutron-lbaasv2-dsvm-api-namespace

Loading…
Cancel
Save