本文整理汇总了Python中bzt.jmx.JMX.get方法的典型用法代码示例。如果您正苦于以下问题:Python JMX.get方法的具体用法?Python JMX.get怎么用?Python JMX.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bzt.jmx.JMX
的用法示例。
在下文中一共展示了JMX.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_json_body_app_str
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import get [as 别名]
def test_json_body_app_str(self):
obj = JMeterExecutor()
obj.engine = EngineEmul()
obj.execution.merge({
"scenario": {
"requests": [{
"url": "http://blazedemo.com",
"headers": {"Content-Type": "application/json"},
"body": "{\"store_id\": \"${store_id}\", \"display_name\": \"${display_name}\"}"
}]}})
obj.prepare()
jmx = JMX(obj.original_jmx)
selector = 'elementProp[name="HTTPsampler.Arguments"]>collectionProp'
selector += '>elementProp>stringProp[name="Argument.value"]'
self.assertNotEqual(jmx.get(selector)[0].text.find('store_id'), -1)
示例2: test_jmx_2tg
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import get [as 别名]
def test_jmx_2tg(self):
obj = JMeterExecutor()
obj.engine = EngineEmul()
obj.engine.config[Provisioning.PROV] = 'test'
obj.execution.merge({
"concurrency": 1051,
"ramp-up": 15,
"iterations": 100,
"scenario": {"script": __dir__() + "/../jmx/two_tg.jmx"}
})
obj.prepare()
jmx = JMX(obj.modified_jmx)
selector = 'jmeterTestPlan>hashTree>hashTree>ThreadGroup'
selector += '>stringProp[name=ThreadGroup\.num_threads]'
thr = jmx.get(selector)
self.assertEquals('420', thr[0].text)
self.assertEquals('631', thr[1].text)
示例3: test_jmx_modification_unicode
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import get [as 别名]
def test_jmx_modification_unicode(self):
obj = JMeterExecutor()
obj.engine = EngineEmul()
cfg_selector = ('Home Page>HTTPsampler.Arguments>Arguments.arguments'
'>param>Argument.value')
obj.execution.merge({
"scenario": {
"script": __dir__() + "/../jmx/dummy_plan.jmx",
"modifications": {
"set-prop": {
cfg_selector: u"✓",
}
}
}
})
selector = ("[testname='Home Page']>[name='HTTPsampler.Arguments']"
">[name='Arguments.arguments']>[name='param']>[name='Argument.value']")
obj.prepare()
jmx = JMX(obj.modified_jmx)
self.assertEqual(jmx.get(selector)[0].text, u"✓")
示例4: TestLoadSettingsProcessor
# 需要导入模块: from bzt.jmx import JMX [as 别名]
# 或者: from bzt.jmx.JMX import get [as 别名]
class TestLoadSettingsProcessor(BZTestCase):
def configure(self, jmx_file=None, load=None, settings=None, has_ctg=None):
executor = MockJMeterExecutor(load, settings, has_ctg)
executor.engine.config.merge({Provisioning.PROV: 'local'})
executor.install_required_tools()
self.obj = LoadSettingsProcessor(executor)
if jmx_file:
self.jmx = JMX(jmx_file)
def get_groupset(self, testname=None):
groupset = []
for group in self.obj.tg_handler.groups(self.jmx):
# 'testname == None' means 'get all groups'
if not testname or (testname and group.element.attrib['testname'] == testname):
groupset.append(group)
return groupset
def test_keep_original(self):
self.configure(jmx_file=RESOURCES_DIR + 'jmeter/jmx/threadgroups.jmx')
self.assertEqual(LoadSettingsProcessor.TG, self.obj.tg) # because no duration
self.sniff_log(self.obj.log)
self.obj.modify(self.jmx)
msg = "No iterations/concurrency/duration found, thread group modification is skipped"
self.assertIn(msg, self.log_recorder.debug_buff.getvalue())
groupset = self.get_groupset()
groups = [group.gtype for group in groupset]
self.assertEqual(5, len(set(groups))) # no one group was modified
self.assertEqual("", self.log_recorder.warn_buff.getvalue())
res_values = {}
for group in groupset:
res_values[group.get_testname()] = {
'conc': group.get_concurrency(),
'rate': group.get_rate(),
'duration': group.get_duration(),
'iterations': group.get_iterations()}
self.assertEqual(res_values,
{'TG.01': {'conc': 2, 'duration': 3, 'iterations': 100, 'rate': None},
'CTG.02': {'conc': 3, 'duration': 100, 'iterations': None, 'rate': None},
'STG.03': {'conc': 4, 'duration': None, 'iterations': None, 'rate': None},
'UTG.04': {'conc': 1, 'duration': None, 'iterations': None, 'rate': None},
'ATG.05': {'conc': 1, 'duration': 480, 'iterations': 33, 'rate': 2}})
def test_TG_cs(self):
""" ThreadGroup: concurrency, steps """
self.configure(load={'concurrency': 76, 'steps': 5},
jmx_file=RESOURCES_DIR + 'jmeter/jmx/threadgroups.jmx')
self.assertEqual(LoadSettingsProcessor.TG, self.obj.tg) # because no duration
self.sniff_log(self.obj.log)
self.obj.modify(self.jmx)
msg = 'Getting of concurrency for UltimateThreadGroup not implemented'
self.assertIn(msg, self.log_recorder.warn_buff.getvalue())
msg = "Had to add 1 more threads to maintain thread group proportion"
self.assertIn(msg, self.log_recorder.warn_buff.getvalue())
msg = "Stepping ramp-up isn't supported for regular ThreadGroup"
self.assertIn(msg, self.log_recorder.warn_buff.getvalue())
res_values = {}
for group in self.get_groupset():
self.assertEqual('ThreadGroup', group.gtype)
self.assertEqual("false", group.element.find(".//*[@name='LoopController.continue_forever']").text)
self.assertEqual("-1", group.element.find(".//*[@name='LoopController.loops']").text) # no loop limit
res_values[group.get_testname()] = {'conc': group.get_concurrency(), 'on_error': group.get_on_error()}
self.assertEqual(res_values,
{'TG.01': {'conc': 14, 'on_error': 'startnextloop'},
'CTG.02': {'conc': 21, 'on_error': 'stopthread'},
'STG.03': {'conc': 28, 'on_error': 'stoptest'},
'UTG.04': {'conc': 7, 'on_error': 'stoptestnow'},
'ATG.05': {'conc': 7, 'on_error': 'continue'}})
def test_CTG_crs(self):
""" ConcurrencyThreadGroup: concurrency, ramp-up, steps """
self.configure(load={'concurrency': 71, 'ramp-up': 100, 'steps': 5},
jmx_file=RESOURCES_DIR + 'jmeter/jmx/threadgroups.jmx')
self.assertEqual(LoadSettingsProcessor.CTG, self.obj.tg)
self.sniff_log(self.obj.log)
self.obj.modify(self.jmx)
msg = 'Getting of concurrency for UltimateThreadGroup not implemented'
self.assertIn(msg, self.log_recorder.warn_buff.getvalue())
msg = "1 threads left undistributed due to thread group proportion"
self.assertIn(msg, self.log_recorder.warn_buff.getvalue())
res_values = {}
for group in self.get_groupset():
self.assertEqual(group.gtype, "ConcurrencyThreadGroup")
self.assertEqual("5", group.element.find(".//*[@name='Steps']").text)
self.assertEqual("100", group.element.find(".//*[@name='RampUp']").text)
self.assertEqual("S", group.element.find(".//*[@name='Unit']").text)
self.assertIn(group.element.find(".//*[@name='Hold']").text, ("", "0"))
res_values[group.get_testname()] = {'conc': group.get_concurrency(), 'on_error': group.get_on_error()}
#.........这里部分代码省略.........