Skip to content

Commit

Permalink
Updated CGW tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SviatoslavBoichuk committed Dec 5, 2024
1 parent 1522b13 commit 8feb522
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 180 deletions.
10 changes: 8 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def default_dev_sim_mac() -> str:
def default_kafka_group() -> str:
return '9999'

@staticmethod
def default_shard_id() -> int:
return 0

def __init__(self):
device = DeviceSimulator(
mac=self.default_dev_sim_mac(),
Expand Down Expand Up @@ -167,8 +171,9 @@ def kafka_default_infra_group(test_context):

uuid_val = random.randint(1, 100)
default_group = test_context.default_kafka_group()
default_shard_id = test_context.default_shard_id()

test_context.kafka_producer.handle_single_group_create(default_group, uuid_val)
test_context.kafka_producer.handle_single_group_create_to_shard(default_group, default_shard_id, uuid_val)
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val)
if not ret_msg:
print('Failed to receive create group result, was expecting ' + str(uuid_val) + ' uuid reply')
Expand Down Expand Up @@ -203,6 +208,7 @@ def kafka_default_infra(test_context):
uuid_val = random.randint(1, 100)
default_group = test_context.default_kafka_group()
default_infra_mac = test_context.default_dev_sim_mac()
default_shard_id = test_context.default_shard_id()

test_context.kafka_producer.handle_single_device_assign(default_group, default_infra_mac, uuid_val)
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val)
Expand All @@ -223,7 +229,7 @@ def kafka_default_infra(test_context):
db_mac = db_mac.replace(":", "-", 5)
assert db_mac == default_infra_mac

infra_info = test_context.redis_client.get_infra(0, default_infra_mac)
infra_info = test_context.redis_client.get_infra(default_shard_id, default_infra_mac)
if not infra_info:
print(f'Failed to get infra {default_infra_mac} from Redis!')
raise Exception('Default infra assign failed!')
Expand Down
3 changes: 0 additions & 3 deletions tests/test_cgw_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import random

from metrics import cgw_metrics_get_connections_num, \
cgw_metrics_get_active_shards_num, \
cgw_metrics_get_groups_assigned_num, \
cgw_metrics_get_group_infras_assigned_num

Expand Down Expand Up @@ -97,7 +96,6 @@ def test_unassigned_infra_base(self, test_context):
infra_is_unassigned = True
continue

assert cgw_metrics_get_active_shards_num() == 1
assert cgw_metrics_get_connections_num() == 1

assert join_message_received,\
Expand Down Expand Up @@ -140,7 +138,6 @@ def test_assigned_infra_base(self, test_context):
infra_is_assigned = True
break

assert cgw_metrics_get_active_shards_num() == 1
assert cgw_metrics_get_groups_assigned_num() == 1
assert cgw_metrics_get_connections_num() == 1
assert cgw_metrics_get_group_infras_assigned_num(int(default_group)) == 1
Expand Down
Loading

0 comments on commit 8feb522

Please sign in to comment.