def test_clusterinit_run_pods_failure(caplog): fake_exception = RuntimeError('fake') with patch('intel.clusterinit.wait_for_pod_phase', MagicMock(side_effect=fake_exception)): with pytest.raises(SystemExit): clusterinit.run_pods(None, ["discover"], "fake_img", "Never", "fake-conf-dir", "fake-install-dir", "2", "2", ["fakenode"], "", "", "vertical", "vertical", "default") caplog_tuple = caplog.record_tuples assert caplog_tuple[-2][2] == "{}".format(fake_exception) assert caplog_tuple[-1][2] == "Aborting cluster-init ..."
def test_clusterinit_run_cmd_pods_nodereport_failure(caplog): fake_http_resp = FakeHTTPResponse(500, "fake reason", "fake body") fake_api_exception = K8sApiException(http_resp=fake_http_resp) with patch('intel.k8s.create_ds', MagicMock(side_effect=fake_api_exception)): with pytest.raises(SystemExit): clusterinit.run_pods(["nodereport"], None, "fake_img", "Never", "fake-conf-dir", "fake-install-dir", "2", "2", ["fakenode"], "", "") exp_err = "Exception when creating pod for ['nodereport'] command(s)" exp_log_err = get_expected_log_error(exp_err) caplog_tuple = caplog.record_tuples assert caplog_tuple[1][2] == exp_log_err
def test_clusterinit_run_cmd_pods_install_failure(caplog): fake_http_resp = FakeHTTPResponse(500, FAKE_REASON, FAKE_BODY) fake_api_exception = K8sApiException(http_resp=fake_http_resp) with patch(CREATE_POD, MagicMock(side_effect=fake_api_exception)): with pytest.raises(SystemExit): clusterinit.run_pods(None, ["install"], "fake_img", "Never", "fake-install-dir", "2", "2", ["fakenode"], "", "", "vertical", "vertical", "default", "-1", False) exp_err = "Exception when creating pod for ['install'] command(s)" exp_log_err = get_expected_log_error(exp_err) caplog_tuple = caplog.record_tuples assert caplog_tuple[1][2] == exp_log_err