You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Shahaf <da...@elego.de> on 2013/06/26 00:54:50 UTC

Re: svn commit: r1496127 - /subversion/trunk/subversion/tests/cmdline/checkout_tests.py

Philip Martin wrote on Tue, Jun 25, 2013 at 10:08:38 +0100:
> Daniel Shahaf <da...@apache.org> writes:
> 
> >> -  # note the current time to use it as peg revision date.
> >> -  current_time = time.strftime("%Y-%m-%dT%H:%M:%S")
> >> +  exit_code, output, errput = svntest.main.run_svn(None, 'propget', 'svn:date',
> >> +                                                   '--revprop', '-r1',
> >> +                                                   '--strict',
> >> +                                                   sbox.repo_url)
> >> +  if exit_code or errput != [] or len(output) != 1:
> >> +    raise svntest.Failure("svn:date propget failed")
> >> +  r1_time = output[0]
> 
> > This tests updating to a {time} equal to the svn:date property, shouldn't it
> > try updating to a slightly later time to test that resolution works in the
> > common case too?
> 
> I thought about that.
> 
> Commit times are not limited by the filesystem timestamp resolution so
> svn:date will always have sub-second resolution, however Python 2.5
> appears to be a bit limited when converting sub-second times to/from
> strings as datetime doesn't have %f.
> 
> There is a 1.1 second sleep between r1 and r2 and we want to construct a
> date that is strictly after the r1 svn:date and strictly before the r2
> svn:date.  How do we do something like the following without %f support?
> 
>   fmt = "%Y-%m-%dT%H:%M:%S.%fZ"
>   r1_dt = datetime.datetime.strptime(r1_time, fmt)
>   still_r1_time = (r1_dt + datetime.timedelta(seconds=1)).strftime(fmt)
> 
> If we do have %f we could probably use a shorter sleep and a smaller delta.

We could just treat %s.%f as an 8-digit decimal number, so long as
it doesn't wrap around?  Take it, increment the ones place, and stitch
it back onto the string.  In one run out of 6.0e7, the %S.%f will be
59.999999 and we'll need to do something else (or raise Skip).

Does that make sense?  It's a bit hacky, if I have a better idea I'll
add it to this thread.

Re: svn commit: r1496127 - /subversion/trunk/subversion/tests/cmdline/checkout_tests.py

Posted by Philip Martin <ph...@wandisco.com>.
Greg Stein <gs...@gmail.com> writes:

> We turn off the client sleeping for a second (via that crazy env var)
> during the test suite.

That doesn't affect this test.  The timestamps involved are commit times
which are not limited by filesystem resolution but by internal clock
resolution.

> How about for this *one* test, we just insert: time.sleep(1)

We already have a 1.1s sleep.  That's because the test was written using
timestamp manipulation that was limited to whole seconds.  It was buggy
and I fixed it by getting the svn:date which has sub-second resolution.

I suppose we could increase the sleep to 2.1s and continue to use whole
second manipulations.  I'm a bit reluctant to do that since the the
sleep is already the main contribution to runtime of checkout_tests.py
on my machine.

-- 
Philip Martin | Subversion Committer
WANdisco | Non-Stop Data
www.wandisco.com

Re: svn commit: r1496127 - /subversion/trunk/subversion/tests/cmdline/checkout_tests.py

