Skip to content

Commit

Permalink
enhance jmeter variables (nebula-contrib#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisChu authored Jul 21, 2021
1 parent 898b729 commit 275a08e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 32 deletions.
50 changes: 26 additions & 24 deletions ldbc/jmx/go_step.jmx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
<collectionProp name="Arguments.arguments" />
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
Expand All @@ -18,54 +18,55 @@
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">-1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">{nums}</stringProp>
<stringProp name="ThreadGroup.num_threads">{nums}</stringProp>
<stringProp name="ThreadGroup.ramp_time">0</stringProp>
<boolProp name="ThreadGroup.scheduler">true</boolProp>
<stringProp name="ThreadGroup.duration">{duration}</stringProp>
<stringProp name="ThreadGroup.duration">{duration}</stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>
<hashTree>
<JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Java Request" enabled="true">
<elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="hosts" elementType="Argument">
<collectionProp name="Arguments.arguments">
<elementProp name="hosts" elementType="Argument">
<stringProp name="Argument.name">hosts</stringProp>
<stringProp name="Argument.value"></stringProp>
<stringProp name="Argument.value">{hosts}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="maxconn" elementType="Argument">
</elementProp>
<elementProp name="maxconn" elementType="Argument">
<stringProp name="Argument.name">maxconn</stringProp>
<stringProp name="Argument.value">10</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="user" elementType="Argument">
</elementProp>
<elementProp name="user" elementType="Argument">
<stringProp name="Argument.name">user</stringProp>
<stringProp name="Argument.value"></stringProp>
<stringProp name="Argument.value">{user}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</elementProp>
<elementProp name="pwd" elementType="Argument">
<stringProp name="Argument.name">pwd</stringProp>
<stringProp name="Argument.value"></stringProp>
<stringProp name="Argument.value">{pwd}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="var2" elementType="Argument">
<elementProp name="space" elementType="Argument">
<stringProp name="Argument.name">space</stringProp>
<stringProp name="Argument.value">ldbc</stringProp>
<stringProp name="Argument.value">{space}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>

<elementProp name="person" elementType="Argument">
<stringProp name="Argument.name">person</stringProp>
<stringProp name="Argument.value">${person}</stringProp>
<elementProp name="var2" elementType="Argument">
<stringProp name="Argument.name">var2</stringProp>
<stringProp name="Argument.value">${c2}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>

<elementProp name="nGQL" elementType="Argument">
<stringProp name="Argument.name">nGQL</stringProp>
<stringProp name="Argument.value">GO 3 STEP FROM "replace" OVER knows</stringProp>
<stringProp name="Argument.value">GO 3 STEP FROM var2 OVER knows</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</collectionProp>

</elementProp>
<stringProp name="classname">com.vesoft.LdbcGoStep</stringProp>
Expand All @@ -80,11 +81,12 @@
<boolProp name="recycle">true</boolProp>
<stringProp name="shareMode">shareMode.all</stringProp>
<boolProp name="stopThread">false</boolProp>
<stringProp name="variableNames">var1,person,var3,var4,var5,var6,var7,var8</stringProp>
</CSVDataSet>`
<hashTree/>
<stringProp name="variableNames">c1,c2,c3,c4,c5,c6,c7,c8</stringProp>
</CSVDataSet>

<hashTree />
</hashTree>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
</jmeterTestPlan>
14 changes: 10 additions & 4 deletions util/LdbcGoStep/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vesoft</groupId>
<artifactId>LdbcGoStep</artifactId>
Expand All @@ -21,7 +20,7 @@
<dependency>
<groupId>com.vesoft</groupId>
<artifactId>client</artifactId>
<version>2.0.0</version>
<version>2.0.0-SNAPSHOT</version>

</dependency>
<dependency>
Expand Down Expand Up @@ -49,6 +48,13 @@
<scope>compile</scope>
</dependency>
</dependencies>

<repositories>
<repository>
<id>snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
<build>
<plugins>
<!-- Maven Assembly Plugin -->
Expand Down Expand Up @@ -80,4 +86,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
13 changes: 9 additions & 4 deletions util/LdbcGoStep/src/main/java/vesoft/LdbcGoStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class LdbcGoStep extends AbstractJavaSamplerClient {
private final Logger log = getNewLogger();
private NebulaPool pool = null;
private Session session = null;
private Integer maxVars = 20;


@Override
Expand Down Expand Up @@ -100,8 +101,7 @@ public void setupTest(JavaSamplerContext javaSamplerContext) {
ResultSet resp = null;
resp = session.execute(use_space);
if (!resp.isSucceeded()) {
System.out.println("Switch space failed:" + space);

System.out.println("Switch space failed:" + space + "\nError is " + resp.getErrorMessage());
System.exit(1);
}
} else {
Expand All @@ -126,9 +126,14 @@ public void setupTest(JavaSamplerContext javaSamplerContext) {

@Override
public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
String person = javaSamplerContext.getParameter("person");
String nGQL = javaSamplerContext.getParameter("nGQL");
nGQL = nGQL.replace("replace", person);
for (int i=0;i<maxVars;i++){
String var = "var" + String.valueOf(i);
String value = javaSamplerContext.getParameter(var);
if (value != null){
nGQL = nGQL.replace(var, value);
}
}
ResultSet resp = null;
long stamp = System.currentTimeMillis();
long startTime = System.nanoTime();
Expand Down

0 comments on commit 275a08e

Please sign in to comment.