Skip to content

Commit

Permalink
Tests: Manually stop daemon after verdi devel revive test
Browse files Browse the repository at this point in the history
There was a problem where the `verdi process pause` test in the
`tests/cmdline/commands/test_process.py` would except because the
timeout would be hit. The direct result was because the daemon worker
could not load the node from the database, which in turns was because
the session was in a pending rollback state. This was because a previous
operation on the database excepted. This exception seemed to be due to
the daemon trying to call `CalcJob.delete_state` or
`Process.delete_checkpoint` in the `on_terminated` calls. For some
reason, the update statement that would be executed for this, to remove
the relevant attribute key, would match 0 rows. The suspicion is because
the relevant node had already been removed from the database, probably
because another test, ran between the two daemon tests, had cleaned the
database and so the node no longer existed, but the process task somehow
did.

It is not quite clear exactly where the problem lies, but for now the
temporary work-around is to manually stop the daemon in the first test,
which apparently cleans the state such that the original exception is no
longer hit and the daemon doesn't get stuck with an inconsistent session.
  • Loading branch information
sphuber committed Oct 7, 2022
1 parent ce1ebd1 commit ea135d3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/cmdline/commands/test_devel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def test_revive_without_daemon(run_cli_command):
assert run_cli_command(cmd_devel.devel_revive, raises=True)


@pytest.mark.usefixtures('aiida_profile', 'started_daemon_client')
def test_revive(run_cli_command, monkeypatch, aiida_local_code_factory, submit_and_await):
@pytest.mark.usefixtures('aiida_profile')
def test_revive(run_cli_command, monkeypatch, aiida_local_code_factory, submit_and_await, started_daemon_client):
"""Test ``verdi devel revive``."""
code = aiida_local_code_factory('core.arithmetic.add', '/bin/bash')
builder = code.get_builder()
Expand All @@ -56,3 +56,8 @@ def test_revive(run_cli_command, monkeypatch, aiida_local_code_factory, submit_a
# should timeout and raise an exception
submit_and_await(node, ProcessState.FINISHED)
assert node.is_finished_ok

# Need to manually stop the daemon such that it cleans all state related to the submitted processes. It is not quite
# understood how, but leaving the daemon running, a following test that will submit to the daemon may hit an
# an exception because the node submitted here would no longer exist and the daemon would try to operate on it.
started_daemon_client.stop_daemon(wait=True)

0 comments on commit ea135d3

Please sign in to comment.