28
28
from influxdb import InfluxDBClient
29
29
from influxdb .client import InfluxDBClientError
30
30
31
- from .misc import get_free_port , is_port_open
31
+ from tests . influxdb .misc import get_free_port , is_port_open
32
32
33
33
34
34
THIS_DIR = os .path .abspath (os .path .dirname (__file__ ))
35
35
36
36
37
- # try to find where is located the 'influxd' binary:
37
+ # try to find where the 'influxd' binary is located :
38
38
# You can define 'InfluxDbPythonClientTest_SERVER_BIN_PATH'
39
39
# env var to force it :
40
40
influxdb_bin_path = influxdb_forced_bin = os .environ .get (
65
65
print (version , file = sys .stderr )
66
66
67
67
68
- dummy_point = [ # some dummy points .. :o
68
+ dummy_point = [ # some dummy points
69
69
{
70
70
"name" : "cpu_load_short" ,
71
71
"tags" : {
79
79
}
80
80
]
81
81
82
- dummy_points = [ # some dummy points .. :o
82
+ dummy_points = [ # some dummy points
83
83
dummy_point [0 ],
84
84
{
85
85
"name" : "memory" ,
111
111
class InfluxDbInstance (object ):
112
112
113
113
def __init__ (self , conf_template ):
114
- # create a fresh temporary place for storing all needed files
114
+ # create a temporary dir to store all needed files
115
115
# for the influxdb server instance :
116
116
self .temp_dir_base = tempfile .mkdtemp ()
117
117
# "temp_dir_base" will be used for conf file and logs,
@@ -121,7 +121,7 @@ def __init__(self, conf_template):
121
121
# we need some "free" ports :
122
122
self .broker_port = get_free_port ()
123
123
self .admin_port = get_free_port ()
124
- # as it's UDP we can reuse the same port than the broker:
124
+ # as it's UDP we can reuse the same port as the broker:
125
125
self .udp_port = get_free_port ()
126
126
127
127
self .logs_file = os .path .join (
@@ -157,8 +157,8 @@ def __init__(self, conf_template):
157
157
158
158
# wait for it to listen on the broker and admin ports:
159
159
# usually a fresh instance is ready in less than 1 sec ..
160
- timeout = time .time () + 10 # so 10 secs should be rather enough,
161
- # otherwise either your system load is rather high,
160
+ timeout = time .time () + 10 # so 10 secs should be enough,
161
+ # otherwise either your system load is high,
162
162
# or you run a 286 @ 1Mhz ?
163
163
try :
164
164
while time .time () < timeout :
@@ -200,7 +200,7 @@ def close(self, remove_tree=True):
200
200
201
201
class InfluxDbClientTestWithServerInstanceMixin (object ):
202
202
''' A mixin for unittest.TestCase to start an influxdb server instance
203
- in a fresh temporary place .
203
+ in a temporary directory .
204
204
'''
205
205
206
206
# 'influxdb_template_conf' attribute must be set on the class or instance
@@ -219,7 +219,7 @@ def tearDown(self):
219
219
self .influxd_inst .close (remove_tree = remove_tree )
220
220
221
221
222
- @unittest .skipIf (not is_influxdb_bin_ok , "not found any influxd binary" )
222
+ @unittest .skipIf (not is_influxdb_bin_ok , "could not find influxd binary" )
223
223
class TestInfluxDBClient (InfluxDbClientTestWithServerInstanceMixin ,
224
224
unittest .TestCase ):
225
225
@@ -479,7 +479,7 @@ def test_create_retention_policy(self):
479
479
)
480
480
481
481
482
- @unittest .skipIf (not is_influxdb_bin_ok , "not found any influxd binary" )
482
+ @unittest .skipIf (not is_influxdb_bin_ok , "could not find influxd binary" )
483
483
class UdpTests (InfluxDbClientTestWithServerInstanceMixin ,
484
484
unittest .TestCase ):
485
485
@@ -497,11 +497,9 @@ def test_write_points_udp(self):
497
497
cli .create_database ('db' )
498
498
cli .write_points (dummy_point )
499
499
500
- # ho boy,
501
- # once write_points finishes then the points aren't actually
502
- # already directly available !!
503
- # Well, it's normal because we sent by udp (no response !).
504
- # So we have to wait some enough time,
500
+ # The points are not immediately available after write_points.
501
+ # This is to be expected because we are using udp (no response !).
502
+ # So we have to wait some time,
505
503
time .sleep (1 ) # 1 sec seems to be a good choice.
506
504
rsp = cli .query ('SELECT * FROM cpu_load_short' )
507
505
0 commit comments