Ejemplo n.º 1
0
 def set_up(self):
     try:
         environment.topo_server_setup()
         utils.wait_procs([t.init_mysql() for t in self.tablets])
         utils.run_vtctl(['CreateKeyspace', self.keyspace])
         utils.run_vtctl([
             'SetKeyspaceShardingInfo', '-force', self.keyspace,
             'keyspace_id', 'uint64'
         ])
         for t in self.tablets:
             t.init_tablet(t.type, keyspace=self.keyspace, shard=t.shard)
         utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace],
                         auto_log=True)
         for t in self.tablets:
             t.create_db('vt_' + self.keyspace)
             t.mquery(t.dbname, create_table)
             t.start_vttablet(wait_for_state=None)
         for t in self.tablets:
             t.wait_for_vttablet_state('SERVING')
         for t in self.tablets:
             if t.type == "master":
                 utils.run_vtctl([
                     'ReparentShard', '-force',
                     self.keyspace + '/' + t.shard, t.tablet_alias
                 ],
                                 auto_log=True)
         utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace],
                         auto_log=True)
         self.vtgate_server, self.vtgate_port = utils.vtgate_start()
         vtgate_client = zkocc.ZkOccConnection(
             "localhost:%u" % self.vtgate_port, "test_nj", 30.0)
         topology.read_topology(vtgate_client)
     except:
         self.shutdown()
         raise
Ejemplo n.º 2
0
 def set_up(self):
   try:
     environment.topo_server_setup()
     utils.wait_procs([t.init_mysql() for t in self.tablets])
     utils.run_vtctl(['CreateKeyspace', self.keyspace])
     utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', self.keyspace, 'keyspace_id', 'uint64'])
     for t in self.tablets:
       t.init_tablet(t.type, keyspace=self.keyspace, shard=t.shard)
     utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace], auto_log=True)
     for t in self.tablets:
       t.create_db('vt_' + self.keyspace)
       t.mquery(t.dbname, create_table)
       t.start_vttablet(wait_for_state=None)
     for t in self.tablets:
       t.wait_for_vttablet_state('SERVING')
     for t in self.tablets:
       if t.type == "master":
         utils.run_vtctl(['ReparentShard', '-force', self.keyspace+'/'+t.shard, t.tablet_alias], auto_log=True)
     utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace], auto_log=True)
     self.vtgate_server, self.vtgate_port = utils.vtgate_start()
     vtgate_client = zkocc.ZkOccConnection("localhost:%u" % self.vtgate_port, "test_nj", 30.0)
     topology.read_topology(vtgate_client)
   except:
     self.shutdown()
     raise
Ejemplo n.º 3
0
 def set_up(self):
   try:
     environment.topo_server().setup()
     utils.wait_procs([t.init_mysql() for t in self.tablets])
     utils.run_vtctl(['CreateKeyspace', self.keyspace])
     utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', self.keyspace, 'keyspace_id', 'uint64'])
     for t in self.tablets:
       t.init_tablet(t.type, keyspace=self.keyspace, shard=t.shard)
     utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace], auto_log=True)
     for t in self.tablets:
       t.create_db('vt_' + self.keyspace)
       t.start_vttablet(
         wait_for_state=None,
         extra_args=['-queryserver-config-schema-reload-time', '1'],
       )
     for t in self.tablets:
       t.wait_for_vttablet_state('SERVING')
     for t in self.tablets:
       if t.type == "master":
         utils.run_vtctl(['ReparentShard', '-force', self.keyspace+'/'+t.shard, t.tablet_alias], auto_log=True)
     utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace], auto_log=True)
     if self.schema:
       utils.run_vtctl(['ApplySchemaKeyspace', '-simple', '-sql', self.schema, self.keyspace])
     if self.vschema:
       if self.vschema[0] == '{':
         utils.run_vtctl(['ApplyVSchema', "-vschema", self.vschema])
       else:
         utils.run_vtctl(['ApplyVSchema', "-vschema_file", self.vschema])
     self.vtgate_server, self.vtgate_port = utils.vtgate_start(cache_ttl='500s', vtport=self.vtgate_port)
     vtgate_client = zkocc.ZkOccConnection("localhost:%u" % self.vtgate_port, "test_nj", 30.0)
     topology.read_topology(vtgate_client)
   except:
     self.shutdown()
     raise
