def Churn(percent_per_minute): num_vaults = len(processes) churn_interval = (60 * 100) / (num_vaults * percent_per_minute) print("Running churn test at a rate of every " + str(churn_interval) + " seconds one node drop and another join") print("press Ctrl-C to stop") stopped = [] for i in range(num_vaults + 2, num_vaults + 5): stopped.append(i) global stop_churn while stop_churn != 'q': time.sleep(churn_interval) if stop_churn != 'q': selected_index = random.choice(processes.keys()) print("node with index : " + str(selected_index) + " is going to stop") KillProc(selected_index) if len(stopped) > 0: selected_join = stopped.pop(random.randint( 0, len(stopped) - 1)) print("node with index : " + str(selected_join) + " is going to join") processes[selected_join] = work(selected_join, utils.GetIp(), None) stopped.append(selected_index) stop_churn = 'g'
def CheckLiveUdpIsOpen(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) host = utils.GetIp() try: # s.connect((host, 5483)) s.bind((host, 5483)) s.shutdown(2) return -1 except: return 0
def DeleteChunk(key_index, chunk_index): prog = utils.GetProg('vault_key_helper') subprocess.call([ prog, '-l3', '-k', str(key_index), '--peer=' + utils.GetIp() + ':5483', '--chunk_index=' + str(chunk_index) ], shell=False, stdout=None, stderr=None)
def TestStoreWithDelete(num, index): prog = utils.GetProg('vault_key_helper') subprocess.call([ prog, '-lw', '-k', str(index), '--peer=' + utils.GetIp() + ':5483', '--chunk_set_count=' + str(num) ], shell=False, stdout=None, stderr=None) raw_input("Press any key to continue")
def VaultMenu(): option = 'a' utils.ResetScreen() while (option != 'm'): procs = PrintVaultMenu() option = input( "Please select an option (m for main QA menu): ").lower() if not ValidOption(procs, option): continue if option == "1": RunBootstrapAndVaultSetup() elif (option == "2"): StartVaultsWithGivenBootstrap() elif (option == "3"): number = GetPositiveNumber( "Please input number of chunks in test: ") index = GetPositiveNumber( "Please input the key_index to be used as client: ") TestStore(number, index) elif (option == "4"): number = GetPositiveNumber( "Please input number of rounds in test: ") index = GetPositiveNumber( "Please input the key_index to be used as client: ") TestStoreWithDelete(number, index) elif (option == "5"): key_index = GetPositiveNumber( "Please input the key_index to be used as client: ") chunk_index = GetPositiveNumber( "Please input the chunk_index to be used as data: ") TestProlonged(key_index, chunk_index) elif (option == "6"): keys_path = input( "Please input the absolute/relative path to the keys_file: ") index = GetPositiveNumber( "Please input the key_index to be used as client: ") num_keys = GetPositiveNumber( "Please input how many keys in the keys_file: ") SaveKeys(utils.GetIp(), keys_path, index, num_keys) elif (option == "7"): churn_rate = GetPositiveNumber( "Please input rate (%% churn per minute): ") Churn(churn_rate) elif (option == "8"): vault_killer.KillLifeStuff() processes.clear()
def StartVaultsWithGivenBootstrap(): number = GetPositiveNumber("Please input number of vaults to run: ") ip = input("Please input ip address of bootstrap machine: ") prog = utils.GetProg('vault_key_helper') print(prog) CreateChunkStores(number) subprocess.call([prog, '-c', '-n', str(int(number) + 3)]) keys_path = input( "Please input the absolute/relative path to the keys_file: ") index = GetPositiveNumber( "Please input the key_index to be used as client: ") num_keys = GetPositiveNumber( "Please input how many keys in the keys_file: ") if SaveKeys(utils.GetIp(), keys_path, index, num_keys) == 0: RunNetwork(int(number) + 3, ip, None) else: input("Could not store keys, giving up! (press any key)")
def SetupNetwork(ip_address, vault_count, user_id): try: vault.RemoveChunkStores(vault_count) bool_result = vault.SanityCheck(vault_count + 2, user_id) if bool_result == False: print "Failed in SanityCheck" return -1 peer = "" if ip_address != None: peer = ip_address else: peer = utils.GetIp() int_result = vault.SaveKeys(peer) if int_result != 0: print "Failed in SaveKeys" return -1 return 0 except Exception as e: print "Failed starting network: ", e return -1