def test_02_stressng_class(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address stressng_cmd1 = ("stress-ng --class os --all %s --timeout %s" % (self.stressng_inst_num, self.stressng_timeout)) log.info("stress-ng command is %s" % (stressng_cmd1)) stressng_cmd2 = ("stress-ng --class io --all %s --timeout %s" % (self.stressng_inst_num, self.stressng_timeout)) log.info("stress-ng command is %s" % (stressng_cmd2)) benchmark_helper.configure_stressng_on_vm(self.credentials, ip) thread_helper.start_thread(target=helper.execute_cmd_vm_output, args=( stressng_cmd1, self.credentials, ip, )) thread_helper.start_thread(target=helper.execute_cmd_vm_output, args=( stressng_cmd2, self.credentials, ip, )) thread_helper.join_all() helper.check_vm_health(self.credentials, ip)
def test_13_run_ltp_network(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address vm_ifname = helper.get_vm_net_ifname(domain) [rhost, lhost, ltp_network, ltp_network_rev ] = benchmark_helper.setup_req_LTPNetwork(ip, self.credentials) self.ltp_network_args = (( "RHOST=%s PASSWD=%s NS_DURATION=%s HTTP_DOWNLOAD_DIR=%s FTP_DOWNLOAD_DIR=%s " "FTP_UPLOAD_DIR=%s FTP_UPLOAD_URLDIR=%s IPV4_NETWORK=%s IPV4_NET_REV=%s " "RHOST_IPV4_HOST=%s LHOST_IPV4_HOST=%s LHOST_IFACES=%s RHOST_IFACES=%s " ) % (self.credentials.get('username'), self.credentials.get('password'), const.NS_DURATION, const.HTTP_DOWNLOAD_DIR, const.FTP_DOWNLOAD_DIR, const.FTP_UPLOAD_DIR, const.FTP_UPLOAD_URLDIR, ltp_network, ltp_network_rev, rhost, const.LHOST_IPV4_HOST, self.eth_ifname, vm_ifname)) self.ltp_command = "%s %s%s" % (self.ltp_network_args, const.LTP_DIR, const.LTP_NETWORK_COMMAND) benchmark_helper.run_ltp_on_host(self.log_dir, self.ltp_command, " ")
def test_11_start_vm(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) # Create as many VM(s) specified by num_vm for i in xrange(self.num_vm): # Create a new VM in thread thread_helper.start_thread(target=vm_handle.create_vm, args=("test" + str(i), )) # Wait for threads to finish thread_helper.join_all() log.info("%d VM(s) created" % self.num_vm) # Deque each domain from thread return queue and wait for them to boot for i in xrange(self.num_vm): self.domain_list.append(thread_helper.return_queue.get()) thread_helper.start_thread(target=vm_handle.wait_for_vm_boot, args=( self.domain_list[i], self.credentials, )) thread_helper.join_all() # Store IP of each Vm created in test directory for i in xrange(self.num_vm): vm_handle.vm_liveliness(self.domain_list[i]) self.vm_dir[self.domain_list[i].name()] = vm_handle.ip_address # Check VM health for keys, values in self.vm_dir.items(): helper.check_vm_health(self.credentials, values)
def test_04_check_cpu_mem(self): for i in range(self.num_vcpus, self.max_vcpus): self.num_vcpus = i log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address mem = helper.check_vm_mem(self.credentials, ip) log.info("Total memory inside VM is %s" % mem) difference = int(self.memory) - int(mem) log.info( "Memory difference between provided memory and allocated memory is %s" % difference) tolerence = ((float(self.mem_tolerence) / float(100)) * float(self.memory)) log.info("Memory tolerence value is %s" % tolerence) if difference >= tolerence: raise Exception("Memory difference has exceed tolerence level") cpus = helper.check_vm_cpu_num(self.credentials, ip) log.info("CPUs allocated in VM is %s" % cpus) if self.num_vcpus != cpus: raise Exception( "Number of CPUs provided do not match the number allocated" ) helper.check_vm_health(self.credentials, ip) helper.delete_all_vms(self.hyp_handle) if self.memory <= self.max_mem: self.memory += 1024
def test_01_start_vm(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address helper.check_vm_health(self.credentials, ip)
def test_10_test_kbuild(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address benchmark_helper.cmpl_kernel_on_vm(self.credentials, ip, self.kernel_url, self.kernel_ver, self.krnl_cmp_itr) helper.check_vm_health(self.credentials, ip)
def test_08_test_ltp(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address benchmark_helper.run_ltp_on_vm(self.credentials, ip, self.log_dir, self.ltp_command) benchmark_helper.run_ltp_on_host(self.log_dir, self.ltp_command) helper.check_vm_health(self.credentials, ip)
def test_05_on_off_cpu(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address for i in range(1, self.num_vcpus): helper.check_cpu_offline_vm(str(i), self.credentials, ip) for i in range(1, self.num_vcpus): helper.check_cpu_online_vm(str(i), self.credentials, ip) helper.check_vm_health(self.credentials, ip)
def test_05_on_off_cpu(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address cpu_num = str(random.randint(1, self.num_vcpus - 1)) log.info("CPU%s will be on/off" % cpu_num) for i in range(0, self.on_off_itr): helper.check_cpu_offline_vm(cpu_num, self.credentials, ip) helper.check_cpu_online_vm(cpu_num, self.credentials, ip) helper.check_vm_health(self.credentials, ip)
def test_01_stressng_all(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address stressng_cmd = ("stress-ng -a %s --timeout %s" % (self.stressng_inst_num, self.stressng_timeout)) log.info("stress-ng command is %s" % (stressng_cmd)) benchmark_helper.configure_stressng_on_vm(self.credentials, ip) output = helper.execute_cmd_vm_output(stressng_cmd, self.credentials, ip, root=False) helper.check_vm_health(self.credentials, ip)
def test_01_reboot_vm(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) thread_helper.start_thread(target=vm_handle.wait_for_vm_boot, args=( domain, self.credentials, ), kwargs={'reboot': True}) vm_handle.vm_liveliness(domain) vm_handle.reboot_vm(domain, self.reboot_itr, self.credentials) ip = vm_handle.ip_address helper.check_vm_health(self.credentials, ip) helper.delete_all_vms(self.hyp_handle) thread_helper.join_all()
def test_03_run_iozone(self): log.info("Creating VM") self.vm_args = "--disk path=/opt/tmpfs.img,bus=virtio,perms=rw" vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address log.info("Running Iozone test on host machine") status = benchmark_helper.run_iozone_host(self.log_dir) if not status: raise Exception("Iozone tests failed on host") log.info("Running Iozone test on VM") status = benchmark_helper.run_iozone_vm(self.credentials, self.log_dir, ip) if not status: raise Exception("Iozone tests failed on vm") helper.check_vm_health(self.credentials, ip)
def test_01_run_fio(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address block_list = [] for i in self.block_size.split(","): block_list.append(i) log.info("block list provided is %s" % self.block_size) log.info("Running FIO on host now...") benchmark_helper.run_fio_on_host(self.log_dir, block_list, self.io_pattern, self.runtime) log.info("Running FIO on VM now...") benchmark_helper.run_fio_on_vm(self.credentials, ip, self.log_dir, block_list, self.io_pattern, self.runtime) helper.check_vm_health(self.credentials, ip)
def test_05_run_dd_cmd(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address block_list = [] for i in self.block_size.split(","): block_list.append(int(i)) cmd = ("sudo mkdir -p /mnt/dd-tests") output = helper.execute_cmd_vm_output(cmd, self.credentials, ip) log.info("Command output is %s" % output) for i in block_list: cmd = ( "sudo time dd if=/dev/urandom of=/mnt/dd-tests/test bs=%dM count=10" % i) output = helper.execute_cmd_vm_output(cmd, self.credentials, ip) log.info("Command output is %s" % output) cmd = ("sudo rm -rf /mnt/dd-tests/test") output = helper.execute_cmd_vm_output(cmd, self.credentials, ip) log.info("Command output is %s" % output) helper.check_vm_health(self.credentials, ip)
def test_12_run_iperf(self): log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) # Setup virt-install with tap interface self.vm_args = " --network bridge=%s,model=virtio" % self.bridge_name # Create 2 guests thread_helper.start_thread(target=vm_handle.create_vm, args=("test0", )) thread_helper.start_thread(target=vm_handle.create_vm, args=("test1", )) # Wait for threads to finish thread_helper.join_all() log.info("%d VM(s) created" % self.num_vm) # Configure TAP interface on guests thread_helper.start_thread(target=vm_handle.setup_tap_on_vm, args=( thread_helper.return_queue.get(), self.credentials, ), kwargs={ 'dhcp': self.dhcp, 'tap_type': self.tap_type }) thread_helper.start_thread(target=vm_handle.setup_tap_on_vm, args=( thread_helper.return_queue.get(), self.credentials, ), kwargs={ 'dhcp': self.dhcp, 'tap_type': self.tap_type }) # Wait for threads to finish thread_helper.join_all() # Get domain and IP of guests [domain0, ip0] = thread_helper.return_queue.get() [domain1, ip1] = thread_helper.return_queue.get() # Intll/configure iperf on VMs thread_helper.start_thread( target=benchmark_helper.configure_iperf_on_vm, kwargs={ 'credentials': None, 'ip': ip0, 'domain': domain0 }) thread_helper.start_thread( target=benchmark_helper.configure_iperf_on_vm, kwargs={ 'credentials': None, 'ip': ip1, 'domain': domain1 }) thread_helper.join_all() length_list = [] for i in self.iperf_length_size.split(","): length_list.append(int(i)) udp_bandwidth = self.iperf_bandwidth parallel_val = [False, self.iperf_threads] for par in parallel_val: if self.tap_type == "default": log.info("###########Running iperf between vms###########") iperf_server_ip = ip0 iperf_client_ip = ip1 iperf_server_credentials = domain0 iperf_client_credentials = domain1 traffic_helper.validate_iperf(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, parallel=par, telnet=True) traffic_helper.validate_iperf_udp(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, udp_bandwidth, parallel=par, telnet=True) log.info("Reversing roles") iperf_server_ip = ip1 iperf_client_ip = ip0 iperf_server_credentials = domain1 iperf_client_credentials = domain0 traffic_helper.validate_iperf(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, parallel=par, telnet=True) traffic_helper.validate_iperf_udp(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, udp_bandwidth, parallel=par, telnet=True) if self.tap_type == "host_only": log.info( "###########Running iperf between host and VMs###########") iperf_server_ip = const.TAP_DEFAULT_IP iperf_client_ip = ip1 iperf_server_credentials = False iperf_client_credentials = self.credentials traffic_helper.validate_iperf(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, parallel=par, telnet=False) traffic_helper.validate_iperf_udp(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, udp_bandwidth, parallel=par, telnet=False) log.info("Reversing roles") iperf_server_ip = ip1 iperf_client_ip = const.TAP_DEFAULT_IP iperf_server_credentials = self.credentials iperf_client_credentials = False traffic_helper.validate_iperf(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, parallel=par, telnet=False) traffic_helper.validate_iperf_udp(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, udp_bandwidth, parallel=par, telnet=False) if self.tap_type == "external": ext_host_credentials = { 'username': const.EXT_USERNAME, 'password': const.EXT_PASSWORD } log.info( "###########Running iperf between vm and external host###########" ) iperf_server_ip = ip0 iperf_client_ip = const.EXT_HOST_IP iperf_server_credentials = self.credentials iperf_client_credentials = ext_host_credentials traffic_helper.validate_iperf(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, parallel=par, telnet=False) traffic_helper.validate_iperf_udp(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, udp_bandwidth, parallel=par, telnet=False) log.info("Reversing roles") iperf_server_ip = const.EXT_HOST_IP iperf_client_ip = ip0 iperf_server_credentials = ext_host_credentials iperf_client_credentials = self.credentials traffic_helper.validate_iperf(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, parallel=par, telnet=False) traffic_helper.validate_iperf_udp(iperf_server_credentials, iperf_server_ip, iperf_client_credentials, iperf_client_ip, length_list, udp_bandwidth, parallel=par, telnet=False)
def test_02_network_latency(self): # Create 1 guest log.info("Creating VM") vm_handle = vm.Vminfo(self, self.hyp_handle) domain = vm_handle.create_vm() log.info("VM has been created with name %s", domain.name()) # Wait for guest to boot and get its IP vm_handle.wait_for_vm_boot(domain, self.credentials) vm_handle.vm_liveliness(domain) ip = vm_handle.ip_address # Run network loopback latency test on guest and store result in dictionary self.test_result[ 'Loop-Back'] = benchmark_helper.run_network_latency_test( self.credentials, ip) # Remove guest domain.destroy() domain.undefine() # Setup virt-install with tap interface self.vm_args = " --network bridge=%s,model=virtio" % self.bridge_name # Create 2 guests thread_helper.start_thread(target=vm_handle.create_vm, args=("test0", )) thread_helper.start_thread(target=vm_handle.create_vm, args=("test1", )) # Wait for threads to finish thread_helper.join_all() log.info("%d VM(s) created" % self.num_vm) # Configure TAP interface on guests thread_helper.start_thread(target=vm_handle.setup_tap_on_vm, args=( thread_helper.return_queue.get(), self.credentials, ), kwargs={ 'dhcp': self.dhcp, 'tap_type': self.tap_type }) thread_helper.start_thread(target=vm_handle.setup_tap_on_vm, args=( thread_helper.return_queue.get(), self.credentials, ), kwargs={ 'dhcp': self.dhcp, 'tap_type': self.tap_type }) # Wait for threads to finish thread_helper.join_all() # Get domain and IP of guests [domain0, ip0] = thread_helper.return_queue.get() [domain1, ip1] = thread_helper.return_queue.get() # Run network Virtio latency test on guest and store result in dictionary self.test_result['VirtIO'] = benchmark_helper.run_network_latency_test( self.credentials, ip0, domain=domain1) # Dump result data in file filename = "%s/%s" % (self.log_dir, const.NET_RTT_FILE) with open(filename, 'w') as outfile: outfile.write("\t\t".join(const.NET_RTT_NAMES) + "\n") for test_name, results in self.test_result.items(): for result in results: outfile.write(test_name + "\t\t" + "\t\t".join(result) + "\n") outfile.close()