def run(self, result): """execute the benchmark""" if not self.setup_done: self.setup() network_id = op_utils.get_network_id(self.neutron_client, self.external_network) image_id = op_utils.get_image_id(self.glance_client, self.image) flavor_id = op_utils.get_flavor_id(self.nova_client, "yardstick-pinned-flavor") # Create multiple VMs to test CPU ran out LOG.debug("Creating server instance: test_server") json_body = { 'flavor': flavor_id, 'image': image_id, 'nics': [{ "net-id": network_id }], 'name': "test_server" } self.instance = op_utils.create_instance(json_body) status = op_utils.check_status("ERROR", "test_server", 10, 5) if status: LOG.info("Create test_server failed: lack of resources.") else: LOG.info("Create test_server successful.") op_utils.delete_instance(self.nova_client, self.instance.id)
def run(self, result): """execute the benchmark""" network_id = op_utils.get_network_id(self.neutron_client, self.external_network) image_id = op_utils.get_image_id(self.glance_client, self.image) LOG.debug("Creating NUMA-pinned-instance-1...") self.instance = op_utils.create_instance_and_wait_for_active( "yardstick-pinned-flavor", image_id, network_id, instance_name="NUMA-pinned-instance-1") cmd = "virsh dumpxml %s" % self.instance.id LOG.debug("Dumping VM configrations: %s", cmd) status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) pinning = [] root = ET.fromstring(stdout) for memnode in root.iter('memnode'): pinning.append(memnode.attrib) result.update({"pinning": pinning}) # Create multiple VMs to test CPU ran out LOG.debug("Creating NUMA-pinned-instance-2...") self.instance_2 = op_utils.create_instance( "yardstick-pinned-flavor", image_id, network_id, instance_name="NUMA-pinned-instance-2") status = op_utils.check_status("ERROR", "NUMA-pinned-instance-2", 10, 5) if status: print("Create NUMA-pinned-instance-2 failed: lack of resources.") if len(pinning) == 1 and status: result.update({"Test": 1}) print("Test passed!") else: result.update({"Test": 0}) print("Test failed!") op_utils.delete_instance(self.nova_client, self.instance.id) op_utils.delete_instance(self.nova_client, self.instance_2.id)
def test_delete_instance_exception(self, mock_logger): self.mock_shade_client.delete_server.side_effect = ( exc.OpenStackCloudException('error message')) output = openstack_utils.delete_instance(self.mock_shade_client, 'instance_name_id') mock_logger.error.assert_called_once() self.assertFalse(output)
def run(self, result): """execute the test""" if not self.setup_done: self.setup() status = op_utils.delete_instance(self.nova_client, instance_id=self.server_id) if status: LOG.info("Delete server successful!") else: LOG.error("Delete server failed!")
def run(self, result): """execute the benchmark""" network_id = op_utils.get_network_id(self.neutron_client, self.external_network) image_id = op_utils.get_image_id(self.glance_client, self.image) LOG.debug("Creating Virtaul machine: cpu-pinned-instance") self.instance = op_utils.create_instance_and_wait_for_active( "yardstick-pinned-flavor", image_id, network_id, instance_name="cpu-pinned-instance") cmd = "virsh dumpxml %s" % self.instance.id LOG.debug("Dumping VM configrations: %s", cmd) status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) pinning = [] test_status = 1 root = ET.fromstring(stdout) for vcpupin in root.iter('vcpupin'): pinning.append(vcpupin.attrib) for item in pinning: if str(item["cpuset"]) not in self.cpu_set: test_status = 0 print("Test failed: VM CPU not pinned correctly!") break print("Test passed: VM CPU pinned correctly!") result.update({"Test": test_status}) result.update({"pinning": pinning}) op_utils.delete_instance(self.nova_client, self.instance.id)
def run(self, result): """execute the test""" if not self.setup_done: self.setup() status = openstack_utils.delete_instance( self.shade_client, self.server_name_or_id, wait=self.wait, timeout=self.timeout, delete_ips=self.delete_ips, delete_ip_retry=self.delete_ip_retry) if not status: result.update({"delete_server": 0}) LOG.error("Delete server failed!") raise exceptions.ScenarioDeleteServerError result.update({"delete_server": 1}) LOG.info("Delete server successful!")
def test_delete_instance_fail(self): self.mock_shade_client.delete_server.return_value = False output = openstack_utils.delete_instance(self.mock_shade_client, 'instance_name_id') self.assertFalse(output)
def run(self, result): """execute the benchmark""" # flavor1 network_id = op_utils.get_network_id(self.neutron_client, self.external_network) image_id = op_utils.get_image_id(self.glance_client, self.image) free_mem_before = self._check_compute_node_free_hugepage( self.compute_node_name[0]) self.instance = op_utils.create_instance_and_wait_for_active( self.flavor1, image_id, network_id, instance_name="hugepages-2M-VM") free_mem_after = self._check_compute_node_free_hugepage( self.compute_node_name[0]) LOG.debug("free_mem_before: %s, after: %s", free_mem_before, free_mem_after) op_utils.delete_instance(self.nova_client, self.instance.id) result.update({ "hugepagesz-2M": self._pof(free_mem_before == free_mem_after + 512) }) result.update({"2M-free-mem_before": free_mem_before}) result.update({"2M-free-mem_after": free_mem_after}) # flavor2 network_id = op_utils.get_network_id(self.neutron_client, self.external_network) LOG.debug("self.external_network: %s, self.image: %s, flavor:%s", self.external_network, self.image, self.flavor1) image_id = op_utils.get_image_id(self.glance_client, self.image) free_mem_before = self._check_compute_node_free_hugepage( self.compute_node_name[1]) # config hugepages to be 1G and reboot status, stdout, stderr = self.client.execute( "sudo bash hugepages_config.sh") # wait to reeboot LOG.info("node restarting... wait 120s") time.sleep(120) LOG.info("node restarting... wait ends") self._ssh_host(self.compute_node_name[1]) self.instance = op_utils.create_instance_and_wait_for_active( self.flavor2, image_id, network_id, instance_name="hugepages-1G-VM") free_mem_after = self._check_compute_node_free_hugepage( self.compute_node_name[1]) LOG.debug("free_mem_before: %s, after: %s", free_mem_before, free_mem_after) op_utils.delete_instance(self.nova_client, self.instance.id) result.update({ "hugepagesz-1G": self._pof(free_mem_before == free_mem_after + 1) }) result.update({"1G-free-mem_before": free_mem_before}) result.update({"1G-free-mem_after": free_mem_after})