Merge "Use memcached based cache in nova in all devstack-tempest jobs"
diff --git a/.zuul.yaml b/.zuul.yaml
index 710c66c..a7e653e 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -464,13 +464,6 @@
       tox_envlist: plugin-sanity-check
     voting: false
     timeout: 5000
-    irrelevant-files:
-      - ^.*\.rst$
-      - ^doc/.*$
-      - ^etc/.*$
-      - ^releasenotes/.*$
-      - ^tempest/hacking/.*$
-      - ^tempest/tests/.*$
     required-projects:
       - opendev.org/airship/tempest-plugin
       - opendev.org/x/almanach
diff --git a/releasenotes/notes/segments-client-866f02948f40d4ff.yaml b/releasenotes/notes/segments-client-866f02948f40d4ff.yaml
new file mode 100644
index 0000000..90ac3e8
--- /dev/null
+++ b/releasenotes/notes/segments-client-866f02948f40d4ff.yaml
@@ -0,0 +1,12 @@
+---
+features:
+  - |
+    Add ``segments`` client to Tempest to make possible the testing of the
+    Routed Provider Networks feature.
+    The following API calls are available for tempest from now:
+
+    * POST /segments
+    * PUT /segments/{segment_id}
+    * GET /segment/{segment_id}
+    * DELETE /segments/{segment_id}
+    * GET /segments
diff --git a/releasenotes/source/index.rst b/releasenotes/source/index.rst
index e5d5bfe..1d0d914 100644
--- a/releasenotes/source/index.rst
+++ b/releasenotes/source/index.rst
@@ -6,6 +6,7 @@
    :maxdepth: 1
 
    unreleased
+   v21.0.0
    v20.0.0
    v19.0.0
    v18.0.0
diff --git a/releasenotes/source/v21.0.0.rst b/releasenotes/source/v21.0.0.rst
new file mode 100644
index 0000000..9ea8120
--- /dev/null
+++ b/releasenotes/source/v21.0.0.rst
@@ -0,0 +1,6 @@
+=====================
+v21.0.0 Release Notes
+=====================
+
+.. release-notes:: 21.0.0 Release Notes
+   :version: 21.0.0
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index c69e4c8..5aec931 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -34,6 +34,14 @@
                          map(lambda x: x[key], body))
 
     @classmethod
+    def skip_checks(cls):
+        super(UsersV3TestJSON, cls).skip_checks()
+        if CONF.identity_feature_enabled.immutable_user_source:
+            raise cls.skipException('Skipped because environment has an '
+                                    'immutable user source and solely '
+                                    'provides read-only access to users.')
+
+    @classmethod
     def resource_setup(cls):
         super(UsersV3TestJSON, cls).resource_setup()
         alt_user = data_utils.rand_name('test_user')
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
index 54a5ab7..78e3cce 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -33,6 +33,10 @@
         super(TrustsV3TestJSON, cls).skip_checks()
         if not CONF.identity_feature_enabled.trust:
             raise cls.skipException("Trusts aren't enabled")
+        if CONF.identity_feature_enabled.immutable_user_source:
+            raise cls.skipException('Skipped because environment has an '
+                                    'immutable user source and solely '
+                                    'provides read-only access to users.')
 
     def setUp(self):
         super(TrustsV3TestJSON, self).setUp()
diff --git a/tempest/clients.py b/tempest/clients.py
index f7a83be..6aed92e 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -71,6 +71,7 @@
         self.tags_client = self.network.TagsClient()
         self.qos_client = self.network.QosClient()
         self.qos_min_bw_client = self.network.QosMinimumBandwidthRulesClient()
+        self.segments_client = self.network.SegmentsClient()
 
     def _set_image_clients(self):
         if CONF.service_available.glance:
diff --git a/tempest/lib/services/network/__init__.py b/tempest/lib/services/network/__init__.py
index 69f178e..f7ac046 100644
--- a/tempest/lib/services/network/__init__.py
+++ b/tempest/lib/services/network/__init__.py
@@ -30,6 +30,7 @@
     SecurityGroupRulesClient
 from tempest.lib.services.network.security_groups_client import \
     SecurityGroupsClient
+from tempest.lib.services.network.segments_client import SegmentsClient
 from tempest.lib.services.network.service_providers_client import \
     ServiceProvidersClient
 from tempest.lib.services.network.subnetpools_client import SubnetpoolsClient
@@ -42,5 +43,5 @@
            'NetworksClient', 'NetworkVersionsClient', 'PortsClient',
            'QosClient', 'QosMinimumBandwidthRulesClient', 'QuotasClient',
            'RoutersClient', 'SecurityGroupRulesClient', 'SecurityGroupsClient',
