Skip to content

Commit

Permalink
Do not ignore Jmeter property for ramp-up
Browse files Browse the repository at this point in the history
  • Loading branch information
matanbanner1 committed Oct 9, 2023
1 parent b6124c8 commit 6abe1a1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions bzt/jmx/threadgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def groups(self, jmx):
if group.get("enabled") != "false":
yield _class(group, self.log)

def convert(self, source, target_gtype, load, concurrency, iterations):
def convert(self, source, target_gtype, load, concurrency, ramp_up, iterations):
"""
Convert a thread group to ThreadGroup/ConcurrencyThreadGroup for applying of load
"""
Expand All @@ -201,7 +201,7 @@ def convert(self, source, target_gtype, load, concurrency, iterations):

new_group_element = JMX.get_thread_group(
concurrency=concurrency,
rampup=load.ramp_up,
rampup=ramp_up,
hold=load.hold,
iterations=iterations if iterations is not None else load.iterations,
testname=source.get_testname(),
Expand All @@ -216,7 +216,7 @@ def convert(self, source, target_gtype, load, concurrency, iterations):

new_group_element = JMX.get_concurrency_thread_group(
concurrency=concurrency,
rampup=load.ramp_up,
rampup=ramp_up,
hold=load.hold,
steps=load.steps,
testname=source.get_testname(),
Expand Down
5 changes: 4 additions & 1 deletion bzt/jmx/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ def modify(self, jmx, is_jmx_generated=False):
existed_tg = (not is_jmx_generated) and (group.gtype == self.TG)
if not self.force_ctg and existed_tg:
iterations = group.get_iterations()

ramp_up = self.load.ramp_up if self.raw_load.ramp_up is not None else group.get_ramp_up()

self.tg_handler.convert(source=group, target_gtype=self.tg, load=self.load,
concurrency=concurrency, iterations=iterations)
concurrency=concurrency, ramp_up=ramp_up, iterations=iterations)
if self.load.throughput:
self._add_shaper(jmx)

Expand Down
7 changes: 6 additions & 1 deletion tests/unit/modules/jmeter/test_JMX.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ def test_TG_prop_cih(self):
self.assertEqual(group.gtype, "ThreadGroup")
self.assertEqual("${__P(c)}", group.element.find(".//*[@name='ThreadGroup.num_threads']").text)
self.assertEqual("${__P(i)}", group.element.find(".//*[@name='LoopController.loops']").text)
self.assertEqual("${__P(h)}", group.element.find(".//*[@name='ThreadGroup.duration']").text)
if group.get_ramp_up() != 0:
duration_comp_exp = "${__intSum(%d,${__P(h)})}" % group.get_ramp_up()
else:
duration_comp_exp = "${__P(h)}"

self.assertEqual(duration_comp_exp, group.element.find(".//*[@name='ThreadGroup.duration']").text)

def test_TG_prop_rh(self):
""" ThreadGroup: properties in ramp-up, hold-for """
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/modules/jmeter/test_JMeterExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ def test_load_overriding(self):
conc = tg.find(".//stringProp[@name='ThreadGroup.num_threads']")
delay = tg.find(".//boolProp[@name='ThreadGroup.delayedStart']")
self.assertEqual(conc.text, '${__P(val_c)}') # concurrency should be saved
self.assertEqual(ramp_up.text, '0') # ramp-up should be removed
self.assertEqual(ramp_up.text, '2') # will not be removed since load.ramp up is 0

delay = delay is not None and delay.text == "true"
self.assertTrue(delay)
Expand Down

0 comments on commit 6abe1a1

Please sign in to comment.