File: test_cli_verify.py

package info (click to toggle)
rally 5.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,364 kB
  • sloc: python: 42,541; javascript: 487; sh: 198; makefile: 192; xml: 43
file content (122 lines) | stat: -rw-r--r-- 5,539 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright 2014: Mirantis Inc.
# All Rights Reserved.
#
#    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 re
import unittest

from tests.functional import utils


class VerifyTestCase(unittest.TestCase):

    def test_list_plugins(self):
        rally = utils.Rally(plugin_path="tests/functional/extra")
        output = rally("verify list-plugins")
        self.assertIn("fakeverifier", output)
        self.assertIn("installation", output)

    def test_create_list_show_verifier(self):
        rally = utils.Rally(plugin_path="tests/functional/extra")
        output = rally("verify create-verifier --name fakeverify "
                       "--type installation --platform fakeverifier",
                       write_report=False)
        self.assertIn("fakeverify was installed successfully.",
                      output)

        uuid = re.search(r"UUID=([0-9a-f\-]{36})", output).group(1)
        output = rally("--debug verify list-verifiers", write_report=False)
        self.assertIn(uuid, output)
        self.assertIn("installed", output)

        output = rally("--debug verify show-verifier %s" % uuid,
                       write_report=False)
        self.assertIn(uuid, output)
        self.assertIn("installed", output)

    def test_list_tests(self):
        rally = utils.Rally(plugin_path="tests/functional/extra")
        output = rally("verify create-verifier --name fakeverify "
                       "--type installation --platform fakeverifier",
                       write_report=False)
        uuid = re.search(r"UUID=([0-9a-f\-]{36})", output).group(1)
        output = rally("--debug verify list-verifier-tests"
                       " --id %s --pattern \\.test_testr\\." % uuid)
        self.assertIn(".test_testr.", output)

    def test_run_list_show_tests(self):
        rally = utils.Rally(plugin_path="tests/functional/extra")
        output = rally("verify create-verifier --name fakeverify "
                       "--type installation --platform fakeverifier",
                       write_report=False)
        uuid = re.search(r"UUID=([0-9a-f\-]{36})", output).group(1)
        output = rally("verify start --id %s --tag tag-1 tag-2"
                       " --pattern \\.test_testr\\." % uuid)
        self.assertIn("successfully finished", output)

        verification_uuid = re.search(r"UUID=([0-9a-f\-]{36})",
                                      output).group(1)
        output = rally("verify list")
        self.assertIn(verification_uuid, output)

        output = rally("verify show %s" % verification_uuid)
        self.assertIn(".test_testr.", output)

    def test_delete_verification(self):
        rally = utils.Rally(plugin_path="tests/functional/extra")
        output = rally("verify create-verifier --name fakeverify "
                       "--type installation --platform fakeverifier",
                       write_report=False)
        uuid = re.search(r"UUID=([0-9a-f\-]{36})", output).group(1)
        output = rally(
            "verify start --id %s --pattern \\.test_testr\\." % uuid)
        verification_uuid = re.search(r"UUID=([0-9a-f\-]{36})",
                                      output).group(1)
        output = rally("verify delete --uuid %s" % verification_uuid)
        self.assertIn("successfully deleted", output)
        output = rally("verify list")
        self.assertNotIn(verification_uuid, output)

    def test_rerun_verification(self):
        rally = utils.Rally(plugin_path="tests/functional/extra")
        output = rally("verify create-verifier --name fakeverify "
                       "--type installation --platform fakeverifier",
                       write_report=False)
        uuid = re.search(r"UUID=([0-9a-f\-]{36})", output).group(1)
        output = rally(
            "verify start --id %s --pattern \\.test_testr\\." % uuid)
        verification_uuid = re.search(r"UUID=([0-9a-f\-]{36})",
                                      output).group(1)

        output = rally("verify rerun %s" % verification_uuid)
        self.assertIn("successfully finished", output)

    def test_add_list_delete_extension(self):
        rally = utils.Rally(plugin_path="tests/functional/extra")
        output = rally("verify create-verifier --name extension "
                       "--type extension --platform fakeverifier",
                       write_report=False)
        uuid = re.search(r"UUID=([0-9a-f\-]{36})", output).group(1)
        output = rally("--debug verify add-verifier-ext"
                       " --id %s --source fake_url" % uuid)
        self.assertIn(uuid, output)
        self.assertIn("successfully added", output)

        output = rally("--debug verify list-verifier-exts --id %s" % uuid)
        self.assertIn("fake_extension", output)
        self.assertIn("fake_entrypoint", output)

        output = rally("--debug verify delete-verifier-ext"
                       " --id %s --name fake_extension" % uuid)
        self.assertIn("uninstalled extension successfully.", output)