-           'ServiceProvidersClient', 'SubnetpoolsClient', 'SubnetsClient',
-           'TagsClient']
+           'SegmentsClient', 'ServiceProvidersClient', 'SubnetpoolsClient',
+           'SubnetsClient', 'TagsClient']
diff --git a/tempest/lib/services/network/segments_client.py b/tempest/lib/services/network/segments_client.py
new file mode 100644
index 0000000..dfdc418
--- /dev/null
+++ b/tempest/lib/services/network/segments_client.py
@@ -0,0 +1,63 @@
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from tempest.lib.services.network import base
+
+
+class SegmentsClient(base.BaseNetworkClient):
+
+    def create_segment(self, **kwargs):
+        """Creates a segment.
+
+        For a full list of available parameters, please refer to the official
+        API reference:
+        http://developer.openstack.org/api-ref/networking/v2/index.html#create-segment
+        """
+        uri = '/segments'
+        post_data = {'segment': kwargs}
+        return self.create_resource(uri, post_data)
+
+    def update_segment(self, segment_id, **kwargs):
+        """Updates a segment.
+
+        For a full list of available parameters, please refer to the official
+        API reference:
+        http://developer.openstack.org/api-ref/networking/v2/index.html#update-segment
+        """
+        uri = '/segments/%s' % segment_id
+        post_data = {'segment': kwargs}
+        return self.update_resource(uri, post_data)
+
+    def show_segment(self, segment_id, **fields):
+        """Shows details of a segment.
+
+        For a full list of available parameters, please refer to the official
+        API reference:
+        http://developer.openstack.org/api-ref/networking/v2/index.html#show-segment
+        """
+        uri = '/segments/%s' % segment_id
+        return self.show_resource(uri, **fields)
+
+    def delete_segment(self, segment_id):
+        """Deletes a segment"""
+        uri = '/segments/%s' % segment_id
+        return self.delete_resource(uri)
+
+    def list_segments(self, **filters):
+        """Lists segments.
+
+        For a full list of available parameters, please refer to the official
+        API reference:
+        http://developer.openstack.org/api-ref/networking/v2/index.html#list-segments
+        """
+        uri = '/segments'
+        return self.list_resources(uri, **filters)
diff --git a/tempest/tests/lib/services/network/test_segments_client.py b/tempest/tests/lib/services/network/test_segments_client.py
new file mode 100644
index 0000000..579c78f
--- /dev/null
+++ b/tempest/tests/lib/services/network/test_segments_client.py
@@ -0,0 +1,140 @@
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+import copy
+
+from tempest.lib.services.network import segments_client
+from tempest.tests.lib import fake_auth_provider
+from tempest.tests.lib.services import base
+
+
+class TestSegmentsClient(base.BaseServiceTest):
+
+    FAKE_SEGMENT_ID = '83a59912-a473-11e9-a012-af494c35c9c2'
+    FAKE_NETWORK_ID = '913ab0e4-a473-11e9-84a3-af1c16fc05de'
+
+    FAKE_SEGMENT_REQUEST = {
+        'segment': {
+            'network_id': FAKE_NETWORK_ID,
+            'segmentation_id': 2000,
+            'network_type': 'vlan',
+            'physical_network': 'segment-1'
+        }
+    }
+
+    FAKE_SEGMENT_RESPONSE = {
+        'segment': {
+            'name': 'foo',
+            'network_id': FAKE_NETWORK_ID,
+            'segmentation_id': 2000,
+            'network_type': 'vlan',
+            'physical_network': 'segment-1',
+            'revision_number': 1,
+            'id': FAKE_SEGMENT_ID,
+            'created_at': '2019-07-12T09:13:56Z',
+            'updated_at': '2019-07-12T09:13:56Z',
+            'description': 'bar'
+        }
+    }
+
+    FAKE_SEGMENTS = {
+        'segments': [
+            FAKE_SEGMENT_RESPONSE['segment']
+        ]
+    }
+
+    def setUp(self):
+        super(TestSegmentsClient, self).setUp()
+        fake_auth = fake_auth_provider.FakeAuthProvider()
+        self.segments_client = segments_client.SegmentsClient(
+            fake_auth, 'compute', 'regionOne')
+
+    def _test_create_segment(self, bytes_body=False):
+        self.check_service_client_function(
+            self.segments_client.create_segment,
+            'tempest.lib.common.rest_client.RestClient.post',
+            self.FAKE_SEGMENT_RESPONSE,
+            bytes_body,
+            201,
+            **self.FAKE_SEGMENT_REQUEST['segment']
+        )
+
+    def _test_list_segments(self, bytes_body=False):
+        self.check_service_client_function(
+            self.segments_client.list_segments,
+            'tempest.lib.common.rest_client.RestClient.get',
+            self.FAKE_SEGMENTS,
+            bytes_body,
+            200
+        )
+
+    def _test_show_segment(self, bytes_body=False):
+        self.check_service_client_function(
+            self.segments_client.show_segment,
+            'tempest.lib.common.rest_client.RestClient.get',
+            self.FAKE_SEGMENT_RESPONSE,
+            bytes_body,
+            200,
+            segment_id=self.FAKE_SEGMENT_ID
+        )
+
+    def _test_update_segment(self, bytes_body=False):
+        update_kwargs = {
+            'name': 'notfoo'
+        }
+
+        resp_body = {
+            'segment': copy.deepcopy(self.FAKE_SEGMENT_RESPONSE['segment'])
+        }
+        resp_body['segment'].update(update_kwargs)
+
+        self.check_service_client_function(
+            self.segments_client.update_segment,
+            'tempest.lib.common.rest_client.RestClient.put',
+            resp_body,
+            bytes_body,
+            200,
+            segment_id=self.FAKE_SEGMENT_ID,
+            **update_kwargs
+        )
+
+    def test_create_segment_with_str_body(self):
+        self._test_create_segment()
+
+    def test_create_segment_with_bytes_body(self):
+        self._test_create_segment(bytes_body=True)
+
+    def test_update_segment_with_str_body(self):
+        self._test_update_segment()
+
+    def test_update_segment_with_bytes_body(self):
+        self._test_update_segment(bytes_body=True)
+
+    def test_show_segment_with_str_body(self):
+        self._test_show_segment()
+
+    def test_show_segment_with_bytes_body(self):
+        self._test_show_segment(bytes_body=True)
+
+    def test_delete_segment(self):
+        self.check_service_client_function(
+            self.segments_client.delete_segment,
+            'tempest.lib.common.rest_client.RestClient.delete',
+            {},
+            status=204,
+            segment_id=self.FAKE_SEGMENT_ID)
+
+    def test_list_segment_with_str_body(self):
+        self._test_list_segments()
+
+    def test_list_segment_with_bytes_body(self):
+        self._test_list_segments(bytes_body=True)