I have the following JMeter based Azure Load Test which leverages the external JAR to convert the given JPG into DICOM(Type of file)
Note: The custom JAR(Dicom JAR) works without any issues when tested separately outside JMeter.
Note: This custom JAR takes two arguments, input and output files.
JMeter - Preprocessor(Groovy based)
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.commons.lang3.RandomStringUtils;
String ext = "dcm";
String outputFilePath = String.format("%s.%s", RandomStringUtils.randomAlphanumeric(8), ext);
try {
log.error("Current Path : " + System.getProperty("user.dir"));
String command = "java -jar Dicom.jar Images-1-min.jpg " + outputFilePath;
log.error("Command is: " + command);
def process = command.execute();
// Capture and log the process output
def output = new StringBuilder();
process.waitForProcessOutput(output, System.err);
process.waitFor();
// Log the process output
log.error("Process output: " + output.toString());
def p = "ls -R".execute();
// Capture and log the process output
def o = new StringBuilder();
p.waitForProcessOutput(o, System.err);
p.waitFor();
log.error("List Directory : " + o.toString());
try {
byte[] binaryData = Files.readAllBytes(Paths.get("output.dcm"));
sampler.getArguments().removeAllArguments();
sampler.addNonEncodedArgument('', new String(binaryData), '');
// Set the Content-Type header (optional, only if required by the server)
sampler.setPostBodyRaw(true);
} catch (Exception ex) {
log.error("Error modifying and sending DICOM file: " + ex.getMessage());
throw ex;
}
} catch (Exception e) {
log.error("Error executing command: " + e.toString());
}
Config.YAML:
displayName: DICOM
testPlan: DICOM Load Test.jmx
description: ''
engineInstances: 1
testId: fcba51b1-b4fd-4ae7-a3c2-694080bfd662
splitAllCSVs: False
configurationFiles:
- Dicom.jar
- output.dcm
- Images-1-min.jpg
failureCriteria: []
env:
- name: SUBSCRIPTION_KEY
value: xxxxxxx
- name: APIM_FHIR_URL
value: xxxxxxx.azure-api.net
- name: TENANT_ID
value: xxxx
- name: THREADS_NUM
value: 1
- name: THREADS_LOOP
value: 1
autoStop:
errorPercentage: 90
timeWindow: 60
As you see, I have uploaded all the required files
I am getting the following error while executing the load test
2023-08-15 12:23:22,241 WARN o.a.j.JMeter: LogLevel: INFO
2023-08-15 12:23:22,918 WARN c.a.c.j.j.c.MALTListener: TEST STARTED EVENT - received
2023-08-15 12:23:23,139 WARN c.a.c.j.j.c.MALTFileWriterListener: Received Event testStarted
2023-08-15 12:23:23,150 WARN c.a.c.j.j.c.MALTAutostopListener: MALT autostop test started with error rate 90 for 60s.
2023-08-15 12:23:24,650 ERROR o.a.j.m.J.Convert JPG to DICOM and set it as a Body: Current Path : /
2023-08-15 12:23:24,651 ERROR o.a.j.m.J.Convert JPG to DICOM and set it as a Body: Command is: java -jar Dicom.jar Images-1-min.jpg xaNzytIY.dcm
2023-08-15 12:23:24,692 ERROR o.a.j.m.J.Convert JPG to DICOM and set it as a Body: Process output:
2023-08-15 12:23:24,909 ERROR o.a.j.m.J.Convert JPG to DICOM and set it as a Body: List Directory : .:
./jmeter/lib/ext:
ApacheJMeter_bolt.jar
ApacheJMeter_components.jar
ApacheJMeter_core.jar
ApacheJMeter_ftp.jar
ApacheJMeter_functions.jar
ApacheJMeter_http.jar
ApacheJMeter_java.jar
ApacheJMeter_jdbc.jar
ApacheJMeter_jms.jar
ApacheJMeter_junit.jar
ApacheJMeter_ldap.jar
ApacheJMeter_mail.jar
ApacheJMeter_mongodb.jar
ApacheJMeter_native.jar
ApacheJMeter_tcp.jar
Dicom.jar
azure-loadtesting-getsecret-0.0.2.jar
jmeter-plugins-autostop-0.1.jar
jmeter-plugins-casutg-2.10.jar
jmeter-plugins-cmn-jmeter-0.7.jar
jmeter-plugins-dummy-0.4.jar
jmeter-plugins-graphs-additional-2.0.jar
jmeter-plugins-graphs-basic-2.0.jar
jmeter-plugins-malt-2.4.jar
jmeter-plugins-manager-1.8.jar
jmeter-plugins-tst-2.6.jar
json-lib-2.4-jdk15.jar
log4j-layout-template-json-2.17.2.jar
readme.txt
./root/artifacts:
Dicom.jar
Images-1-min.jpg
jmeter.log
logs
metrics
output.dcm
results
testplan.jmx
2023-08-14 20:38:56,306 ERROR o.a.j.m.J.Convert JPG to DICOM and set it as a Body: Error modifying and sending DICOM file: output.dcm
2023-08-14 20:38:56,307 ERROR o.a.j.m.J.Convert JPG to DICOM and set it as a Body: Error executing command: java.nio.file.NoSuchFileException: output.dcm
2023-08-14 20:38:56,398 WARN o.a.j.u.SSLManager: Keystore file not found, loading empty keystore
2023-08-14 20:38:57,388 WARN c.a.c.j.j.c.MALTListener: TEST ENDED EVENT - received
2023-08-14 20:38:57,399 WARN c.a.c.j.j.c.MALTListener: TEST ENDED EVENT - uploading jmeter.log file
2023-08-14 20:38:57,432 WARN c.a.c.j.j.c.MALTListener: TEST ENDED EVENT - completed
2023-08-14 20:38:57,433 WARN c.a.c.j.j.c.MALTFileWriterListener: Received Event testEnded
2023-08-14 20:38:57,435 INFO o.a.j.r.Summariser: summary = 1 in 00:00:03 = 0.4/s Avg: 1008 Min: 1008 Max: 1008 Err: 1 (100.00%)
I could see the custom JAR (Dicom.jar) file under ./jmeter/lib/ext folder but I don't see output.dcm and Images-1-min.jpg anywhere.