test_upgrade tests assume you can upgrade to format knit

Bug #408824 reported by Martin Pool
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Martin Pool

Bug Description

When the default format is 2a, there are some failures where tests try to go from the default branch format to 'knit', which is no longer possible if the default is rich-root:

test: bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit
failure: bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit [
RemoteException: Traceback (most recent call last):
  File "/home/mbp/bzr/398668-2a-default/bzrlib/tests/blackbox/test_upgrade.py", line 129, in test_upgrade_explicit_knit
    ['upgrade', '--format=knit', url])
AssertionError: Unexpected return code
not equal:
a = 0
b = 3

]
test: bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_repo
failure: bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_repo [
RemoteException: Traceback (most recent call last):
  File "/home/mbp/bzr/398668-2a-default/bzrlib/tests/blackbox/test_upgrade.py", line 146, in test_upgrade_repo
    self.run_bzr('upgrade --format=knit repo')
AssertionError: Unexpected return code
not equal:
a = 0
b = 3

]

Related branches

Revision history for this message
Robert Collins (lifeless) wrote :

I suggest using 1.9-rich-root rather than knit; -or- hardcoding a starting format of 1.9, depending on the intent o f the individual tests.

Revision history for this message
Robert Collins (lifeless) wrote :

This bug doesn't make sense: the tests already explicitly set a metaweave format, which is upgradable to knits.

I suspect Martin's 2a default plugin is interfering with explicit format selection somewhere.

Changed in bzr:
assignee: Martin Pool (mbp) → Robert Collins (lifeless)
assignee: Robert Collins (lifeless) → nobody
status: Confirmed → Incomplete
Martin Pool (mbp)
Changed in bzr:
status: Incomplete → In Progress
assignee: nobody → Martin Pool (mbp)
Revision history for this message
Martin Pool (mbp) wrote :

I agree it is confusing, but it's not due to my plugin: when I run it in a copy of your bug 398668 branch with no plugins, I still get

3.752 Traceback (most recent call last):
  File "/home/mbp/bzr/398668-2a-default/bzrlib/commands.py", line 1131, in run_bzr_catch_user_errors
    return run_bzr(argv)
  File "/home/mbp/bzr/398668-2a-default/bzrlib/commands.py", line 1030, in run_bzr
    ret = run(*run_argv)
  File "/home/mbp/bzr/398668-2a-default/bzrlib/commands.py", line 647, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/mbp/bzr/398668-2a-default/bzrlib/builtins.py", line 3140, in run
    upgrade(url, format)
  File "/home/mbp/bzr/398668-2a-default/bzrlib/upgrade.py", line 85, in upgrade
    Convert(url, format)
  File "/home/mbp/bzr/398668-2a-default/bzrlib/upgrade.py", line 40, in __init__
    self.convert()
  File "/home/mbp/bzr/398668-2a-default/bzrlib/upgrade.py", line 74, in convert
    self.bzrdir.check_conversion_target(format)
  File "/home/mbp/bzr/398668-2a-default/bzrlib/bzrdir.py", line 134, in check_conversion_target
    source_repo_format.check_conversion_target(target_repo_format)
  File "/home/mbp/bzr/398668-2a-default/bzrlib/repofmt/groupcompress_repo.py", line 1101, in check_conversion_target
    'Does not support rich root data.', target_format)
BadConversionTarget: Cannot convert to format <RepositoryFormatKnit1>. Does not support rich root data.

3.753 errors:
'bzr: ERROR: Cannot convert to format <RepositoryFormatKnit1>. Does not support rich root data.\n'
3.759 opening working tree '/tmp/testbzr-D9P2yF.tmp'

^^^^[log from bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mbp/bzr/398668-2a-default/bzrlib/tests/blackbox/test_upgrade.py", line 129, in test_upgrade_explicit_knit
    ['upgrade', '--format=knit', url])
AssertionError: Unexpected return code
not equal:
a = 0
b = 3

Revision history for this message
Martin Pool (mbp) wrote :
Download full text (9.5 KiB)

The attached branch gives a better message and shows the failures are actually like this:

======================================================================
FAIL: test_upgrade_explicit_knit (bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches)

vvvv[log from bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit]
5.309 creating repository in file:///tmp/testbzr-boa9Al.tmp/bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit/work/metadir_weave_branch/.bzr/.
5.314 creating branch <bzrlib.branch.BzrBranchFormat5 object at 0xb2dad8c> in file:///tmp/testbzr-boa9Al.tmp/bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit/work/metadir_weave_branch/.bzr/
5.325 opening working tree '/tmp/testbzr-boa9Al.tmp/bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit/work/metadir_weave_branch'
5.326 failed to open /tmp/testbzr-boa9Al.tmp/bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit/work/metadir_weave_branch/.bzr/checkout/stat-cache: [Errno 2] No such file or directory: u'/tmp/testbzr-boa9Al.tmp/bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit/work/metadir_weave_branch/.bzr/checkout/stat-cache'
5.326 write hc
5.332 run bzr: ['upgrade', '--format=knit', 'file:///tmp/testbzr-boa9Al.tmp/bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit/work/metadir_weave_branch/']
5.332 bzr arguments: ['upgrade', '--format=knit', 'file:///tmp/testbzr-boa9Al.tmp/bzrlib.tests.blackbox.test_upgrade.TestWithUpgradableBranches.test_upgrade_explicit_knit/work/metadir_weave_branch/']
5.336 encoding stdout as sys.stdout encoding 'UTF-8'
5.344 Traceback (most recent call last):
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/commands.py", line 1131, in run_bzr_catch_user_errors
    return run_bzr(argv)
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/commands.py", line 1030, in run_bzr
    ret = run(*run_argv)
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/commands.py", line 647, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/builtins.py", line 3140, in run
    upgrade(url, format)
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/upgrade.py", line 85, in upgrade
    Convert(url, format)
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/upgrade.py", line 40, in __init__
    self.convert()
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/upgrade.py", line 74, in convert
    self.bzrdir.check_conversion_target(format)
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/bzrdir.py", line 134, in check_conversion_target
    source_repo_format.check_conversion_target(target_repo_format)
  File "/home/mbp/bzr/408824-test-upgrade/bzrlib/repofmt/groupcompress_repo.py", line 1108, in check_conversion_target
    from_format=self)
