Browse Source

Merge "Add freezer-tempest-client job"

tags/0.1.0
Zuul 8 months ago
parent
commit
d912cb6e67

+ 9
- 0
.zuul.yaml View File

@@ -5,11 +5,13 @@
5 5
     check:
6 6
       jobs:
7 7
         - freezer-tempest-basic
8
+        - freezer-tempest-client
8 9
 
9 10
     gate:
10 11
       queue: freezer
11 12
       jobs:
12 13
         - freezer-tempest-basic
14
+        - freezer-tempest-client
13 15
 
14 16
 - job:
15 17
     name: freezer-tempest-basic
@@ -44,3 +46,10 @@
44 46
         PYTHONUNBUFFERED: 'true'
45 47
       zuul_copy_output:
46 48
         /etc/hosts: logs
49
+
50
+- job:
51
+    name: freezer-tempest-client
52
+    parent: freezer-tempest-basic
53
+    voting: true
54
+    vars:
55
+      tempest_test_regex: freezer_tempest_plugin.tests.freezerclient

+ 0
- 0
freezer_tempest_plugin/tests/freezerclient/__init__.py View File


+ 81
- 0
freezer_tempest_plugin/tests/freezerclient/base.py View File

@@ -0,0 +1,81 @@
1
+# (C) opyright 2018 ZTE Corporation.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# 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, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+import os
15
+import subprocess
16
+from tempest import test
17
+
18
+
19
+class BaseFreezerTest(test.BaseTestCase):
20
+    credentials = ['primary']
21
+
22
+    def __init__(self, *args, **kwargs):
23
+
24
+        super(BaseFreezerTest, self).__init__(*args, **kwargs)
25
+
26
+    # noinspection PyAttributeOutsideInit
27
+    def setUp(self):
28
+        super(BaseFreezerTest, self).setUp()
29
+        self.get_environ()
30
+
31
+    def tearDown(self):
32
+
33
+        super(BaseFreezerTest, self).tearDown()
34
+
35
+    @classmethod
36
+    def get_auth_url(cls):
37
+        return cls.os_primary.auth_provider.auth_client.auth_url[:-len(
38
+            '/auth/tokens')]
39
+
40
+    @classmethod
41
+    def setup_clients(cls):
42
+        super(BaseFreezerTest, cls).setup_clients()
43
+        cls.get_environ()
44
+
45
+    @classmethod
46
+    def get_environ(cls):
47
+        os.environ['OS_PASSWORD'] = cls.os_primary.credentials.password
48
+        os.environ['OS_USERNAME'] = cls.os_primary.credentials.username
49
+        os.environ['OS_PROJECT_NAME'] = cls.os_primary.credentials.project_name
50
+        os.environ['OS_TENANT_NAME'] = cls.os_primary.credentials.project_name
51
+        os.environ['OS_PROJECT_DOMAIN_NAME'] = \
52
+            cls.os_primary.credentials.project_domain_name
53
+        os.environ['OS_USER_DOMAIN_NAME'] = \
54
+            cls.os_primary.credentials.user_domain_name
55
+
56
+        # Allow developers to set OS_AUTH_URL when developing so that
57
+        # Keystone may be on a host other than localhost.
58
+        if 'OS_AUTH_URL' not in os.environ:
59
+            os.environ['OS_AUTH_URL'] = cls.get_auth_url()
60
+
61
+        # Mac OS X uses gtar located in /usr/local/bin
62
+        os.environ['PATH'] = '/usr/local/bin:' + os.environ['PATH']
63
+
64
+        return os.environ
65
+
66
+    def run_subprocess(self, sub_process_args, fail_message):
67
+
68
+        proc = subprocess.Popen(sub_process_args,
69
+                                stdout=subprocess.PIPE,
70
+                                stderr=subprocess.PIPE,
71
+                                env=self.environ, shell=False)
72
+
73
+        out, err = proc.communicate()
74
+
75
+        self.assertEqual(0, proc.returncode,
76
+                         fail_message + " Output: {0}. "
77
+                                        "Error: {1}".format(out, err))
78
+
79
+        self.assertEqual('', err,
80
+                         fail_message + " Output: {0}. "
81
+                                        "Error: {1}".format(out, err))

+ 33
- 0
freezer_tempest_plugin/tests/freezerclient/test_freezer_cmd_action.py View File

@@ -0,0 +1,33 @@
1
+# (C) opyright 2018 ZTE Corporation.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# 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, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+from freezer_tempest_plugin.tests.freezerclient import base
15
+from tempest.lib import decorators
16
+
17
+
18
+class TestFreezerCmdAction(base.BaseFreezerTest):
19
+    def __init__(self, *args, **kwargs):
20
+        super(TestFreezerCmdAction, self).__init__(*args, **kwargs)
21
+
22
+    def setUp(self):
23
+        super(TestFreezerCmdAction, self).setUp()
24
+        self.environ = super(TestFreezerCmdAction, self).get_environ()
25
+
26
+    def tearDown(self):
27
+        super(TestFreezerCmdAction, self).tearDown()
28
+
29
+    @decorators.attr(type="gate")
30
+    def test_freezer_cmd_actionlist(self):
31
+        args = ['freezer', 'action-list']
32
+
33
+        self.run_subprocess(args, "List all actions")

