def test_sabotage(): pass """ scenario countering a sysadmin removing files (s)he shouldn't (eta : 16s) """ clu = Common._getCluster() tlog_size = 1000 num_tlogs = 2 test_size = num_tlogs * tlog_size Common.iterate_n_times(test_size, Common.simple_set) time.sleep(10) clu.stop() node_id = Common.node_names[0] node_cfg = clu.getNodeConfig(node_id) node_home_dir = node_cfg ['home'] node_tlf_dir = node_cfg ['tlf_dir'] logging.debug("node_tlf_dir=%s", node_tlf_dir) files = map(lambda x : "%s/%s" % (node_home_dir, x), [ "002.tlog", "%s.db" % (node_id,), #"%s.db.wal" % (node_id,), # should not exist after a `proper` close ]) for f in files: print f X.removeFile(f) cmd = clu._cmd('sturdy_0') returncode = X.subprocess.call(cmd) assert_equals(returncode, 50)
def regenerateClientConfig( cluster_id ): h = '/'.join([X.cfgDir,'arakoonclients']) p = X.getConfig(h) if cluster_id in p.sections(): clusterDir = p.get(cluster_id, "path") clientCfgFile = '/'.join([clusterDir, "%s_client.cfg" % cluster_id]) if X.fileExists(clientCfgFile): X.removeFile(clientCfgFile) client = ArakoonClient.ArakoonClient() cliCfg = client.getClientConfig( cluster_id ) cliCfg.generateFromServerConfig()
def test_issue125(): n = 31234 Common.iterate_n_times(n, Common.simple_set) slave = Common.CONFIG.node_names[1] Common.collapse(slave, 10) Common.stopOne(slave) Common.iterate_n_times(n, Common.simple_set) # others move forward dir_names = Common.build_node_dir_names(slave) db_dir = dir_names[0] log_dir = dir_names[1] tlx_dir = dir_names[2] X.removeFile('%s/035.tlog' % db_dir) X.removeFile('%s/034.tlx' % tlx_dir) X.removeFile('%s/%s.log' % (log_dir, slave)) X.removeFile('%s/%s.db' % (db_dir, slave)) # we have a cluster with head.db, no db and no tlog file. # can we launch ? Common.startOne(slave, ['-autofix']) time.sleep(20) Common.assert_running_nodes(3)
def test_sabotage(): pass """ scenario countering a sysadmin removing files (s)he shouldn't (eta : 16s) """ clu = Common._getCluster() tlog_size = 1000 num_tlogs = 2 test_size = num_tlogs * tlog_size Common.iterate_n_times(test_size, Common.simple_set) time.sleep(10) print "stopping" clu.stop() node_id = Common.node_names[0] node_cfg = clu.getNodeConfig(node_id) node_home_dir = node_cfg ['home'] node_tlf_dir = node_cfg ['tlf_dir'] logging.debug("node_tlf_dir=%s", node_tlf_dir) files = map(lambda x : "%s/%s" % (node_home_dir, x), [ "002.tlog", "%s.db" % (node_id,), #"%s.db.wal" % (node_id,), # should not exist after a `proper` close ]) for f in files: print "removing", f X.removeFile(f) print "starting" cmd = clu._cmd('sturdy_0') print cmd def start_node(): returncode = X.subprocess.call(cmd) assert_equals(returncode, 50) print "startup failure + correct returncode" try: t = threading.Thread(target = start_node) t.start() t.join(10.0) except Exception,e: print e assert_true(False)