def _get_publish_sampler(request): mqtt = etree.Element("net.xmeter.samplers.PubSampler", guiclass="net.xmeter.gui.PubSamplerUI", testclass="net.xmeter.samplers.PubSampler", testname=request.label) topic_missed = TaurusConfigError( f'Topic is required for request "{request.config}"') mqtt.append( JMX._string_prop("mqtt.topic_name", request.config.get("topic", topic_missed))) mqtt.append(JMX._string_prop("mqtt.qos_level", "0")) mqtt.append(JMX._bool_prop("mqtt.add_timestamp", True)) mqtt.append(JMX._string_prop("mqtt.message_type", "String")) mqtt.append(JMX._string_prop("mqtt.message_type_fixed_length", "1024")) mqtt.append( JMX._string_prop("mqtt.message_to_sent", request.config.get("message", ""))) mqtt.append(JMX._bool_prop("mqtt.retained_message", False)) return mqtt
def _get_subscribe_sampler(request): mqtt = etree.Element("net.xmeter.samplers.SubSampler", guiclass="net.xmeter.gui.SubSamplerUI", testclass="net.xmeter.samplers.SubSampler", testname=request.label) topic_missed = TaurusConfigError( f'Topic is required for request "{request.config}"') time_interval = int(dehumanize_time(request.config.get("time", 1))) mqtt.append( JMX._string_prop("mqtt.topic_name", request.config.get("topic", topic_missed))) mqtt.append(JMX._string_prop("mqtt.qos_level", "0")) mqtt.append(JMX._bool_prop("mqtt.add_timestamp", False)) mqtt.append(JMX._bool_prop("mqtt.debug_response", False)) mqtt.append( JMX._string_prop("mqtt.sample_condition", "specified elapsed time (ms)")) mqtt.append( JMX._string_prop("mqtt.sample_condition_value", str(time_interval * 1000))) return mqtt
def _get_connect_sampler(request): mqtt = etree.Element("net.xmeter.samplers.ConnectSampler", guiclass="net.xmeter.gui.ConnectSamplerUI", testclass="net.xmeter.samplers.ConnectSampler", testname=request.label) mqtt.append( JMX._string_prop("mqtt.server", request.config.get("addr", "127.0.0.1"))) mqtt.append(JMX._string_prop("mqtt.port", "1883")) mqtt.append(JMX._string_prop("mqtt.version", "3.1")) mqtt.append(JMX._string_prop("mqtt.conn_timeout", "10")) mqtt.append(JMX._string_prop("mqtt.protocol", "TCP")) mqtt.append(JMX._string_prop("mqtt.ws_path", "")) mqtt.append(JMX._bool_prop("mqtt.dual_ssl_authentication", False)) mqtt.append(JMX._string_prop("mqtt.clientcert_file_path", "")) mqtt.append(JMX._string_prop("mqtt.clientcert_password", "")) mqtt.append(JMX._string_prop("mqtt.client_id_prefix", "conn_")) mqtt.append(JMX._bool_prop("mqtt.client_id_suffix", True)) mqtt.append(JMX._string_prop("mqtt.conn_keep_alive", "300")) mqtt.append(JMX._string_prop("mqtt.conn_attampt_max", "0")) mqtt.append(JMX._string_prop("mqtt.reconn_attampt_max", "0")) mqtt.append(JMX._string_prop("mqtt.conn_clean_session", "true")) return mqtt
def _gen_wait(self, action, wait_for): action.append( JMX._bool_prop("%swaitSync" % RTE_SAMPLER_, 'sync' in wait_for)) if 'sync' in wait_for: sync_timeout = self.safe_time(wait_for['sync']) action.append( JMX._string_prop("%swaitSyncTimeout" % RTE_SAMPLER_, sync_timeout)) action.append( JMX._bool_prop("%swaitCursor" % RTE_SAMPLER_, 'cursor' in wait_for)) if 'cursor' in wait_for: cursor = wait_for['cursor'] if type(cursor) is unicode: row, column = cursor.split(',') else: row, column = cursor['position'].split(',') action.append( JMX._string_prop("%swaitCursorRow" % RTE_SAMPLER_, row)) action.append( JMX._string_prop("%swaitCursorColumn" % RTE_SAMPLER_, column)) if 'timeout' in cursor: cursor_timeout = self.safe_time(cursor['timeout']) action.append( JMX._string_prop("%swaitCursorTimeout" % RTE_SAMPLER_, cursor_timeout)) action.append( JMX._bool_prop("%swaitSilent" % RTE_SAMPLER_, 'silent' in wait_for)) if 'silent' in wait_for: silent = wait_for['silent'] if type(silent) is unicode: stable_time = self.safe_time(silent) else: stable_time = self.safe_time(silent['stable-time']) action.append( JMX._string_prop("%swaitSilentTime" % RTE_SAMPLER_, stable_time)) if 'timeout' in silent: silent_timeout = self.safe_time(silent['timeout']) action.append( JMX._string_prop("%swaitSilentTimeout" % RTE_SAMPLER_, silent_timeout)) action.append( JMX._bool_prop("%swaitText" % RTE_SAMPLER_, 'text' in wait_for)) if 'text' in wait_for: text = wait_for['text'] if type(text) is unicode: regex = text else: regex = text['regex'] action.append( JMX._string_prop("%swaitTextRegex" % RTE_SAMPLER_, regex)) timeout = self.safe_time(text['timeout']) action.append(JMX._string_prop("%swaitTextTimeout" % RTE_SAMPLER_, timeout)) if \ 'timeout' in text else None if 'search-area' in text: top, left, bot, right = re.findall(r'\d+', text['search-area']) action.append( JMX._string_prop("%swaitTextAreaTop" % RTE_SAMPLER_, top)) action.append( JMX._string_prop("%swaitTextAreaLeft" % RTE_SAMPLER_, left)) action.append( JMX._string_prop("%swaitTextAreaBottom" % RTE_SAMPLER_, bot)) action.append( JMX._string_prop("%swaitTextAreaRight" % RTE_SAMPLER_, right))