Ejemplo n.º 4
0
def setup_tablets():
    global vtgate_server
    global vtgate_port

    # Start up a master mysql and vttablet
    logging.debug("Setting up tablets")
    utils.run_vtctl(['CreateKeyspace', 'test_keyspace'])
    utils.run_vtctl([
        'SetKeyspaceShardingInfo', '-force', 'test_keyspace', 'keyspace_id',
        'uint64'
    ])
    shard_0_master.init_tablet('master', keyspace='test_keyspace', shard='-80')
    shard_0_replica.init_tablet('replica',
                                keyspace='test_keyspace',
                                shard='-80')
    shard_1_master.init_tablet('master', keyspace='test_keyspace', shard='80-')
    shard_1_replica.init_tablet('replica',
                                keyspace='test_keyspace',
                                shard='80-')

    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

    for t in [
            shard_0_master, shard_0_replica, shard_1_master, shard_1_replica
    ]:
        t.create_db('vt_test_keyspace')
        t.mquery(shard_0_master.dbname, create_vt_insert_test)
        t.mquery(shard_0_master.dbname, create_vt_a)
        t.start_vttablet(wait_for_state=None)

    for t in [
            shard_0_master, shard_0_replica, shard_1_master, shard_1_replica
    ]:
        t.wait_for_vttablet_state('SERVING')

    utils.run_vtctl([
        'ReparentShard', '-force', 'test_keyspace/-80',
        shard_0_master.tablet_alias
    ],
                    auto_log=True)
    utils.run_vtctl([
        'ReparentShard', '-force', 'test_keyspace/80-',
        shard_1_master.tablet_alias
    ],
                    auto_log=True)

    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

    utils.check_srv_keyspace(
        'test_nj', 'test_keyspace', 'Partitions(master): -80 80-\n' +
        'Partitions(replica): -80 80-\n' + 'TabletTypes: master,replica')

    vtgate_server, vtgate_port = utils.vtgate_start()
    vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
                                          "test_nj", 30.0)
    topology.read_topology(vtgate_client)
Ejemplo n.º 5
0
def setup_tablets():
    global vtgate_server
    global vtgate_port

    # Start up a master mysql and vttablet
    logging.debug("Setting up tablets")
    utils.run_vtctl(['CreateKeyspace', KEYSPACE_NAME])
    utils.run_vtctl([
        'SetKeyspaceShardingInfo', '-force', KEYSPACE_NAME, 'keyspace_id',
        'uint64'
    ])
    shard_0_master.init_tablet('master', keyspace=KEYSPACE_NAME, shard='-80')
    shard_0_replica.init_tablet('replica', keyspace=KEYSPACE_NAME, shard='-80')
    shard_1_master.init_tablet('master', keyspace=KEYSPACE_NAME, shard='80-')
    shard_1_replica.init_tablet('replica', keyspace=KEYSPACE_NAME, shard='80-')

    utils.run_vtctl(['RebuildKeyspaceGraph', KEYSPACE_NAME], auto_log=True)

    for t in [
            shard_0_master, shard_0_replica, shard_1_master, shard_1_replica
    ]:
        t.create_db('vt_test_keyspace')
        for create_table in create_tables:
            t.mquery(shard_0_master.dbname, create_table)
        t.start_vttablet(wait_for_state=None)

    for t in [
            shard_0_master, shard_0_replica, shard_1_master, shard_1_replica
    ]:
        t.wait_for_vttablet_state('SERVING')

    utils.run_vtctl([
        'ReparentShard', '-force', KEYSPACE_NAME + '/-80',
        shard_0_master.tablet_alias
    ],
                    auto_log=True)
    utils.run_vtctl([
        'ReparentShard', '-force', KEYSPACE_NAME + '/80-',
        shard_1_master.tablet_alias
    ],
                    auto_log=True)

    utils.run_vtctl(['RebuildKeyspaceGraph', KEYSPACE_NAME], auto_log=True)

    utils.check_srv_keyspace(
        'test_nj', KEYSPACE_NAME, 'Partitions(master): -80 80-\n' +
        'Partitions(replica): -80 80-\n' + 'TabletTypes: master,replica')

    vtgate_server, vtgate_port = utils.vtgate_start()
    # FIXME(shrutip): this should be removed once vtgate_cursor's
    # dependency on topology goes away.
    vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
                                          "test_nj", 30.0)
    topology.read_topology(vtgate_client)
