Пример #1
0
    def test_recover_default_target(self, get_server_mock,
                                    parse_backup_id_mock, monkeypatch, capsys):
        backup_info = Mock()
        backup_info.status = BackupInfo.DONE
        backup_info.tablespaces = []

        parse_backup_id_mock.return_value = backup_info

        monkeypatch.setattr(
            barman,
            "__config__",
            build_config_from_dicts(main_conf={
                "archiver": "on",
            }),
        )

        # This parameters are fine
        args = Mock()
        args.backup_id = "20170823T104400"
        args.server_name = "main"
        args.destination_directory = "recovery_dir"
        args.tablespace = None
        args.target_name = None
        args.target_tli = None
        args.target_immediate = None
        args.target_time = None
        args.target_xid = None
        args.target_lsn = None
        args.target_action = None

        with pytest.raises(SystemExit):
            recover(args)

        _, err = capsys.readouterr()
        assert "" == err
Пример #2
0
    def test_recover_one_target(self, get_server_mock, parse_backup_id_mock,
                                monkeypatch, capsys):
        backup_info = Mock()
        backup_info.status = BackupInfo.DONE
        backup_info.tablespaces = []

        parse_backup_id_mock.return_value = backup_info

        monkeypatch.setattr(
            barman, '__config__',
            build_config_from_dicts(main_conf={
                'archiver': 'on',
            }))

        # This parameters are fine
        args = Mock()
        args.backup_id = '20170823T104400'
        args.server_name = 'main'
        args.destination_directory = 'recovery_dir'
        args.tablespace = None
        args.target_name = None
        args.target_tli = None
        args.target_immediate = True
        args.target_time = None
        args.target_xid = None

        _, err = capsys.readouterr()
        with pytest.raises(SystemExit):
            recover(args)
        assert "" == err
Пример #3
0
    def test_recover_multiple_targets(self, get_server_mock,
                                      parse_backup_id_mock, monkeypatch,
                                      capsys):
        backup_info = Mock()
        backup_info.status = BackupInfo.DONE
        backup_info.tablespaces = []

        parse_backup_id_mock.return_value = backup_info

        monkeypatch.setattr(
            barman, '__config__',
            build_config_from_dicts(main_conf={
                'archiver': 'on',
            }))

        # Testing mutual exclusiveness of target options
        args = Mock()
        args.backup_id = '20170823T104400'
        args.server_name = 'main'
        args.destination_directory = 'recovery_dir'
        args.tablespace = None
        args.target_name = None
        args.target_tli = 3
        args.target_immediate = True
        args.target_time = None
        args.target_xid = None

        with pytest.raises(SystemExit):
            recover(args)

        _, err = capsys.readouterr()
        assert 'ERROR: You cannot specify multiple targets for the recovery ' \
               'operation' in err
Пример #4
0
    def test_recover_multiple_targets(
        self, get_server_mock, parse_backup_id_mock, monkeypatch, capsys
    ):
        backup_info = Mock()
        backup_info.status = BackupInfo.DONE
        backup_info.tablespaces = []

        parse_backup_id_mock.return_value = backup_info

        monkeypatch.setattr(
            barman,
            "__config__",
            build_config_from_dicts(
                main_conf={
                    "archiver": "on",
                }
            ),
        )

        # Testing mutual exclusiveness of target options
        args = Mock()
        args.backup_id = "20170823T104400"
        args.server_name = "main"
        args.destination_directory = "recovery_dir"
        args.tablespace = None
        args.target_name = None
        args.target_tli = None
        args.target_lsn = None
        args.target_immediate = True
        args.target_time = "2021-01-001 00:00:00.000"
        args.target_xid = None

        with pytest.raises(SystemExit):
            recover(args)

        _, err = capsys.readouterr()
        assert (
            "ERROR: You cannot specify multiple targets for the recovery "
            "operation" in err
        )