Example #1
0
def test_coordinator_validate_degenerate_fields(empty_coordinator):
    empty_coordinator['coordJobId'] = SAMPLE_COORD_ID
    empty_coordinator['status'] = 'RUNNING'
    empty_coordinator[
        'toString'] = 'Coordinator application id[blarg] status [RUNNING]'
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.Coordinator(None, empty_coordinator, None)
    assert 'toString does not contain coordinator ID' in str(err)

    empty_coordinator['status'] = 'KILLED'
    empty_coordinator[
        'toString'] = 'Coordinator application id[' + SAMPLE_COORD_ID + '] status [RUNNING]'
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.Coordinator(None, empty_coordinator, None)
    assert 'toString does not contain status' in str(err)
Example #2
0
def test_parse_empty_coordinator(empty_coordinator):
    with pytest.raises(exceptions.OozieParsingException) as err:
        coord = model.Coordinator(None, empty_coordinator, None)
    assert "Required key 'coordJobId' missing or invalid in Coordinator" in str(
        err)

    empty_coordinator['coordJobId'] = 'bad-coord-id'
    with pytest.raises(exceptions.OozieParsingException) as err:
        coord = model.Coordinator(None, empty_coordinator, None)
    assert "Required key 'coordJobId' missing or invalid in Coordinator" in str(
        err)

    empty_coordinator['coordJobId'] = SAMPLE_COORD_ID
    coord = model.Coordinator(None, empty_coordinator, None)
    assert coord.coordJobId == SAMPLE_COORD_ID
    assert coord._details == {'wat?': 'blarg'}
Example #3
0
def test_parse_empty_coordinator(empty_coordinator, mock_client):
    with pytest.raises(exceptions.OozieParsingException) as err:
        coord = model.Coordinator(mock_client, empty_coordinator, None)
    assert "Required key 'coordJobId' missing or invalid in Coordinator" in str(
        err)

    empty_coordinator['coordJobId'] = 'bad-coord-id'
    with pytest.raises(exceptions.OozieParsingException) as err:
        coord = model.Coordinator(mock_client, empty_coordinator, None)
    assert "Required key 'coordJobId' missing or invalid in Coordinator" in str(
        err)

    empty_coordinator['coordJobId'] = SAMPLE_COORD_ID
    coord = model.Coordinator(mock_client, empty_coordinator, None)
    assert coord.coordJobId == SAMPLE_COORD_ID
    assert coord.client_url == 'https://oozie-server:1234/oozie'
    assert coord._details == {'wat?': 'blarg'}
Example #4
0
def test_parse_coordinator(valid_coordinator):
    coord = model.Coordinator(None, valid_coordinator, None)
    assert coord.conf == {
        'key1': 'value1',
        'key two': 'value two',
    }
    assert coord.coordJobId == SAMPLE_COORD_ID
    assert coord.coordJobName == 'my-test-coordinator'
    assert coord.startTime == datetime.datetime(2016, 5, 14, 1, 0, 0)
    assert coord.endTime == datetime.datetime(2116, 5, 13, 23, 42, 0)
    assert coord.lastAction == datetime.datetime(2016, 6, 3, 1, 0, 0)
    assert coord.nextMaterializedTime == datetime.datetime(2016, 6, 3, 1, 0, 0)
    assert coord.status == model.CoordinatorStatus.RUNNING
    assert coord._details == {'wat?': 'blarg'}
Example #5
0
def test_coordinator_extrapolate_degenerate_fields(empty_coordinator):
    empty_coordinator['coordJobId'] = SAMPLE_COORD_ID
    empty_coordinator['status'] = 'RUNNING'
    coord = model.Coordinator(None, empty_coordinator, None)
    assert coord.toString == 'Coordinator application id[' + SAMPLE_COORD_ID + '] status[RUNNING]'
Example #6
0
def sample_coordinator(valid_coordinator, mock_client):
    return model.Coordinator(mock_client, valid_coordinator, None)
Example #7
0
def sample_coordinator(valid_coordinator):
    return model.Coordinator(mock.Mock(), valid_coordinator, None)