Skip to content

Commit f08bc34

Browse files
committed
Fixed tests
1 parent f02d1a2 commit f08bc34

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

influxdb/tests/dataframe_client_test.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def test_write_points_from_dataframe(self):
3232
columns=["column_one", "column_two",
3333
"column_three"])
3434
expected = (
35-
b"foo column_one=\"1\",column_three=1.0,column_two=1 0\n"
36-
b"foo column_one=\"2\",column_three=2.0,column_two=2 "
35+
b"foo column_one=\"1\",column_three=1.0,column_two=1i 0\n"
36+
b"foo column_one=\"2\",column_three=2.0,column_two=2i "
3737
b"3600000000000\n"
3838
)
3939

@@ -71,8 +71,8 @@ def test_write_points_from_dataframe_with_numeric_column_names(self):
7171
index=[now, now + timedelta(hours=1)])
7272

7373
expected = (
74-
b'foo,hello=there 0=\"1\",1=1,2=1.0 0\n'
75-
b'foo,hello=there 0=\"2\",1=2,2=2.0 3600000000000\n'
74+
b'foo,hello=there 0=\"1\",1=1i,2=1.0 0\n'
75+
b'foo,hello=there 0=\"2\",1=2i,2=2.0 3600000000000\n'
7676
)
7777

7878
with requests_mock.Mocker() as m:
@@ -92,8 +92,8 @@ def test_write_points_from_dataframe_with_period_index(self):
9292
columns=["column_one", "column_two",
9393
"column_three"])
9494
expected = (
95-
b"foo column_one=\"1\",column_three=1.0,column_two=1 0\n"
96-
b"foo column_one=\"2\",column_three=2.0,column_two=2 "
95+
b"foo column_one=\"1\",column_three=1.0,column_two=1i 0\n"
96+
b"foo column_one=\"2\",column_three=2.0,column_two=2i "
9797
b"86400000000000\n"
9898
)
9999

@@ -125,48 +125,48 @@ def test_write_points_from_dataframe_with_time_precision(self):
125125
cli.write_points(dataframe, measurement, time_precision='h')
126126
self.assertEqual(m.last_request.qs['precision'], ['h'])
127127
self.assertEqual(
128-
b'foo column_one="1",column_three=1.0,column_two=1 0\nfoo '
129-
b'column_one="2",column_three=2.0,column_two=2 1\n',
128+
b'foo column_one="1",column_three=1.0,column_two=1i 0\nfoo '
129+
b'column_one="2",column_three=2.0,column_two=2i 1\n',
130130
m.last_request.body,
131131
)
132132

133133
cli.write_points(dataframe, measurement, time_precision='m')
134134
self.assertEqual(m.last_request.qs['precision'], ['m'])
135135
self.assertEqual(
136-
b'foo column_one="1",column_three=1.0,column_two=1 0\nfoo '
137-
b'column_one="2",column_three=2.0,column_two=2 60\n',
136+
b'foo column_one="1",column_three=1.0,column_two=1i 0\nfoo '
137+
b'column_one="2",column_three=2.0,column_two=2i 60\n',
138138
m.last_request.body,
139139
)
140140

141141
cli.write_points(dataframe, measurement, time_precision='s')
142142
self.assertEqual(m.last_request.qs['precision'], ['s'])
143143
self.assertEqual(
144-
b'foo column_one="1",column_three=1.0,column_two=1 0\nfoo '
145-
b'column_one="2",column_three=2.0,column_two=2 3600\n',
144+
b'foo column_one="1",column_three=1.0,column_two=1i 0\nfoo '
145+
b'column_one="2",column_three=2.0,column_two=2i 3600\n',
146146
m.last_request.body,
147147
)
148148

149149
cli.write_points(dataframe, measurement, time_precision='ms')
150150
self.assertEqual(m.last_request.qs['precision'], ['ms'])
151151
self.assertEqual(
152-
b'foo column_one="1",column_three=1.0,column_two=1 0\nfoo '
153-
b'column_one="2",column_three=2.0,column_two=2 3600000\n',
152+
b'foo column_one="1",column_three=1.0,column_two=1i 0\nfoo '
153+
b'column_one="2",column_three=2.0,column_two=2i 3600000\n',
154154
m.last_request.body,
155155
)
156156

157157
cli.write_points(dataframe, measurement, time_precision='u')
158158
self.assertEqual(m.last_request.qs['precision'], ['u'])
159159
self.assertEqual(
160-
b'foo column_one="1",column_three=1.0,column_two=1 0\nfoo '
161-
b'column_one="2",column_three=2.0,column_two=2 3600000000\n',
160+
b'foo column_one="1",column_three=1.0,column_two=1i 0\nfoo '
161+
b'column_one="2",column_three=2.0,column_two=2i 3600000000\n',
162162
m.last_request.body,
163163
)
164164

