~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to tests/test_run_chaos_monkey.py

  • Committer: Curtis Hovey
  • Date: 2015-12-04 15:35:31 UTC
  • mto: This revision was merged to the branch mainline in revision 1168.
  • Revision ID: curtis@canonical.com-20151204153531-gyhv0uix87mwcypq
Attempt to delete machines stuck in provisioning. Explain when it must be done in the Joyent UI.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
from chaos import MonkeyRunner
12
12
from jujupy import (
13
13
    EnvJujuClient,
14
 
    JujuData,
 
14
    SimpleEnvironment,
15
15
    )
16
16
from run_chaos_monkey import (
17
17
    get_args,
19
19
    )
20
20
 
21
21
 
 
22
def fake_EnvJujuClient_by_version(env, path=None, debug=None):
 
23
    return EnvJujuClient(env=env, version='1.2.3.4', full_path=path)
 
24
 
 
25
 
 
26
def fake_SimpleEnvironment_from_config(name):
 
27
    return SimpleEnvironment(name, {})
 
28
 
 
29
 
22
30
class TestRunChaosMonkey(TestCase):
23
31
 
24
32
    def test_get_args(self):
32
40
        self.assertEqual(args.health_checker, 'baz')
33
41
 
34
42
    def test_run_while_healthy_or_timeout(self):
35
 
        client = EnvJujuClient(JujuData('foo', {}), None, '/foo')
 
43
        client = EnvJujuClient(SimpleEnvironment('foo', {}), None, '/foo')
36
44
        runner = MonkeyRunner('foo', 'bar', 'script', client, total_timeout=60)
37
45
        runner.expire_time = (datetime.now() - timedelta(seconds=1))
38
46
        with patch.object(runner, 'is_healthy', autospec=True,
45
53
        wait_mock.assert_called_once_with()
46
54
 
47
55
    def test_run_while_healthy_or_timeout_exits_non_zero(self):
48
 
        client = EnvJujuClient(JujuData('foo', {}), None, '/foo')
 
56
        client = EnvJujuClient(SimpleEnvironment('foo', {}), None, '/foo')
49
57
        runner = MonkeyRunner('foo', 'bar', 'script', client, total_timeout=60)
50
58
        with patch.object(runner, 'is_healthy', autospec=True,
51
59
                          return_value=False):