+ 34
- 0
freezer_tempest_plugin/tests/freezerclient/test_freezer_cmd_backup.py View File

@@ -0,0 +1,34 @@
1
+# (C) Copyright 2018 ZTE corporation
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# 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, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+from tempest.lib import decorators
15
+
16
+from freezer_tempest_plugin.tests.freezerclient import base
17
+
18
+
19
+class TestFreezerCmdBackup(base.BaseFreezerTest):
20
+    def __init__(self, *args, **kwargs):
21
+        super(TestFreezerCmdBackup, self).__init__(*args, **kwargs)
22
+
23
+    def setUp(self):
24
+        super(TestFreezerCmdBackup, self).setUp()
25
+        self.environ = super(TestFreezerCmdBackup, self).get_environ()
26
+
27
+    def tearDown(self):
28
+        super(TestFreezerCmdBackup, self).tearDown()
29
+
30
+    @decorators.attr(type="gate")
31
+    def test_freezer_cmd_backuplist(self):
32
+        args = ['freezer', 'backup-list']
33
+
34
+        self.run_subprocess(args, " List all backups")

+ 35
- 0
freezer_tempest_plugin/tests/freezerclient/test_freezer_cmd_client.py View File

@@ -0,0 +1,35 @@
1
+# (C) Copyright 2018 ZTE corporation.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# 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, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+from tempest.lib import decorators
16
+
17
+from freezer_tempest_plugin.tests.freezerclient import base
18
+
19
+
20
+class TestFreezerCmdClient(base.BaseFreezerTest):
21
+    def __init__(self, *args, **kwargs):
22
+        super(TestFreezerCmdClient, self).__init__(*args, **kwargs)
23
+
24
+    def setUp(self):
25
+        super(TestFreezerCmdClient, self).setUp()
26
+        self.environ = super(TestFreezerCmdClient, self).get_environ()
27
+
28
+    def tearDown(self):
29
+        super(TestFreezerCmdClient, self).tearDown()
30
+
31
+    @decorators.attr(type="gate")
32
+    def test_freezer_cmd_clientlist(self):
33
+        args = ['freezer', 'client-list']
34
+
35
+        self.run_subprocess(args, "List of clients registered in the api")

+ 35
- 0
freezer_tempest_plugin/tests/freezerclient/test_freezer_cmd_job.py View File

@@ -0,0 +1,35 @@
1
+# (C) Copyright 2018 ZTE Corporation.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# 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, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+from tempest.lib import decorators
16
+
17
+from freezer_tempest_plugin.tests.freezerclient import base
18
+
19
+
20
+class TestFreezerCmdJob(base.BaseFreezerTest):
21
+    def __init__(self, *args, **kwargs):
22
+        super(TestFreezerCmdJob, self).__init__(*args, **kwargs)
23
+
24
+    def setUp(self):
25
+        super(TestFreezerCmdJob, self).setUp()
26
+        self.environ = super(TestFreezerCmdJob, self).get_environ()
27
+
28
+    def tearDown(self):
29
+        super(TestFreezerCmdJob, self).tearDown()
30
+
31
+    @decorators.attr(type="gate")
32
+    def test_freezer_cmd_joblist(self):
33
+        args = ['freezer', 'job-list']
34
+
35
+        self.run_subprocess(args, "List all the jobs")

+ 34
- 0
freezer_tempest_plugin/tests/freezerclient/test_freezer_cmd_session.py View File

@@ -0,0 +1,34 @@
1
+# (C) Copyright 2018 ZTE Corporation.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# 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, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+from tempest.lib import decorators
15
+
16
+from freezer_tempest_plugin.tests.freezerclient import base
17
+
18
+
19
+class TestFreezerCmdSession(base.BaseFreezerTest):
20
+    def __init__(self, *args, **kwargs):
21
+        super(TestFreezerCmdSession, self).__init__(*args, **kwargs)
22
+
23
+    def setUp(self):
24
+        super(TestFreezerCmdSession, self).setUp()
25
+        self.environ = super(TestFreezerCmdSession, self).get_environ()
26
+
27
+    def tearDown(self):
28
+        super(TestFreezerCmdSession, self).tearDown()
29
+
30
+    @decorators.attr(type="gate")
31
+    def test_freezer_cmd_sessionlist(self):
32
+        args = ['freezer', 'session-list']
33
+
34
+        self.run_subprocess(args, "List all the sessions")

Loading…
Cancel
Save