def prestart(self): super().prestart() # geth is locked to user home home = os.path.expanduser("~") dagfile = os.path.join(home, '.ethash', 'full-R23-0000000000000000') if not os.path.exists(dagfile): raise Exception("Missing DAG {}. run {} makedag 0 {} to initialise ethminer before tests can be run".format( dagfile, self.geth_server, os.path.join(home, '.ethash'))) if self.settings['rpcport'] is None: self.settings['rpcport'] = get_unused_port() if self.settings['node_key'] is None: self.settings['node_key'] = "{:0>64}".format(binascii.b2a_hex(os.urandom(32)).decode('ascii')) if self.settings['ws'] is not None: self.settings['wsport'] = get_unused_port() pub_x, pub_y = privtopub(binascii.a2b_hex(self.settings['node_key'])) pub = encode_int32(pub_x) + encode_int32(pub_y) self.public_key = "{:0>128}".format(binascii.b2a_hex(pub).decode('ascii')) # write chain file write_chain_file(self.version, self.chainfile, self.author, self.difficulty) p = subprocess.Popen([self.geth_server, '--datadir', self.get_data_directory(), 'init', self.chainfile], stdout=subprocess.PIPE, stderr=subprocess.PIPE) outs, errs = p.communicate(timeout=15) with open(os.path.join(self.get_data_directory(), 'keystore', 'UTC--2017-02-06T16-16-34.720321115Z--de3d2d9dd52ea80f7799ef4791063a5458d13913'), 'w') as inf: inf.write('''{"address":"de3d2d9dd52ea80f7799ef4791063a5458d13913","crypto":{"cipher":"aes-128-ctr","ciphertext":"8d6528acfb366722d9c98f64435bb151f5671f9e4623e546cc7206382a1d54f7","cipherparams":{"iv":"de95c854face9aa50686370cc47d6025"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"6baa74518f9cc34575c981e027154e9c714b400710478c587043c900a37a89b8"},"mac":"37b6d35ea394b129f07e9a90a09b8cc1356d731590201e84405f4592013b4333"},"id":"ce658bd4-6910-4eef-aa39-b32000c38ccc","version":3}''')
def prestart(self): os.environ['CASSANDRA_CONF'] = os.path.join(self.base_dir, 'conf') # assign ports to cassandra config_keys = ['rpc_port', 'storage_port', 'ssl_storage_port', 'native_transport_port'] for key in config_keys: if key in self.cassandra_yaml: self.cassandra_yaml[key] = get_unused_port() # replace cassandra-env.sh with open(os.path.join(self.base_dir, 'conf', 'cassandra-env.sh'), 'r+t') as fd: script = re.sub('JMX_PORT="7199"', 'JMX_PORT="%d"' % get_unused_port(), fd.read()) fd.seek(0) fd.write(script) # generate cassandra.yaml with open(os.path.join(self.base_dir, 'conf', 'cassandra.yaml'), 'wt') as fd: fd.write(yaml.dump(self.cassandra_yaml))
def prestart(self): super(ParityServer, self).prestart() if self.settings['rpcport'] is None: self.settings['rpcport'] = get_unused_port() if self.settings['no_dapps'] is False and self.settings[ 'dapps_port'] is None: self.settings['dapps_port'] = get_unused_port() if self.settings['node_key'] is None: self.settings['node_key'] = "{:0>64}".format( binascii.b2a_hex(os.urandom(32)).decode('ascii')) self.public_key = "{:0>128}".format( binascii.b2a_hex( bitcoin.privtopub(binascii.a2b_hex( self.settings['node_key']))[1:]).decode('ascii')) # write chain file write_chain_file(self.version, self.chainfile, self.faucet, self.difficulty)
def prestart(self): super(ParityServer, self).prestart() if self.settings['jsonrpc_port'] is None: self.settings['jsonrpc_port'] = get_unused_port() if self.version < (1, 7, 0) and self.settings[ 'no_dapps'] is False and self.settings['dapps_port'] is None: self.settings['dapps_port'] = get_unused_port() if self.settings['node_key'] is None: self.settings['node_key'] = "{:0>64}".format( binascii.b2a_hex(os.urandom(32)).decode('ascii')) pub_x, pub_y = privtopub(binascii.a2b_hex(self.settings['node_key'])) pub = encode_int32(pub_x) + encode_int32(pub_y) self.public_key = "{:0>128}".format( binascii.b2a_hex(pub).decode('ascii')) # write chain file write_chain_file(self.version, self.chainfile, self.faucet, self.difficulty)
def initialize_database(self): # assign port if networking not disabled if 'port' not in self.my_cnf and 'skip-networking' not in self.my_cnf: self.my_cnf['port'] = get_unused_port() # my.cnf with open(os.path.join(self.base_dir, 'etc', 'my.cnf'), 'wt') as my_cnf: my_cnf.write("[mysqld]\n") for key, value in self.my_cnf.items(): if value: my_cnf.write("%s=%s\n" % (key, value)) else: my_cnf.write("%s\n" % key) # initialize databse if not os.path.exists(os.path.join(self.base_dir, 'var', 'mysql')): args = [ "--defaults-file=%s/etc/my.cnf" % self.base_dir, "--datadir=%s" % self.my_cnf['datadir'] ] mysql_base_dir = self.mysql_install_db if os.path.islink(mysql_base_dir): link = os.readlink(mysql_base_dir) mysql_base_dir = os.path.join(os.path.dirname(mysql_base_dir), link) mysql_base_dir = os.path.normpath(mysql_base_dir) if re.search('[^/]+/mysql_install_db$', mysql_base_dir): args.append( "--basedir=%s" % re.sub('[^/]+/mysql_install_db$', '', mysql_base_dir)) try: mysqld_args = [self.mysqld] + args + ["--initialize-insecure"] mysqld = subprocess.Popen(mysqld_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) mysqld.communicate() if mysqld.returncode: # MySQL < 5.7 install_db_args = [self.mysql_install_db] + args subprocess.Popen(install_db_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate() except Exception as exc: raise RuntimeError("failed to spawn mysql_install_db: %r" % exc)
def prestart(self): os.environ['CASSANDRA_CONF'] = os.path.join(self.base_dir, 'conf') # assign ports to cassandra config_keys = [ 'rpc_port', 'storage_port', 'ssl_storage_port', 'native_transport_port' ] for key in config_keys: if key in self.cassandra_yaml: self.cassandra_yaml[key] = get_unused_port() # replace cassandra-env.sh with open(os.path.join(self.base_dir, 'conf', 'cassandra-env.sh'), 'r+t') as fd: script = re.sub('JMX_PORT="7199"', 'JMX_PORT="%d"' % get_unused_port(), fd.read()) fd.seek(0) fd.write(script) # generate cassandra.yaml with open(os.path.join(self.base_dir, 'conf', 'cassandra.yaml'), 'wt') as fd: fd.write(yaml.dump(self.cassandra_yaml))
def initialize_database(self): # assign port if networking not disabled if 'port' not in self.my_cnf and 'skip-networking' not in self.my_cnf: self.my_cnf['port'] = get_unused_port() # my.cnf with open(os.path.join(self.base_dir, 'etc', 'my.cnf'), 'wt') as my_cnf: my_cnf.write("[mysqld]\n") for key, value in self.my_cnf.items(): if value: my_cnf.write("%s=%s\n" % (key, value)) else: my_cnf.write("%s\n" % key) # initialize databse if not os.path.exists(os.path.join(self.base_dir, 'var', 'mysql')): args = ["--defaults-file=%s/etc/my.cnf" % self.base_dir, "--datadir=%s" % self.my_cnf['datadir']] mysql_base_dir = self.mysql_install_db if os.path.islink(mysql_base_dir): link = os.readlink(mysql_base_dir) mysql_base_dir = os.path.join(os.path.dirname(mysql_base_dir), link) mysql_base_dir = os.path.normpath(mysql_base_dir) if re.search('[^/]+/mysql_install_db$', mysql_base_dir): args.append("--basedir=%s" % re.sub('[^/]+/mysql_install_db$', '', mysql_base_dir)) try: mysqld_args = [self.mysqld] + args + ["--initialize-insecure"] mysqld = subprocess.Popen(mysqld_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) mysqld.communicate() if mysqld.returncode: # MySQL < 5.7 install_db_args = [self.mysql_install_db] + args subprocess.Popen(install_db_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate() except Exception as exc: raise RuntimeError("failed to spawn mysql_install_db: %r" % exc)