- Create an ISA.
  - Create a subscription, response should include the pre-existing ISA.
  - Modify the ISA, response should include the subscription.
  - Delete the ISA, response should include the subscription.
  - Delete the subscription.
"""

import datetime

from monitoring.monitorlib.infrastructure import default_scope
from monitoring.monitorlib import rid
from monitoring.monitorlib.rid import SCOPE_READ, SCOPE_WRITE
from monitoring.prober.infrastructure import register_resource_type
from . import common

ISA_TYPE = register_resource_type(325, 'ISA')
SUB_TYPE = register_resource_type(326, 'Subscription')


def test_ensure_clean_workspace(ids, session):
    resp = session.get('/identification_service_areas/{}'.format(
        ids(ISA_TYPE)),
                       scope=SCOPE_READ)
    if resp.status_code == 200:
        version = resp.json()['service_area']['version']
        resp = session.delete('/identification_service_areas/{}/{}'.format(
            ids(ISA_TYPE), version),
                              scope=SCOPE_WRITE)
        assert resp.status_code == 200, resp.content
    elif resp.status_code == 404:
        # As expected.
Exemple #2
0
"""Strategic conflict detection Subscription query tests:

  - add a few Subscriptions spaced in time and footprints
  - query with various combinations of arguments
"""

import datetime

from monitoring.monitorlib.infrastructure import default_scope
from monitoring.monitorlib import scd
from monitoring.monitorlib.scd import SCOPE_SC
from monitoring.prober.infrastructure import for_api_versions, register_resource_type
from monitoring.prober.scd import actions

SUB1_TYPE = register_resource_type(216, 'Subscription 1')
SUB2_TYPE = register_resource_type(217, 'Subscription 2')
SUB3_TYPE = register_resource_type(218, 'Subscription 3')

LAT0 = 23
LNG0 = 56

# This value should be large enough to ensure areas separated by this distance
# will lie in separate grid cells.
FOOTPRINT_SPACING_M = 10000


def _make_sub1_req(scd_api):
    time_start = datetime.datetime.utcnow()
    time_end = time_start + datetime.timedelta(minutes=60)
    lat = LAT0 - scd.latitude_degrees(FOOTPRINT_SPACING_M)
    req = {
Exemple #3
0
"""Operation References state transition tests:
"""

import json

from monitoring.monitorlib.infrastructure import default_scope
from monitoring.monitorlib import scd
from monitoring.monitorlib.scd import SCOPE_SC
from monitoring.prober.infrastructure import for_api_versions, register_resource_type

OP_TYPE = register_resource_type(8, 'Operational intent')


@for_api_versions(scd.API_0_3_5)
@default_scope(SCOPE_SC)
def test_ensure_clean_workspace_v5(ids, scd_api, scd_session):
    resp = scd_session.get('/operation_references/{}'.format(ids(OP_TYPE)),
                           scope=SCOPE_SC)
    if resp.status_code == 200:
        resp = scd_session.delete('/operation_references/{}'.format(
            ids(OP_TYPE)),
                                  scope=SCOPE_SC)
        assert resp.status_code == 200, resp.content
    elif resp.status_code == 404:
        # As expected.
        pass
    else:
        assert False, resp.content


@for_api_versions(scd.API_0_3_17)
import datetime
from typing import Dict

from monitoring.monitorlib.infrastructure import default_scope
from monitoring.monitorlib import scd
from monitoring.monitorlib.scd import SCOPE_CI, SCOPE_CM, SCOPE_SC, SCOPE_CP
from monitoring.prober.infrastructure import for_api_versions, register_resource_type
from monitoring.prober.scd import actions

CONSTRAINT_BASE_URL_1 = 'https://example.com/con1/uss'
CONSTRAINT_BASE_URL_2 = 'https://example.com/con2/uss'
CONSTRAINT_BASE_URL_3 = 'https://example.com/con3/uss'
SUB_BASE_URL_A = 'https://example.com/sub1/uss'
SUB_BASE_URL_B = 'https://example.com/sub2/uss'

CONSTRAINT_TYPE = register_resource_type(2, 'Single constraint')
SUB1_TYPE = register_resource_type(3, 'Constraint subscription 1')
SUB2_TYPE = register_resource_type(4, 'Constraint subscription 2')
SUB3_TYPE = register_resource_type(5, 'Constraint subscription 3')


def _make_c1_request():
    time_start = datetime.datetime.utcnow()
    time_end = time_start + datetime.timedelta(minutes=60)
    return {
        'extents': [
            scd.make_vol4(time_start, time_end, 0, 120,
                          scd.make_circle(-12.00001, 33.99999, 50))
        ],
        'old_version':
        0,
  - create the Operation with a 60 minute length
  - get by ID
  - search with earliest_time and latest_time
  - mutate
  - delete
"""

