def main(): cpus = 1 memory = 1024 Bdisksize = 10 no_of_disks = 0 data_disksize = 0 vm_specs = [no_of_disks, data_disksize, Bdisksize, memory, cpus] sys.path.append(os.getcwd()) from performance_testing.utils import utils ccl = j.clients.osis.getNamespace("cloudbroker") pcl = j.clients.portal.getByInstance("main") scl = j.clients.osis.getNamespace("system") USERNAME = "******" email = "*****@*****.**" % str(uuid.uuid4())[0:8] utils.create_user(USERNAME, email, pcl, scl) ACCOUNTNAME = str(uuid.uuid4())[0:8] accountId = utils.create_account(USERNAME, email, ACCOUNTNAME, ccl, pcl) current_stack = ccl.stack.search( {"referenceId": str(j.application.whoAmI.nid), "gid": j.application.whoAmI.gid} )[1] stacks = utils.get_stacks(ccl) loc = ccl.location.search({})[1]["locationCode"] cs_No = 1 while True: for stackid in stacks: if stackid == current_stack["id"]: continue print("Creating cloudspace No.%s ..." % cs_No) cloudspaceId = pcl.actors.cloudapi.cloudspaces.create( accountId=accountId, location=loc, name="CS%s" % cs_No, access=USERNAME ) print(" |--Deploying cloudspace...") try: pcl.actors.cloudbroker.cloudspace.deployVFW(cloudspaceId) cloudspace = ccl.cloudspace.get(cloudspaceId).dump() except: print(" |-- No more cloudspaces can be created") return [[cpus, memory, Bdisksize, cs_No]] try: utils.create_machine_onStack( stackid, cloudspace, 0, ccl, pcl, scl, vm_specs, cs_publicport=0, Res_dir="wait_for_VMIP", ) cs_No += 1 except: print(" |--failed to create the machine") return [[cpus, memory, Bdisksize, cs_No]]
def main(snapshots_number): cpu = 1 memory = 512 Bdisksize = 10 no_of_disks = 0 data_disksize = 0 vm_specs = [no_of_disks, data_disksize, Bdisksize, memory, cpu] ccl = j.clients.osis.getNamespace("cloudbroker") pcl = j.clients.portal.getByInstance("main") scl = j.clients.osis.getNamespace("system") j.do.execute("apt-get install sshpass") sys.path.append(os.getcwd()) from performance_testing.utils import utils USERNAME = "******" email = "*****@*****.**" % str(uuid.uuid4())[0:8] utils.create_user(USERNAME, email, pcl, scl) ACCOUNTNAME = str(uuid.uuid4())[0:8] accountId = utils.create_account(USERNAME, email, ACCOUNTNAME, ccl, pcl) cloudspace = utils.create_cloudspace(accountId, USERNAME, ccl, pcl) cloudspace_publicport = 9000 current_stack = ccl.stack.search({ "referenceId": str(j.application.whoAmI.nid), "gid": j.application.whoAmI.gid })[1] stacks = utils.get_stacks(ccl) stacks.remove(current_stack["id"]) stackid = stacks[0] print( "A new machine will be created on the node with stackId:%s" % stackid ) #################################################################3 name of the vm [machineId, cloudspace_publicip] = utils.create_machine_onStack( stackid, cloudspace, "_unlimited_snapshotvm", ccl, pcl, scl, vm_specs, cloudspace_publicport, Res_dir="test_res", ) machine = pcl.actors.cloudapi.machines.get(machineId) account = machine["accounts"][0] for i in range(snapshots_number): utils.writefile_on_vm( account, cloudspace_publicip, cloudspace_publicport, "snapshot%s.txt" % (i + 1), ) time.sleep(6) # utils.run_again_if_failed(pcl.actors.cloudapi.machines.stop, machineId=machineId) print(" |--creating snapshot No.%s ..." % (i + 1)) try: pcl.actors.cloudapi.machines.snapshot(machineId=machineId, name="snapshot%s" % (i + 1)) snapshots = pcl.actors.cloudapi.machines.listSnapshots( machineId=machineId) print("snapshots length: %s" % len(snapshots)) except: snapshots = utils.run_again_if_failed( pcl.actors.cloudapi.machines.listSnapshots, machineId=machineId) print("snapshots length: %s" % len(snapshots)) continue time.sleep(5) # utils.run_again_if_failed(pcl.actors.cloudapi.machines.start, machineId=machineId) # time.sleep(20) print("Rolling back to snapshot No.%s ..." % (snapshots_number - 1)) utils.run_again_if_failed(pcl.actors.cloudapi.machines.stop, machineId=machineId) snapshots = pcl.actors.cloudapi.machines.listSnapshots(machineId=machineId) snapshots.sort() utils.run_again_if_failed( pcl.actors.cloudapi.machines.rollbackSnapshot, machineId=machineId, epoch=snapshots[snapshots_number - 2]["epoch"], ) utils.run_again_if_failed(pcl.actors.cloudapi.machines.start, machineId=machineId) time.sleep(30) connection = j.remote.cuisine.connect( cloudspace_publicip, cloudspace_publicport, account["password"], account["login"], ) count_snapshots = connection.run("ls -1 | wc -l") j.do.execute('ssh-keygen -f "/root/.ssh/known_hosts" -R [%s]:%s' % (cloudspace_publicip, cloudspace_publicport)) return count_snapshots
def main(): config = ConfigParser.ConfigParser() config.read( "functional_testing/Openvcloud/compute_node_hosted/6_vm_live_migration_test/parameters.cfg" ) cpu = int(config.get("parameters", "cpu")) memory = int(config.get("parameters", "memory")) Bdisksize = int(config.get("parameters", "Bdisksize")) no_of_disks = 0 data_disksize = 0 vm_specs = [no_of_disks, data_disksize, Bdisksize, memory, cpu] ccl = j.clients.osis.getNamespace('cloudbroker') pcl = j.clients.portal.getByInstance('main') scl = j.clients.osis.getNamespace('system') j.do.execute('apt-get install sshpass') sys.path.append(os.getcwd()) from performance_testing.utils import utils USERNAME = '******' email = "*****@*****.**" % str(uuid.uuid4())[0:8] utils.create_user(USERNAME, email, pcl, scl) ACCOUNTNAME = str(uuid.uuid4())[0:8] accountId = utils.create_account(USERNAME, email, ACCOUNTNAME, ccl, pcl) cloudspace = utils.create_cloudspace(accountId, USERNAME, ccl, pcl) cloudspace_publicport = 6000 current_stack = ccl.stack.search({ 'referenceId': str(j.application.whoAmI.nid), 'gid': j.application.whoAmI.gid })[1] stacks = utils.get_stacks(ccl) stacks.remove(current_stack['id']) stackid = stacks[0] print('A new machine will be created on the node with stackId:%s' % stackid) [machineId, cloudspace_publicip] = utils.create_machine_onStack(stackid, cloudspace, 0, ccl, pcl, scl, vm_specs, cloudspace_publicport, Res_dir='test_res') machine = pcl.actors.cloudapi.machines.get(machineId) account = machine['accounts'][0] try: if not j.system.net.waitConnectionTest(cloudspace_publicip, cloudspace_publicport, 40): print 'Could not connect to VM over public interface' else: connection = j.remote.cuisine.connect(cloudspace_publicip, cloudspace_publicport, account['password'], account['login']) connection.fabric.state.output["running"] = False connection.fabric.state.output["stdout"] = False connection.user(account['login']) connection.apt_get('update') connection.apt_get('install fio') j.do.execute( 'sshpass -p%s scp -o \'StrictHostKeyChecking=no\' -P %s functional_testing/Openvcloud/compute_node_hosted/6_vm_live_migration_test/machine_script.py %s@%s:' % (account['password'], cloudspace_publicport, account['login'], cloudspace_publicip)) j.do.execute( 'sshpass -p%s scp -o \'StrictHostKeyChecking=no\' -P %s functional_testing/Openvcloud/compute_node_hosted/6_vm_live_migration_test/check_script.py %s@%s:' % (account['password'], cloudspace_publicport, account['login'], cloudspace_publicip)) network.disconnect_all() processes = [] for i in range(2): if i == 0: p = multiprocessing.Process(target=utils.run_script, args=(account, cloudspace_publicip, cloudspace_publicport, 'test1')) processes.append(p) else: p = multiprocessing.Process(target=pcl.actors.cloudbroker. machine.moveToDifferentComputeNode, args=(machineId, 'Testing', stacks[1], False)) processes.append(p) for l in range(len(processes)): if l == 0: print('started writing a file on the created machine ...') processes[l].start() if l == 1: time.sleep(7) machine_db = ccl.vmachine.get(machineId) if machine_db.status == 'RUNNING' and machine_db.stackId == stacks[ 1]: print( 'The VM have been successfully installed on other node with approximately no downtime during live migration' ) else: print( 'A high downtime (more than 7 secs) have been noticed') return None time.sleep(15) if l == 0: print('Machine will be moved to the node with stackId:%s' % stacks[1]) for k in range(len(processes)): processes[k].join() network.disconnect_all() print('writing a second file to compare with ...') utils.run_script(account, cloudspace_publicip, cloudspace_publicport, 'test2') network.disconnect_all() print('checking if there is no data loss ...') test_result = utils.check_script(account, cloudspace_publicip, cloudspace_publicport, 'test1.1.0', 'test2.1.0') if test_result != 'Two files are identical': print('There is a data loss') j.do.execute('ssh-keygen -f "/root/.ssh/known_hosts" -R [%s]:%s' % (cloudspace_publicip, cloudspace_publicport)) return test_result finally: j.do.execute('ssh-keygen -f "/root/.ssh/known_hosts" -R [%s]:%s' % (cloudspace_publicip, cloudspace_publicport))
def main(): config = ConfigParser.ConfigParser() config.read( "functional_testing/Openvcloud/compute_node_hosted/8_node_maintenance_test/parameters.cfg" ) cpu = int(config.get("parameters", "cpu")) memory = int(config.get("parameters", "memory")) Bdisksize = int(config.get("parameters", "Bdisksize")) no_of_disks = 0 data_disksize = 0 vm_specs = [no_of_disks, data_disksize, Bdisksize, memory, cpu] ccl = j.clients.osis.getNamespace('cloudbroker') pcl = j.clients.portal.getByInstance('main') scl = j.clients.osis.getNamespace('system') j.do.execute('apt-get install sshpass') sys.path.append(os.getcwd()) from performance_testing.utils import utils USERNAME = '******' email = "*****@*****.**" % str(uuid.uuid4())[0:8] utils.create_user(USERNAME, email, pcl, scl) ACCOUNTNAME = str(uuid.uuid4())[0:8] accountId = utils.create_account(USERNAME, email, ACCOUNTNAME, ccl, pcl) cloudspace = utils.create_cloudspace(accountId, USERNAME, ccl, pcl) cloudspace_publicport = 8000 current_stack = ccl.stack.search({ 'referenceId': str(j.application.whoAmI.nid), 'gid': j.application.whoAmI.gid })[1] stacks = utils.get_stacks(ccl) stacks.remove(current_stack['id']) stackid = stacks[0] print('A new machine will be created on the node with stackId:%s' % stackid) [machineId, cloudspace_publicip] = utils.create_machine_onStack(stackid, cloudspace, 0, ccl, pcl, scl, vm_specs, cloudspace_publicport, Res_dir='test_res') utils.setup_machine(cloudspace, machineId, cloudspace_publicport, pcl, no_of_disks, 'onlyfio') machine = pcl.actors.cloudapi.machines.get(machineId) account = machine['accounts'][0] j.do.execute( 'sshpass -p%s scp -o \'StrictHostKeyChecking=no\' -P %s functional_testing/Openvcloud/compute_node_hosted/8_node_maintenance_test/machine_script.py %s@%s:' % (account['password'], cloudspace_publicport, account['login'], cloudspace_publicip)) j.do.execute( 'sshpass -p%s scp -o \'StrictHostKeyChecking=no\' -P %s functional_testing/Openvcloud/compute_node_hosted/6_vm_live_migration_test/check_script.py %s@%s:' % (account['password'], cloudspace_publicport, account['login'], cloudspace_publicip)) network.disconnect_all() processes = [] for i in range(2): if i == 0: p = multiprocessing.Process(target=utils.run_script, args=(account, cloudspace_publicip, cloudspace_publicport, 'test1')) processes.append(p) else: gid = ccl.stack.get(ccl.vmachine.get(machineId).stackId).gid p = multiprocessing.Process( target=pcl.actors.cloudbroker.computenode.maintenance, args=(stackid, gid, 'move', 'testing')) processes.append(p) for l in range(len(processes)): if l == 0: print('started writing a file on the created machine ...') processes[l].start() if l == 1: time.sleep(10) machine_db = ccl.vmachine.get(machineId) if machine_db.stackId == stackid: print('VM didn\'t move to another stackId') return [None, stackid, gid] else: if machine_db.status == 'RUNNING': print( 'The VM have been successfully installed on other node with approximately no downtime during cpu node maintenance' ) else: print('A high downtime have been noticed') return [None, stackid, gid] time.sleep(12) if l == 0: print('cpu node with stackid:%s will be put in maintenance ..' % stackid) for k in range(len(processes)): processes[k].join() network.disconnect_all() print('writing a second file to compare with ...') utils.run_script(account, cloudspace_publicip, cloudspace_publicport, 'test2') network.disconnect_all() print('checking if there is no data loss ...') test_result = utils.check_script(account, cloudspace_publicip, cloudspace_publicport, 'test1.1.0', 'test2.1.0') if test_result != 'Two files are identical': print('There is a data loss') j.do.execute('ssh-keygen -f "/root/.ssh/known_hosts" -R [%s]:%s' % (cloudspace_publicip, cloudspace_publicport)) return [test_result, stackid, gid]
from fabric import network import netaddr import re ccl = j.clients.osis.getNamespace('cloudbroker') pcl = j.clients.portal.getByInstance('main') scl = j.clients.osis.getNamespace('system') j.do.execute('apt-get install sshpass') sys.path.append(os.getcwd()) from performance_testing.utils import utils USERNAME = '******' email = "*****@*****.**" % str(uuid.uuid4())[0:8] utils.create_user(USERNAME, email, pcl, scl) ACCOUNTNAME = str(uuid.uuid4())[0:8] accountId = utils.create_account(USERNAME, email, ACCOUNTNAME, ccl, pcl) cloudspace = utils.create_cloudspace(accountId, USERNAME, ccl, pcl) cloudspace_publicport = 1000 cloudspace_publicIP = str(netaddr.IPNetwork(cloudspace['publicipaddress']).ip) if not j.system.net.waitConnectionTest(cloudspace_publicIP, 9080, 60): print 'Could not connect to VM over public interface' current_stack = ccl.stack.search({ 'referenceId': str(j.application.whoAmI.nid), 'gid': j.application.whoAmI.gid })[1] stacks = utils.get_stacks(ccl) cpu = 2 memory = 2048