From dbe0cb1c122c65f8ec85dfd5a22ab8c1ba7eb9cf Mon Sep 17 00:00:00 2001 From: Andrey Pohilko Date: Tue, 6 Oct 2015 17:40:18 +0300 Subject: [PATCH] fix UTG broken by PR #80 --- site/dat/wiki/Changelog.wiki | 1 + .../jmeter/threads/UltimateThreadGroup.java | 18 +++---- .../threads/UltimateThreadGroupTest.java | 48 ++----------------- 3 files changed, 14 insertions(+), 53 deletions(-) diff --git a/site/dat/wiki/Changelog.wiki b/site/dat/wiki/Changelog.wiki index 258d73989..4c4a10b82 100644 --- a/site/dat/wiki/Changelog.wiki +++ b/site/dat/wiki/Changelog.wiki @@ -8,6 +8,7 @@ * fixed permission-denied-error on unix systems in LoadosophiaUploader-reporter when no storeDir is set * bump up Selenium dependency to 2.47.0 * add basic PhantomJS (GhostDriver) capability to Remote WebDriver + * fix UTG broken by PR #80 == 1.3.0 June 30, 2015== * Java 7 or higher required diff --git a/standard/src/kg/apc/jmeter/threads/UltimateThreadGroup.java b/standard/src/kg/apc/jmeter/threads/UltimateThreadGroup.java index 0c41a8752..64d57847e 100644 --- a/standard/src/kg/apc/jmeter/threads/UltimateThreadGroup.java +++ b/standard/src/kg/apc/jmeter/threads/UltimateThreadGroup.java @@ -21,7 +21,9 @@ public class UltimateThreadGroup implements Serializable, TestStateListener { private static final Logger log = LoggingManager.getLoggerForClass(); - public static final String DATA_PROPERTY = "threads_schedule"; + + public static final String DATA_PROPERTY = "ultimatethreadgroupdata"; + public static final String EXTERNAL_DATA_PROPERTY = "threads_schedule"; public static final int START_THREADS_CNT_FIELD_NO = 0; public static final int INIT_DELAY_FIELD_NO = 1; @@ -32,11 +34,9 @@ public class UltimateThreadGroup private PropertyIterator scheduleIT; private int threadsToSchedule; private CollectionProperty currentRecord; - private CollectionProperty overrideProp; public UltimateThreadGroup() { super(); - trySettingLoadFromProperty(); } @Override @@ -71,6 +71,7 @@ protected void scheduleThread(JMeterThread thread, long tgStartTime) { public JMeterProperty getData() { //log.info("getData: "+getProperty(DATA_PROPERTY)); + CollectionProperty overrideProp = getLoadFromExternalProperty(); if (overrideProp != null) { return overrideProp; } @@ -84,9 +85,9 @@ void setData(CollectionProperty rows) { } - private void trySettingLoadFromProperty() { - String loadProp = JMeterUtils.getProperty(DATA_PROPERTY); - log.info("Profile prop: " + loadProp); + private CollectionProperty getLoadFromExternalProperty() { + String loadProp = JMeterUtils.getProperty(EXTERNAL_DATA_PROPERTY); + log.debug("Profile prop: " + loadProp); if (loadProp != null && loadProp.length() > 0) { //expected format : threads_schedule="spawn(1,1s,1s,1s,1s) spawn(2,1s,3s,1s,2s)" log.info("GUI threads profile will be ignored"); @@ -101,9 +102,10 @@ private void trySettingLoadFromProperty() { } } - log.info("Setting threads profile from property " + DATA_PROPERTY + ": " + loadProp); - overrideProp = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY); + log.info("Setting threads profile from property " + EXTERNAL_DATA_PROPERTY + ": " + loadProp); + return JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.EXTERNAL_DATA_PROPERTY); } + return null; } private static void parseChunk(String chunk, PowerTableModel model) { diff --git a/standard/test/kg/apc/jmeter/threads/UltimateThreadGroupTest.java b/standard/test/kg/apc/jmeter/threads/UltimateThreadGroupTest.java index b2a67be0b..6c250bd60 100644 --- a/standard/test/kg/apc/jmeter/threads/UltimateThreadGroupTest.java +++ b/standard/test/kg/apc/jmeter/threads/UltimateThreadGroupTest.java @@ -2,7 +2,6 @@ import kg.apc.emulators.TestJMeterUtils; import kg.apc.jmeter.JMeterPluginsUtils; -import kg.apc.jmeter.timers.VariableThroughputTimer; import org.apache.jmeter.control.LoopController; import org.apache.jmeter.gui.util.PowerTableModel; import org.apache.jmeter.testelement.property.CollectionProperty; @@ -19,46 +18,29 @@ public class UltimateThreadGroupTest { private UltimateThreadGroup instance; private PowerTableModel dataModel; - /** - * - */ + public UltimateThreadGroupTest() { } - /** - * @throws Exception - */ @BeforeClass public static void setUpClass() throws Exception { TestJMeterUtils.createJmeterEnv(); } - /** - * @throws Exception - */ @AfterClass public static void tearDownClass() throws Exception { } - /** - * - */ @Before public void setUp() { instance = new UltimateThreadGroup(); dataModel = getTestModel(); } - /** - * - */ @After public void tearDown() { } - /** - * - */ @Test public void testScheduleThread() { System.out.println("scheduleThread"); @@ -76,9 +58,6 @@ public void testScheduleThread() { assertTrue(thread.getEndTime() > thread.getStartTime()); } - /** - * - */ @Test public void testScheduleThreadAll() { System.out.println("scheduleThreadAll"); @@ -100,16 +79,13 @@ public void testScheduleThreadAll() { public void testSchedule_Prop() { System.out.println("schedule from property"); String threadsSchedule = "spawn(1,1s,1s,1s,1m) spawn(2,1s,3s,1s,2h)"; - JMeterUtils.setProperty(UltimateThreadGroup.DATA_PROPERTY, threadsSchedule); + JMeterUtils.setProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY, threadsSchedule); UltimateThreadGroup instance = new UltimateThreadGroup(); - JMeterUtils.setProperty(UltimateThreadGroup.DATA_PROPERTY, ""); // clear! JMeterProperty result = instance.getData(); + JMeterUtils.setProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY, ""); // clear! assertEquals("[[1, 1, 1, 1, 60], [2, 1, 3, 1, 7200]]", result.toString()); } - /** - * - */ @Test public void testSetData() { System.out.println("setSchedule"); @@ -117,9 +93,6 @@ public void testSetData() { instance.setData(prop); } - /** - * - */ @Test public void testGetData() { System.out.println("getSchedule"); @@ -130,9 +103,6 @@ public void testGetData() { assertEquals(prop.getStringValue(), result.getStringValue()); } - /** - * - */ @Test public void testGetNumThreads() { System.out.println("getNumThreads"); @@ -145,18 +115,12 @@ public void testGetNumThreads() { assertEquals(expResult, result); } - /** - * Test of testStarted method, of class UltimateThreadGroup. - */ @Test public void testTestStarted_0args() { System.out.println("testStarted"); instance.testStarted(); } - /** - * Test of testStarted method, of class UltimateThreadGroup. - */ @Test public void testTestStarted_String() { System.out.println("testStarted"); @@ -164,18 +128,12 @@ public void testTestStarted_String() { instance.testStarted(host); } - /** - * Test of testEnded method, of class UltimateThreadGroup. - */ @Test public void testTestEnded_0args() { System.out.println("testEnded"); instance.testEnded(); } - /** - * Test of testEnded method, of class UltimateThreadGroup. - */ @Test public void testTestEnded_String() { System.out.println("testEnded");