127
127
# Now call with wait_for_steady=True and confirm wait is called even
128
128
# though juju status is okay.
129
129
self.status.check_and_wait(wait_for_steady=True, max_wait=300)
130
_wait.assert_called_with(max_wait=300)
131
# Also confirm our logging is as expected.
132
expected_logging_args_list = [
133
"Waiting up to 1800 seconds for environment to become ready (not blocked or in maintenance)",
134
"Environment is ready (not blocked or in maintenance)",
135
"Waiting up to 300 seconds for environment to reach steady state (not running any hook)",
130
_wait.assert_called_with(max_wait=300, wait_for_workload=False)
131
# Also confirm our logging is as expected.
132
expected_logging_args_list = [
133
"Waiting up to 1800 seconds for environment to become ready (not blocked or in maintenance)",
134
"Environment is ready (not blocked or in maintenance)",
135
"Waiting up to 300 seconds for environment to reach steady state (not running any hook), "
136
"with wait-for-workload set to False",
137
"Environment has reached steady state (not running any hook)",
139
self.assertEquals(len(_logging_info.call_args_list), len(expected_logging_args_list))
140
for i, call in enumerate(_logging_info.call_args_list):
141
self.assertEquals(call, mock.call(expected_logging_args_list[i]))
142
_logging_info.reset_mock()
144
# Now call with wait_for_workload=True as well and confirm that's
145
# passed to juju-check-wait and logged correctly.
146
self.status.check_and_wait(wait_for_steady=True, max_wait=300, wait_for_workload=True)
147
_wait.assert_called_with(max_wait=300, wait_for_workload=True)
148
# Also confirm our logging is as expected.
149
expected_logging_args_list = [
150
"Waiting up to 1800 seconds for environment to become ready (not blocked or in maintenance)",
151
"Environment is ready (not blocked or in maintenance)",
152
"Waiting up to 300 seconds for environment to reach steady state (not running any hook), "
153
"with wait-for-workload set to True",
136
154
"Environment has reached steady state (not running any hook)",
138
156
self.assertEquals(len(_logging_info.call_args_list), len(expected_logging_args_list))
185
203
with mock.patch("mojo.juju.status.major_version", new=2):
186
204
self.status = mojo.juju.status.Juju2Status()
187
205
status_mock.return_value = self._testdata_from_file("juju2-busy.yaml")
188
with mock.patch("mojo.juju.status.wait", new=lambda max_wait: None):
206
with mock.patch("mojo.juju.status.wait"):
189
207
self.status.check_and_wait(wait_for_steady=True, timeout=1)
191
209
@mock.patch("subprocess.check_output")