mirror of
https://github.com/optim-enterprises-bv/openlan-cgw.git
synced 2025-10-29 17:32:21 +00:00
Updated CGW tests
This commit is contained in:
@@ -22,6 +22,10 @@ class TestContext:
|
||||
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(),
|
||||
@@ -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')
|
||||
@@ -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)
|
||||
@@ -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!')
|
||||
|
||||
@@ -3,7 +3,6 @@ import json
|
||||
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
|
||||
|
||||
@@ -97,7 +96,6 @@ class TestCgwBasic:
|
||||
infra_is_unassigned = True
|
||||
continue
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
assert cgw_metrics_get_connections_num() == 1
|
||||
|
||||
assert join_message_received,\
|
||||
@@ -140,7 +138,6 @@ class TestCgwBasic:
|
||||
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
|
||||
|
||||
@@ -2,8 +2,7 @@ import pytest
|
||||
import uuid
|
||||
import random
|
||||
|
||||
from metrics import cgw_metrics_get_active_shards_num, \
|
||||
cgw_metrics_get_groups_assigned_num, \
|
||||
from metrics import cgw_metrics_get_groups_assigned_num, \
|
||||
cgw_metrics_get_groups_capacity, \
|
||||
cgw_metrics_get_groups_threshold
|
||||
|
||||
@@ -20,13 +19,13 @@ class TestCgwInfraGroup:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -35,7 +34,7 @@ class TestCgwInfraGroup:
|
||||
group_id = 100
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -64,10 +63,10 @@ class TestCgwInfraGroup:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
@@ -90,10 +89,10 @@ class TestCgwInfraGroup:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -119,13 +118,13 @@ class TestCgwInfraGroup:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -137,7 +136,7 @@ class TestCgwInfraGroup:
|
||||
group_id = (100 + group)
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -166,10 +165,10 @@ class TestCgwInfraGroup:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == (group + 1)
|
||||
@@ -197,10 +196,10 @@ class TestCgwInfraGroup:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -229,13 +228,13 @@ class TestCgwInfraGroup:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -244,7 +243,7 @@ class TestCgwInfraGroup:
|
||||
group_id = 100
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -273,16 +272,16 @@ class TestCgwInfraGroup:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
|
||||
# Try to create the same group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -296,10 +295,10 @@ class TestCgwInfraGroup:
|
||||
if ret_msg.value['success'] is True:
|
||||
raise Exception('Infra group create completed, while expected to be failed!')
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
@@ -322,10 +321,10 @@ class TestCgwInfraGroup:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -351,13 +350,13 @@ class TestCgwInfraGroup:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -379,10 +378,10 @@ class TestCgwInfraGroup:
|
||||
raise Exception('Infra group delete completed, while expected to be failed!')
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -400,23 +399,22 @@ class TestCgwInfraGroup:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
|
||||
uuid_val = uuid.uuid4()
|
||||
group_id = 100
|
||||
shard_id = 0
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), shard_id, uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -445,10 +443,10 @@ class TestCgwInfraGroup:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
@@ -471,10 +469,10 @@ class TestCgwInfraGroup:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -500,18 +498,17 @@ class TestCgwInfraGroup:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
|
||||
shard_id = 0
|
||||
groups_num = random.randint(1, 10)
|
||||
|
||||
for group in range(0, groups_num):
|
||||
@@ -519,7 +516,7 @@ class TestCgwInfraGroup:
|
||||
group_id = (100 + group)
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), shard_id, uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -548,10 +545,10 @@ class TestCgwInfraGroup:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == (group + 1)
|
||||
@@ -579,10 +576,10 @@ class TestCgwInfraGroup:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -611,13 +608,13 @@ class TestCgwInfraGroup:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -642,10 +639,10 @@ class TestCgwInfraGroup:
|
||||
raise Exception('Infra group create completed, while expected to be failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -671,13 +668,13 @@ class TestCgwInfraGroup:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -692,7 +689,7 @@ class TestCgwInfraGroup:
|
||||
group_id = (100 + group)
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -721,10 +718,10 @@ class TestCgwInfraGroup:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == (group + 1)
|
||||
@@ -735,7 +732,7 @@ class TestCgwInfraGroup:
|
||||
# Try to create additional group to simulate group capacity overflow
|
||||
group_to_fail_id = 2024
|
||||
uuid_val = uuid.uuid4()
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_to_fail_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_to_fail_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -758,10 +755,10 @@ class TestCgwInfraGroup:
|
||||
assert group_info_redis == {}
|
||||
|
||||
# Get shard info
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Double check groups number assigned to CGW
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == groups_num
|
||||
@@ -787,10 +784,10 @@ class TestCgwInfraGroup:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
|
||||
@@ -3,8 +3,7 @@ import uuid
|
||||
import random
|
||||
from randmac import RandMac
|
||||
|
||||
from metrics import cgw_metrics_get_active_shards_num, \
|
||||
cgw_metrics_get_groups_assigned_num, \
|
||||
from metrics import cgw_metrics_get_groups_assigned_num, \
|
||||
cgw_metrics_get_group_infras_assigned_num, \
|
||||
cgw_metrics_get_group_ifras_capacity
|
||||
|
||||
@@ -22,13 +21,13 @@ class TestCgwInfra:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -37,7 +36,7 @@ class TestCgwInfra:
|
||||
group_id = 100
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -66,10 +65,10 @@ class TestCgwInfra:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
@@ -107,7 +106,7 @@ class TestCgwInfra:
|
||||
assert int(group_info_redis.get('infras_assigned')) == cgw_metrics_get_group_infras_assigned_num(group_id) == 1
|
||||
|
||||
# Get infra info from Redis Infra Cache
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if not infra_info_redis:
|
||||
print(f'Failed to get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infra assign failed!')
|
||||
@@ -139,7 +138,7 @@ class TestCgwInfra:
|
||||
assert (ret_msg.value["infra_group_infras"][0] == infra_mac)
|
||||
|
||||
# Validate infra removed from Redis Infra Cache
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
assert infra_info_redis == None
|
||||
|
||||
# Validate infra removed from PSQL
|
||||
@@ -179,10 +178,10 @@ class TestCgwInfra:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -207,13 +206,13 @@ class TestCgwInfra:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -239,10 +238,10 @@ class TestCgwInfra:
|
||||
assert cgw_metrics_get_group_infras_assigned_num(group_id) == 0
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -259,13 +258,13 @@ class TestCgwInfra:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -291,10 +290,10 @@ class TestCgwInfra:
|
||||
assert cgw_metrics_get_group_infras_assigned_num(group_id) == 0
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -312,13 +311,13 @@ class TestCgwInfra:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -327,7 +326,7 @@ class TestCgwInfra:
|
||||
group_id = 100
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -356,10 +355,10 @@ class TestCgwInfra:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
@@ -414,10 +413,10 @@ class TestCgwInfra:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -443,13 +442,13 @@ class TestCgwInfra:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -458,7 +457,7 @@ class TestCgwInfra:
|
||||
group_id = 100
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -487,10 +486,10 @@ class TestCgwInfra:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
@@ -532,7 +531,7 @@ class TestCgwInfra:
|
||||
# Get infras from Redis Infra Cache
|
||||
redis_infras_list = []
|
||||
for infra_mac in infras_mac_list:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if not infra_info_redis:
|
||||
print(f'Failed to get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras assign failed!')
|
||||
@@ -568,7 +567,7 @@ class TestCgwInfra:
|
||||
|
||||
# Get infras from Redis Infra Cache
|
||||
for infra_mac in infras_mac_list:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if infra_info_redis != None:
|
||||
print(f'Unexpectedly get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras deassign failed!')
|
||||
@@ -612,10 +611,10 @@ class TestCgwInfra:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -641,13 +640,13 @@ class TestCgwInfra:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -656,7 +655,7 @@ class TestCgwInfra:
|
||||
group_id = 100
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -685,10 +684,10 @@ class TestCgwInfra:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
@@ -730,7 +729,7 @@ class TestCgwInfra:
|
||||
# Get infras from Redis Infra Cache
|
||||
redis_infras_list = []
|
||||
for infra_mac in infras_mac_list:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if not infra_info_redis:
|
||||
print(f'Failed to get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras assign failed!')
|
||||
@@ -779,7 +778,7 @@ class TestCgwInfra:
|
||||
# Get infras from Redis Infra Cache
|
||||
redis_infras_list = []
|
||||
for infra_mac in infras_mac_list:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if not infra_info_redis:
|
||||
print(f'Failed to get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras assign failed!')
|
||||
@@ -814,7 +813,7 @@ class TestCgwInfra:
|
||||
|
||||
# Get infras from Redis Infra Cache
|
||||
for infra_mac in infras_mac_list:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if infra_info_redis != None:
|
||||
print(f'Unexpectedly get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras deassign failed!')
|
||||
@@ -858,10 +857,10 @@ class TestCgwInfra:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
@@ -893,13 +892,13 @@ class TestCgwInfra:
|
||||
assert test_context.kafka_consumer.is_connected(),\
|
||||
f'Cannot create default group: kafka consumer is not connected to Kafka'
|
||||
|
||||
assert cgw_metrics_get_active_shards_num() == 1
|
||||
default_shard_id = test_context.default_shard_id()
|
||||
|
||||
# Get shard infro from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 0
|
||||
@@ -908,7 +907,7 @@ class TestCgwInfra:
|
||||
group_id = 100
|
||||
|
||||
# Create single group
|
||||
test_context.kafka_producer.handle_single_group_create(str(group_id), uuid_val.int)
|
||||
test_context.kafka_producer.handle_single_group_create_to_shard(str(group_id), default_shard_id, uuid_val.int)
|
||||
ret_msg = test_context.kafka_consumer.get_result_msg(uuid_val.int)
|
||||
if not ret_msg:
|
||||
print('Failed to receive create group result, was expecting ' + str(uuid_val.int) + ' uuid reply')
|
||||
@@ -937,10 +936,10 @@ class TestCgwInfra:
|
||||
# Validate group
|
||||
assert group_info_psql[0] == int(group_info_redis.get('gid')) == group_id
|
||||
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate number of assigned groups
|
||||
assert int(shard_info.get('assigned_groups_num')) == cgw_metrics_get_groups_assigned_num() == 1
|
||||
@@ -977,7 +976,7 @@ class TestCgwInfra:
|
||||
# Get infras from Redis Infra Cache
|
||||
redis_infras_list = []
|
||||
for infra_mac in infras_mac_list:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if not infra_info_redis:
|
||||
print(f'Failed to get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras assign failed!')
|
||||
@@ -1026,7 +1025,7 @@ class TestCgwInfra:
|
||||
infras_expected_to_be_installed = list(set(infras_mac_list + infras_mac_list_new))
|
||||
redis_infras_list = []
|
||||
for infra_mac in infras_expected_to_be_installed:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if not infra_info_redis:
|
||||
print(f'Failed to get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras assign failed!')
|
||||
@@ -1075,7 +1074,7 @@ class TestCgwInfra:
|
||||
infras_expected_to_be_installed = list(set(infras_expected_to_be_installed + infras_mac_list_new))
|
||||
redis_infras_list = []
|
||||
for infra_mac in infras_expected_to_be_installed:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if not infra_info_redis:
|
||||
print(f'Failed to get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras assign failed!')
|
||||
@@ -1124,7 +1123,7 @@ class TestCgwInfra:
|
||||
infras_expected_to_be_installed = list(set(infras_expected_to_be_installed + infras_mac_list_new))
|
||||
redis_infras_list = []
|
||||
for infra_mac in infras_expected_to_be_installed:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if not infra_info_redis:
|
||||
print(f'Failed to get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras assign failed!')
|
||||
@@ -1159,7 +1158,7 @@ class TestCgwInfra:
|
||||
|
||||
# Get infras from Redis Infra Cache
|
||||
for infra_mac in infras_mac_list:
|
||||
infra_info_redis = test_context.redis_client.get_infra(0, infra_mac)
|
||||
infra_info_redis = test_context.redis_client.get_infra(default_shard_id, infra_mac)
|
||||
if infra_info_redis != None:
|
||||
print(f'Unexpectedly get infra {infra_mac} info from Redis!')
|
||||
raise Exception('Infras deassign failed!')
|
||||
@@ -1203,10 +1202,10 @@ class TestCgwInfra:
|
||||
raise Exception('Infra group delete failed!')
|
||||
|
||||
# Get shard info from Redis
|
||||
shard_info = test_context.redis_client.get_shard(0)
|
||||
shard_info = test_context.redis_client.get_shard(default_shard_id)
|
||||
if not shard_info:
|
||||
print(f'Failed to get shard 0 info from Redis!')
|
||||
raise Exception('Failed to get shard 0 info from Redis!')
|
||||
print(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
raise Exception(f'Failed to get shard {default_shard_id} info from Redis!')
|
||||
|
||||
# Validate group removed from Redis
|
||||
group_info_redis = test_context.redis_client.get_infrastructure_group(group_id)
|
||||
|
||||
Reference in New Issue
Block a user