Esempio n. 1
0
def db_test(username='******', password='******', wildcard='Add_source*.js Edit_source.js Add_synonym.js Remove_*.js', use_password_file=True, preserve_database=False):
    """Test admin functionality using database

     Run tests reading and writing the database and restore database afterwards.
     Default restore database with dump from GitHub.
     Optionally set preserve_database=True to use backup and restore current database.
    """
    
    if use_password_file:
        username = get_value_from_password_store(PASSWORD_FILE_ADMIN_USERNAME_PARAM_NAME, username)
        password = get_value_from_password_store(PASSWORD_FILE_ADMIN_PASSWORD_PARAM_NAME, password)

    url = "http://"+env.roledefs['rinfo'][0]
    output = "%s/target/test-reports/" % env.projectroot
    backup_name = 'Backup_for_test_%s_%s' % (env.target, env.timestamp)

    if preserve_database:
        backup_db(name=backup_name)

    try:
        with lcd(env.projectroot + "/test/regression/db"):
            local("casperjs test %s --xunit=../casperjs.log --includes=../../GAblocker.js "
                  "--includes=../../CommonCapserJS.js --url=%s --target=%s --output=%s --username=%s --password=%s"
                  % (wildcard, url, env.target, output, username, password))
    finally:
        if preserve_database:
            restore_db(name=backup_name)
        else:
            restore_database_for_descructive_tests()
Esempio n. 2
0
def test_durability(repeat):
    server_log_base = server.log_dir + "dur_server_%d.log" % repeat
    client_log_base = server.log_dir + "dur_client_%d.log" % repeat
    server.start_server(extra_args=server_args, log=server_log_base+".1")
    try:
        lsn = 0

        client = Client(server.addr, server.port, log=client_log_base+".1")
        repeat_deposit(client, repeat, 100)
        lsn += repeat + 1
        saved = server.save_db()

        repeat_deposit(client, repeat, 100)
        lsn += repeat
        client.log.close()

        client = Client(server.addr, server.port, log=client_log_base+".1")
        repeat_deposit(client, repeat, 200)
        lsn += repeat + 1
        client.log.close()

        server.stop_server()
        server.restore_db(saved)
        server.start_server(extra_args=server_args, log=server_log_base+".2", remove_old=False)

        client = Client(server.addr, server.port, log=client_log_base+".2", auto_open=False)
        client.id = 1
        _, _, new = client.deposit(0)
        assert new == repeat * 200
        client.id = 2
        _, _, new = client.deposit(0)
        assert new == repeat * 200
        lsn += 2

        client.log.close()
        data.assert_lsn_id(lsn, 2)
    finally:
        server.stop_server()
Esempio n. 3
0
def verify_backup(name, username='', password='', use_password_file=True):
    restore_db(name, username=username, password=password, use_password_file=use_password_file)
    time.sleep(20)
    test(use_password_file=use_password_file)