FSchumacher commented on a change in pull request #638:
URL: https://github.com/apache/jmeter/pull/638#discussion_r543637667
##########
File path:
src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltSampler.java
##########
@@ -135,12 +146,25 @@ private String request() {
.append(getCypher())
.append("\n")
.append("Parameters: \n")
- .append(getParams());
+ .append(getParams())
+ .append("\n")
+ .append("Database: \n")
+ .append(getDatabase())
+ .append("\n")
+ .append("Access Mode: \n")
+ .append(getAccessMode());
return request.toString();
}
private String response(Result result) {
StringBuilder response = new StringBuilder();
+ List<Record> records;
+ if (isRecordQueryResults()) {
+ //get records already as consume() will exhaust the stream
+ records = result.list();
+ } else {
+ records = null;
Review comment:
Would an empty List work here, too? (`Collections#emptyList()`) That
way, we would not have to deal with a null pointer later.
##########
File path:
src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/AbstractBoltTestElement.java
##########
@@ -48,4 +84,27 @@ public boolean isRecordQueryResults() {
public void setRecordQueryResults(boolean recordQueryResults) {
this.recordQueryResults = recordQueryResults;
}
+
+ //returns a SessionConfig object that can be passed to the driver session
+ public SessionConfig getSessionConfig() {
+ SessionConfig.Builder sessionConfigBuilder = SessionConfig.builder()
+ .withDefaultAccessMode(Enum.valueOf(AccessMode.class,
getAccessMode()));
+
+ if (database != null && !"".equals(database)) {
Review comment:
You could probably use `StringUtils#isNotBlank(String)` to make
intention more clear.
##########
File path:
src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/AbstractBoltTestElement.java
##########
@@ -17,13 +17,49 @@
package org.apache.jmeter.protocol.bolt.sampler;
+import java.time.Duration;
+
import org.apache.jmeter.testelement.AbstractTestElement;
+import org.neo4j.driver.AccessMode;
+import org.neo4j.driver.SessionConfig;
+import org.neo4j.driver.TransactionConfig;
public abstract class AbstractBoltTestElement extends AbstractTestElement {
private String cypher;
private String params;
+ private String database;
+ private String accessMode;
private boolean recordQueryResults;
+ private int txTimeout;
+
+ public int getTxTimeout() {
+ return txTimeout;
+ }
+
+ public void setTxTimeout(int txTimeout) {
+ this.txTimeout = txTimeout;
+ }
+
+ public String getAccessMode() {
+ if (accessMode != null) {
+ return accessMode;
+ } else {
+ return "WRITE";
+ }
+ }
+
+ public void setAccessMode(String accessMode) {
+ this.accessMode = accessMode;
Review comment:
Should we check this against the available access modes from the driver?
##########
File path:
src/protocol/bolt/src/main/java/org/apache/jmeter/protocol/bolt/sampler/BoltTestElementBeanInfoSupport.java
##########
@@ -45,5 +47,23 @@ protected BoltTestElementBeanInfoSupport(Class<? extends
TestBean> beanClass) {
propertyDescriptor = property("recordQueryResults");
propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE);
propertyDescriptor.setValue(DEFAULT, Boolean.FALSE);
+
+ propertyDescriptor = property("accessMode",
TypeEditor.ComboStringEditor);
+ propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ propertyDescriptor.setValue(NOT_EXPRESSION, Boolean.TRUE);
+ propertyDescriptor.setValue(DEFAULT, AccessMode.WRITE.toString());
+ propertyDescriptor.setValue(TAGS, getListAccessModes());
+
+ propertyDescriptor = property("database",
TypeEditor.ComboStringEditor);
+ propertyDescriptor.setValue(DEFAULT, "neo4j");
+
+ propertyDescriptor = property("txTimeout");
+ propertyDescriptor.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ propertyDescriptor.setValue(DEFAULT, "60");
+ }
+
+ private String[] getListAccessModes() {
+ String[] list = {AccessMode.READ.toString(),
AccessMode.WRITE.toString()};
Review comment:
Could be returned directly.
##########
File path:
src/protocol/bolt/src/main/resources/org/apache/jmeter/protocol/bolt/sampler/BoltSamplerResources.properties
##########
@@ -17,9 +17,16 @@
displayName=Bolt Request
query.displayName=Query
+options.displayName=Options
cypher.displayName=Cypher Statement
cypher.shortDescription=Cypher Statement
params.displayName=Params
params.shortDescription=Params
recordQueryResults.displayName=Record Query Results
recordQueryResults.shortDescription=Records the results of queries and
displays in listeners such as View Results Tree, this iterates through the
entire resultset. Use to debug only.
+accessMode.displayName=Access Mode
+accessMode.shortDescription=Whether it's a READ or WRITE query (affects query
routing in clusters)
+database.displayName=Database
+database.shortDescription=Neo4j 4.x : database to query (leave empty for 3.5)
Review comment:
There should not be a space in front of the colon in the English
translations. You can certainly add it for the French translation :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]