Ejemplo n.º 6
0
def setup_tablets():
    # Start up a master mysql and vttablet
    logging.debug('Setting up tablets')
    utils.run_vtctl(['CreateKeyspace', 'test_keyspace'])
    utils.run_vtctl([
        'SetKeyspaceShardingInfo', '-force', 'test_keyspace', 'keyspace_id',
        'uint64'
    ])
    shard_0_master.init_tablet('master', keyspace='test_keyspace', shard='-80')
    shard_0_replica.init_tablet('replica',
                                keyspace='test_keyspace',
                                shard='-80')
    shard_1_master.init_tablet('master', keyspace='test_keyspace', shard='80-')
    shard_1_replica.init_tablet('replica',
                                keyspace='test_keyspace',
                                shard='80-')

    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

    for t in [
            shard_0_master, shard_0_replica, shard_1_master, shard_1_replica
    ]:
        t.create_db('vt_test_keyspace')
        t.mquery(shard_0_master.dbname, create_vt_insert_test)
        t.mquery(shard_0_master.dbname, create_vt_a)
        t.start_vttablet(wait_for_state=None)

    for t in [
            shard_0_master, shard_0_replica, shard_1_master, shard_1_replica
    ]:
        t.wait_for_vttablet_state('SERVING')

    utils.run_vtctl(
        ['InitShardMaster', 'test_keyspace/-80', shard_0_master.tablet_alias],
        auto_log=True)
    utils.run_vtctl(
        ['InitShardMaster', 'test_keyspace/80-', shard_1_master.tablet_alias],
        auto_log=True)

    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

    utils.check_srv_keyspace(
        'test_nj', 'test_keyspace', 'Partitions(master): -80 80-\n'
        'Partitions(rdonly): -80 80-\n'
        'Partitions(replica): -80 80-\n')

    utils.VtGate().start()
    vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(), 'test_nj', 30.0)
    topology.read_topology(vtgate_client)
Ejemplo n.º 7
0
 def set_up(self):
     try:
         environment.topo_server().setup()
         utils.wait_procs([t.init_mysql() for t in self.tablets])
         utils.run_vtctl(['CreateKeyspace', self.keyspace])
         utils.run_vtctl([
             'SetKeyspaceShardingInfo', '-force', self.keyspace,
             'keyspace_id', 'uint64'
         ])
         for t in self.tablets:
             t.init_tablet(t.type, keyspace=self.keyspace, shard=t.shard)
         utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace],
                         auto_log=True)
         for t in self.tablets:
             t.create_db('vt_' + self.keyspace)
             t.start_vttablet(
                 wait_for_state=None,
                 extra_args=['-queryserver-config-schema-reload-time', '1'],
             )
         for t in self.tablets:
             t.wait_for_vttablet_state('SERVING')
         for t in self.tablets:
             if t.type == "master":
                 utils.run_vtctl([
                     'ReparentShard', '-force',
                     self.keyspace + '/' + t.shard, t.tablet_alias
                 ],
                                 auto_log=True)
         utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace],
                         auto_log=True)
         if self.schema:
             utils.run_vtctl([
                 'ApplySchemaKeyspace', '-simple', '-sql', self.schema,
                 self.keyspace
             ])
         if self.vschema:
             if self.vschema[0] == '{':
                 utils.run_vtctl(['ApplyVSchema', "-vschema", self.vschema])
             else:
                 utils.run_vtctl(
                     ['ApplyVSchema', "-vschema_file", self.vschema])
         self.vtgate_server, self.vtgate_port = utils.vtgate_start(
             cache_ttl='500s')
         vtgate_client = zkocc.ZkOccConnection(
             "localhost:%u" % self.vtgate_port, "test_nj", 30.0)
         topology.read_topology(vtgate_client)
     except:
         self.shutdown()
         raise
