Skip to content

Commit

Permalink
fix UTG broken by PR #80
Browse files Browse the repository at this point in the history
  • Loading branch information
undera committed Oct 6, 2015
1 parent 140e865 commit dbe0cb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 53 deletions.
1 change: 1 addition & 0 deletions site/dat/wiki/Changelog.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -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 <i><font color=gray size="1">June 30, 2015</font></i>==
* Java 7 or higher required
Expand Down
18 changes: 10 additions & 8 deletions standard/src/kg/apc/jmeter/threads/UltimateThreadGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,11 +34,9 @@ public class UltimateThreadGroup
private PropertyIterator scheduleIT;
private int threadsToSchedule;
private CollectionProperty currentRecord;
private CollectionProperty overrideProp;

public UltimateThreadGroup() {
super();
trySettingLoadFromProperty();
}

@Override
Expand Down Expand Up @@ -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;
}
Expand All @@ -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");
Expand All @@ -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) {
Expand Down
48 changes: 3 additions & 45 deletions standard/test/kg/apc/jmeter/threads/UltimateThreadGroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand All @@ -76,9 +58,6 @@ public void testScheduleThread() {
assertTrue(thread.getEndTime() > thread.getStartTime());
}

/**
*
*/
@Test
public void testScheduleThreadAll() {
System.out.println("scheduleThreadAll");
Expand All @@ -100,26 +79,20 @@ 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");
CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
instance.setData(prop);
}

/**
*
*/
@Test
public void testGetData() {
System.out.println("getSchedule");
Expand All @@ -130,9 +103,6 @@ public void testGetData() {
assertEquals(prop.getStringValue(), result.getStringValue());
}

/**
*
*/
@Test
public void testGetNumThreads() {
System.out.println("getNumThreads");
Expand All @@ -145,37 +115,25 @@ 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");
String host = "";
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");
Expand Down

0 comments on commit dbe0cb1

Please sign in to comment.