[Nagios-devel] Bug in exclude timeperiods code?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Bug in exclude timeperiods code?

Post by Guest »

Hi,

If I'm not wrong the exclude timeperiod feature now working in the
HEAD since the last stable version. I try to add a test case with it
in test_timeperiods.c but I don't think I've got the good result :

I add in t-tap/smallconfig/minimal.cfg theses timeperiods :
define timeperiod{
timeperiod_name Test_exclude
alias Test for exclude timeperiod
tuesday -1 - monday 1 16:30-24:00
exclude myexclude
}


define timeperiod{
timeperiod_name myexclude
alias myexclude
april 1 - august 16 00:00-24:00
saturday -1 - monday 1 16:00-24:00
}


And in the file t-tap/test_timeperiods.c line 404:

/* Tests around clock change going back for TZ=Europe/London.
1256511661 = Sun Oct
25 23:01:01 2009 */
/* A little trip to Paris*/
putenv("TZ=Europe/Paris");
tzset();
temp_timeperiod = find_timeperiod("Test_exclude");
ok(temp_timeperiod!=NULL, "ME: Testing Exclude timeperiod");
test_time=1278939600;
/* printf("Testing at time %s", ctime(&test_time)); */
is_valid_time = check_time_against_period(test_time, temp_timeperiod);
ok( is_valid_time==ERROR, "ME: 12 Jul 2010 15:00:00 - false" );
_get_next_valid_time(test_time, test_time, &chosen_valid_time,
temp_timeperiod);
/* printf("ME: Got chosent time at %s", ctime(&chosen_valid_time)); */
ok( chosen_valid_time==1288103400, "ME: Next valid time=Tue
Oct 26 16:30:00 2010 -> Bug in exclude?");

/* printf("ME Got ask %lu and get %lu\n", test_time,
chosen_valid_time); */

/* Back to New york */
putenv("TZ=America/New_York");
tzset();


The good result should be Tue Oct 26 16:30:00 2010.

We are checking the next valid time for Monday 12 Jul 2010 15:00:00.
It's not valid (it's july tuesday -1 is Tue Jul 27 16:30:00 2010 the
first time available without exclude).
So by months:
*july 27 is not possible because we got nothing until 16 august.
*august : it's the Tues Aug 31, but it's inside "saturday -1 -
monday 1" because saturday -1 is the 28 august, so no.
*september : can be the 28, but saturday -1 is the 25, so still no
*october : now tuesday -1 is 26 and saturday -1 is 30. So ok, it's this one :)

Is is my test false or a bug in the get next valid time with exclude?

Maybe we can try with a less hard case (but I need to run take baby
from the babysitter, so it will be the next week ;) )

Thanks,


Jean





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked