Example #1
0
def test_uninstall_remove_node_taint_failure1(caplog):
    fake_http_resp = FakeHTTPResponse(500, "fake reason", "fake body")
    fake_api_exception = K8sApiException(http_resp=fake_http_resp)
    node_name = os.getenv("NODE_NAME")

    with patch('intel.discover.get_k8s_node',
               MagicMock(side_effect=fake_api_exception)):
        with pytest.raises(SystemExit):
            uninstall.remove_node_taint()
        exp_err = "Aborting uninstall: Exception when getting the " \
                  "node \"{}\" obj".format(node_name)
        exp_log_err = get_expected_log_error(exp_err, fake_http_resp)
        caplog_tuple = caplog.record_tuples

        assert caplog_tuple[-1][2] == exp_log_err
Example #2
0
def test_uninstall_remove_node_taint_failure2(caplog):
    fake_node_resp = {"metadata": {"annotations": {}}}
    fake_http_resp = FakeHTTPResponse(500, "fake reason", "fake body")
    fake_api_exception = K8sApiException(http_resp=fake_http_resp)
    with patch('intel.discover.get_k8s_node',
               MagicMock(return_value=fake_node_resp)), \
            patch('intel.discover.patch_k8s_node',
                  MagicMock(side_effect=fake_api_exception)):
        with pytest.raises(SystemExit):
            uninstall.remove_node_taint()
        patch_path = '/metadata/annotations/' \
                     'scheduler.alpha.kubernetes.io~1taints'
        exp_err = "Aborting uninstall: " \
                  "Exception when removing taint \"{}\"".format(patch_path)
        exp_log_err = get_expected_log_error(exp_err, fake_http_resp)
        caplog_tuple = caplog.record_tuples

        assert caplog_tuple[-1][2] == exp_log_err