Skip to content
Snippets Groups Projects
Commit 3aaf8cc1 authored by Waleed Akbar's avatar Waleed Akbar
Browse files

cleanup for merge

parent 544cdc34
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!207Resolve "(CTTC) Separation of Monitoring"
......@@ -36,9 +36,6 @@ class KafkaTopic(Enum):
"""
Method to create Kafka topics defined as class members
"""
# LOGGER.debug("Topics to be created: {:}".format(KafkaTopic.__members__.values()))
# LOGGER.debug("Topics to be created: {:}".format(KafkaTopic.__members__.keys()))
# LOGGER.debug("Topics to be created: {:}".format([member.value for member in KafkaTopic]))
all_topics = [member.value for member in KafkaTopic]
if( KafkaTopic.create_new_topic_if_not_exists( all_topics )):
LOGGER.debug("All topics created sucsessfully")
......@@ -54,16 +51,20 @@ class KafkaTopic(Enum):
Args:
list of topic: containing the topic name(s) to be created on Kafka
"""
LOGGER.debug("Recevied topic List: {:}".format(new_topics))
LOGGER.debug("Topics names to be verified and created: {:}".format(new_topics))
for topic in new_topics:
try:
topic_metadata = KafkaConfig.ADMIN_CLIENT.value.list_topics(timeout=5)
# LOGGER.debug("Existing topic list: {:}".format(topic_metadata.topics))
if topic not in topic_metadata.topics:
# If the topic does not exist, create a new topic
print(f"Topic '{topic}' does not exist. Creating...")
print("Topic {:} does not exist. Creating...".format(topic))
LOGGER.debug("Topic {:} does not exist. Creating...".format(topic))
new_topic = NewTopic(topic, num_partitions=1, replication_factor=1)
KafkaConfig.ADMIN_CLIENT.value.create_topics([new_topic])
else:
print("Topic name already exists: {:}".format(topic))
LOGGER.debug("Topic name already exists: {:}".format(topic))
except Exception as e:
LOGGER.debug("Failed to create topic: {:}".format(e))
return False
......
confluent-kafka==2.3.0
requests==2.27.1
\ No newline at end of file
......@@ -105,19 +105,16 @@ class KpiValueApiServiceServicerImpl(KpiValueAPIServiceServicer):
return KpiValueType(int64Val=int64_value)
except ValueError:
pass
# Check if the value is a float
try:
float_value = float(value)
return KpiValueType(floatVal=float_value)
except ValueError:
pass
# Check if the value is a boolean
if value.lower() in ['true', 'false']:
bool_value = value.lower() == 'true'
return KpiValueType(boolVal=bool_value)
# If none of the above, treat it as a string
return KpiValueType(stringVal=value)
......
......@@ -90,3 +90,4 @@ def test_store_kpi_values(kpi_value_api_client):
LOGGER.debug(" >>> test_set_list_of_KPIs: START <<< ")
response = kpi_value_api_client.StoreKpiValues(create_kpi_value_list())
assert isinstance(response, Empty)
confluent-kafka==2.3.0
requests==2.27.1
\ No newline at end of file
......@@ -22,31 +22,31 @@ from kpi_value_writer.tests.test_messages import create_kpi_id_request
LOGGER = logging.getLogger(__name__)
def test_GetKpiDescriptor():
LOGGER.info(" >>> test_GetKpiDescriptor: START <<< ")
kpi_manager_client = KpiManagerClient()
# adding KPI
LOGGER.info(" --->>> calling SetKpiDescriptor ")
response_id = kpi_manager_client.SetKpiDescriptor(create_kpi_descriptor_request())
# get KPI
LOGGER.info(" --->>> calling GetKpiDescriptor with response ID")
response = kpi_manager_client.GetKpiDescriptor(response_id)
LOGGER.info("Response gRPC message object: {:}".format(response))
# def test_GetKpiDescriptor():
# LOGGER.info(" >>> test_GetKpiDescriptor: START <<< ")
# kpi_manager_client = KpiManagerClient()
# # adding KPI
# LOGGER.info(" --->>> calling SetKpiDescriptor ")
# response_id = kpi_manager_client.SetKpiDescriptor(create_kpi_descriptor_request())
# # get KPI
# LOGGER.info(" --->>> calling GetKpiDescriptor with response ID")
# response = kpi_manager_client.GetKpiDescriptor(response_id)
# LOGGER.info("Response gRPC message object: {:}".format(response))
LOGGER.info(" --->>> calling GetKpiDescriptor with random ID")
rand_response = kpi_manager_client.GetKpiDescriptor(create_kpi_id_request())
LOGGER.info("Response gRPC message object: {:}".format(rand_response))
# LOGGER.info(" --->>> calling GetKpiDescriptor with random ID")
# rand_response = kpi_manager_client.GetKpiDescriptor(create_kpi_id_request())
# LOGGER.info("Response gRPC message object: {:}".format(rand_response))
LOGGER.info("\n------------------ TEST FINISHED ---------------------\n")
assert isinstance(response, KpiDescriptor)
# LOGGER.info("\n------------------ TEST FINISHED ---------------------\n")
# assert isinstance(response, KpiDescriptor)
# -------- Initial Test ----------------
# def test_validate_kafka_topics():
# LOGGER.debug(" >>> test_validate_kafka_topics: START <<< ")
# response = KafkaTopic.create_all_topics()
# assert isinstance(response, bool)
def test_validate_kafka_topics():
LOGGER.debug(" >>> test_validate_kafka_topics: START <<< ")
response = KafkaTopic.create_all_topics()
assert isinstance(response, bool)
# def test_KafkaConsumer():
# LOGGER.debug(" --->>> test_kafka_consumer: START <<<--- ")
# KpiValueWriter.RunKafkaConsumer()
def test_KafkaConsumer():
LOGGER.debug(" --->>> test_kafka_consumer: START <<<--- ")
KpiValueWriter.RunKafkaConsumer()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment