From c334ae7f2232021c44b3db8b4052b0172eb0ca69 Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Tue, 6 Dec 2016 10:02:09 -0800 Subject: [PATCH] Fix Fake Health API - Add region samples - Add missing data --- ceagle/api_fake_data/fake_status.py | 13 ++++-- raml/api.raml | 2 +- raml/response_examples/200/status_health.json | 13 ++++-- .../200/status_region_health.json | 40 +++++++++++++++++++ 4 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 raml/response_examples/200/status_region_health.json diff --git a/ceagle/api_fake_data/fake_status.py b/ceagle/api_fake_data/fake_status.py index cae1ab6..2db9f9b 100644 --- a/ceagle/api_fake_data/fake_status.py +++ b/ceagle/api_fake_data/fake_status.py @@ -60,7 +60,7 @@ def generate_timestamps(period): def generate_values(period_or_timestamps, - ratio=1, null_result_probability=20): + ratio=1, null_result_probability=20, integer=False): if type(period_or_timestamps) == list: timestamps = period_or_timestamps else: @@ -72,7 +72,10 @@ def generate_values(period_or_timestamps, if random.randint(1, 100) <= null_result_probability: data.append([ts, None]) else: - value = base.randnum(.7, 1) * ratio + if not integer: + value = base.randnum(.7, 1) * ratio + else: + value = random.randint(1, 1000) data.append([ts, value]) data_avg.append(value) avg = round(sum(data_avg) / len(data_avg), 3) @@ -83,7 +86,8 @@ def generate_service_data(period, service): if service == "health": fci_data = generate_values(period)[0] time_data = generate_values(period)[0] - size_data = generate_values(period, 50)[0] + size_data = generate_values(period, 50, integer=True)[0] + count_data = generate_values(period, 50, integer=True)[0] return { "fci": random.randint(0, 100) * 0.01, "response_time": base.randnum(.1, 2.5), @@ -91,7 +95,8 @@ def generate_service_data(period, service): "api_calls_count": random.randint(200, 500), "fci_data": fci_data, "response_time_data": time_data, - "repsonse_size_data": size_data + "repsonse_size_data": size_data, + "api_calls_count_data": count_data } elif service == "performance": diff --git a/raml/api.raml b/raml/api.raml index f85bae7..d0d999c 100644 --- a/raml/api.raml +++ b/raml/api.raml @@ -70,7 +70,7 @@ mediaType: application/json body: application/json: schema: schemas/200.json - example: !include response_examples/200/status_health.json + example: !include response_examples/200/status_region_health.json 404: body: application/json: diff --git a/raml/response_examples/200/status_health.json b/raml/response_examples/200/status_health.json index 1d2bf7a..2a49665 100644 --- a/raml/response_examples/200/status_health.json +++ b/raml/response_examples/200/status_health.json @@ -12,21 +12,28 @@ ["2016-09-16T01:00", 0.7], ["2016-09-16T02:00", 1.0], ["2016-09-16T03:00", 0.95], - ["2016-09-16T04:00", 1.0], + ["2016-09-16T04:00", 1.0] ], "response_time_data": [ ["2016-09-16T01:00", 0.9], ["2016-09-16T02:00", 0.8], ["2016-09-16T03:00", 1.0], ["2016-09-16T04:00", 0.95], - ["2016-09-16T05:00", 1.0], + ["2016-09-16T05:00", 1.0] ], "repsonse_size_data": [ ["2016-09-16T01:00", 100], ["2016-09-16T02:00", 250], ["2016-09-16T03:00", 300], ["2016-09-16T04:00", 400], - ["2016-09-16T05:00", 500], + ["2016-09-16T05:00", 500] + ], + "api_calls_count_data": [ + ["2016-09-16T01:00", 100], + ["2016-09-16T02:00", 250], + ["2016-09-16T03:00", 300], + ["2016-09-16T04:00", 400], + ["2016-09-16T05:00", 500] ] } } diff --git a/raml/response_examples/200/status_region_health.json b/raml/response_examples/200/status_region_health.json new file mode 100644 index 0000000..8639288 --- /dev/null +++ b/raml/response_examples/200/status_region_health.json @@ -0,0 +1,40 @@ +{ + "period": "week", + + "health": { + "keystone": { + "fci": 0.9, + "response_time": 100.43, + "response_size": 234343, + "api_calls_count": 5, + "fci_data": [ + ["2016-09-16T01:00", 0.9], + ["2016-09-16T01:00", 0.7], + ["2016-09-16T02:00", 1.0], + ["2016-09-16T03:00", 0.95], + ["2016-09-16T04:00", 1.0] + ], + "response_time_data": [ + ["2016-09-16T01:00", 0.9], + ["2016-09-16T02:00", 0.8], + ["2016-09-16T03:00", 1.0], + ["2016-09-16T04:00", 0.95], + ["2016-09-16T05:00", 1.0] + ], + "repsonse_size_data": [ + ["2016-09-16T01:00", 100], + ["2016-09-16T02:00", 250], + ["2016-09-16T03:00", 300], + ["2016-09-16T04:00", 400], + ["2016-09-16T05:00", 500] + ], + "api_calls_count_data": [ + ["2016-09-16T01:00", 100], + ["2016-09-16T02:00", 250], + ["2016-09-16T03:00", 300], + ["2016-09-16T04:00", 400], + ["2016-09-16T05:00", 500] + ] + } + } +}