-
-
Notifications
You must be signed in to change notification settings - Fork 805
Open
Description
openbsd7: ________________________________ test_with_lock ________________________________
openbsd7: [gw0] openbsd7 -- Python 3.10.13 /vagrant/borg/borg/.tox/py310-none/bin/python
openbsd7:
openbsd7: tmp_path = PosixPath('/tmp/pytest-of-vagrant/pytest-0/popen-gw0/test_with_lock0')
openbsd7:
openbsd7: def test_with_lock(tmp_path):
openbsd7: repo_path = tmp_path / "repo"
openbsd7: env = os.environ.copy()
openbsd7: env["BORG_REPO"] = "file://" + str(repo_path)
openbsd7: command0 = "python3", "-m", "borg", "repo-create", "--encryption=none"
openbsd7: # timings must be adjusted so that command1 keeps running while command2 tries to get the lock,
openbsd7: # so that lock acquisition for command2 fails as the test expects it.
openbsd7: lock_wait, execution_time, startup_wait = 2, 4, 1
openbsd7: assert lock_wait < execution_time - startup_wait
openbsd7: command1 = "python3", "-c", f'import time; print("first command - acquires the lock"); time.sleep({execution_time})'
openbsd7: command2 = "python3", "-c", 'print("second command - should never get executed")'
openbsd7: borgwl = "python3", "-m", "borg", "with-lock", f"--lock-wait={lock_wait}"
openbsd7: popen_options = dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=env)
openbsd7: subprocess.run(command0, env=env, check=True, text=True, capture_output=True)
openbsd7: assert repo_path.exists()
openbsd7: with subprocess.Popen([*borgwl, *command1], **popen_options) as p1:
openbsd7: time.sleep(startup_wait) # wait until p1 is running
openbsd7: # now try to get another lock on the same repository:
openbsd7: with subprocess.Popen([*borgwl, *command2], **popen_options) as p2:
openbsd7: out, err_out = p2.communicate()
openbsd7: > assert "second command" not in out # command2 is "locked out"
openbsd7: E AssertionError: assert 'second command' not in 'second comm...t executed\n'
openbsd7: E
openbsd7: E 'second command' is contained here:
openbsd7: E second command - should never get executed
openbsd7: E ? ++++++++++++++
openbsd7:
openbsd7: src/borg/testsuite/archiver/lock_cmds_test.py:38: AssertionError