Ejemplo n.º 8
0
def setup_tablets():
  global vtgate_server
  global vtgate_port

  # Start up a master mysql and vttablet
  logging.debug("Setting up tablets")
  utils.run_vtctl(['CreateKeyspace', KEYSPACE_NAME])
  utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', KEYSPACE_NAME,
                   'keyspace_id', 'uint64'])
  shard_0_master.init_tablet('master', keyspace=KEYSPACE_NAME, shard='-80')
  shard_0_replica.init_tablet('replica', keyspace=KEYSPACE_NAME, shard='-80')
  shard_1_master.init_tablet('master', keyspace=KEYSPACE_NAME, shard='80-')
  shard_1_replica.init_tablet('replica', keyspace=KEYSPACE_NAME, shard='80-')

  utils.run_vtctl(['RebuildKeyspaceGraph', KEYSPACE_NAME], auto_log=True)

  for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
    t.create_db('vt_test_keyspace')
    for create_table in create_tables:
      t.mquery(shard_0_master.dbname, create_table)
    t.start_vttablet(wait_for_state=None)

  for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
    t.wait_for_vttablet_state('SERVING')

  utils.run_vtctl(['ReparentShard', '-force', KEYSPACE_NAME+'/-80',
                   shard_0_master.tablet_alias], auto_log=True)
  utils.run_vtctl(['ReparentShard', '-force', KEYSPACE_NAME+'/80-',
                   shard_1_master.tablet_alias], auto_log=True)

  utils.run_vtctl(['RebuildKeyspaceGraph', KEYSPACE_NAME],
                   auto_log=True)

  utils.check_srv_keyspace('test_nj', KEYSPACE_NAME,
                           'Partitions(master): -80 80-\n' +
                           'Partitions(replica): -80 80-\n' +
                           'TabletTypes: master,replica')

  vtgate_server, vtgate_port = utils.vtgate_start()
  # FIXME(shrutip): this should be removed once vtgate_cursor's
  # dependency on topology goes away.
  vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
                                        "test_nj", 30.0)
  topology.read_topology(vtgate_client)
Ejemplo n.º 9
0
def setup_tablets():
  global vtgate_server
  global vtgate_port

  # Start up a master mysql and vttablet
  logging.debug("Setting up tablets")
  utils.run_vtctl(['CreateKeyspace', 'test_keyspace'])
  utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', 'test_keyspace',
                   'keyspace_id', 'uint64'])
  shard_0_master.init_tablet('master', keyspace='test_keyspace', shard='-80')
  shard_0_replica.init_tablet('replica', keyspace='test_keyspace', shard='-80')
  shard_1_master.init_tablet('master', keyspace='test_keyspace', shard='80-')
  shard_1_replica.init_tablet('replica', keyspace='test_keyspace', shard='80-')

  utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

  for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
    t.create_db('vt_test_keyspace')
    t.mquery(shard_0_master.dbname, create_vt_insert_test)
    t.mquery(shard_0_master.dbname, create_vt_a)
    t.start_vttablet(wait_for_state=None)

  for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
    t.wait_for_vttablet_state('SERVING')

  utils.run_vtctl(['ReparentShard', '-force', 'test_keyspace/-80',
                   shard_0_master.tablet_alias], auto_log=True)
  utils.run_vtctl(['ReparentShard', '-force', 'test_keyspace/80-',
                   shard_1_master.tablet_alias], auto_log=True)

  utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'],
                   auto_log=True)

  utils.check_srv_keyspace('test_nj', 'test_keyspace',
                           'Partitions(master): -80 80-\n' +
                           'Partitions(replica): -80 80-\n' +
                           'TabletTypes: master,replica')

  vtgate_server, vtgate_port = utils.vtgate_start()
  vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
                                        "test_nj", 30.0)
  topology.read_topology(vtgate_client)
