コード例 #1
0
def test_missing_conflicted_operation(ids, scd_api, scd_session):
    # Emplace the initial version of Operation 1
    with open('./scd/resources/op_missing_initial.yaml', 'r') as f:
        req = yaml.full_load(f)
    dt = datetime.datetime.utcnow() - scd.start_of(req['extents'])
    req['extents'] = scd.offset_time(req['extents'], dt)
    resp = scd_session.put('/operational_intent_references/{}'.format(
        ids(OP_TYPE)),
                           json=req)
    assert resp.status_code == 200, resp.content
    ovn1a = resp.json()['operational_intent_reference']['ovn']
    sub_id = resp.json()['operational_intent_reference']['subscription_id']

    # Emplace the pre-existing Operation that conflicted in the original observation
    with open('./scd/resources/op_missing_preexisting_unknown.yaml', 'r') as f:
        req = yaml.full_load(f)
    req['extents'] = scd.offset_time(req['extents'], dt)
    req['key'] = [ovn1a]
    resp = scd_session.put('/operational_intent_references/{}'.format(
        ids(OP_TYPE2)),
                           json=req)
    assert resp.status_code == 200, resp.content

    # Attempt to update Operation 1 without OVN for the pre-existing Operation
    with open('./scd/resources/op_missing_update.json', 'r') as f:
        req = json.load(f)
    req['extents'] = scd.offset_time(req['extents'], dt)
    req['key'] = [ovn1a]
    req['subscription_id'] = sub_id
    resp = scd_session.put('/operational_intent_references/{}/{}'.format(
        ids(OP_TYPE), ovn1a),
                           json=req)
    assert resp.status_code == 409, resp.content

    # checking entity conflicts
    conflicts = []
    data = resp.json()
    assert 'missing_operational_intents' in data
    assert ids(OP_TYPE2) in [
        intent['id'] for intent in data['missing_operational_intents']
    ], resp.content

    # Perform an area-based query on the area occupied by Operation 1
    with open('./scd/resources/op_missing_query.json', 'r') as f:
        req = json.load(f)
    req['area_of_interest'] = scd.offset_time([req['area_of_interest']], dt)[0]
    resp = scd_session.post('/operational_intent_references/query', json=req)
    assert resp.status_code == 200, resp.content
    ops = [op['id'] for op in resp.json()['operational_intent_references']]
    assert ids(OP_TYPE) in ops, resp.content

    # ids(OP_ID2) not expected here because its ceiling is <575m whereas query floor is
    # >591m.
    assert ids(OP_TYPE2) not in ops, resp.content
コード例 #2
0
def test_missing_conflicted_operation(scd_session):
  """
  This test reproduces a case where a conflicting Operation did not appear in a
  follow-up area-based query for Operations.
  """
  # Emplace the initial version of Operation 1
  with open('./scd/resources/op_missing_initial.yaml', 'r') as f:
    req = yaml.full_load(f)
  dt = datetime.datetime.utcnow() - scd.start_of(req['extents'])
  req['extents'] = scd.offset_time(req['extents'], dt)
  resp = scd_session.put('/operation_references/{}'.format(OP_ID), json=req)
  assert resp.status_code == 200, resp.content
  ovn1a = resp.json()['operation_reference']['ovn']
  sub_id = resp.json()['operation_reference']['subscription_id']

  # Emplace the pre-existing Operation that conflicted in the original observation
  with open('./scd/resources/op_missing_preexisting_unknown.yaml', 'r') as f:
    req = yaml.full_load(f)
  req['extents'] = scd.offset_time(req['extents'], dt)
  req['key'] = [ovn1a]
  resp = scd_session.put('/operation_references/{}'.format(OP_ID2), json=req)
  assert resp.status_code == 200, resp.content

  # Attempt to update Operation 1 without OVN for the pre-existing Operation
  with open('./scd/resources/op_missing_update.json', 'r') as f:
    req = json.load(f)
  req['extents'] = scd.offset_time(req['extents'], dt)
  req['key'] = [ovn1a]
  req['subscription_id'] = sub_id
  resp = scd_session.put('/operation_references/{}'.format(OP_ID), json=req)
  assert resp.status_code == 409, resp.content
  conflicts = []
  for conflict in resp.json()['entity_conflicts']:
    if conflict.get('operation_reference', None):
      conflicts.append(conflict['operation_reference']['id'])
  assert OP_ID2 in conflicts, resp.content

  # Perform an area-based query on the area occupied by Operation 1
  with open('./scd/resources/op_missing_query.json', 'r') as f:
    req = json.load(f)
  req['area_of_interest'] = scd.offset_time([req['area_of_interest']], dt)[0]
  resp = scd_session.post('/operation_references/query', json=req)
  assert  resp.status_code == 200, resp.content
  ops = [op['id'] for op in resp.json()['operation_references']]
  assert OP_ID in ops, resp.content

  # OP_ID2 not expected here because its ceiling is <575m whereas query floor is
  # >591m.
  assert OP_ID2 not in ops, resp.content
コード例 #3
0
def test_big_operation_search(scd_api, scd_session):
    with open('./scd/resources/op_big_operation.json', 'r') as f:
        req = json.load(f)
    dt = datetime.datetime.utcnow() - scd.start_of([req['area_of_interest']])
    req['area_of_interest'] = scd.offset_time([req['area_of_interest']], dt)[0]
    resp = scd_session.post('/operational_intent_references/query', json=req)
    assert resp.status_code == 400, resp.content
コード例 #4
0
def test_big_operation_search(scd_session):
  """
  This test reproduces a case where a search resulted in 503 because the
  underlying gRPC backend had crashed.
  """
  with open('./scd/resources/op_big_operation.json', 'r') as f:
    req = json.load(f)
  dt = datetime.datetime.utcnow() - scd.start_of([req['area_of_interest']])
  req['area_of_interest'] = scd.offset_time([req['area_of_interest']], dt)[0]
  resp = scd_session.post('/operation_references/query', json=req)
  assert  resp.status_code == 400, resp.content