15
15
import distutils .spawn
16
16
from functools import partial
17
17
import os
18
- import re
19
18
import shutil
20
19
import subprocess
21
20
import sys
@@ -653,96 +652,6 @@ def test_write_points_batch(self):
653
652
self .assertIn (12 , net_out ['series' ][0 ]['values' ][0 ])
654
653
self .assertIn (12.34 , cpu ['series' ][0 ]['values' ][0 ])
655
654
656
- def test_write_points_with_precision (self ):
657
- """ check that points written with an explicit precision have
658
- actually that precision used.
659
- """
660
- # for that we'll check that - for each precision - the actual 'time'
661
- # value returned by a select has the correct regex format..
662
- # n : u'2015-03-20T15:23:36.615654966Z'
663
- # u : u'2015-03-20T15:24:10.542554Z'
664
- # ms : u'2015-03-20T15:24:50.878Z'
665
- # s : u'2015-03-20T15:20:24Z'
666
- # m : u'2015-03-20T15:25:00Z'
667
- # h : u'2015-03-20T15:00:00Z'
668
- base_regex = '\d{4}-\d{2}-\d{2}T\d{2}:' # YYYY-MM-DD 'T' hh:
669
- base_s_regex = base_regex + '\d{2}:\d{2}' # base_regex + mm:ss
670
-
671
- point = {
672
- "measurement" : "cpu_load_short" ,
673
- "tags" : {
674
- "host" : "server01" ,
675
- "region" : "us-west"
676
- },
677
- "time" : "2009-11-10T12:34:56.123456789Z" ,
678
- "fields" : {
679
- "value" : 0.64
680
- }
681
- }
682
-
683
- # As far as we can see the values aren't directly available depending
684
- # on the precision used.
685
- # The less the precision, the more to wait for the value to be
686
- # actually written/available.
687
- for idx , (precision , expected_regex , sleep_time ) in enumerate ((
688
- ('n' , base_s_regex + '\.\d{9}Z' , 1 ),
689
- ('u' , base_s_regex + '\.\d{6}Z' , 1 ),
690
- ('ms' , base_s_regex + '\.\d{3}Z' , 1 ),
691
- ('s' , base_s_regex + 'Z' , 1 ),
692
-
693
- # ('h', base_regex + '00:00Z', ),
694
- # that would require a sleep of possibly up to 3600 secs (/ 2 ?)..
695
- )):
696
- db = 'db1' # to not shoot us in the foot/head,
697
- # we work on a fresh db each time:
698
- self .cli .create_database (db )
699
- before = datetime .datetime .now ()
700
- self .assertIs (
701
- True ,
702
- self .cli .write_points (
703
- [point ],
704
- time_precision = precision ,
705
- database = db ))
706
-
707
- # sys.stderr.write('checking presision with %r :
708
- # before=%s\n' % (precision, before))
709
- after = datetime .datetime .now ()
710
-
711
- if sleep_time > 1 :
712
- sleep_time -= (after if before .min != after .min
713
- else before ).second
714
-
715
- start = time .time ()
716
- timeout = start + sleep_time
717
- # sys.stderr.write('should sleep %s ..\n' % sleep_time)
718
- while time .time () < timeout :
719
- rsp = self .cli .query ('SELECT * FROM cpu_load_short' ,
720
- database = db )
721
- if rsp != {'cpu_load_short' : []}:
722
- # sys.stderr.write('already ? only slept %s\n' % (
723
- # time.time() - start))
724
- break
725
- time .sleep (1 )
726
- else :
727
- pass
728
- # sys.stderr.write('ok !\n')
729
-
730
- # sys.stderr.write('sleeping %s..\n' % sleep_time)
731
-
732
- if sleep_time :
733
- time .sleep (sleep_time )
734
-
735
- rsp = self .cli .query ('SELECT * FROM cpu_load_short' , database = db )
736
- # sys.stderr.write('precision=%s rsp_timestamp = %r\n' % (
737
- # precision, rsp['cpu_load_short'][0]['time']))
738
-
739
- m = re .match (
740
- expected_regex ,
741
- list (rsp ['cpu_load_short' ])[0 ]['time' ]
742
- )
743
- self .assertIsNotNone (m )
744
- self .cli .drop_database (db )
745
-
746
655
def test_query (self ):
747
656
self .assertIs (True , self .cli .write_points (dummy_point ))
748
657
@@ -973,13 +882,11 @@ def test_query_multiple_series(self):
973
882
974
883
############################################################################
975
884
976
- @unittest .skip ("Broken as of 0.9.0" )
977
885
@unittest .skipIf (not is_influxdb_bin_ok , "could not find influxd binary" )
978
886
class UdpTests (ManyTestCasesWithServerMixin ,
979
887
unittest .TestCase ):
980
888
981
889
influxdb_udp_enabled = True
982
-
983
890
influxdb_template_conf = os .path .join (THIS_DIR ,
984
891
'influxdb.conf.template' )
985
892
@@ -990,14 +897,15 @@ def test_write_points_udp(self):
990
897
'root' ,
991
898
'' ,
992
899
database = 'db' ,
993
- use_udp = True , udp_port = self .influxd_inst .udp_port
900
+ use_udp = True ,
901
+ udp_port = self .influxd_inst .udp_port
994
902
)
995
903
cli .write_points (dummy_point )
996
904
997
905
# The points are not immediately available after write_points.
998
906
# This is to be expected because we are using udp (no response !).
999
907
# So we have to wait some time,
1000
- time .sleep (1 ) # 1 sec seems to be a good choice.
908
+ time .sleep (3 ) # 3 sec seems to be a good choice.
1001
909
rsp = self .cli .query ('SELECT * FROM cpu_load_short' )
1002
910
1003
911
self .assertEqual (
0 commit comments