runbot/runbot_merge/tests
Xavier Morel 3c88e033f6 [FIX] runbot_merge: make patcher not rely on branches
This was the root cause of the incident of Feb 13/14: because the
patcher pushed to the local branch before pushing to the remote
failing to push to the remote would leave the local ref broken, as
`fetch("refs/heads/*:refs/heads/*")` apparently does not do non-ff
updates (which does make some sense I guess).

So in this case a staging finished, was pushed to the remote, then git
delayed the read side just enough that when the patcher looked up the
target it got the old commit. It applied a patch on top of that, tried
to push, and got a failure (non-ff update), which led the local and
remote branches divergent, and caused any further update of the local
reference branches to fail, thus every forward port to be blocked.

Using symbolic branches during patching was completely dumb (and
updating the local branch unnecessary), so switch the entire thing to
using just commits, and update a bunch of error reporting while at it.
2025-03-14 14:21:28 +01:00
..
conftest.py [FIX] runbot_merge: project fixture 2025-01-28 15:13:47 +01:00
README.rst [IMP] runbot_merge: test readme & remove leftover pass 2018-09-03 13:16:36 +02:00
test_basic.py [IMP] *: cleanup status contexts in tests 2025-02-06 14:55:28 +01:00
test_batch_consistency.py [IMP] runbot_merge: a PR can't be reopened if its batch is merged 2024-12-09 16:02:28 +01:00
test_by_branch.py [IMP] runbot_merge: add optional statuses on PRs 2025-02-25 09:50:45 +01:00
test_dfm.py [ADD] runbot_merge: rendering of PR descriptions 2024-07-15 10:28:28 +02:00
test_disabled_branch.py [IMP] *: cleanup status contexts in tests 2025-02-06 14:55:28 +01:00
test_multirepo.py [IMP] *: fork with main_branch_only 2025-02-06 12:41:03 +01:00
test_nondeterministic_failures.py [ADD] runbot_merge: basic support for false positive detection 2024-12-09 16:02:28 +01:00
test_oddities.py [IMP] *: remove dead imports 2025-02-28 16:12:40 +01:00
test_patching.py [FIX] runbot_merge: make patcher not rely on branches 2025-03-14 14:21:28 +01:00
test_project_toggles.py [IMP] *: cleanup status contexts in tests 2025-02-06 14:55:28 +01:00
test_provisioning.py [IMP] runbot_merge: rework (de)provisioning 2025-01-28 16:11:14 +01:00
test_staging.py [IMP] *: cleanup status contexts in tests 2025-02-06 14:55:28 +01:00
test_status_overrides.py [IMP] *: modernise tests via to_pr 2024-12-02 16:32:53 +01:00
test_statuses_optional.py [IMP] runbot_merge: add optional statuses on PRs 2025-02-25 09:50:45 +01:00

Execute this test suite using pytest.

The default mode is to run tests locally using a mock github.com.

See the docstring of remote.py for instructions to run against github "actual"
(including remote-specific options) and the end of this file for a sample.

Shared properties running tests, regardless of the github implementation:

* test should be run from the root of the runbot repository providing the
  name of this module aka ``pytest runbot_merge`` or
  ``python -mpytest runbot_merge``
* a database name to use must be provided using ``--db``, the database should
  not exist beforehand
* the addons path must be specified using ``--addons-path``, both "runbot" and
  the standard addons (odoo/addons) must be provided explicitly

See pytest's documentation for other options, I would recommend ``-rXs``,
``-v`` and ``--showlocals``.

When running "remote" tests as they take a very long time (hours) ``-x``
(aka ``--maxfail=1``) and ``--ff`` (run previously failed first) is also
recommended unless e.g. you run the tests overnight.

``pytest.ini`` sample
---------------------

.. code:: ini

    [github]
    owner = test-org
    token = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    [role_reviewer]
    name = Dick Bong
    user = loginb
    token = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

    [role_self_reviewer]
    name = Fanny Chmelar
    user = loginc
    token = cccccccccccccccccccccccccccccccccccccccc

    [role_other]
    name = Harry Baals
    user = logind
    token = dddddddddddddddddddddddddddddddddddddddd