~abentley/juju-ci-tools/client-from-config-4

« back to all changes in this revision

Viewing changes to tests/test_assess_log_rotation.py

  • Committer: Aaron Bentley
  • Date: 2016-03-18 14:47:06 UTC
  • mto: This revision was merged to the branch mainline in revision 1324.
  • Revision ID: aaron.bentley@canonical.com-20160318144706-z7wy9c21m3psi6g5
Introduce set_model_name, update tests, check controller on bootstrap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    LogRotateError,
14
14
    make_client_from_args,
15
15
    parse_args,
16
 
    assess_debug_log,
17
 
    assess_machine_rotation,
 
16
    test_debug_log,
18
17
)
19
18
from jujupy import (
20
19
    EnvJujuClient,
23
22
    yaml_loads,
24
23
    )
25
24
from tests import TestCase
26
 
from tests.test_jujupy import (
27
 
    fake_juju_client,
28
 
    fake_juju_client_optional_jes,
29
 
    )
30
25
 
31
26
good_yaml = \
32
27
    """
164
159
        client = Mock()
165
160
        client.get_juju_output.return_value = '\n'*100
166
161
        # Ensure that no exception is raised
167
 
        assess_debug_log(client, timeout=120)
 
162
        test_debug_log(client, timeout=120)
168
163
        client.get_juju_output.assert_called_once_with(
169
164
            "debug-log", "--lines=100", "--limit=100", timeout=120)
170
165
 
173
168
        client.get_juju_output.return_value = ''
174
169
        # Ensure that no exception is raised
175
170
        with self.assertRaises(LogRotateError):
176
 
            assess_debug_log(client)
 
171
            test_debug_log(client)
177
172
        client.get_juju_output.assert_called_once_with(
178
173
            "debug-log", "--lines=100", "--limit=100", timeout=180)
179
174
 
180
175
 
181
 
class TestMachineRoation(TestCase):
182
 
 
183
 
    def test_respects_machine_id_0(self):
184
 
        client = fake_juju_client()
185
 
        client.bootstrap()
186
 
        client.deploy('fill-logs')
187
 
        with patch('assess_log_rotation.test_rotation') as tr_mock:
188
 
            assess_machine_rotation(client)
189
 
        tr_mock.assert_called_once_with(
190
 
            client, '/var/log/juju/machine-0.log', 'machine-0', 'fill-machine',
191
 
            'machine-size', 'megs=300', 'machine=0')
192
 
 
193
 
    def test_respects_machine_id_1(self):
194
 
        client = fake_juju_client_optional_jes(jes_enabled=False)
195
 
        client.bootstrap()
196
 
        client.deploy('fill-logs')
197
 
        with patch('assess_log_rotation.test_rotation') as tr_mock:
198
 
            assess_machine_rotation(client)
199
 
        tr_mock.assert_called_once_with(
200
 
            client, '/var/log/juju/machine-1.log', 'machine-1',
201
 
            'fill-machine', 'machine-size', 'megs=300', 'machine=1')
202
 
 
203
 
 
204
176
class TestParseArgs(TestCase):
205
177
 
206
178
    def test_parse_args(self):