summaryrefslogtreecommitdiffstats
path: root/extra/docker
diff options
context:
space:
mode:
authorac2550 <ac2550@intl.att.com>2018-03-27 14:00:27 +0200
committerac2550 <ac2550@intl.att.com>2018-03-27 14:03:46 +0200
commit69a7eff895f3971e0913eb534ff566dc7d16ca63 (patch)
treec62ef2319af38ee3be083c9c048f566f38178bea /extra/docker
parent792d8025006a1bd9ae46f8e6b4a48dde43418c26 (diff)
Use parameters to configure DMaaP event generator
Change-Id: Ib569c185a982afa61ec68012a238a8c99d591d31 Signed-off-by: ac2550 <ac2550@intl.att.com> Issue-ID: CLAMP-124
Diffstat (limited to 'extra/docker')
-rwxr-xr-xextra/docker/elk/tools/DMaaPServiceMocker/ds_mocker.py48
1 files changed, 35 insertions, 13 deletions
diff --git a/extra/docker/elk/tools/DMaaPServiceMocker/ds_mocker.py b/extra/docker/elk/tools/DMaaPServiceMocker/ds_mocker.py
index 05c1b9861..c1116066e 100755
--- a/extra/docker/elk/tools/DMaaPServiceMocker/ds_mocker.py
+++ b/extra/docker/elk/tools/DMaaPServiceMocker/ds_mocker.py
@@ -194,19 +194,41 @@ class CLStatus(object):
yield Notification.final().success(**config)
raise StopIteration()
-test_datas = [CLStatus(missing=False, disabled=False, op_failure=False) for i in range(45)] \
+def print_usage():
+ print("""
+ ./ds_mocker.py <DMAAP_URL> <EVENT_TOPIC> [NOTIFICATION_TOPIC [REQUEST_TOPIC]]
+ """)
+ exit()
+
+def push(test_datas):
+ for current_i, status in enumerate(test_datas):
+ time.sleep(random.randint(0,6))
+ for s in status:
+ # print(s)
+ status_code = s.publish()
+ if status_code != 200:
+ print("Error when publishing : status_code={}".format(status_code))
+ exit(1)
+ time.sleep(random.randint(0,3))
+ print("%03d,missing:%5s,disabled:%5s,op_failure:%5s - %s" % (current_i, status._missing, status._disabled, status._op_failure, status._config))
+
+
+def generate_dataset_1():
+ test_datas = [CLStatus(missing=False, disabled=False, op_failure=False) for i in range(45)] \
+ [CLStatus(missing=True, disabled=False, op_failure=False) for i in range(5)] \
+ [CLStatus(missing=False, disabled=True, op_failure=False) for i in range(6)] \
+ [CLStatus(missing=False, disabled=False, op_failure=True) for i in range(7)]
-random.shuffle(test_datas)
-random.shuffle(test_datas)
-
-for current_i, status in enumerate(test_datas):
- time.sleep(random.randint(0,6))
- for s in status:
- status_code = s.publish()
- if status_code != 200:
- print("Error when publishing : status_code={}".format(status_code))
- exit(1)
- time.sleep(random.randint(0,3))
- print("%03d,missing:%5s,disabled:%5s,op_failure:%5s - %s" % (current_i, status._missing, status._disabled, status._op_failure, status._config))
+ random.shuffle(test_datas)
+ return test_datas
+
+
+if __name__ == "__main__":
+ import sys
+ if len(sys.argv) < 3:
+ print_usage()
+
+ DMaaPMessage.dmaap_host_url = sys.argv[1]
+ Event.topic = sys.argv[2]
+ Notification.topic = len(sys.argv) > 3 and sys.argv[3] or sys.argv[2]
+ # Request.topic = len(sys.argv) > 4 or Notification.topic
+ push(generate_dataset_1())