import datetime
import json

from monitoring.monitorlib.infrastructure import default_scope
from monitoring.monitorlib import scd
from monitoring.monitorlib.scd import SCOPE_SC
from monitoring.prober.infrastructure import for_api_versions, register_resource_type

OP1_TYPE = register_resource_type(210, 'Operational intent 1')
OP2_TYPE = register_resource_type(211, 'Operational intent 2')
SUB_TYPE = register_resource_type(212, 'Subscription')


@for_api_versions(scd.API_0_3_5)
@default_scope(SCOPE_SC)
def test_ensure_clean_workspace_v5(ids, scd_api, scd_session):
    for op_id in map(ids, (OP1_TYPE, OP2_TYPE)):
        resp = scd_session.get('/operation_references/{}'.format(op_id))
        if resp.status_code == 200:
            resp = scd_session.delete('/operation_references/{}'.format(op_id))
            assert resp.status_code == 200, resp.content
            resp = scd_session.get('/operation_references/{}'.format(op_id))
            assert resp.status_code == 404, resp.content
        elif resp.status_code == 404:
Exemple #6
0
  - Create an ISA.
  - Create a subscription slightly overlapping with ISA, response should include the pre-existing ISA.
  - Delete the ISA, response should include the subscription.
  - Delete the subscription.
"""

import datetime

from monitoring.monitorlib.infrastructure import default_scope
from monitoring.monitorlib import rid
from monitoring.monitorlib.rid import SCOPE_READ, SCOPE_WRITE
from monitoring.prober.infrastructure import register_resource_type
from . import common

ISA_TYPE = register_resource_type(427, 'ISA')
SUB_TYPE = register_resource_type(428, 'Subscription')


def test_ensure_clean_workspace(ids, session):
    resp = session.get('/identification_service_areas/{}'.format(
        ids(ISA_TYPE)),
                       scope=SCOPE_READ)
    if resp.status_code == 200:
        version = resp.json()['service_area']['version']
        resp = session.delete('/identification_service_areas/{}/{}'.format(
            ids(ISA_TYPE), version),
                              scope=SCOPE_WRITE)
        assert resp.status_code == 200, resp.content
    elif resp.status_code == 404:
        # As expected.
Exemple #7
0
"""Subscription input validation tests:
  - check we can't create too many SUBS (common.MAX_SUBS_PER_AREA)
  - check we can't create the SUB with a huge area
  - check we can't create the SUB with missing fields
  - check we can't create the SUB with a time_start in the past
  - check we can't create the SUB with a time_start after time_end
"""
import datetime

from monitoring.monitorlib.infrastructure import default_scope
from monitoring.monitorlib import rid
from monitoring.monitorlib.rid import SCOPE_READ
from monitoring.prober.infrastructure import register_resource_type
from . import common

SUB_TYPE = register_resource_type(328, 'Subscription')
MULTI_SUB_TYPES = [
    register_resource_type(329 + i,
                           'Subscription limit Subscription {}'.format(i))
    for i in range(11)
]


def test_ensure_clean_workspace(ids, session):
    resp = session.get('/subscriptions/{}'.format(ids(SUB_TYPE)),
                       scope=SCOPE_READ)
    if resp.status_code == 200:
        version = resp.json()['subscription']['version']
        resp = session.delete('/subscriptions/{}/{}'.format(
            ids(SUB_TYPE), version),
                              scope=SCOPE_READ)
import asyncio
import datetime
import json
import inspect

from monitoring.monitorlib.infrastructure import default_scope
from monitoring.monitorlib import scd
from monitoring.monitorlib.scd import SCOPE_SC
from monitoring.monitorlib.testing import assert_datetimes_are_equal
from monitoring.prober.infrastructure import depends_on, for_api_versions, register_resource_type, IDFactory, resource_type_code_descriptions
from monitoring.prober.scd import actions


BASE_URL = 'https://example.com/uss'
# TODO(#742): Increase number of concurrent operations from 20 to 100
OP_TYPES = [register_resource_type(110 + i, 'Operational intent {}'.format(i)) for i in range(20)]
GROUP_SIZE = len(OP_TYPES) // 3 + (1 if len(OP_TYPES) % 3 > 0 else 0)
# Semaphore is added to limit the number of simultaneous requests,
# default is 100.
SEMAPHORE = asyncio.Semaphore(10)

ovn_map = {}


def _calculate_lat(idx):
  return -56 - 0.1 * idx


def _make_op_request_with_extents(extents):
  return {
    'extents': [extents],