Ejemplo n.º 10
0
def setup_tablets():
  # Start up a master mysql and vttablet
  logging.debug('Setting up tablets')
  utils.run_vtctl(['CreateKeyspace', 'test_keyspace'])
  utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', 'test_keyspace',
                   'keyspace_id', 'uint64'])
  shard_0_master.init_tablet('master', keyspace='test_keyspace', shard='-80')
  shard_0_replica.init_tablet('replica', keyspace='test_keyspace', shard='-80')
  shard_1_master.init_tablet('master', keyspace='test_keyspace', shard='80-')
  shard_1_replica.init_tablet('replica', keyspace='test_keyspace', shard='80-')

  utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

  for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
    t.create_db('vt_test_keyspace')
    t.mquery(shard_0_master.dbname, create_vt_insert_test)
    t.mquery(shard_0_master.dbname, create_vt_a)
    t.start_vttablet(wait_for_state=None)

  for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
    t.wait_for_vttablet_state('SERVING')

  utils.run_vtctl(
      ['InitShardMaster', 'test_keyspace/-80',
       shard_0_master.tablet_alias], auto_log=True)
  utils.run_vtctl(
      ['InitShardMaster', 'test_keyspace/80-',
       shard_1_master.tablet_alias], auto_log=True)

  utils.run_vtctl(
      ['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

  utils.check_srv_keyspace('test_nj', 'test_keyspace',
                           'Partitions(master): -80 80-\n'
                           'Partitions(rdonly): -80 80-\n'
                           'Partitions(replica): -80 80-\n')

  utils.VtGate().start()
  vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(), 'test_nj', 30.0)
  topology.read_topology(vtgate_client)
Ejemplo n.º 11
0
def setup_tablets():
    global vtgate_server
    global vtgate_port

    # Start up a master mysql and vttablet
    logging.debug("Setting up tablets")
    utils.run_vtctl(["CreateKeyspace", "test_keyspace"])
    utils.run_vtctl(["SetKeyspaceShardingInfo", "-force", "test_keyspace", "keyspace_id", "uint64"])
    shard_0_master.init_tablet("master", keyspace="test_keyspace", shard="-80")
    shard_0_replica.init_tablet("replica", keyspace="test_keyspace", shard="-80")
    shard_1_master.init_tablet("master", keyspace="test_keyspace", shard="80-")
    shard_1_replica.init_tablet("replica", keyspace="test_keyspace", shard="80-")

    utils.run_vtctl(["RebuildKeyspaceGraph", "test_keyspace"], auto_log=True)

    for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
        t.create_db("vt_test_keyspace")
        t.mquery(shard_0_master.dbname, create_vt_insert_test)
        t.mquery(shard_0_master.dbname, create_vt_a)
        t.start_vttablet(wait_for_state=None)

    for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
        t.wait_for_vttablet_state("SERVING")

    utils.run_vtctl(["ReparentShard", "-force", "test_keyspace/-80", shard_0_master.tablet_alias], auto_log=True)
    utils.run_vtctl(["ReparentShard", "-force", "test_keyspace/80-", shard_1_master.tablet_alias], auto_log=True)

    utils.run_vtctl(["RebuildKeyspaceGraph", "test_keyspace"], auto_log=True)

    utils.check_srv_keyspace(
        "test_nj",
        "test_keyspace",
        "Partitions(master): -80 80-\n" + "Partitions(replica): -80 80-\n" + "TabletTypes: master,replica",
    )

    vtgate_server, vtgate_port = utils.vtgate_start()
    vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port, "test_nj", 30.0)
    topology.read_topology(vtgate_client)
Ejemplo n.º 12
0
def main():
  env = TestEnv(options)
  if args and args[0] == 'setup':
    env.set_up()
    # prime the vtgate topology cache, so if the topo service goes away
    # when we exit this python script, the cache is already primed.
    vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(), "test_nj",
                                          30.0)
    topology.read_topology(vtgate_client)
    sys.stdout.write(json.dumps({
      "port": utils.vtgate.port,
      }) + "\n")
    sys.stdout.flush()
  elif args and args[0] == 'teardown':
    env.shutdown()
  else:
    env.set_up()
    sys.stdout.write(json.dumps({
      "port": utils.vtgate.port,
      }) + "\n")
    sys.stdout.flush()
    raw_input()
    env.shutdown()
