From ab74cd2a16f55e71455e21164334a0825ceba448 Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Wed, 23 Oct 2024 12:15:03 +0000 Subject: [PATCH] Fixed CI/CD pipeline: - Proto and Assertions for NBI tests - PolicyClient for Automation component --- proto/context.proto | 6 ++---- src/automation/client/PolicyClient.py | 3 +-- src/common/type_checkers/Assertions.py | 6 +++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/proto/context.proto b/proto/context.proto index eb87dccf3..bb769a5a2 100644 --- a/proto/context.proto +++ b/proto/context.proto @@ -154,8 +154,7 @@ message Topology { string name = 2; repeated DeviceId device_ids = 3; repeated LinkId link_ids = 4; - - repeated LinkId optical_link_ids=5; + repeated LinkId optical_link_ids = 5; } message TopologyDetails { @@ -163,8 +162,7 @@ message TopologyDetails { string name = 2; repeated Device devices = 3; repeated Link links = 4; - - repeated OpticalLink optical_links =5 ; + repeated OpticalLink optical_links = 5; } message TopologyIdList { diff --git a/src/automation/client/PolicyClient.py b/src/automation/client/PolicyClient.py index f2b25f242..f7b6412a6 100644 --- a/src/automation/client/PolicyClient.py +++ b/src/automation/client/PolicyClient.py @@ -19,7 +19,7 @@ from common.proto.policy_pb2 import PolicyRuleService, PolicyRuleState from common.proto.policy_pb2_grpc import PolicyServiceStub from common.tools.client.RetryDecorator import retry, delay_exponential from common.tools.grpc.Tools import grpc_message_to_json_string -from common.proto.openconfig_device_pb2_grpc import OpenConfigServiceStub + LOGGER = logging.getLogger(__name__) MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) @@ -40,7 +40,6 @@ class PolicyClient: def connect(self): self.channel = grpc.insecure_channel(self.endpoint) self.stub = PolicyServiceStub(self.channel) - self.openconfig_stub=OpenConfigServiceStub(self.channel) def close(self): if self.channel is not None: self.channel.close() diff --git a/src/common/type_checkers/Assertions.py b/src/common/type_checkers/Assertions.py index 3934c9d89..01100eb68 100644 --- a/src/common/type_checkers/Assertions.py +++ b/src/common/type_checkers/Assertions.py @@ -451,7 +451,7 @@ def validate_slice(message): def validate_topology(message, num_devices=None, num_links=None): assert isinstance(message, dict) - assert len(message.keys()) == 4 + assert len(message.keys()) == 5 assert 'topology_id' in message validate_topology_id(message['topology_id']) assert 'name' in message @@ -464,6 +464,10 @@ def validate_topology(message, num_devices=None, num_links=None): assert isinstance(message['link_ids'], list) if num_links is not None: assert len(message['link_ids']) == num_links for link_id in message['link_ids']: validate_link_id(link_id) + assert 'optical_link_ids' in message + assert isinstance(message['optical_link_ids'], list) + if num_links is not None: assert len(message['optical_link_ids']) == num_links + for link_id in message['optical_link_ids']: validate_link_id(link_id) def validate_endpoint(message): assert isinstance(message, dict) -- GitLab