You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2013/06/24 19:14:10 UTC

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

Author: philip
Date: Mon Jun 24 17:14:10 2013
New Revision: 1496127

URL: http://svn.apache.org/r1496127
Log:
Fix occasional failure of checkout_test.py 12 due to dropping the
fractional seconds from the current time.

* subversion/tests/cmdline/checkout_tests.py
  (checkout_peg_rev_date): Get svn:date revision property rather than
   getting the current time.

Modified:
    subversion/trunk/subversion/tests/cmdline/checkout_tests.py

Modified: subversion/trunk/subversion/tests/cmdline/checkout_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/checkout_tests.py?rev=1496127&r1=1496126&r2=1496127&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/checkout_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/checkout_tests.py Mon Jun 24 17:14:10 2013
@@ -660,8 +660,13 @@ def checkout_peg_rev_date(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  # 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]
 
   # sleep till the next second.
   time.sleep(1.1)
@@ -686,7 +691,7 @@ def checkout_peg_rev_date(sbox):
 
   # use an old date to checkout, that way we're sure we get the first revision
   svntest.actions.run_and_verify_checkout(sbox.repo_url +
-                                          '@{' + current_time + '}',
+                                          '@{' + r1_time + '}',
                                           checkout_target,
                                           expected_output,
                                           expected_wc)



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

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

Posted by Daniel Shahaf <da...@elego.de>.
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 Daniel Shahaf <da...@elego.de>.
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>.
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.

-- 
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 Philip Martin <ph...@wandisco.com>.
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.

-- 
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 Daniel Shahaf <da...@apache.org>.
On Mon, Jun 24, 2013 at 05:14:10PM -0000, philip@apache.org wrote:
> Author: philip
> Date: Mon Jun 24 17:14:10 2013
> New Revision: 1496127
> 
> URL: http://svn.apache.org/r1496127
> Log:
> Fix occasional failure of checkout_test.py 12 due to dropping the
> fractional seconds from the current time.
> 
> * subversion/tests/cmdline/checkout_tests.py
>   (checkout_peg_rev_date): Get svn:date revision property rather than
>    getting the current time.
> 
> Modified:
>     subversion/trunk/subversion/tests/cmdline/checkout_tests.py
> 
> Modified: subversion/trunk/subversion/tests/cmdline/checkout_tests.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/checkout_tests.py?rev=1496127&r1=1496126&r2=1496127&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/tests/cmdline/checkout_tests.py (original)
> +++ subversion/trunk/subversion/tests/cmdline/checkout_tests.py Mon Jun 24 17:14:10 2013
> @@ -660,8 +660,13 @@ def checkout_peg_rev_date(sbox):
>    sbox.build()
>    wc_dir = sbox.wc_dir
>  
> -  # 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]
>  
>    # sleep till the next second.
>    time.sleep(1.1)
> @@ -686,7 +691,7 @@ def checkout_peg_rev_date(sbox):
>  
>    # use an old date to checkout, that way we're sure we get the first revision
>    svntest.actions.run_and_verify_checkout(sbox.repo_url +
> -                                          '@{' + current_time + '}',
> +                                          '@{' + r1_time + '}',

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?

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

Posted by Daniel Shahaf <da...@apache.org>.
On Mon, Jun 24, 2013 at 05:14:10PM -0000, philip@apache.org wrote:
> Author: philip
> Date: Mon Jun 24 17:14:10 2013
> New Revision: 1496127
> 
> URL: http://svn.apache.org/r1496127
> Log:
> Fix occasional failure of checkout_test.py 12 due to dropping the
> fractional seconds from the current time.
> 
> * subversion/tests/cmdline/checkout_tests.py
>   (checkout_peg_rev_date): Get svn:date revision property rather than
>    getting the current time.
> 
> Modified:
>     subversion/trunk/subversion/tests/cmdline/checkout_tests.py
> 
> Modified: subversion/trunk/subversion/tests/cmdline/checkout_tests.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/checkout_tests.py?rev=1496127&r1=1496126&r2=1496127&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/tests/cmdline/checkout_tests.py (original)
> +++ subversion/trunk/subversion/tests/cmdline/checkout_tests.py Mon Jun 24 17:14:10 2013
> @@ -660,8 +660,13 @@ def checkout_peg_rev_date(sbox):
>    sbox.build()
>    wc_dir = sbox.wc_dir
>  
> -  # 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]
>  
>    # sleep till the next second.
>    time.sleep(1.1)
> @@ -686,7 +691,7 @@ def checkout_peg_rev_date(sbox):
>  
>    # use an old date to checkout, that way we're sure we get the first revision
>    svntest.actions.run_and_verify_checkout(sbox.repo_url +
> -                                          '@{' + current_time + '}',
> +                                          '@{' + r1_time + '}',

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?