def wait_until_up_add_cells(self): import utils # pylint: disable=g-import-not-at-top for cluster in self.clusters.itervalues(): cluster.wait_until_up() # Add entries in global cell list. for cell, cluster in self.clusters.iteritems(): if cell != 'global': utils.run_vtctl_vtctl([ 'AddCellInfo', '-root', '/', '-server_address', cluster.client_addr, cell ])
def wait_until_up_add_cells(self): import utils # pylint: disable=g-import-not-at-top for cluster in self.clusters.itervalues(): cluster.wait_until_up() # Add entries in global cell list. for cell, cluster in self.clusters.iteritems(): if cell != 'global': utils.run_vtctl_vtctl(['AddCellInfo', '-root', '/', '-server_address', cluster.client_addr, cell])
def setup(self, add_bad_host=False): from environment import run, binary_args, vtlogroot # pylint: disable=g-import-not-at-top,g-multiple-import import utils # pylint: disable=g-import-not-at-top self.assign_ports() run(binary_args('zkctl') + [ '-log_dir', vtlogroot, '-zk.cfg', '1@%s:%s' % (self.hostname, self.zk_ports), 'init']) # Create the cell configurations using 'vtctl AddCellInfo' utils.run_vtctl_vtctl(['AddCellInfo', '-root', '/test_nj', '-server_address', self.addr, 'test_nj']) utils.run_vtctl_vtctl(['AddCellInfo', '-root', '/test_ny', '-server_address', self.addr, 'test_ny']) ca_addr = self.addr if add_bad_host: ca_addr += ',does.not.exists:1234' # Use UpdateCellInfo for this one, more coverage. utils.run_vtctl_vtctl(['UpdateCellInfo', '-root', '/test_ca', '-server_address', ca_addr, 'test_ca'])
def setup(self): from environment import run, binary_args, vtlogroot # pylint: disable=g-import-not-at-top,g-multiple-import import utils # pylint: disable=g-import-not-at-top self.assign_ports() run(binary_args('zkctl') + [ '-log_dir', vtlogroot, '-zk.cfg', '1@%s:%s' % (self.hostname, self.zk_ports), 'init']) # Create the cell configurations using 'vtctl AddCellInfo' utils.run_vtctl_vtctl(['AddCellInfo', '-root', '/test_nj', '-server_address', self.addr, 'test_nj']) utils.run_vtctl_vtctl(['AddCellInfo', '-root', '/test_ny', '-server_address', self.addr, 'test_ny']) ca_addr = self.addr # Use UpdateCellInfo for this one, more coverage. utils.run_vtctl_vtctl(['UpdateCellInfo', '-root', '/test_ca', '-server_address', ca_addr, 'test_ca'])
def setup(self, add_bad_host=False): from environment import run, binary_args, vtlogroot # pylint: disable=g-import-not-at-top,g-multiple-import import utils # pylint: disable=g-import-not-at-top self.assign_ports() run(binary_args('zkctl') + [ '-log_dir', vtlogroot, '-zk.cfg', '1@%s:%s' % (self.hostname, self.zk_ports), 'init']) # Create toplevel directories for global ZK, and one per cell. run(binary_args('zk') + ['-server', self.addr, 'touch', '-p', '/global']) run(binary_args('zk') + ['-server', self.addr, 'touch', '-p', '/test_nj']) run(binary_args('zk') + ['-server', self.addr, 'touch', '-p', '/test_ny']) run(binary_args('zk') + ['-server', self.addr, 'touch', '-p', '/test_ca']) # Create the cell configurations using 'vtctl AddCellInfo' utils.run_vtctl_vtctl(['AddCellInfo', '-root', '/test_nj', '-server_address', self.addr, 'test_nj']) utils.run_vtctl_vtctl(['AddCellInfo', '-root', '/test_ny', '-server_address', self.addr, 'test_ny']) ca_addr = self.addr if add_bad_host: ca_addr += ',does.not.exists:1234' utils.run_vtctl_vtctl(['AddCellInfo', '-root', '/test_ca', '-server_address', ca_addr, 'test_ca'])
def setup(self): import environment # pylint: disable=g-import-not-at-top import utils # pylint: disable=g-import-not-at-top self.port_base = environment.reserve_ports(5) self.server_addr = 'localhost:%d' % (self.port_base + 1) # Write our config file. self.config_file = os.path.join(environment.vtdataroot, 'consul.json') config = { 'ports': { 'dns': self.port_base, 'http': self.port_base + 1, 'rpc': self.port_base + 2, 'serf_lan': self.port_base + 3, 'serf_wan': self.port_base + 4, }, } with open(self.config_file, 'w') as fd: fd.write(json.dumps(config)) log_base = os.path.join(environment.vtlogroot, 'consul') self.proc = utils.run_bg([ 'consul', 'agent', '-dev', '-config-file', self.config_file], stdout=open(log_base + '.stdout', 'a'), stderr=open(log_base + '.stderr', 'a')) # Wait until the daemon is ready. utils.curl( 'http://' + self.server_addr + '/v1/kv/?keys', retry_timeout=10) # Create the cell configurations using 'vtctl AddCellInfo' for cell in ['test_nj', 'test_ny', 'test_ca']: utils.run_vtctl_vtctl(['AddCellInfo', '-root', cell, '-server_address', self.server_addr, cell])