X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcmd%2Fmon_utils.py;h=9640543cf85cd658e65e5ef95a0c1ed3f6c8021e;hb=refs%2Ftags%2Fbranch-bug1511-start;hp=5b62d6c95c7ea9784899a9556e9186fcbfaa83ef;hpb=321ca740b8b2aacb30315b081efd49cabd3f5751;p=osm%2FMON.git diff --git a/osm_mon/cmd/mon_utils.py b/osm_mon/cmd/mon_utils.py index 5b62d6c..9640543 100644 --- a/osm_mon/cmd/mon_utils.py +++ b/osm_mon/cmd/mon_utils.py @@ -59,8 +59,18 @@ def wait_till_kafka_is_ready(config, process_name="osm-mon", kafka_wait_time=5): bootstrap_servers=[config.conf.get("message", {}).get("host", "kafka") + ":" + config.conf["message"] .get("port")]) - topics = consumer.topics() - logging.debug("Number of topics found: %s", len(topics)) + all_topics = consumer.topics() + logging.debug("Number of topics found: %s", len(all_topics)) + + # Send dummy message in kafka topics. If kafka is not ready exception will be thrown. + producer = kafka.KafkaProducer(bootstrap_servers=[config.conf.get("message", {}).get("host", + "kafka") + ":" + config.conf["message"] + .get("port")]) + mon_topics = ["alarm_request", "users", "project"] + for mon_topic in mon_topics: + producer.send(mon_topic, key=b"echo", value=b"dummy message") + + # Kafka is ready now kafka_ready = True except Exception as e: logging.info("Error when trying to get kafka status.")