~veebers/juju-ci-tools/explore-perf-bulk-model-destruction

« back to all changes in this revision

Viewing changes to tests/test_remote.py

  • Committer: Aaron Bentley
  • Date: 2016-05-25 16:12:07 UTC
  • mto: This revision was merged to the branch mainline in revision 1447.
  • Revision ID: aaron.bentley@canonical.com-20160525161207-h5z5uev3jkyewvxt
Update tests to use applications, not services.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    machines:
31
31
        "1":
32
32
            series: precise
33
 
    services:
34
 
        a-service:
 
33
    applications:
 
34
        a-application:
35
35
            units:
36
 
                a-service/0:
 
36
                a-application/0:
37
37
                    machine: "1"
38
38
                    public-address: 10.55.60.1
39
39
    """
42
42
    machines:
43
43
        "2":
44
44
            series: win2012hvr2
45
 
    services:
46
 
        a-service:
 
45
    applications:
 
46
        a-application:
47
47
            units:
48
 
                a-service/0:
 
48
                a-application/0:
49
49
                    machine: "2"
50
50
                    public-address: 10.55.60.2
51
51
    """
53
53
    def test_remote_from_unit(self):
54
54
        env = JujuData("an-env", {"type": "nonlocal"})
55
55
        client = EnvJujuClient(env, None, None)
56
 
        unit = "a-service/0"
 
56
        unit = "a-application/0"
57
57
        with patch.object(client, "get_status", autospec=True) as st:
58
58
            st.return_value = Status.from_text(self.precise_status_output)
59
59
            remote = remote_from_unit(client, unit)
60
60
        self.assertEqual(
61
61
            repr(remote),
62
 
            "<SSHRemote env='an-env' unit='a-service/0'>")
 
62
            "<SSHRemote env='an-env' unit='a-application/0'>")
63
63
        self.assertIs(False, remote.is_windows())
64
64
 
65
65
    def test_remote_from_unit_with_series(self):
66
66
        env = JujuData("an-env", {"type": "nonlocal"})
67
67
        client = EnvJujuClient(env, None, None)
68
 
        unit = "a-service/0"
 
68
        unit = "a-application/0"
69
69
        remote = remote_from_unit(client, unit, series="trusty")
70
70
        self.assertEqual(
71
71
            repr(remote),
72
 
            "<SSHRemote env='an-env' unit='a-service/0'>")
 
72
            "<SSHRemote env='an-env' unit='a-application/0'>")
73
73
        self.assertIs(False, remote.is_windows())
74
74
 
75
75
    def test_remote_from_unit_with_status(self):
76
76
        env = JujuData("an-env", {"type": "nonlocal"})
77
77
        client = EnvJujuClient(env, None, None)
78
 
        unit = "a-service/0"
 
78
        unit = "a-application/0"
79
79
        status = Status.from_text(self.win2012hvr2_status_output)
80
80
        remote = remote_from_unit(client, unit, status=status)
81
81
        self.assertEqual(
82
82
            repr(remote),
83
 
            "<WinRmRemote env='an-env' unit='a-service/0' addr='10.55.60.2'>")
 
83
            "<WinRmRemote env='an-env' unit='a-application/0'"
 
84
            " addr='10.55.60.2'>")
84
85
        self.assertIs(True, remote.is_windows())
85
86
 
86
87
    def test_remote_from_address(self):
101
102
    def test_run_with_unit(self):
102
103
        env = JujuData("an-env", {"type": "nonlocal"})
103
104
        client = EnvJujuClient(env, None, None)
104
 
        unit = "a-service/0"
 
105
        unit = "a-application/0"
105
106
        remote = remote_from_unit(client, unit, series="trusty")
106
107
        with patch.object(client, "get_juju_output") as mock_cmd:
107
108
            mock_cmd.return_value = "contents of /a/file"
113
114
    def test_run_with_unit_fallback(self):
114
115
        env = JujuData("an-env", {"type": "nonlocal"})
115
116
        client = EnvJujuClient(env, None, None)
116
 
        unit = "a-service/0"
 
117
        unit = "a-application/0"
117
118
        with patch.object(client, "get_status") as st:
118
119
            st.return_value = Status.from_text(self.precise_status_output)
119
120
            remote = remote_from_unit(client, unit)
137
138
        ])
138
139
        self.assertRegexpMatches(
139
140
            self.log_stream.getvalue(),
140
 
            "(?m)^WARNING juju ssh to 'a-service/0' failed, .*")
 
141
            "(?m)^WARNING juju ssh to 'a-application/0' failed, .*")
141
142
 
142
143
    def test_run_with_address(self):
143
144
        remote = remote_from_address("10.55.60.1")
172
173
    def test_cat_on_windows(self):
173
174
        env = JujuData("an-env", {"type": "nonlocal"})
174
175
        client = EnvJujuClient(env, None, None)
175
 
        unit = "a-service/0"
 
176
        unit = "a-application/0"
176
177
        with patch.object(client, "get_status", autospec=True) as st:
177
178
            st.return_value = Status.from_text(self.win2012hvr2_status_output)
178
179
            response = winrm.Response(("contents of /a/file", "",  0))
204
205
    def test_copy_on_windows(self):
205
206
        env = JujuData("an-env", {"type": "nonlocal"})
206
207
        client = EnvJujuClient(env, None, None)
207
 
        unit = "a-service/0"
 
208
        unit = "a-application/0"
208
209
        dest = "/local/path"
209
210
        with patch.object(client, "get_status", autospec=True) as st:
210
211
            st.return_value = Status.from_text(self.win2012hvr2_status_output)
243
244
    def test_run_cmd(self):
244
245
        env = JujuData("an-env", {"type": "nonlocal"})
245
246
        client = EnvJujuClient(env, None, None)
246
 
        unit = "a-service/0"
 
247
        unit = "a-application/0"
247
248
        with patch.object(client, "get_status", autospec=True) as st:
248
249
            st.return_value = Status.from_text(self.win2012hvr2_status_output)
249
250
            response = winrm.Response(("some out", "some err",  0))