Posted by Greg Stein <gs...@gmail.com>.
On Tue, Jun 25, 2013 at 6:54 PM, Daniel Shahaf <da...@elego.de> wrote:
> Philip Martin wrote on Tue, Jun 25, 2013 at 10:08:38 +0100:
>> Daniel Shahaf <da...@apache.org> writes:
>>
>> >> -  # note the current time to use it as peg revision date.
>> >> -  current_time = time.strftime("%Y-%m-%dT%H:%M:%S")
>> >> +  exit_code, output, errput = svntest.main.run_svn(None, 'propget', 'svn:date',
>> >> +                                                   '--revprop', '-r1',
>> >> +                                                   '--strict',
>> >> +                                                   sbox.repo_url)
>> >> +  if exit_code or errput != [] or len(output) != 1:
>> >> +    raise svntest.Failure("svn:date propget failed")
>> >> +  r1_time = output[0]
>>
>> > This tests updating to a {time} equal to the svn:date property, shouldn't it
>> > try updating to a slightly later time to test that resolution works in the
>> > common case too?
>>
>> I thought about that.
>>
>> Commit times are not limited by the filesystem timestamp resolution so
>> svn:date will always have sub-second resolution, however Python 2.5
>> appears to be a bit limited when converting sub-second times to/from
>> strings as datetime doesn't have %f.
>>
>> There is a 1.1 second sleep between r1 and r2 and we want to construct a
>> date that is strictly after the r1 svn:date and strictly before the r2
>> svn:date.  How do we do something like the following without %f support?
>>
>>   fmt = "%Y-%m-%dT%H:%M:%S.%fZ"
>>   r1_dt = datetime.datetime.strptime(r1_time, fmt)
>>   still_r1_time = (r1_dt + datetime.timedelta(seconds=1)).strftime(fmt)
>>
>> If we do have %f we could probably use a shorter sleep and a smaller delta.
>
> We could just treat %s.%f as an 8-digit decimal number, so long as
> it doesn't wrap around?  Take it, increment the ones place, and stitch
> it back onto the string.  In one run out of 6.0e7, the %S.%f will be
> 59.999999 and we'll need to do something else (or raise Skip).
>
> Does that make sense?  It's a bit hacky, if I have a better idea I'll
> add it to this thread.

We turn off the client sleeping for a second (via that crazy env var)
during the test suite.

How about for this *one* test, we just insert: time.sleep(1)

Simple and fixes the problem.

Cheers,
-g

Re: svn commit: r1496127 - /subversion/trunk/subversion/tests/cmdline/checkout_tests.py

Posted by Greg Stein <gs...@gmail.com>.
On Tue, Jun 25, 2013 at 6:54 PM, Daniel Shahaf <da...@elego.de> wrote:
> Philip Martin wrote on Tue, Jun 25, 2013 at 10:08:38 +0100:
>> Daniel Shahaf <da...@apache.org> writes:
>>
>> >> -  # note the current time to use it as peg revision date.
>> >> -  current_time = time.strftime("%Y-%m-%dT%H:%M:%S")
>> >> +  exit_code, output, errput = svntest.main.run_svn(None, 'propget', 'svn:date',
>> >> +                                                   '--revprop', '-r1',
>> >> +                                                   '--strict',
>> >> +                                                   sbox.repo_url)
>> >> +  if exit_code or errput != [] or len(output) != 1:
>> >> +    raise svntest.Failure("svn:date propget failed")
>> >> +  r1_time = output[0]
>>
>> > This tests updating to a {time} equal to the svn:date property, shouldn't it
>> > try updating to a slightly later time to test that resolution works in the
>> > common case too?
>>
>> I thought about that.
>>
>> Commit times are not limited by the filesystem timestamp resolution so
>> svn:date will always have sub-second resolution, however Python 2.5
>> appears to be a bit limited when converting sub-second times to/from
>> strings as datetime doesn't have %f.
>>
>> There is a 1.1 second sleep between r1 and r2 and we want to construct a
>> date that is strictly after the r1 svn:date and strictly before the r2
>> svn:date.  How do we do something like the following without %f support?
>>
>>   fmt = "%Y-%m-%dT%H:%M:%S.%fZ"
>>   r1_dt = datetime.datetime.strptime(r1_time, fmt)
>>   still_r1_time = (r1_dt + datetime.timedelta(seconds=1)).strftime(fmt)
>>
>> If we do have %f we could probably use a shorter sleep and a smaller delta.
>
> We could just treat %s.%f as an 8-digit decimal number, so long as
> it doesn't wrap around?  Take it, increment the ones place, and stitch
> it back onto the string.  In one run out of 6.0e7, the %S.%f will be
> 59.999999 and we'll need to do something else (or raise Skip).
>
> Does that make sense?  It's a bit hacky, if I have a better idea I'll
> add it to this thread.

We turn off the client sleeping for a second (via that crazy env var)
during the test suite.

How about for this *one* test, we just insert: time.sleep(1)

Simple and fixes the problem.

Cheers,
-g