Browse Source

Framework for Airship Tempest Plugin

This commit includes the following:

- Base Classes for:
  * Shipyard tests
  * Shipyard RBAC tests

- Unfinished Shipyard REST Clients for:
  * Document Staging API
  * Action API
  * Airflow Monitoring API
  * Log Retrieval API

- RBAC Tests for Shipyard:
  * get workflows
  * get actions
  * get configdocs

Future commits can follow this commit to further test Airship
components.
Rick Bartra 8 months ago
commit
6b87d7d633

+ 6
- 0
README.rst View File

@@ -0,0 +1,6 @@
1
+===============================================
2
+Tempest Integration of airship-tempest-plugin
3
+===============================================
4
+
5
+The purpose of this plugin is to provide automated tests
6
+for all OpenStack Airship components.

+ 6
- 0
airship_tempest_plugin/README.rst View File

@@ -0,0 +1,6 @@
1
+===============================================
2
+Tempest Integration of airship-tempest-plugin
3
+===============================================
4
+
5
+This directory contains Tempest tests to cover the airship-tempest-plugin project.
6
+

+ 0
- 0
airship_tempest_plugin/__init__.py View File


+ 46
- 0
airship_tempest_plugin/config.py View File

@@ -0,0 +1,46 @@
1
+# Copyright 2015
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+from oslo_config import cfg
16
+
17
+service_available_group = cfg.OptGroup(name="service_available",
18
+                                       title="Available Airship Services")
19
+
20
+ServiceAvailableGroup = [
21
+    cfg.BoolOpt("shipyard",
22
+                default=True,
23
+                help="Whether or not Shipyard is expected to be available."),
24
+]
25
+
26
+shipyard_group = cfg.OptGroup(name='shipyard',
27
+                         title='Shipyard service options')
28
+
29
+ShipyardGroup = [
30
+    cfg.StrOpt('endpoint_type',
31
+               default='internal',
32
+               choices=['public', 'admin', 'internal'],
33
+               help="The endpoint type to use for the Shipyard service"),
34
+    cfg.StrOpt('catalog_type',
35
+               default='shipyard',
36
+               help="Catalog type of the Shipyard service"),
37
+]
38
+
39
+def get_opt_lists(self, conf):
40
+    """
41
+    Get a list of options for sample config generation
42
+    """
43
+    return [
44
+        (service_available_group, ServiceAvailableGroup),
45
+        (shipyard_group, ShipyardGroup)
46
+    ]

+ 43
- 0
airship_tempest_plugin/plugin.py View File

@@ -0,0 +1,43 @@
1
+# Copyright 2015
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+
16
+
17
+import os
18
+
19
+from tempest import config
20
+from tempest.test_discover import plugins
21
+
22
+from airship_tempest_plugin import config as project_config
23
+
24
+
25
+class AirshipRbacPlugin(plugins.TempestPlugin):
26
+    def load_tests(self):
27
+        base_path = os.path.split(os.path.dirname(
28
+            os.path.abspath(__file__)))[0]
29
+        test_dir = "airship_tempest_plugin/tests"
30
+        full_test_dir = os.path.join(base_path, test_dir)
31
+        return full_test_dir, base_path
32
+
33
+    def register_opts(self, conf):
34
+        config.register_opt_group(conf, project_config.service_available_group,
35
+                                  project_config.ServiceAvailableGroup)
36
+        config.register_opt_group(conf, project_config.shipyard_group,
37
+                                  project_config.ShipyardGroup)
38
+    def get_opt_lists(self):
39
+        return [
40
+            (project_config.service_available_group.name,
41
+             project_config.ServiceAvailableGroup),
42
+            (project_config.shipyard_group.name, project_config.ShipyardGroup),
43
+        ]

+ 0
- 0
airship_tempest_plugin/services/__init__.py View File


+ 0
- 0
airship_tempest_plugin/services/shipyard/__init__.py View File


+ 0
- 0
airship_tempest_plugin/services/shipyard/json/__init__.py View File


+ 34
- 0
airship_tempest_plugin/services/shipyard/json/actions_client.py View File

