80
79
args = ['bundles', 'an-env', '/bin/juju', 'logs', 'deployer-env']
81
80
env = JujuData('an-env')
82
81
client = EnvJujuClient(env, '1.234-76', None)
83
with patch('run_deployer.client_from_config',
84
return_value=client) as c_mock:
85
with patch('run_deployer.boot_context'):
86
with patch('run_deployer.assess_deployer') as ad_mock:
88
c_mock.assert_called_once_with('an-env', '/bin/juju', debug=False)
89
ad_mock.assert_called_once_with(parse_args(args), client, 1200, 1800)
91
def test_basic_args_native_deploy(self):
92
args = ['mediawiki-scalable.yaml', 'an-env', '/bin/juju', 'logs',
93
'deployer-env', '--allow-native-deploy',
94
'--bundle-verification-script',
95
'verify_mediawiki_bundle.py']
96
env = JujuData('an-env')
97
client = EnvJujuClient(env, '1.234-76', None)
98
with patch('run_deployer.client_from_config',
99
return_value=client) as c_mock:
100
with patch('run_deployer.boot_context'):
101
with patch('run_deployer.assess_deployer') as ad_mock:
102
with patch('run_deployer.run_command') as mb_mock:
82
with patch('jujupy.SimpleEnvironment.from_config',
83
return_value=env) as e_mock:
84
with patch('jujupy.EnvJujuClient.by_version',
85
return_value=client) as c_mock:
86
with patch('run_deployer.boot_context'):
87
with patch('run_deployer.assess_deployer') as ad_mock:
104
c_mock.assert_called_once_with('an-env', '/bin/juju', debug=False)
105
ad_mock.assert_called_once_with(parse_args(args), client, 1200, 1800)
106
client_ser = pickle.dumps(client)
107
mb_mock.assert_called_once_with(['verify_mediawiki_bundle.py',
110
def test_basic_args_native_deploy_landscape(self):
111
args = ['cs:~landscape/bundle/landscape-scalable', 'an-env',
112
'/bin/juju', 'logs', 'deployer-env',
113
'--allow-native-deploy',
114
'--bundle-verification-script',
115
'verify_landscape_bundle.py']
116
env = JujuData('an-env')
117
client = EnvJujuClient(env, '1.234-76', None)
118
with patch('run_deployer.client_from_config',
119
return_value=client) as c_mock:
120
with patch('run_deployer.boot_context'):
121
with patch('run_deployer.assess_deployer') as ad_mock:
122
with patch('run_deployer.run_command') as rc:
124
c_mock.assert_called_once_with('an-env', '/bin/juju', debug=False)
125
ad_mock.assert_called_once_with(parse_args(args), client, 1200, 1800)
126
client_ser = pickle.dumps(client)
127
rc.assert_called_once_with(['verify_landscape_bundle.py',
89
e_mock.assert_called_once_with('an-env')
90
c_mock.assert_called_once_with(env, '/bin/juju', debug=False)
91
ad_mock.assert_called_once_with(parse_args(args), client, 1200, 1800)
131
94
class TestAssessDeployer(tests.TestCase):
185
148
self.assertEqual(
186
149
ch_mock.call_args_list, [call('/tmp/check', 'foo', environ)] * 2)
151
@patch('run_deployer.SimpleEnvironment.from_config')
188
152
@patch('run_deployer.boot_context', autospec=True)
189
153
def test_run_deployer_upgrade(self, *args):
190
154
args = self.make_args(
191
155
juju_bin='baz/juju', upgrade=True,
192
156
upgrade_condition=['bla/0:clock_skew', 'foo/1:fill_disk'])
193
client = fake_juju_client()
195
with patch('run_deployer.client_from_config', return_value=client):
157
client = FakeJujuClient()
158
with patch('run_deployer.EnvJujuClient.by_version',
159
return_value=client):
196
160
with patch('run_deployer.apply_condition') as ac_mock:
197
161
with patch('run_deployer.assess_upgrade') as au_mock:
198
162
assess_deployer(args, client, 600, 1800)