Ejemplo n.º 13
0
def setUpModule():
  global vtgate_server, vtgate_port
  logging.debug("in setUpModule")
  try:
    environment.topo_server().setup()
    setup_topology()

    # start mysql instance external to the test
    global __tablets
    setup_procs = []
    for tablet in __tablets:
      setup_procs.append(tablet.init_mysql())
    utils.wait_procs(setup_procs)
    create_db()
    start_tablets()
    vtgate_server, vtgate_port = utils.vtgate_start()
    # FIXME(shrutip): this should be removed once vtgate_cursor's
    # dependency on topology goes away.
    vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
                                          "test_nj", 30.0)
    topology.read_topology(vtgate_client)
  except:
    tearDownModule()
    raise
Ejemplo n.º 14
0
 def setUp(self):
     self.vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(),
                                                "test_nj", 30.0)
     topology.read_topology(self.vtgate_client)
     self.perform_insert(400)
Ejemplo n.º 15
0
# Parse args
parser = argparse.ArgumentParser()
parser.add_argument('--server', dest='server', default='localhost:15001')
parser.add_argument('--timeout', dest='timeout', type=float, default='10.0')
args = parser.parse_args()

vtgate_addrs = {"_vt": [args.server]}

# Connect
conn = vtgatev2.connect(vtgate_addrs, args.timeout)

# Read topology
# This is a temporary work-around until the VTGate V2 client is topology-free.
topoconn = zkocc.ZkOccConnection(args.server, 'test_cell', args.timeout)
topology.read_topology(topoconn)
topoconn.close()

# Insert something.
print('Inserting into master...')
cursor = conn.cursor(cursorclass, conn, 'test_keyspace', 'master',
                     keyranges=UNSHARDED, writable=True)
cursor.begin()
cursor.execute(
    "INSERT INTO test_table (msg) VALUES (%(msg)s)",
    {'msg': 'V is for speed'})
cursor.commit()


# Read it back from the master.
print('Reading from master...')
Ejemplo n.º 16
0
 def setUp(self):
   self.vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(),
                                              "test_nj", 30.0)
   topology.read_topology(self.vtgate_client)
   self.perform_insert(400)
Ejemplo n.º 17
0
 def setUp(self):
     self.vtgate_client = zkocc.ZkOccConnection(vtgate_socket_file,
                                                "test_nj", 30.0)
     topology.read_topology(self.vtgate_client)
Ejemplo n.º 18
0
 def setUp(self):
   self.vtgate_client = zkocc.ZkOccConnection(vtgate_socket_file,
                                              "test_nj", 30.0)
   topology.read_topology(self.vtgate_client)
Ejemplo n.º 19
0
 def _populate_topo_cache(self):
   topology.read_topology(self.vtgate_client)
Ejemplo n.º 20
0
 def setUp(self):
   self.vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
                                              "test_nj", 30.0)
   topology.read_topology(self.vtgate_client)
   self.perform_insert(400)
Ejemplo n.º 21
0
# Parse args
parser = argparse.ArgumentParser()
parser.add_argument('--server', dest='server', default='localhost:15001')
parser.add_argument('--timeout', dest='timeout', type=float, default='10.0')
args = parser.parse_args()

vtgate_addrs = {"vt": [args.server]}

# Connect
conn = vtgatev2.connect(vtgate_addrs, args.timeout)

# Read topology
# This is a temporary work-around until the VTGate V2 client is topology-free.
topoconn = zkocc.ZkOccConnection(args.server, 'test', args.timeout)
topology.read_topology(topoconn)
topoconn.close()

# Insert something.
print('Inserting into master...')
cursor = conn.cursor('test_keyspace', 'master',
                     keyranges=UNSHARDED, writable=True)
cursor.begin()
cursor.execute(
    "INSERT INTO test_table (msg) VALUES (%(msg)s)",
    {'msg': 'V is for speed'})
cursor.commit()


# Read it back from the master.
print('Reading from master...')
Ejemplo n.º 22
0
 def _populate_topo_cache(self):
     topology.read_topology(self.vtgate_client)
Ejemplo n.º 23
0
 def setUp(self):
     self.vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(),
                                                'test_nj', 30.0)
     topology.read_topology(self.vtgate_client)
Ejemplo n.º 24
0
 def setUp(self):
   self.vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(),
                                              'test_nj', 30.0)
   topology.read_topology(self.vtgate_client)