@@ -0,0 +1,34 @@
1
+# Copyright 2018 AT&T Corp
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+
17
+"""
18
+http://airship-shipyard.readthedocs.io/en/latest/API.html#action-api
19
+"""
20
+
21
+from oslo_serialization import jsonutils as json
22
+from six.moves.urllib import parse as urllib
23
+
24
+from tempest.lib.common import rest_client
25
+
26
+
27
+class ActionsClient(rest_client.RestClient):
28
+    api_version = "v1.0"
29
+
30
+    def get_actions(self):
31
+        resp, body = self.get('actions')
32
+        self.expected_success(200, resp.status)
33
+        body = json.loads(body)
34
+        return rest_client.ResponseBody(resp, body)

+ 34
- 0
airship_tempest_plugin/services/shipyard/json/airflow_monitoring_client.py View File

@@ -0,0 +1,34 @@
1
+# Copyright 2018 AT&T Corp
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+
17
+"""
18
+http://airship-shipyard.readthedocs.io/en/latest/API.html#airflow-monitoring-api
19
+"""
20
+
21
+from oslo_serialization import jsonutils as json
22
+from six.moves.urllib import parse as urllib
23
+
24
+from tempest.lib.common import rest_client
25
+
26
+
27
+class AirflowMonitoringClient(rest_client.RestClient):
28
+    api_version = "v1.0"
29
+
30
+    def get_workflows(self):
31
+        resp, body = self.get('workflows')
32
+        self.expected_success(200, resp.status)
33
+        body = json.loads(body)
34
+        return rest_client.ResponseBody(resp, body)

+ 34
- 0
airship_tempest_plugin/services/shipyard/json/document_staging_client.py View File

@@ -0,0 +1,34 @@
1
+# Copyright 2018 AT&T Corp
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+
17
+"""
18
+http://airship-shipyard.readthedocs.io/en/latest/API.html#document-staging-api
19
+"""
20
+
21
+from oslo_serialization import jsonutils as json
22
+from six.moves.urllib import parse as urllib
23
+
24
+from tempest.lib.common import rest_client
25
+
26
+
27
+class DocumentStagingClient(rest_client.RestClient):
28
+    api_version = "v1.0"
29
+
30
+    def get_configdocs(self):
31
+        resp, body = self.get('configdocs')
32
+        self.expected_success(200, resp.status)
33
+        body = json.loads(body)
34
+        return rest_client.ResponseBody(resp, body)

+ 0
- 0
airship_tempest_plugin/tests/__init__.py View File


+ 0
- 0
airship_tempest_plugin/tests/api/__init__.py View File


+ 0
- 0
airship_tempest_plugin/tests/api/common/__init__.py View File


+ 13
- 0
airship_tempest_plugin/tests/api/common/rbac_roles.yaml View File

@@ -0,0 +1,13 @@
1
+shipyard:
2
+  get_actions:
3
+    - admin
4
+    - admin_ucp
5
+    - admin_ucp_viewer
6
+  get_configdocs:
7
+    - admin
8
+    - admin_ucp
9
+    - admin_ucp_viewer
10
+  get_workflows:
11
+    - admin
12
+    - admin_ucp
13
+    - admin_ucp_viewer

+ 0
- 0
airship_tempest_plugin/tests/api/shipyard/__init__.py View File


+ 57
- 0
airship_tempest_plugin/tests/api/shipyard/base.py View File

