コード例 #1
0
def test_basic(topology_st):
    BACKUP_DIR = os.path.join(topology_st.standalone.ds_paths.backup_dir,
                              "basic_backup")
    topology_st.logcap = LogCapture()
    args = FakeArgs()

    users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX)
    user = users.create_test_user()
    user.replace("description", "backup_test")

    # Clean the backup dir first
    if os.path.exists(BACKUP_DIR):
        shutil.rmtree(BACKUP_DIR)

    # Create the backup
    args.archive = BACKUP_DIR
    args.db_type = None
    backup_create(topology_st.standalone, None, topology_st.logcap.log, args)
    assert os.listdir(BACKUP_DIR)

    # Restore the backup
    args.archive = topology_st.standalone.ds_paths.backup_dir
    args.db_type = None
    backup_restore(topology_st.standalone, None, topology_st.logcap.log, args)
    assert user.present("description", "backup_test")

    # No error has happened! Done!
    # Clean up
    if os.path.exists(BACKUP_DIR):
        shutil.rmtree(BACKUP_DIR)
コード例 #2
0
def test_db2bak_bak2db(topology_be_latest):
    standalone = topology_be_latest.standalone
    standalone.stop()
    args = FakeArgs()
    args.archive = os.path.join(standalone.get_bak_dir(), "testdb2bak")
    # Stop the instance
    dbtasks_db2bak(standalone, topology_be_latest.logcap.log, args)
    # Assert none.
    assert topology_be_latest.logcap.contains("db2bak successful")
    topology_be_latest.logcap.flush()
    # We can re-use the same arguments
    dbtasks_bak2db(standalone, topology_be_latest.logcap.log, args)
    # Assert none.
    assert topology_be_latest.logcap.contains("bak2db successful")
コード例 #3
0
def test_ldif2db_db2ldif_repl(topology_be_latest):
    standalone = topology_be_latest.standalone
    standalone.stop()
    args = FakeArgs()
    args.backend = 'userRoot'
    args.ldif = os.path.join(standalone.get_ldif_dir(), "test.ldif")
    args.encrypted = False
    args.replication = False
    args.archive = os.path.join(standalone.get_ldif_dir(), "test.ldif")
    # Stop the instance
    dbtasks_db2ldif(standalone, topology_be_latest.logcap.log, args)
    # Assert none.
    assert topology_be_latest.logcap.contains("db2ldif successful")
    topology_be_latest.logcap.flush()
    # We can re-use the same arguments
    dbtasks_ldif2db(standalone, topology_be_latest.logcap.log, args)
    # Assert none.
    assert topology_be_latest.logcap.contains("ldif2db successful")