Page MenuHomeSoftware Heritage

Jenkins > .tox.py3-core-db-server-slow-cover.lib.python3.7.site-packages.swh.core.db.tests.test_cli::test_cli_swh_db_upgrade_new_api
Failed

TEST RESULT

Run At
Feb 2 2022, 2:54 PM
Details
cli_runner = <click.testing.CliRunner object at 0x7fb7469c0cf8> postgresql = <connection object at 0x7fb748b30408; dsn: 'user=postgres password=xxx dbname=tests host=127.0.0.1 port=28141 options=''', closed: 0> mock_package_sql = <function mock_package_sql.<locals>.get_sql_for_package_mock at 0x7fb746a4fbf8> mocker = <pytest_mock.plugin.MockerFixture object at 0x7fb7469c0e80> tmp_path = PosixPath('/tmp/pytest-of-jenkins/pytest-0/test_cli_swh_db_upgrade_new_ap0') def test_cli_swh_db_upgrade_new_api( cli_runner, postgresql, mock_package_sql, mocker, tmp_path ): """Create a db then initializing it should be ok for a "new style" datastore """ module_name = "test.cli_new" from unittest.mock import MagicMock from swh.core.db.db_utils import import_swhmodule, swh_db_version current_version = 1 def import_swhmodule_mock(modname): if modname.startswith("test."): def get_datastore(cls, **kw): # XXX probably not the best way of doing this... return MagicMock(get_current_version=lambda: current_version) return MagicMock(name=modname, get_datastore=get_datastore) return import_swhmodule(modname) mocker.patch("swh.core.db.db_utils.import_swhmodule", import_swhmodule_mock) conninfo = craft_conninfo(postgresql) # This initializes the schema and data cfgfile = tmp_path / "config.yml" cfgfile.write_text( f""" {module_name}: cls: postgresql db: {conninfo} """ ) result = cli_runner.invoke(swhdb, ["init-admin", module_name, "--dbname", conninfo]) assert result.exit_code == 0, f"Unexpected output: {result.output}" result = cli_runner.invoke(swhdb, ["-C", cfgfile, "init", module_name]) import traceback assert ( result.exit_code == 0 ), f"Unexpected output: {traceback.print_tb(result.exc_info[2])}" assert swh_db_version(conninfo) == 1 # the upgrade should not do anything because the datastore does advertise # version 1 result = cli_runner.invoke(swhdb, ["-C", cfgfile, "upgrade", module_name]) assert swh_db_version(conninfo) == 1 # advertize current version as 3, a simple upgrade should get us there, but # no further current_version = 3 result = cli_runner.invoke(swhdb, ["-C", cfgfile, "upgrade", module_name]) > assert swh_db_version(conninfo) == 3 E assert 1 == 3 E +1 E -3 .tox/py3-core-db-server-slow-cover/lib/python3.7/site-packages/swh/core/db/tests/test_cli.py:326: AssertionError