@@ -0,0 +1,57 @@
1
+# Copyright 2018 AT&T Corp
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+
17
+from airship_tempest_plugin.services.shipyard.json.actions_client import ActionsClient
18
+from airship_tempest_plugin.services.shipyard.json.document_staging_client import DocumentStagingClient
19
+from airship_tempest_plugin.services.shipyard.json.airflow_monitoring_client import AirflowMonitoringClient
20
+
21
+from tempest import config
22
+from tempest import test
23
+
24
+from patrole_tempest_plugin import rbac_utils
25
+
26
+CONF = config.CONF
27
+
28
+class BaseShipyardTest(test.BaseTestCase):
29
+    """Base class for Shipyard tests."""
30
+    credentials = ['primary', 'admin']
31
+
32
+    @classmethod
33
+    def skip_checks(cls):
34
+        super(BaseShipyardTest, cls).skip_checks()
35
+        if not CONF.service_available.shipyard:
36
+            raise cls.skipException("Shipyard is not enabled in the deployment")
37
+
38
+    @classmethod
39
+    def setup_clients(cls):
40
+        super(BaseShipyardTest, cls).setup_clients()
41
+        cls.auth_provider = cls.os_primary.auth_provider
42
+
43
+        cls.shipyard_actions_client = ActionsClient(
44
+            cls.auth_provider,
45
+            CONF.shipyard.catalog_type,
46
+            CONF.identity.region,
47
+            CONF.shipyard.endpoint_type)
48
+        cls.shipyard_document_staging_client = DocumentStagingClient(
49
+            cls.auth_provider,
50
+            CONF.shipyard.catalog_type,
51
+            CONF.identity.region,
52
+            CONF.shipyard.endpoint_type)
53
+        cls.shipyard_airflow_monitoring_client = AirflowMonitoringClient(
54
+            cls.auth_provider,
55
+            CONF.shipyard.catalog_type,
56
+            CONF.identity.region,
57
+            CONF.shipyard.endpoint_type)

+ 0
- 0
airship_tempest_plugin/tests/api/shipyard/rbac/__init__.py View File


+ 38
- 0
airship_tempest_plugin/tests/api/shipyard/rbac/rbac_base.py View File

@@ -0,0 +1,38 @@
1
+# Copyright 2018 AT&T Corp
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+
17
+from airship_tempest_plugin.services.shipyard.json.actions_client import ActionsClient
18
+from airship_tempest_plugin.tests.api.shipyard import base
19
+
20
+from tempest import config
21
+
22
+from patrole_tempest_plugin import rbac_utils
23
+
24
+CONF = config.CONF
25
+
26
+class BaseShipyardRbacTest(rbac_utils.RbacUtilsMixin,
27
+                           base.BaseShipyardTest):
28
+    """Base class for Shipyard RBAC tests."""
29
+
30
+    @classmethod
31
+    def skip_checks(cls):
32
+        super(BaseShipyardRbacTest, cls).skip_checks()
33
+        cls.skip_rbac_checks()
34
+
35
+    @classmethod
36
+    def setup_clients(cls):
37
+        super(BaseShipyardRbacTest, cls).setup_clients()
38
+        cls.setup_rbac_utils()

+ 35
- 0
airship_tempest_plugin/tests/api/shipyard/rbac/test_actions_rbac.py View File

@@ -0,0 +1,35 @@
1
+# Copyright 2018 AT&T Corp
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+
17
+from airship_tempest_plugin.tests.api.shipyard.rbac import rbac_base
18
+
19
+from patrole_tempest_plugin import rbac_rule_validation
20
+
21
+from tempest.common import utils
22
+from tempest.lib import decorators
23
+from tempest.lib.common.utils import data_utils
24
+from tempest.lib.common.utils import test_utils
25
+
26
+from tempest.api.identity import base
27
+
28
+class ActionsRbacTest(rbac_base.BaseShipyardRbacTest):
29
+
30
+    @rbac_rule_validation.action(service="shipyard",
31
+                                 rules=["get_actions"])
32
+    @decorators.idempotent_id('183dd007-8a97-4070-afc3-9318401ebad7')
33
+    def test_get_actions(self):
34
+        with self.rbac_utils.override_role(self):
35
+            self.shipyard_actions_client.get_actions()

+ 35
- 0
airship_tempest_plugin/tests/api/shipyard/rbac/test_airflow_monitoring_rbac.py View File

@@ -0,0 +1,35 @@
1
+# Copyright 2018 AT&T Corp
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+
17
+from airship_tempest_plugin.tests.api.shipyard.rbac import rbac_base
18
+
19
+from patrole_tempest_plugin import rbac_rule_validation
20
+
21
+from tempest.common import utils
22
+from tempest.lib import decorators
23
+from tempest.lib.common.utils import data_utils
24
+from tempest.lib.common.utils import test_utils
25
+
26
+from tempest.api.identity import base
27
+
28
+class AirflowMonitoringRbacTest(rbac_base.BaseShipyardRbacTest):
29
+
30
+    @rbac_rule_validation.action(service="shipyard",
31
+                                 rules=["get_configdocs"])
32
+    @decorators.idempotent_id('0ab53b15-bce9-494f-9a11-34dd2c44d699')
33
+    def test_get_workflows(self):
34
+        with self.rbac_utils.override_role(self):
35
+            self.shipyard_airflow_monitoring_client.get_workflows()

