summaryrefslogtreecommitdiffstats
path: root/tests/unit/dispatcher/test_influxdb_line_protocol.py
diff options
context:
space:
mode:
authorQiLiang <liangqi1@huawei.com>2015-12-23 22:13:15 +0800
committerqi liang <liangqi1@huawei.com>2016-01-07 03:53:37 +0000
commit99ba990d4a01c0f3f4837f11a24b695f4a2393d2 (patch)
tree68bfa1b7c80080a294f61a3b2bddbbbdfe96957f /tests/unit/dispatcher/test_influxdb_line_protocol.py
parentffdd523055d2395d1216c5fa0007ed6af0b6146e (diff)
Initial InfluxDB dispatcher
Supports: - Basic influxDB write with timestamp - Add general result format func - Add UT TODO: - refine database schema (e.g. add more tags) plan in another patch JIRA: YARDSTICK-212 Change-Id: I1526568bbd850f1343135420ec59ed1b833bb99f Signed-off-by: QiLiang <liangqi1@huawei.com>
Diffstat (limited to 'tests/unit/dispatcher/test_influxdb_line_protocol.py')
-rw-r--r--tests/unit/dispatcher/test_influxdb_line_protocol.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/unit/dispatcher/test_influxdb_line_protocol.py b/tests/unit/dispatcher/test_influxdb_line_protocol.py
new file mode 100644
index 000000000..cb05bf4d2
--- /dev/null
+++ b/tests/unit/dispatcher/test_influxdb_line_protocol.py
@@ -0,0 +1,55 @@
+# Unittest for yardstick.dispatcher.influxdb_line_protocol
+
+# yardstick comment: this file is a modified copy of
+# influxdb-python/influxdb/tests/test_line_protocol.py
+
+import unittest
+from yardstick.dispatcher.influxdb_line_protocol import make_lines
+
+
+class TestLineProtocol(unittest.TestCase):
+
+ def test_make_lines(self):
+ data = {
+ "tags": {
+ "empty_tag": "",
+ "none_tag": None,
+ "integer_tag": 2,
+ "string_tag": "hello"
+ },
+ "points": [
+ {
+ "measurement": "test",
+ "fields": {
+ "string_val": "hello!",
+ "int_val": 1,
+ "float_val": 1.1,
+ "none_field": None,
+ "bool_val": True,
+ }
+ }
+ ]
+ }
+
+ self.assertEqual(
+ make_lines(data),
+ 'test,integer_tag=2,string_tag=hello '
+ 'bool_val=True,float_val=1.1,int_val=1i,string_val="hello!"\n'
+ )
+
+ def test_string_val_newline(self):
+ data = {
+ "points": [
+ {
+ "measurement": "m1",
+ "fields": {
+ "multi_line": "line1\nline1\nline3"
+ }
+ }
+ ]
+ }
+
+ self.assertEqual(
+ make_lines(data),
+ 'm1 multi_line="line1\\nline1\\nline3"\n'
+ )