summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQiLiang <liangqi1@huawei.com>2015-12-30 14:58:53 +0000
committerQiLiang <liangqi1@huawei.com>2016-01-07 06:23:51 +0000
commit65e32e513544392ce84c190434d23281b5c1afd2 (patch)
tree06db325e85da8aaee7e064a08e53a54df8d9310a
parent99ba990d4a01c0f3f4837f11a24b695f4a2393d2 (diff)
InfluxDB dispatcher add more tags
- add runner_id tag - add test case name tag - add task_id tag JIRA: YARDSTICK-212 Change-Id: I75c27e23942a6e2189019e94bfe8026a5fd67621 Signed-off-by: QiLiang <liangqi1@huawei.com> Conflicts: yardstick/dispatcher/influxdb.py
-rw-r--r--tests/unit/dispatcher/test_influxdb.py4
-rwxr-xr-xyardstick/cmd/commands/task.py14
-rw-r--r--yardstick/dispatcher/influxdb.py14
3 files changed, 29 insertions, 3 deletions
diff --git a/tests/unit/dispatcher/test_influxdb.py b/tests/unit/dispatcher/test_influxdb.py
index 3989f5889..5553c86a9 100644
--- a/tests/unit/dispatcher/test_influxdb.py
+++ b/tests/unit/dispatcher/test_influxdb.py
@@ -47,7 +47,9 @@ class InfluxdbDispatcherTestCase(unittest.TestCase):
"sla": {
"action": "monitor",
"max_rtt": 10
- }
+ },
+ "tc": "ping",
+ "task_id": "ea958583-c91e-461a-af14-2a7f9d7f79e7"
}
}
self.data2 = {
diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py
index fbbca29ad..17e8f4c42 100755
--- a/yardstick/cmd/commands/task.py
+++ b/yardstick/cmd/commands/task.py
@@ -16,7 +16,9 @@ import atexit
import ipaddress
import time
import logging
+import uuid
from itertools import ifilter
+
from yardstick.benchmark.contexts.base import Context
from yardstick.benchmark.runners import base as base_runner
from yardstick.common.task_template import TaskTemplate
@@ -81,7 +83,9 @@ class TaskCommands(object):
for i in range(0, len(task_files)):
one_task_start_time = time.time()
parser.path = task_files[i]
- scenarios, run_in_parallel = parser.parse_task(task_args[i],
+ task_name = os.path.splitext(os.path.basename(task_files[i]))[0]
+ scenarios, run_in_parallel = parser.parse_task(task_name,
+ task_args[i],
task_args_fnames[i])
self._run(scenarios, run_in_parallel, args.output_file)
@@ -199,7 +203,7 @@ class TaskParser(object):
return suite_params
- def parse_task(self, task_args=None, task_args_file=None):
+ def parse_task(self, task_name, task_args=None, task_args_file=None):
'''parses the task file and return an context and scenario instances'''
print "Parsing task config:", self.path
@@ -250,6 +254,12 @@ class TaskParser(object):
run_in_parallel = cfg.get("run_in_parallel", False)
+ # add tc and task id for influxdb extended tags
+ task_id = str(uuid.uuid4())
+ for scenario in cfg["scenarios"]:
+ scenario["tc"] = task_name
+ scenario["task_id"] = task_id
+
# TODO we need something better here, a class that represent the file
return cfg["scenarios"], run_in_parallel
diff --git a/yardstick/dispatcher/influxdb.py b/yardstick/dispatcher/influxdb.py
index c58054167..2f3ff089f 100644
--- a/yardstick/dispatcher/influxdb.py
+++ b/yardstick/dispatcher/influxdb.py
@@ -53,6 +53,8 @@ class InfluxdbDispatcher(DispatchBase):
self.influxdb_url = "%s/write?db=%s" % (self.target, self.db_name)
self.raw_result = []
self.case_name = ""
+ self.tc = ""
+ self.task_id = -1
self.static_tags = {
"pod_name": os.environ.get('POD_NAME', 'unknown'),
"installer": os.environ.get('INSTALLER_TYPE', 'unknown'),
@@ -86,12 +88,22 @@ class InfluxdbDispatcher(DispatchBase):
return str(int(float(timestamp) * 1000000000))
+ def _get_extended_tags(self, data):
+ tags = {
+ "runner_id": data["runner_id"],
+ "tc": self.tc,
+ "task_id": self.task_id
+ }
+
+ return tags
+
def _data_to_line_protocol(self, data):
msg = {}
point = {}
point["measurement"] = self.case_name
point["fields"] = self._dict_key_flatten(data["benchmark"]["data"])
point["time"] = self._get_nano_timestamp(data)
+ point["tags"] = self._get_extended_tags(data)
msg["points"] = [point]
msg["tags"] = self.static_tags
@@ -108,6 +120,8 @@ class InfluxdbDispatcher(DispatchBase):
if isinstance(data, dict) and "scenario_cfg" in data:
self.case_name = data["scenario_cfg"]["type"]
+ self.tc = data["scenario_cfg"]["tc"]
+ self.task_id = data["scenario_cfg"]["task_id"]
return 0
if self.case_name == "":