+ 35
- 0
airship_tempest_plugin/tests/api/shipyard/rbac/test_document_staging_rbac.py View File

@@ -0,0 +1,35 @@
1
+# Copyright 2018 AT&T Corp
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+
17
+from airship_tempest_plugin.tests.api.shipyard.rbac import rbac_base
18
+
19
+from patrole_tempest_plugin import rbac_rule_validation
20
+
21
+from tempest.common import utils
22
+from tempest.lib import decorators
23
+from tempest.lib.common.utils import data_utils
24
+from tempest.lib.common.utils import test_utils
25
+
26
+from tempest.api.identity import base
27
+
28
+class DocumentStagingRbacTest(rbac_base.BaseShipyardRbacTest):
29
+
30
+    @rbac_rule_validation.action(service="shipyard",
31
+                                 rules=["get_configdocs"])
32
+    @decorators.idempotent_id('0ab53b15-bce9-494f-9a11-34dd2c44d699')
33
+    def test_get_configdocs(self):
34
+        with self.rbac_utils.override_role(self):
35
+            self.shipyard_document_staging_client.get_configdocs()

+ 0
- 0
airship_tempest_plugin/tests/scenario/__init__.py View File


+ 51
- 0
setup.cfg View File

@@ -0,0 +1,51 @@
1
+[metadata]
2
+name = airship-tempest-plugin
3
+summary = This project contains tests for Airship components
4
+description-file =
5
+    README.rst
6
+author = OpenStack
7
+author-email = openstack-dev@lists.openstack.org
8
+home-page = http://www.openstack.org/
9
+classifier =
10
+    Environment :: OpenStack
11
+    Intended Audience :: Information Technology
12
+    Intended Audience :: System Administrators
13
+    License :: OSI Approved :: Apache Software License
14
+    Operating System :: POSIX :: Linux
15
+    Programming Language :: Python
16
+    Programming Language :: Python :: 2
17
+    Programming Language :: Python :: 2.7
18
+    Programming Language :: Python :: 3
19
+    Programming Language :: Python :: 3.3
20
+    Programming Language :: Python :: 3.4
21
+
22
+[files]
23
+packages =
24
+    airship_tempest_plugin
25
+
26
+[build_sphinx]
27
+all-files = 1
28
+warning-is-error = 1
29
+source-dir = doc/source
30
+build-dir = doc/build
31
+
32
+[upload_sphinx]
33
+upload-dir = doc/build/html
34
+
35
+[compile_catalog]
36
+directory = airship-tempest-plugin/locale
37
+domain = airship-tempest-plugin
38
+
39
+[update_catalog]
40
+domain = airship-tempest-plugin
41
+output_dir = airship-tempest-plugin/locale
42
+input_file = airship-tempest-plugin/locale/airship-tempest-plugin.pot
43
+
44
+[extract_messages]
45
+keywords = _ gettext ngettext l_ lazy_gettext
46
+mapping_file = babel.cfg
47
+output_file = airship-tempest-plugin/locale/airship-tempest-plugin.pot
48
+
49
+[entry_points]
50
+tempest.test_plugins =
51
+    airship_rbac_tests = airship_tempest_plugin.plugin:AirshipRbacPlugin

+ 29
- 0
setup.py View File

@@ -0,0 +1,29 @@
1
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#    http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
+# implied.
13
+# See the License for the specific language governing permissions and
14
+# limitations under the License.
15
+
16
+# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
17
+import setuptools
18
+
19
+# In python < 2.7.4, a lazy loading of package `pbr` will break
20
+# setuptools if some other modules registered functions in `atexit`.
21
+# solution from: http://bugs.python.org/issue15881#msg170215
22
+try:
23
+    import multiprocessing  # noqa
24
+except ImportError:
25
+    pass
26
+
27
+setuptools.setup(
28
+    setup_requires=['pbr'],
29
+    pbr=True)

Loading…
Cancel
Save