BadConversionTarget: Cannot convert from format <RepositoryFormat2a> to format <RepositoryFormatKnit1>. Does not support rich root data.

5.344 errors:
'bzr: ERROR: Cannot convert from format <RepositoryFormat2a> to format <Reposito...

Read more...

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 408824] Re: test_upgrade tests assume you can upgrade to format knit

This is tricky.

I suspect its roughly of the form
loop_until_done:
step 1:
  bzrdir5(pre-meta) -> 'default-meta'(==2a)
step 2:
  boom

-Rob

Revision history for this message
Martin Pool (mbp) wrote :

So in the case of upgrade_explicit_knit, the strange thing is that the source directory does in fact seem to contain weaves, so I'm not sure why it's complaining

BadConversionTarget: Cannot convert from format <RepositoryFormat2a> to format <RepositoryFormatKnit1>. Does not support rich root data.

I can reproduce this interactively:

mbp@lithe% ./bzr init --metaweave /tmp/meta
default2a plugin set default format to 2a
Format <RepositoryFormat7> for file:///tmp/meta/.bzr/ is deprecated - please use 'bzr upgrade' to get better performance
Created a standalone tree (format: metaweave)
mbp@lithe% ./bzr info /tmp/meta
default2a plugin set default format to 2a
Format <RepositoryFormat7> for file:///tmp/meta/.bzr/ is deprecated - please use 'bzr upgrade' to get better performance
Standalone tree (format: metaweave)
Location:
  branch root: /tmp/meta
mbp@lithe% ./bzr upgrade --knit /tmp/meta
default2a plugin set default format to 2a
Format <RepositoryFormat7> for file:///tmp/meta/.bzr/ is deprecated - please use 'bzr upgrade' to get better performance
bzr: ERROR: Cannot convert from format <RepositoryFormat2a> to format <RepositoryFormatKnit1>. Does not support rich root data.

however with the default2a plugin removed, it succeeds.

The problem seems to be that the BzrDirFormat object for the source doesn't reflect the formats that are actually present:

(Pdb) l
130
131 def check_conversion_target(self, target_format):
132 target_repo_format = target_format.repository_format
133 source_repo_format = self._format.repository_format
134 import pdb;pdb.set_trace()
135 -> source_repo_format.check_conversion_target(target_repo_format)
136
137 @staticmethod
138 def _check_supported(format, allow_unsupported,
139 recommend_upgrade=True,
140 basedir=None):
(Pdb) p source_repo_format
<bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a object at 0xa2a212c>
(Pdb) p self
<bzrlib.bzrdir.BzrDirMeta1 object at 0xb798ca0c>
(Pdb) p self._format
<bzrlib.bzrdir.BzrDirMetaFormat1 object at 0xa257d6c>
(Pdb) p self._format.repository_format
<bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a object at 0xa350bec>
(Pdb) p self.open_repository()
WeaveMetaDirRepository('file:///tmp/meta/.bzr/repository/')
(Pdb) p self.open_repository()._format
<bzrlib.repofmt.weaverepo.RepositoryFormat7 object at 0xa350ecc>

I suspect that line 133 should be asking what format is actually there - or indeed perhaps this whole thing should be delegated to the source repository object.

There are several check_conversion_target methods on random RepositoryFormats and I suspect they shouldn't be overriding to remove the checks.

Revision history for this message
Martin Pool (mbp) wrote :

I think this is the fix:

=== modified file 'bzrlib/bzrdir.py'
--- bzrlib/bzrdir.py 2009-08-14 09:31:37 +0000
+++ bzrlib/bzrdir.py 2009-08-14 11:02:19 +0000
@@ -130,8 +130,7 @@

     def check_conversion_target(self, target_format):
         target_repo_format = target_format.repository_format
- source_repo_format = self._format.repository_format
- source_repo_format.check_conversion_target(target_repo_format)
+ self.open_repository()._format.check_conversion_target(target_repo_format)

     @staticmethod
     def _check_supported(format, allow_unsupported,

shell returned 1

Revision history for this message
Martin Pool (mbp) wrote :

I think strictly speaking we could write a test for this case: upgrading from something where the repository format is different to the bzrdir's default repository format and that difference makes it incompatible. But, it seems a bit contrived, and the fix is I think fairly obviously correct, and there is a blackbox test that catches the problem.

Revision history for this message
Martin Pool (mbp) wrote :

There's still another related failure bug 413541.

Changed in bzr:
status: In Progress → Fix Committed
Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.