From ef219637949b8da168a7b4f6d2ccf850233252b1 Mon Sep 17 00:00:00 2001
From: Stephen C Phillips <steve@scphillips.com>
Date: Fri, 25 May 2018 13:05:05 +0100
Subject: [PATCH] Adds bandwidth to each path

---
 clmctest/monitoring/E2ESim.py                | 14 +++++++++-----
 clmctest/monitoring/LineProtocolGenerator.py |  6 ++++--
 clmctest/monitoring/test_e2eresults.py       |  2 +-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/clmctest/monitoring/E2ESim.py b/clmctest/monitoring/E2ESim.py
index 1a62443..a6520d2 100644
--- a/clmctest/monitoring/E2ESim.py
+++ b/clmctest/monitoring/E2ESim.py
@@ -78,25 +78,29 @@ class Simulator(object):
                 'target': 'SR2',
                 'source': 'SR1',
                 'path_id': 'SR1---SR2',
-                'latency': 5
+                'latency': 5,
+                'bandwidth': 100*1024*1024
             },
             {
                 'target': 'SR1',
                 'source': 'SR2',
                 'path_id': 'SR1---SR2',
-                'latency': 5
+                'latency': 5,
+                'bandwidth': 100*1024*1024
             },
             {
                 'target': 'SR3',
                 'source': 'SR1',
                 'path_id': 'SR1---SR3',
-                'latency': 15
+                'latency': 5,
+                'bandwidth': 100*1024*1024
             },
             {
                 'target': 'SR1',
                 'source': 'SR3',
                 'path_id': 'SR1---SR3',
-                'latency': 15
+                'latency': 5,
+                'bandwidth': 100*1024*1024
             }
         ]
 
@@ -133,7 +137,7 @@ class Simulator(object):
             if i % sample_period_net == 0:
                 path = random.choice(paths)
                 self.db_client.write_points(
-                    lp.generate_network_delay_report(path['path_id'], path['source'], path['target'], path['latency'], sim_time))
+                    lp.generate_network_delay_report(path['path_id'], path['source'], path['target'], path['latency'], path['bandwidth'], sim_time))
 
                 # increase/decrease the delay in every sample report (min delay is 1)
                 path['latency'] = max(1, path['latency'] + random.randint(-3, 3))
diff --git a/clmctest/monitoring/LineProtocolGenerator.py b/clmctest/monitoring/LineProtocolGenerator.py
index 30e37a4..2d2b7a0 100644
--- a/clmctest/monitoring/LineProtocolGenerator.py
+++ b/clmctest/monitoring/LineProtocolGenerator.py
@@ -64,7 +64,7 @@ def generate_e2e_delay_report(path_id, source_sfr, target_sfr, endpoint, sf_inst
     return result
 
 
-def generate_network_delay_report(path_id, source_sfr, target_sfr, latency, time):
+def generate_network_delay_report(path_id, source_sfr, target_sfr, latency, bandwidth, time):
     """
     Generates a platform measurement about the network delay between two specific service routers.
 
@@ -72,6 +72,7 @@ def generate_network_delay_report(path_id, source_sfr, target_sfr, latency, time
     :param source_sfr: the source service router
     :param target_sfr: the target service router
     :param latency: the e2e network delay for traversing the path between the two service routers
+    :param bandwidth: the bandwidth of the path (minimum of bandwidths of the links it is composed of)
     :param time: the measurement timestamp
     :return: a list of dict-formatted reports to post on influx
     """
@@ -83,7 +84,8 @@ def generate_network_delay_report(path_id, source_sfr, target_sfr, latency, time
                    "target": target_sfr
                },
                "fields": {
-                   "latency": latency
+                   "latency": latency,
+                   "bandwidth": bandwidth
                },
                "time": _getNSTime(time)
                }]
diff --git a/clmctest/monitoring/test_e2eresults.py b/clmctest/monitoring/test_e2eresults.py
index ab4fd13..2f469b7 100644
--- a/clmctest/monitoring/test_e2eresults.py
+++ b/clmctest/monitoring/test_e2eresults.py
@@ -59,7 +59,7 @@ class TestE2ESimulation(object):
 
     @pytest.mark.parametrize("query, expected_result", [
         ('SELECT count(*) FROM "E2EMetrics"."autogen"."network_delays"',
-         {"time": "1970-01-01T00:00:00Z", "count_latency": 120}),
+         {"time": "1970-01-01T00:00:00Z", "count_latency": 120, "count_bandwidth": 120}),
         ('SELECT count(*) FROM "E2EMetrics"."autogen"."service_delays"',
          {"time": "1970-01-01T00:00:00Z", "count_response_time": 24, "count_request_size": 24, "count_response_size": 24}),
         ('SELECT count(*) FROM "E2EMetrics"."autogen"."e2e_delays"',
-- 
GitLab