A production version of the image should have the assert statements as a no-op, and should instead return an error code, instead of asserting and crashing the system.
SMO-47
Signed-off-by: santanude <santanu.de@xoriant.com>
Change-Id: Ia79d1cdf3e0adee756446d1c20a37ee8e2e0260d
Signed-off-by: santanude <santanu.de@xoriant.com>
cat $config_file
if [ "$loglevel" != "" ]; then
- python3 /opt/smo/evel-test-collector/code/collector/monitor.py \
- --config /opt/smo/evel-test-collector/config/collector.conf \
- --section default > /opt/smo/monitor.log 2>&1
+ if [ "$enable_assert" != "True" ]; then
+ python3 -O /opt/smo/evel-test-collector/code/collector/monitor.py \
+ --config /opt/smo/evel-test-collector/config/collector.conf \
+ --section default > /opt/smo/monitor.log 2>&1
+ else
+ python3 /opt/smo/evel-test-collector/code/collector/monitor.py \
+ --config /opt/smo/evel-test-collector/config/collector.conf \
+ --section default > /opt/smo/monitor.log 2>&1
+ fi
else
- python3 /opt/smo/evel-test-collector/code/collector/monitor.py \
- --config /opt/smo/evel-test-collector/config/collector.conf \
- --section default
+ if [ "$enable_assert" != "True" ]; then
+ python3 -O /opt/smo/evel-test-collector/code/collector/monitor.py \
+ --config /opt/smo/evel-test-collector/config/collector.conf \
+ --section default
+ else
+ python3 /opt/smo/evel-test-collector/code/collector/monitor.py \
+ --config /opt/smo/evel-test-collector/config/collector.conf \
+ --section default
+ fi
fi
class AppConfig:
kafka_broker = ""
logger = logging.getLogger()
+ enable_assert = ""
def __init__(self):
parser = ArgumentParser(description="",
config.read(config_file)
self.kafka_broker = config.get(config_section, 'kafka_broker', vars=overrides)
+ self.enable_assert = config.get(config_section, 'enable_assert', vars=overrides)
log_file = config.get(config_section, 'log_file', vars=overrides)
log_level = config.get(config_section, 'log_level', vars=overrides)
def getKafkaBroker(self):
return self.kafka_broker
+ def getAssertConfigValue(self):
+ return self.enable_assert
+
def getLogger(self):
return self.logger
from flask import request
from consumer import EventConsumer, TopicConsumer
from prepare_response import PrepareResponse
+from app_config import AppConfig
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route(api_base_url + '/topics/<topic>', methods=['GET'])
def topic_details(topic):
- assert topic == request.view_args['topic']
+ topic == request.view_args['topic']
prepareResponse = PrepareResponse()
topicConsumer = TopicConsumer()
topicConsumer.getTopicDetails(prepareResponse, topic)
@app.route(api_base_url + '/events/<topic>/<consumergroup>/<consumerid>', methods=['GET'])
def get_events(topic, consumergroup, consumerid):
- assert topic == request.view_args['topic']
- assert consumergroup == request.view_args['consumergroup']
- assert consumerid == request.view_args['consumerid']
+ topic == request.view_args['topic']
+ consumergroup == request.view_args['consumergroup']
+ consumerid == request.view_args['consumerid']
limit = ""
timeout = ""
if __name__ == '__main__':
- app.run(debug=True, host='0.0.0.0')
+ appConfig = AppConfig()
+
+ if(appConfig.getAssertConfigValue() == 'False'):
+ app.run(debug=False, host='0.0.0.0')
+ else:
+ app.run(debug=True, host='0.0.0.0')
log_file = dmaap.log
log_level =
kafka_broker =
-
+enable_assert =
$config_file
sed -i -- "s/log_level =/log_level = $log_level/g" \
$config_file
+sed -i -- "s/enable_assert =/enable_assert = $enable_assert/g" \
+ $config_file
echo; echo $config_file
if [ "$log_level" != "" ]; then
- python3 /opt/smo/adapter/code/dmaap_adapter.py \
- --config /opt/smo/adapter/config/adapter.conf \
- --section default > /opt/smo/dmaap.log 2>&1
+ if [ "$enable_assert" != "True" ]; then
+ python3 -O /opt/smo/adapter/code/dmaap_adapter.py \
+ --config /opt/smo/adapter/config/adapter.conf \
+ --section default > /opt/smo/dmaap.log 2>&1
+ else
+ python3 /opt/smo/adapter/code/dmaap_adapter.py \
+ --config /opt/smo/adapter/config/adapter.conf \
+ --section default > /opt/smo/dmaap.log 2>&1
+ fi
else
- python3 /opt/smo/adapter/code/dmaap_adapter.py \
- --config /opt/smo/adapter/config/adapter.conf \
- --section default
+ if [ "$enable_assert" != "True" ]; then
+ python3 -O /opt/smo/adapter/code/dmaap_adapter.py \
+ --config /opt/smo/adapter/config/adapter.conf \
+ --section default
+ else
+ python3 /opt/smo/adapter/code/dmaap_adapter.py \
+ --config /opt/smo/adapter/config/adapter.conf \
+ --section default
+ fi
fi
kafka_host: "smo-kafka"
kafka_port: "29092"
log_level: "DEBUG"
+ enable_assert: "False"
smo-collector:
container_name: smo-collector
build: ./collector
collector_pass: "password"
collector_path: ""
loglevel: "ERROR"
+ enable_assert: "False"
depends_on:
- smo-kafka
smo-influxdb-connector:
smo_kafka_host: "smo-kafka"
smo_kafka_port: "29092"
loglevel: "ERROR"
+ enable_assert: "False"
depends_on:
- smo-kafka
- smo-influxdb
--data-urlencode "q=CREATE DATABASE eventsdb"
if [ "$loglevel" != "" ]; then
- python3 /opt/smo/influxdb-connector/code/influxdb_connector.py \
- --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
- --influxdb $smo_influxdb_host:$smo_influxdb_port \
- --section default > /opt/smo/monitor.log 2>&1
+ if [ "$enable_assert" != "True" ]; then
+ python3 -O /opt/smo/influxdb-connector/code/influxdb_connector.py \
+ --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
+ --influxdb $smo_influxdb_host:$smo_influxdb_port \
+ --section default > /opt/smo/monitor.log 2>&1
+ else
+ python3 /opt/smo/influxdb-connector/code/influxdb_connector.py \
+ --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
+ --influxdb $smo_influxdb_host:$smo_influxdb_port \
+ --section default > /opt/smo/monitor.log 2>&1
+ fi
else
- python3 /opt/smo/influxdb-connector/code/influxdb_connector.py \
- --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
- --influxdb $smo_influxdb_host:$smo_influxdb_port \
- --section default
+ if [ "$enable_assert" != "True" ]; then
+ python3 -O /opt/smo/influxdb-connector/code/influxdb_connector.py \
+ --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
+ --influxdb $smo_influxdb_host:$smo_influxdb_port \
+ --section default
+ else
+ python3 /opt/smo/influxdb-connector/code/influxdb_connector.py \
+ --config /opt/smo/influxdb-connector/config/influxdb_connector.conf \
+ --influxdb $smo_influxdb_host:$smo_influxdb_port \
+ --section default
+ fi
fi