Beispiel #1
0
    def test_cron_lock_acquisition(self, subprocess_mock,
                                   tmpdir, capsys, caplog):
        """
        Basic test for cron process lock acquisition
        """
        server = build_real_server({'barman_home': tmpdir.strpath})

        # Basic cron lock acquisition
        with ServerCronLock(tmpdir.strpath, server.config.name):
            server.cron(wals=True, retention_policies=False)
            out, err = capsys.readouterr()
            assert ("Another cron process is already running on server %s. "
                    "Skipping to the next server\n" %
                    server.config.name) in out

        # Lock acquisition for archive-wal
        with ServerWalArchiveLock(tmpdir.strpath, server.config.name):
            server.cron(wals=True, retention_policies=False)
            out, err = capsys.readouterr()
            assert ("Another archive-wal process is already running "
                    "on server %s. Skipping to the next server"
                    % server.config.name) in out
        # Lock acquisition for receive-wal
        with ServerWalArchiveLock(tmpdir.strpath, server.config.name):
            with ServerWalReceiveLock(tmpdir.strpath, server.config.name):
                # force the streaming_archiver to True for this test
                server.config.streaming_archiver = True
                server.cron(wals=True, retention_policies=False)
                assert ("Another STREAMING ARCHIVER process is running for "
                        "server %s" % server.config.name) in caplog.text
Beispiel #2
0
 def test_server_cron_lock(self, tmpdir):
     """
     Tests for ServerCronLock class
     """
     lock = ServerCronLock(tmpdir.strpath, 'server_name')
     assert lock.filename == tmpdir.join('.server_name-cron.lock')
     assert lock.raise_if_fail
     assert not lock.wait