def test_workload(self):

        primary = self.getPrimaryForShard(0)
        idleServer = None
        for server in self.cluster:
            if server not in self.getReplicasForShard(0) + [primary]:
                idleServer = server
                break
        else:
            raise Exception(
                'Could not find a server that was not serving this table')
        assert primary != idleServer

        with workload_runner.ContinuousWorkload(
                opts["workload"],
                primary,
                db_name=self.dbName,
                table_name=self.tableName) as workload:

            utils.print_with_time(
                "Starting workload and running for 10 seconds")
            workload.start()
            time.sleep(10)
            self.checkCluster

            utils.print_with_time("Killing the idle server")
            idleServer.kill()  # this removes it from the cluster
            self.checkCluster

            utils.print_with_time("Running workload for 10 more seconds")
            time.sleep(10)
            self.checkCluster

        utils.print_with_time("Done with kill_access_point")
Example #2
0
    print("Pinning database to only the first server (%.2fs)" % (time.time() - startTime))
    assert r.db(dbName).table(tableName).config() \
        .update({'shards':
            [{'primary_replica':database_server.name, 'replicas':[database_server.name]}]
        }).run(conn)['errors'] == 0
    r.db(dbName).wait().run(conn)
    cluster.check()
    assert [] == list(r.db('rethinkdb').table('current_issues').run(conn))

    sys.stderr.write('before workoad: %s\n' % (repr(list(r.db(dbName).table(tableName).config().run(conn)))))

    print("Starting workload (%.2fs)" % (time.time() - startTime))

    workload_ports = workload_runner.RDBPorts(host=database_server.host, http_port=database_server.http_port, rdb_port=database_server.driver_port, db_name=dbName, table_name=tableName)
    with workload_runner.ContinuousWorkload(opts["workload"], workload_ports) as workload:
        workload.start()

        print("Running workload for 10 seconds (%.2fs)" % (time.time() - startTime))
        time.sleep(10)
        cluster.check()
        assert [] == list(r.db('rethinkdb').table('current_issues').run(conn))

        print("Killing the access server (%.2fs)" % (time.time() - startTime))
        access_server.kill()

        issues = list(r.db('rethinkdb').table('current_issues').run(conn))
        assert len(issues) == 0, 'Issues were raised when server stopped: %s' % repr(issues)

        # Don't bother stopping the workload, just exit and it will get killed