示例#1
0
def test_coordinator_action_validate_degenerate_fields(
        empty_coordinator_action):
    empty_coordinator_action['id'] = SAMPLE_COORD_ACTION
    empty_coordinator_action['coordJobId'] = 'bad-coord-C'
    empty_coordinator_action['actionNumber'] = 666
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.CoordinatorAction(None, empty_coordinator_action, None)
    assert 'coordJobId does not match coordinator action ID' in str(err)

    empty_coordinator_action['coordJobId'] = SAMPLE_COORD_ID
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.CoordinatorAction(None, empty_coordinator_action, None)
    assert 'actionNumber does not match coordinator action ID' in str(err)
    empty_coordinator_action['actionNumber'] = 12

    empty_coordinator_action['id'] = SAMPLE_COORD_ACTION
    empty_coordinator_action['status'] = 'RUNNING'
    empty_coordinator_action[
        'toString'] = 'CoordinatorAction name[blarg] status [RUNNING]'
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.CoordinatorAction(None, empty_coordinator_action, None)
    assert 'toString does not contain coordinator action ID' in str(err)

    empty_coordinator_action['status'] = 'KILLED'
    empty_coordinator_action[
        'toString'] = 'CoordinatorAction name[' + SAMPLE_COORD_ACTION + '] status [RUNNING]'
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.CoordinatorAction(None, empty_coordinator_action, None)
    assert 'toString does not contain status' in str(err)
示例#2
0
def test_coordinator_action_extrapolate_degenerate_fields(
        empty_coordinator_action):
    empty_coordinator_action['id'] = SAMPLE_COORD_ACTION
    coord = model.CoordinatorAction(None, empty_coordinator_action, None)
    assert coord.coordJobId == SAMPLE_COORD_ID
    assert coord.actionNumber == 12

    empty_coordinator_action['status'] = 'RUNNING'
    coord = model.CoordinatorAction(None, empty_coordinator_action, None)
    assert coord.toString == 'CoordinatorAction name[' + SAMPLE_COORD_ACTION + '] status[RUNNING]'
示例#3
0
def test_parse_empty_coordinator_action(empty_coordinator_action):
    with pytest.raises(exceptions.OozieParsingException) as err:
        coord = model.CoordinatorAction(None, empty_coordinator_action, None)
    assert "Required key 'id' missing or invalid in CoordinatorAction" in str(
        err)

    empty_coordinator_action['id'] = 'bad-coord-C@should-be-int'
    with pytest.raises(exceptions.OozieParsingException) as err:
        coord = model.CoordinatorAction(None, empty_coordinator_action, None)
    assert "Required key 'id' missing or invalid in CoordinatorAction" in str(
        err)

    empty_coordinator_action['id'] = SAMPLE_COORD_ACTION
    coord = model.CoordinatorAction(None, empty_coordinator_action, None)
    assert coord.id == SAMPLE_COORD_ACTION
    assert coord._details == {'wat?': 'blarg'}
示例#4
0
def test_parse_coordinator_action(valid_coordinator_action):
    coord = model.CoordinatorAction(None, valid_coordinator_action, None)
    assert coord.actionNumber == 12
    assert coord.id == SAMPLE_COORD_ACTION
    assert coord.coordJobId == SAMPLE_COORD_ID
    assert coord.externalId == SAMPLE_WF_ID
    assert coord.createdTime == datetime.datetime(2016, 6, 2, 12, 58, 26)
    assert coord.lastModifiedTime == datetime.datetime(2016, 6, 2, 21, 40, 38)
    assert coord.nominalTime == datetime.datetime(2016, 6, 2, 13, 0, 0)
    assert coord.status == model.CoordinatorActionStatus.SUCCEEDED
    assert coord._details == {'wat?': 'blarg'}
示例#5
0
def sample_coordinator_action(valid_coordinator_action, mock_client):
    return model.CoordinatorAction(mock_client, valid_coordinator_action, None)
示例#6
0
def sample_coordinator_action(valid_coordinator_action):
    return model.CoordinatorAction(mock.Mock(), valid_coordinator_action, None)