def compile_set_variables_block(self, block): # pause current thread for 0s test_action = JMX._get_action_block(action_index=1, target_index=0, duration_ms=0) children = etree.Element("hashTree") fmt = "vars.put('%s', %r);" block.config["jsr223"] = [{ "language": "groovy", "execute": "before", "script-text": "\n".join(fmt % (var, expr) for var, expr in iteritems(block.mapping)) }] self.__add_jsr_elements(children, block) return [test_action, children]
def compile_action_block(self, block): """ :type block: ActionBlock :return: """ actions = { 'stop': 0, 'pause': 1, 'stop-now': 2, 'continue': 3, } targets = {'current-thread': 0, 'all-threads': 2} action = actions[block.action] target = targets[block.target] duration = 0 if block.duration is not None: duration = int(block.duration * 1000) test_action = JMX._get_action_block(action, target, duration) children = etree.Element("hashTree") self.__add_jsr_elements(children, block) return [test_action, children]