def values(self): raise TaurusInternalException("Invalid call")
def viewitems(self): if PY3: raise TaurusInternalException("Invalid call") for item in super(KPISet, self).viewitems(): yield (item[0], self.__getitem__(item[0]))
def _get_resource_stats(self): if not self.monitor: raise TaurusInternalException('Local monitor must be instantiated') return self.monitor.resource_stats()
def check_virtual_display(self): if self.virtual_display: if not self.virtual_display.is_alive(): self.log.info("Virtual display out: %s", self.virtual_display.stdout) self.log.warning("Virtual display err: %s", self.virtual_display.stderr) raise TaurusInternalException("Virtual display failed: %s" % self.virtual_display.return_code)
def _get_http_request(url, label, method, timeout, body, keepalive, files=(), encoding=None, follow_redirects=True, use_random_host_ip=False, host_ips=()): """ Generates HTTP request :type method: str :type label: str :type url: str :rtype: lxml.etree.Element """ proxy = etree.Element("HTTPSamplerProxy", guiclass="HttpTestSampleGui", testclass="HTTPSamplerProxy") proxy.set("testname", label) args = JMX._get_arguments_panel("HTTPsampler.Arguments") if isinstance(body, string_types): JMX.__add_body_from_string(args, body, proxy) elif isinstance(body, dict): JMX.__add_body_from_script(args, body, proxy) elif body: msg = "Cannot handle 'body' option of type %s: %s" raise TaurusInternalException(msg % (type(body), body)) parsed_url = parse.urlparse(url) JMX.__add_hostnameport_2sampler(parsed_url, proxy, url) path = parsed_url.path if parsed_url.query: path += "?" + parsed_url.query proxy.append(JMX._string_prop("HTTPSampler.path", path)) proxy.append(JMX._string_prop("HTTPSampler.method", method)) proxy.append(JMX._bool_prop("HTTPSampler.use_keepalive", keepalive)) proxy.append(JMX._bool_prop("HTTPSampler.follow_redirects", follow_redirects)) proxy.append(JMX._bool_prop("HTTPSampler.auto_redirects", False)) if timeout is not None: proxy.append(JMX._string_prop("HTTPSampler.connect_timeout", timeout)) proxy.append(JMX._string_prop("HTTPSampler.response_timeout", timeout)) if encoding is not None: proxy.append(JMX._string_prop("HTTPSampler.contentEncoding", encoding)) if files: proxy.append(JMX._bool_prop("HTTPSampler.DO_MULTIPART_POST", True)) proxy.append(JMX._bool_prop("HTTPSampler.BROWSER_COMPATIBLE_MULTIPART", True)) files_prop = JMX._element_prop("HTTPsampler.Files", "HTTPFileArgs") files_coll = JMX._collection_prop("HTTPFileArgs.files") for file_dict in files: file_elem = JMX._element_prop(file_dict['path'], "HTTPFileArg") file_elem.append(JMX._string_prop("File.path", file_dict['path'])) file_elem.append(JMX._string_prop("File.paramname", file_dict["param"])) file_elem.append(JMX._string_prop("File.mimetype", file_dict['mime-type'])) files_coll.append(file_elem) files_prop.append(files_coll) proxy.append(files_prop) if use_random_host_ip and host_ips: if len(host_ips) > 1: expr = "${__chooseRandom(%s,randomAddr)}" % ",".join(host_ips) else: expr = host_ips[0] proxy.append(JMX._string_prop("HTTPSampler.ipSource", expr)) return proxy
def visit(self, node): class_name = node.__class__.__name__.lower() visitor = getattr(self, 'visit_' + class_name, None) if visitor is not None: return visitor(node) raise TaurusInternalException("Visitor for class %s not found" % class_name)