Commit 59af3544 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Context:

- configured constant with event collection timeout for unitary tests and debug purposes
- cosmetic changes
- migrated event reporting for Connection entity
parent b8ec2a6a
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -278,29 +278,29 @@ class ContextServiceServicerImpl(ContextServiceServicer, ContextPolicyServiceSer

    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def ListConnectionIds(self, request : ServiceId, context : grpc.ServicerContext) -> ConnectionIdList:
        return connection_list_ids(self.db_engine, request)
        return ConnectionIdList(connection_ids=connection_list_ids(self.db_engine, request))

    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def ListConnections(self, request : ContextId, context : grpc.ServicerContext) -> ConnectionList:
        return connection_list_objs(self.db_engine, request)
        return ConnectionList(connections=connection_list_objs(self.db_engine, request))

    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def GetConnection(self, request : ConnectionId, context : grpc.ServicerContext) -> Connection:
        return connection_get(self.db_engine, request)
        return Connection(**connection_get(self.db_engine, request))

    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def SetConnection(self, request : Connection, context : grpc.ServicerContext) -> ConnectionId:
        connection_id,updated = connection_set(self.db_engine, request) # pylint: disable=unused-variable
        #event_type = EventTypeEnum.EVENTTYPE_UPDATE if updated else EventTypeEnum.EVENTTYPE_CREATE
        #notify_event(self.messagebroker, TOPIC_CONNECTION, event_type, {'connection_id': connection_id})
        return connection_id
        connection_id,updated = connection_set(self.db_engine, request)
        event_type = EventTypeEnum.EVENTTYPE_UPDATE if updated else EventTypeEnum.EVENTTYPE_CREATE
        notify_event(self.messagebroker, TOPIC_CONNECTION, event_type, {'connection_id': connection_id})
        return ConnectionId(**connection_id)

    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def RemoveConnection(self, request : ConnectionId, context : grpc.ServicerContext) -> Empty:
        deleted = connection_delete(self.db_engine, request) # pylint: disable=unused-variable
        #if deleted:
        #    event_type = EventTypeEnum.EVENTTYPE_REMOVE
        #    notify_event(self.messagebroker, TOPIC_CONNECTION, event_type, {'connection_id': request})
        connection_id,deleted = connection_delete(self.db_engine, request)
        if deleted:
            event_type = EventTypeEnum.EVENTTYPE_REMOVE
            notify_event(self.messagebroker, TOPIC_CONNECTION, event_type, {'connection_id': connection_id})
        return Empty()

    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
+31 −18
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy_cockroachdb import run_transaction
from typing import Dict, List, Optional, Tuple
from common.proto.context_pb2 import Connection, ConnectionId, ConnectionIdList, ConnectionList, ServiceId
from common.proto.context_pb2 import Connection, ConnectionId, ServiceId
from common.method_wrappers.ServiceExceptions import NotFoundException
from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.object_factory.Connection import json_connection_id
@@ -28,23 +28,23 @@ from .uuids.Connection import connection_get_uuid
from .uuids.EndPoint import endpoint_get_uuid
from .uuids.Service import service_get_uuid

def connection_list_ids(db_engine : Engine, request : ServiceId) -> ConnectionIdList:
LOGGER = logging.getLogger(__name__)

def connection_list_ids(db_engine : Engine, request : ServiceId) -> List[Dict]:
    _,service_uuid = service_get_uuid(request, allow_random=False)
    def callback(session : Session) -> List[Dict]:
        obj_list : List[ConnectionModel] = session.query(ConnectionModel).filter_by(service_uuid=service_uuid).all()
        #.options(selectinload(ContextModel.connection)).filter_by(context_uuid=context_uuid).one_or_none()
        return [obj.dump_id() for obj in obj_list]
    return ConnectionIdList(connection_ids=run_transaction(sessionmaker(bind=db_engine), callback))
    return run_transaction(sessionmaker(bind=db_engine), callback)

def connection_list_objs(db_engine : Engine, request : ServiceId) -> ConnectionList:
def connection_list_objs(db_engine : Engine, request : ServiceId) -> List[Dict]:
    _,service_uuid = service_get_uuid(request, allow_random=False)
    def callback(session : Session) -> List[Dict]:
        obj_list : List[ConnectionModel] = session.query(ConnectionModel).filter_by(service_uuid=service_uuid).all()
        #.options(selectinload(ContextModel.connection)).filter_by(context_uuid=context_uuid).one_or_none()
        return [obj.dump() for obj in obj_list]
    return ConnectionList(connections=run_transaction(sessionmaker(bind=db_engine), callback))
    return run_transaction(sessionmaker(bind=db_engine), callback)

def connection_get(db_engine : Engine, request : ConnectionId) -> Connection:
def connection_get(db_engine : Engine, request : ConnectionId) -> Dict:
    connection_uuid = connection_get_uuid(request, allow_random=False)
    def callback(session : Session) -> Optional[Dict]:
        obj : Optional[ConnectionModel] = session.query(ConnectionModel)\
@@ -55,17 +55,21 @@ def connection_get(db_engine : Engine, request : ConnectionId) -> Connection:
        raise NotFoundException('Connection', request.connection_uuid.uuid, extra_details=[
            'connection_uuid generated was: {:s}'.format(connection_uuid),
        ])
    return Connection(**obj)
    return obj

def connection_set(db_engine : Engine, request : Connection) -> Tuple[ConnectionId, bool]:
def connection_set(db_engine : Engine, request : Connection) -> Tuple[Dict, bool]:
    connection_uuid = connection_get_uuid(request.connection_id, allow_random=True)
    _,service_uuid = service_get_uuid(request.service_id, allow_random=False)
    settings = grpc_message_to_json_string(request.settings),

    now = datetime.datetime.utcnow()

    connection_data = [{
        'connection_uuid': connection_uuid,
        'service_uuid'   : service_uuid,
        'settings'       : settings,
        'created_at'     : now,
        'updated_at'     : now,
    }]

    connection_endpoints_data : List[Dict] = list()
@@ -78,21 +82,27 @@ def connection_set(db_engine : Engine, request : Connection) -> Tuple[Connection
        })

    connection_subservices_data : List[Dict] = list()
    for i,service_id in enumerate(request.sub_service_ids):
    for service_id in request.sub_service_ids:
        _, service_uuid = service_get_uuid(service_id, allow_random=False)
        connection_subservices_data.append({
            'connection_uuid': connection_uuid,
            'subservice_uuid': service_uuid,
        })

    def callback(session : Session) -> None:
    def callback(session : Session) -> bool:
        stmt = insert(ConnectionModel).values(connection_data)
        stmt = stmt.on_conflict_do_update(
            index_elements=[ConnectionModel.connection_uuid],
            set_=dict(settings = stmt.excluded.settings)
            set_=dict(
                settings   = stmt.excluded.settings,
                updated_at = stmt.excluded.updated_at,
            )
        session.execute(stmt)
        )
        stmt = stmt.returning(ConnectionModel.created_at, ConnectionModel.updated_at)
        created_at,updated_at = session.execute(stmt).fetchone()
        updated = updated_at > created_at

        # TODO: manage update connection endpoints
        if len(connection_endpoints_data) > 0:
            stmt = insert(ConnectionEndPointModel).values(connection_endpoints_data)
            stmt = stmt.on_conflict_do_nothing(
@@ -115,6 +125,7 @@ def connection_set(db_engine : Engine, request : Connection) -> Tuple[Connection
                else:
                    raise

        # TODO: manage update connection subservices
        if len(connection_subservices_data) > 0:
            stmt = insert(ConnectionSubServiceModel).values(connection_subservices_data)
            stmt = stmt.on_conflict_do_nothing(
@@ -122,13 +133,15 @@ def connection_set(db_engine : Engine, request : Connection) -> Tuple[Connection
            )
            session.execute(stmt)

    run_transaction(sessionmaker(bind=db_engine), callback)
    updated = False # TODO: improve and check if created/updated
        return updated

    updated = run_transaction(sessionmaker(bind=db_engine), callback)
    return ConnectionId(**json_connection_id(connection_uuid)),updated

def connection_delete(db_engine : Engine, request : ConnectionId) -> bool:
def connection_delete(db_engine : Engine, request : ConnectionId) -> Tuple[Dict, bool]:
    connection_uuid = connection_get_uuid(request, allow_random=False)
    def callback(session : Session) -> bool:
        num_deleted = session.query(ConnectionModel).filter_by(connection_uuid=connection_uuid).delete()
        return num_deleted > 0
    return run_transaction(sessionmaker(bind=db_engine), callback)
    deleted = run_transaction(sessionmaker(bind=db_engine), callback)
    return ConnectionId(**json_connection_id(connection_uuid)),deleted
+3 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
# limitations under the License.

import json, logging, operator
from sqlalchemy import Column, ForeignKey, Integer, CheckConstraint, String
from sqlalchemy import Column, DateTime, ForeignKey, Integer, CheckConstraint, String
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
from typing import Dict
@@ -27,6 +27,8 @@ class ConnectionModel(_Base):
    connection_uuid = Column(UUID(as_uuid=False), primary_key=True)
    service_uuid    = Column(ForeignKey('service.service_uuid', ondelete='RESTRICT'), nullable=False)
    settings        = Column(String, nullable=False)
    created_at      = Column(DateTime, nullable=False)
    updated_at      = Column(DateTime, nullable=False)

    connection_service     = relationship('ServiceModel') # back_populates='connections'
    connection_endpoints   = relationship('ConnectionEndPointModel') # lazy='joined', back_populates='connection'
+87 −93
Original line number Diff line number Diff line
@@ -12,28 +12,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import copy, grpc, pytest
import copy, grpc, pytest, time
from common.proto.context_pb2 import (
    Connection, ConnectionId, Context, ContextId, Device, DeviceId, EndPointId, Service, ServiceId, Topology, TopologyId)
    Connection, ConnectionEvent, ConnectionId, Context, ContextEvent, ContextId, Device, DeviceEvent, DeviceId, EndPointId, EventTypeEnum, Service, ServiceEvent, ServiceId, Topology, TopologyEvent, TopologyId)
from context.client.ContextClient import ContextClient
from context.service.database.uuids.Connection import connection_get_uuid
from context.service.database.uuids.EndPoint import endpoint_get_uuid
#from context.client.EventsCollector import EventsCollector
from context.client.EventsCollector import EventsCollector
from .Objects import (
    CONNECTION_R1_R3, CONNECTION_R1_R3_ID, CONNECTION_R1_R3_NAME, CONTEXT, CONTEXT_ID, DEVICE_R1, DEVICE_R1_ID,
    DEVICE_R2, DEVICE_R2_ID, DEVICE_R3, DEVICE_R3_ID, SERVICE_R1_R2, SERVICE_R1_R2_ID, SERVICE_R1_R3, SERVICE_R1_R3_ID,
    SERVICE_R2_R3, SERVICE_R2_R3_ID, TOPOLOGY, TOPOLOGY_ID)

GET_EVENTS_TIMEOUT = 10.0

@pytest.mark.depends(on=['context/tests/test_service.py::test_service', 'context/tests/test_slice.py::test_slice'])
def test_connection(context_client : ContextClient) -> None:

    # ----- Initialize the EventsCollector -----------------------------------------------------------------------------
    #events_collector = EventsCollector(
    #    context_client, log_events_received=True,
    #    activate_context_collector = False, activate_topology_collector = False, activate_device_collector = False,
    #    activate_link_collector = False, activate_service_collector = False, activate_slice_collector = False,
    #    activate_connection_collector = True)
    #events_collector.start()
    events_collector = EventsCollector(
        context_client, log_events_received=True,
        activate_context_collector = True, activate_topology_collector = True, activate_device_collector = True,
        activate_link_collector = True, activate_service_collector = True, activate_slice_collector = True,
        activate_connection_collector = True)
    events_collector.start()
    time.sleep(3)

    # ----- Prepare dependencies for the test and capture related events -----------------------------------------------
    response = context_client.SetContext(Context(**CONTEXT))
@@ -47,61 +50,52 @@ def test_connection(context_client : ContextClient) -> None:
    device_r1_uuid = response.device_uuid.uuid

    response = context_client.SetDevice(Device(**DEVICE_R2))
    device_r2_uuid = response.device_uuid.uuid # pylint: disable=unused-variable
    device_r2_uuid = response.device_uuid.uuid

    response = context_client.SetDevice(Device(**DEVICE_R3))
    device_r3_uuid = response.device_uuid.uuid # pylint: disable=unused-variable
    device_r3_uuid = response.device_uuid.uuid

    response = context_client.SetService(Service(**SERVICE_R1_R2))
    assert response.context_id.context_uuid.uuid == context_uuid
    service_r1_r2_uuid = response.service_uuid.uuid # pylint: disable=unused-variable
    service_r1_r2_uuid = response.service_uuid.uuid

    response = context_client.SetService(Service(**SERVICE_R2_R3))
    assert response.context_id.context_uuid.uuid == context_uuid
    service_r2_r3_uuid = response.service_uuid.uuid # pylint: disable=unused-variable
    service_r2_r3_uuid = response.service_uuid.uuid

    response = context_client.SetService(Service(**SERVICE_R1_R3))
    assert response.context_id.context_uuid.uuid == context_uuid
    service_r1_r3_uuid = response.service_uuid.uuid

    #events = events_collector.get_events(block=True, count=8)
    #assert isinstance(events[0], ContextEvent)
    #assert events[0].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert events[0].context_id.context_uuid.uuid == context_uuid
    #assert isinstance(events[1], TopologyEvent)
    #assert events[1].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert events[1].topology_id.context_id.context_uuid.uuid == context_uuid
    #assert events[1].topology_id.topology_uuid.uuid == topology_uuid
    #assert isinstance(events[2], DeviceEvent)
    #assert events[2].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert events[2].device_id.device_uuid.uuid == device_r1_uuid
    #assert isinstance(events[3], DeviceEvent)
    #assert events[3].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert events[3].device_id.device_uuid.uuid == device_r2_uuid
    #assert isinstance(events[4], DeviceEvent)
    #assert events[4].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert events[4].device_id.device_uuid.uuid == device_r3_uuid
    #assert isinstance(events[5], ServiceEvent)
    #assert events[5].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert events[5].service_id.context_id.context_uuid.uuid == context_uuid
    #assert events[5].service_id.service_uuid.uuid == service_r1_r2_uuid
    #assert isinstance(events[6], ContextEvent)
    #assert events[6].event.event_type == EventTypeEnum.EVENTTYPE_UPDATE
    #assert events[6].context_id.context_uuid.uuid == context_uuid
    #assert isinstance(events[7], ServiceEvent)
    #assert events[7].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert events[7].service_id.context_id.context_uuid.uuid == context_uuid
    #assert events[7].service_id.service_uuid.uuid == service_r2_r3_uuid
    #assert isinstance(events[8], ContextEvent)
    #assert events[8].event.event_type == EventTypeEnum.EVENTTYPE_UPDATE
    #assert events[8].context_id.context_uuid.uuid == context_uuid
    #assert isinstance(events[9], ServiceEvent)
    #assert events[9].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert events[9].service_id.context_id.context_uuid.uuid == context_uuid
    #assert events[9].service_id.service_uuid.uuid == service_r1_r3_uuid
    #assert isinstance(events[10], ContextEvent)
    #assert events[10].event.event_type == EventTypeEnum.EVENTTYPE_UPDATE
    #assert events[10].context_id.context_uuid.uuid == context_uuid
    events = events_collector.get_events(block=True, count=8, timeout=GET_EVENTS_TIMEOUT)
    assert isinstance(events[0], ContextEvent)
    assert events[0].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert events[0].context_id.context_uuid.uuid == context_uuid
    assert isinstance(events[1], TopologyEvent)
    assert events[1].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert events[1].topology_id.context_id.context_uuid.uuid == context_uuid
    assert events[1].topology_id.topology_uuid.uuid == topology_uuid
    assert isinstance(events[2], DeviceEvent)
    assert events[2].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert events[2].device_id.device_uuid.uuid == device_r1_uuid
    assert isinstance(events[3], DeviceEvent)
    assert events[3].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert events[3].device_id.device_uuid.uuid == device_r2_uuid
    assert isinstance(events[4], DeviceEvent)
    assert events[4].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert events[4].device_id.device_uuid.uuid == device_r3_uuid
    assert isinstance(events[5], ServiceEvent)
    assert events[5].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert events[5].service_id.context_id.context_uuid.uuid == context_uuid
    assert events[5].service_id.service_uuid.uuid == service_r1_r2_uuid
    assert isinstance(events[6], ServiceEvent)
    assert events[6].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert events[6].service_id.context_id.context_uuid.uuid == context_uuid
    assert events[6].service_id.service_uuid.uuid == service_r2_r3_uuid
    assert isinstance(events[7], ServiceEvent)
    assert events[7].event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert events[7].service_id.context_id.context_uuid.uuid == context_uuid
    assert events[7].service_id.service_uuid.uuid == service_r1_r3_uuid

    # ----- Get when the object does not exist -------------------------------------------------------------------------
    connection_id = ConnectionId(**CONNECTION_R1_R3_ID)
@@ -137,10 +131,10 @@ def test_connection(context_client : ContextClient) -> None:
    connection_r1_r3_uuid = response.connection_uuid.uuid

    # ----- Check create event -----------------------------------------------------------------------------------------
    #event = events_collector.get_event(block=True)
    #assert isinstance(event, ConnectionEvent)
    #assert event.event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    #assert event.connection_id.connection_uuid.uuid == connection_r1_r3_uuid
    event = events_collector.get_event(block=True, timeout=GET_EVENTS_TIMEOUT)
    assert isinstance(event, ConnectionEvent)
    assert event.event.event_type == EventTypeEnum.EVENTTYPE_CREATE
    assert event.connection_id.connection_uuid.uuid == connection_r1_r3_uuid

    # ----- Get when the object exists ---------------------------------------------------------------------------------
    response = context_client.GetConnection(ConnectionId(**CONNECTION_R1_R3_ID))
@@ -167,10 +161,10 @@ def test_connection(context_client : ContextClient) -> None:
    assert response.connection_uuid.uuid == connection_r1_r3_uuid

    # ----- Check update event -----------------------------------------------------------------------------------------
    #event = events_collector.get_event(block=True)
    #assert isinstance(event, ConnectionEvent)
    #assert event.event.event_type == EventTypeEnum.EVENTTYPE_UPDATE
    #assert event.connection_id.connection_uuid.uuid == connection_r1_r3_uuid
    event = events_collector.get_event(block=True, timeout=GET_EVENTS_TIMEOUT)
    assert isinstance(event, ConnectionEvent)
    assert event.event.event_type == EventTypeEnum.EVENTTYPE_UPDATE
    assert event.connection_id.connection_uuid.uuid == connection_r1_r3_uuid

    # ----- Get when the object is modified ----------------------------------------------------------------------------
    response = context_client.GetConnection(ConnectionId(**CONNECTION_R1_R3_ID))
@@ -195,10 +189,10 @@ def test_connection(context_client : ContextClient) -> None:
    context_client.RemoveConnection(ConnectionId(**CONNECTION_R1_R3_ID))

    # ----- Check remove event -----------------------------------------------------------------------------------------
    #event = events_collector.get_event(block=True)
    #assert isinstance(event, ConnectionEvent)
    #assert event.event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert event.connection_id.connection_uuid.uuid == connection_r1_r3_uuid
    event = events_collector.get_event(block=True, timeout=GET_EVENTS_TIMEOUT)
    assert isinstance(event, ConnectionEvent)
    assert event.event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert event.connection_id.connection_uuid.uuid == connection_r1_r3_uuid

    # ----- List after deleting the object -----------------------------------------------------------------------------
    response = context_client.ListConnectionIds(ServiceId(**SERVICE_R1_R3_ID))
@@ -217,35 +211,35 @@ def test_connection(context_client : ContextClient) -> None:
    context_client.RemoveTopology(TopologyId(**TOPOLOGY_ID))
    context_client.RemoveContext(ContextId(**CONTEXT_ID))

    #events = events_collector.get_events(block=True, count=8)
    #assert isinstance(events[0], ServiceEvent)
    #assert events[0].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert events[0].service_id.context_id.context_uuid.uuid == context_uuid
    #assert events[0].service_id.service_uuid.uuid == service_r1_r3_uuid
    #assert isinstance(events[1], ServiceEvent)
    #assert events[1].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert events[1].service_id.context_id.context_uuid.uuid == context_uuid
    #assert events[1].service_id.service_uuid.uuid == service_r2_r3_uuid
    #assert isinstance(events[2], ServiceEvent)
    #assert events[2].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert events[2].service_id.context_id.context_uuid.uuid == context_uuid
    #assert events[2].service_id.service_uuid.uuid == service_r1_r2_uuid
    #assert isinstance(events[3], DeviceEvent)
    #assert events[3].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert events[3].device_id.device_uuid.uuid == device_r1_uuid
    #assert isinstance(events[4], DeviceEvent)
    #assert events[4].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert events[4].device_id.device_uuid.uuid == device_r2_uuid
    #assert isinstance(events[5], DeviceEvent)
    #assert events[5].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert events[5].device_id.device_uuid.uuid == device_r3_uuid
    #assert isinstance(events[6], TopologyEvent)
    #assert events[6].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert events[6].topology_id.context_id.context_uuid.uuid == context_uuid
    #assert events[6].topology_id.topology_uuid.uuid == topology_uuid
    #assert isinstance(events[7], ContextEvent)
    #assert events[7].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    #assert events[7].context_id.context_uuid.uuid == context_uuid
    events = events_collector.get_events(block=True, count=8, timeout=GET_EVENTS_TIMEOUT)
    assert isinstance(events[0], ServiceEvent)
    assert events[0].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert events[0].service_id.context_id.context_uuid.uuid == context_uuid
    assert events[0].service_id.service_uuid.uuid == service_r1_r3_uuid
    assert isinstance(events[1], ServiceEvent)
    assert events[1].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert events[1].service_id.context_id.context_uuid.uuid == context_uuid
    assert events[1].service_id.service_uuid.uuid == service_r2_r3_uuid
    assert isinstance(events[2], ServiceEvent)
    assert events[2].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert events[2].service_id.context_id.context_uuid.uuid == context_uuid
    assert events[2].service_id.service_uuid.uuid == service_r1_r2_uuid
    assert isinstance(events[3], DeviceEvent)
    assert events[3].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert events[3].device_id.device_uuid.uuid == device_r1_uuid
    assert isinstance(events[4], DeviceEvent)
    assert events[4].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert events[4].device_id.device_uuid.uuid == device_r2_uuid
    assert isinstance(events[5], DeviceEvent)
    assert events[5].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert events[5].device_id.device_uuid.uuid == device_r3_uuid
    assert isinstance(events[6], TopologyEvent)
    assert events[6].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert events[6].topology_id.context_id.context_uuid.uuid == context_uuid
    assert events[6].topology_id.topology_uuid.uuid == topology_uuid
    assert isinstance(events[7], ContextEvent)
    assert events[7].event.event_type == EventTypeEnum.EVENTTYPE_REMOVE
    assert events[7].context_id.context_uuid.uuid == context_uuid

    # ----- Stop the EventsCollector -----------------------------------------------------------------------------------
    #events_collector.stop()
    events_collector.stop()
+5 −3

File changed.

Preview size limit exceeded, changes collapsed.

Loading