165165
cli.write_points(dataframe, measurement, time_precision='n')
166166
self.assertEqual(m.last_request.qs['precision'], ['n'])
167167
self.assertEqual(
168-
b'foo column_one="1",column_three=1.0,column_two=1 0\n'
169-
b'foo column_one="2",column_three=2.0,column_two=2 '
168+
b'foo column_one="1",column_three=1.0,column_two=1i 0\n'
169+
b'foo column_one="2",column_three=2.0,column_two=2i '
170170
b'3600000000000\n',
171171
m.last_request.body,
172172
)

influxdb/tests/server_tests/client_test_with_server.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ def test_write_check_read(self):
303303
self.test_write()
304304
time.sleep(1)
305305
rsp = self.cli.query('SELECT * FROM cpu_load_short', database='db')
306-
self.assertListEqual([{'value': 0.64,
307-
'time': '2009-11-10T23:00:00Z'}],
306+
self.assertListEqual([{'value': 0.64, 'time': '2009-11-10T23:00:00Z',
307+
"host": "server01", "region": "us-west"}],
308308
list(rsp.get_points()))
309309

310310
def test_write_points(self):
@@ -328,7 +328,8 @@ def test_write_points_check_read(self):
328328

329329
self.assertEqual(
330330
list(rsp),
331-
[[{'value': 0.64, 'time': '2009-11-10T23:00:00Z'}]]
331+
[[{'value': 0.64, 'time': '2009-11-10T23:00:00Z',
332+
"host": "server01", "region": "us-west"}]]
332333
)
333334

334335
rsp2 = list(rsp.get_points())
@@ -337,7 +338,8 @@ def test_write_points_check_read(self):
337338

338339
self.assertEqual(
339340
pt,
340-
{'time': '2009-11-10T23:00:00Z', 'value': 0.64}
341+
{'time': '2009-11-10T23:00:00Z', 'value': 0.64,
342+
"host": "server01", "region": "us-west"}
341343
)
342344

343345
@unittest.skip("Broken as of 0.9.0")
@@ -367,15 +369,17 @@ def test_write_multiple_points_different_series(self):
367369
lrsp = list(rsp)
368370

369371
self.assertEqual(
370-
[[{'value': 0.64, 'time': '2009-11-10T23:00:00Z'}]],
372+
[[{'value': 0.64, 'time': '2009-11-10T23:00:00Z',
373+
"host": "server01", "region": "us-west"}]],
371374
lrsp
372375
)
373376

374377
rsp = list(self.cli.query('SELECT * FROM memory'))
375378

376379
self.assertEqual(
377380
rsp,
378-
[[{'value': 33, 'time': '2009-11-10T23:01:35Z'}]]
381+
[[{'value': 33, 'time': '2009-11-10T23:01:35Z',
382+
"host": "server01", "region": "us-west"}]]
379383
)
380384

381385
@unittest.skip("Broken as of 0.9.0")
@@ -678,6 +682,7 @@ def test_write_points_udp(self):
678682

679683
self.assertEqual(
680684
# this is dummy_points :
681-
[{'value': 0.64, 'time': '2009-11-10T23:00:00Z'}],
685+
[{'value': 0.64, 'time': '2009-11-10T23:00:00Z',
686+
"host": "server01", "region": "us-west"}],
682687
list(rsp['cpu_load_short'])
683688
)

influxdb/tests/server_tests/influxdb.conf.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
[data]
1212
dir = "{data_dir}"
13+
wal-dir = "{wal_dir}"
1314
retention-auto-create = true
1415
retention-check-enabled = true
1516
retention-check-period = "10m0s"
@@ -54,7 +55,7 @@
5455
retention-policy = ""
5556
consistency-level = "one"
5657

57-
[udp]
58+
[[udp]]
5859
enabled = {udp_enabled}
5960
bind-address = ":{udp_port}"
6061
database = "db"

influxdb/tests/server_tests/influxdb_instance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(self,
5151
conf_data = dict(
5252
meta_dir=os.path.join(tempdir, 'meta'),
5353
data_dir=os.path.join(tempdir, 'data'),
54+
wal_dir=os.path.join(tempdir, 'wal'),
5455
cluster_dir=os.path.join(tempdir, 'state'),
5556
handoff_dir=os.path.join(tempdir, 'handoff'),
5657
logs_file=os.path.join(self.temp_dir_base, 'logs.txt'),

influxdb/tests/test_line_protocol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_make_lines(self):
2020
"fields": {
2121
"string_val": "hello!",
2222
"int_val": 1,
23+
"float_val": 1.1,
2324
"none_field": None,
2425
}
2526
}
@@ -29,7 +30,7 @@ def test_make_lines(self):
2930
self.assertEqual(
3031
line_protocol.make_lines(data),
3132
'test,integer_tag=2,string_tag=hello '
32-
'int_val=1,string_val="hello!"\n'
33+
'float_val=1.1,int_val=1i,string_val="hello!"\n'
3334
)
3435

3536
def test_string_val_newline(self):

0 commit comments

Comments
 (0)