Git Product home page Git Product logo

Comments (12)

gst avatar gst commented on July 17, 2024

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]

from alignak.

gst avatar gst commented on July 17, 2024

working on this..

from alignak.

gst avatar gst commented on July 17, 2024

@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..

from alignak.

gst avatar gst commented on July 17, 2024

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..

from alignak.

gst avatar gst commented on July 17, 2024

@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 ;)

from alignak.

Seb-Solon avatar Seb-Solon commented on July 17, 2024

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

from alignak.

gst avatar gst commented on July 17, 2024

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)

  1. 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

from alignak.

gst avatar gst commented on July 17, 2024

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..

from alignak.

gst avatar gst commented on July 17, 2024

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

from alignak.

ddurieux avatar ddurieux commented on July 17, 2024

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

I will try this

from alignak.

gst avatar gst commented on July 17, 2024

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.. ;)

from alignak.

gst avatar gst commented on July 17, 2024

FYI: I've temporarily disabled that test : 8aba80a

from alignak.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.