Bug in exclude timeperiods code? (t-tap/test_timeperiods.c)

nap naparuba at gmail.com
Thu Aug 5 14:43:59 CEST 2010


Hi,

I can't code, but I can propose an algorithm that works (optimal I
don't know). It just need functions to get the start and end see from
a time we want for all daterange types (maybe there are already theses
functions).

Then it' a recursive algo between valid/invalid (will always go
thurser and stop at begining+1 year so it will stop). The "next
invalid" function is like valid, for each daterange we search the next
invalid, check is this time is globally invalid (can be invalid for a
daterange but valid for another one) and take the min. Then check for
it's own exclude of course (so next valid for them).

I hope someone will code it.


Jean

On Thu, Aug 5, 2010 at 1:50 AM, Ethan Galstad <egalstad at nagios.org> wrote:
> nap wrote:
>> 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
>>
>
> The "exclude" functionality was discovered to have some bugs that
> returned an incorrect result as is currently a known issue.  A fix looks
> to be difficult.  If you figure out a patch, let us know.  Thanks!
>
> - Ethan
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://p.sf.net/sfu/dev2dev-palm
> _______________________________________________
> Nagios-devel mailing list
> Nagios-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-devel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: excludes_algo.png
Type: image/png
Size: 47407 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20100805/e984332a/attachment.png>
-------------- next part --------------
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list