Alignak-monitoring / alignak

Monitoring tool, highly flexible and new standard oriented
https://alignak-monitoring.github.io
GNU Affero General Public License v3.0
86 stars 19 forks source link

daterange test failure currently #164

Closed gst closed 9 years ago

gst commented 9 years ago
gstarck@taf 10:07 $ nosetests -xv test_dateranges.py:TestDataranges.test_weekdaydaterange_start_end_time
test_weekdaydaterange_start_end_time (test_dateranges.TestDataranges) ... FAIL

======================================================================
FAIL: test_weekdaydaterange_start_end_time (test_dateranges.TestDataranges)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gstarck/work/work/SFL/Supervision/alignak/test/test_dateranges.py", line 139, in test_weekdaydaterange_start_end_time
    self.assertEqual(start, ret[0])
AssertionError: 1442203200.0 != 1439179200.0
-------------------- >> begin captured stdout << ---------------------

to be investigated .. probably a "timing" issue I'd say at first.

gst commented 9 years ago

probably a "timing" issue I'd say at first.

Effectively, I've changed my date to 1 month ago and then the test succeed :

gstarck@taf 09:10 $ date
vendredi 10 juillet 2015, 09:10:14 (UTC-0400)
(alignak) ✔ ~/work/work/SFL/Supervision/alignak/test [develop|…5⚑ 4]
gstarck@taf 09:10 $ nosetests -xv test_dateranges.py:TestDataranges.test_weekdaydaterange_start_end_time
test_weekdaydaterange_start_end_time (test_dateranges.TestDataranges) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.034s

OK
(alignak) ✔ ~/work/work/SFL/Supervision/alignak/test [develop|…5⚑ 4]
gst commented 9 years ago

working on this..

gst commented 9 years ago

@ddurieux

I give it to you as you initialy wrote that test.. don't know what's going on.. but clearly there is/are some things to correct/fix .. I don't know if it's in the test only, or in daterange code itself, or both..

gst commented 9 years ago

and if you set your system date to, for instance, 1st January 2015 then there are even more assertion errors in this test module (test_dateranges.py)..

on 1st February : 5 failures on 1st March: 7 failures on 1st April : all succeed ... April joke ? :p

etc.. with such inconsistent results unfortunately..

gst commented 9 years ago

@ddurieux

for you to easier debug, you can launch a loop to check each day of the year (2015 or not) like this :

# assuming you are in alignak/test :

$ cp /bin/date .  && sudo chmod +s date  # make a local date sticky..  
# then :
$ date -s 20141231 ; for d in $(seq 365) ; do date -s "1 days" &>/dev/null ; curdate=$(date) ; nosetests -xv test_dateranges.py:TestDataranges.test_weekdaydaterange_start_end_time &>res$d || echo $curdate failed ; done

nb: this will only test the specific test_weekdaydaterange_start_end_time one but there others tests in there where it's failing on particular dates.. (just replace use nosetests -xv test_dateranges.py to test the whole module ;)

Seb-Solon commented 9 years ago

Found it. The if in the test (for changing start and end value) was not the same condition in the code. Pr incoming

gst commented 9 years ago

It's maybe corrected for the particular date you've worked on.. but it's still failing on (quite a lot of) others date :

please reproduce with :

1) copy /bin/date in a temp dir, then chown root on it and chmod +s on it : cp /bin/date /tmp && sudo chown root /tmp/date && sudo chmod +s /tmp/date (assuming your date utility is in /bin)

1.1) not sure but it maybe safer to stop any ntpd.. (I had not to do that on my side)

2) go into the alignak test directory (activate your virtualenv if need to be or anything else) and :

/tmp/date -s 20151231
for d in $(seq 365)
do
    /tmp/date -s "1 days" &>/dev/null
    curdate=$(date)
    nosetests -xv test_dateranges.py:TestDataranges.test_weekdaydaterange_start_end_time &>res$d || { echo "$curdate ($d) failed" ;}
done

(you can copy/paste into your terminal/shell)

NB: this actually change the date for each test run to the day after it is (date -s '1 days') ; beginning at 2015/12/31 .. (so that the first tested date is 2016/01/01).

Change the starting date as you wish to test others dates/years..

and let it run..

Don't forget to reset your date once you're done ;)

For the info, here is the result/output on my station, it should be exactly (normaly) the same on your side :

gstarck@taf 00:00 $ ../date -s 20151231 ; for d in $(seq 365) ; do ../date -s "1 days" &>/dev/null ; curdate=$(date) ; nosetests -xv test_dateranges.py:TestDataranges.test_weekdaydaterange_start_end_time &>res$d || { echo "$curdate ($d) failed" ;} ; done
jeudi 31 décembre 2015, 00:00:00 (UTC-0500)
mercredi 17 février 2016, 00:00:10 (UTC-0500) (48) failed
jeudi 18 février 2016, 00:00:10 (UTC-0500) (49) failed
vendredi 19 février 2016, 00:00:10 (UTC-0500) (50) failed
samedi 20 février 2016, 00:00:11 (UTC-0500) (51) failed
dimanche 21 février 2016, 00:00:11 (UTC-0500) (52) failed
lundi 22 février 2016, 00:00:11 (UTC-0500) (53) failed
mardi 23 février 2016, 00:00:11 (UTC-0500) (54) failed
mercredi 24 février 2016, 00:00:12 (UTC-0500) (55) failed
jeudi 25 février 2016, 00:00:12 (UTC-0500) (56) failed
vendredi 26 février 2016, 00:00:12 (UTC-0500) (57) failed
samedi 27 février 2016, 00:00:12 (UTC-0500) (58) failed
dimanche 28 février 2016, 00:00:12 (UTC-0500) (59) failed
lundi 29 février 2016, 00:00:13 (UTC-0500) (60) failed
mardi 1 mars 2016, 00:00:13 (UTC-0500) (61) failed
mercredi 2 mars 2016, 00:00:13 (UTC-0500) (62) failed
jeudi 3 mars 2016, 00:00:13 (UTC-0500) (63) failed
vendredi 4 mars 2016, 00:00:14 (UTC-0500) (64) failed
samedi 5 mars 2016, 00:00:14 (UTC-0500) (65) failed
dimanche 6 mars 2016, 00:00:14 (UTC-0500) (66) failed
lundi 7 mars 2016, 00:00:14 (UTC-0500) (67) failed
mardi 8 mars 2016, 00:00:14 (UTC-0500) (68) failed
mercredi 9 mars 2016, 00:00:15 (UTC-0500) (69) failed
jeudi 10 mars 2016, 00:00:15 (UTC-0500) (70) failed
vendredi 11 mars 2016, 00:00:15 (UTC-0500) (71) failed
samedi 12 mars 2016, 00:00:15 (UTC-0500) (72) failed
dimanche 13 mars 2016, 00:00:16 (UTC-0500) (73) failed
mercredi 19 octobre 2016, 01:01:06 (UTC-0400) (293) failed
jeudi 20 octobre 2016, 01:01:06 (UTC-0400) (294) failed
vendredi 21 octobre 2016, 01:01:06 (UTC-0400) (295) failed
samedi 22 octobre 2016, 01:01:06 (UTC-0400) (296) failed
dimanche 23 octobre 2016, 01:01:07 (UTC-0400) (297) failed
lundi 24 octobre 2016, 01:01:07 (UTC-0400) (298) failed
mardi 25 octobre 2016, 01:01:07 (UTC-0400) (299) failed
mercredi 26 octobre 2016, 01:01:07 (UTC-0400) (300) failed
jeudi 27 octobre 2016, 01:01:07 (UTC-0400) (301) failed
vendredi 28 octobre 2016, 01:01:08 (UTC-0400) (302) failed
samedi 29 octobre 2016, 01:01:08 (UTC-0400) (303) failed
dimanche 30 octobre 2016, 01:01:08 (UTC-0400) (304) failed
lundi 31 octobre 2016, 01:01:08 (UTC-0400) (305) failed
mardi 1 novembre 2016, 01:01:09 (UTC-0400) (306) failed
mercredi 2 novembre 2016, 01:01:09 (UTC-0400) (307) failed
jeudi 3 novembre 2016, 01:01:09 (UTC-0400) (308) failed
vendredi 4 novembre 2016, 01:01:09 (UTC-0400) (309) failed
samedi 5 novembre 2016, 01:01:10 (UTC-0400) (310) failed
dimanche 6 novembre 2016, 01:01:10 (UTC-0400) (311) failed
gst commented 9 years ago

For the info, here is the result/output on my station, it should be exactly (normaly) the same on your side :

though with the timezone difference there maybe some slight differences..

gst commented 9 years ago

By the way : running this loop should be also useful with others tests concerning dates features or related to that.. because it'll detect eventually certainly others problems

ddurieux commented 9 years ago

Thanks for the tests, perhaps more simple with test with mock (+ date).

I will try this

gst commented 9 years ago

Thanks for the tests,

You're welcome.

perhaps more simple with test with mock (+ date).

it was just to show, reliably (normally) & quite easily, the issue. otherwise with mocks it would not be simpler.. do it and let's see.. ;)

gst commented 9 years ago

FYI: I've temporarily disabled that test : https://github.com/Alignak-monitoring/alignak/commit/8aba80ac5818d7109710853dc7155fe81fca7f00