Through JavaSamplerClient, I need to expose a REST-Endpoint in the JMeter scope and test the signal to be received by that particular REST-Endpoint. I have developed a spring-boot application based on JavaSamplerClient and it can be run in JMeter TestPlan as an intermediate step. Unfortunately, I can't access my endpoint through either Postman or curl. I found out that when my microservice is running, the right port is not open. It looks like the microservice is running in a JMeter container or VM (I don't know).
You can take a look at the implementation:
git clone [email protected]:oduv/jmeter-sse.git
git clone https://gitlab.com/oduv/jmeter-sse.git
the JMуtertest is in src/resource/jmeter folder
please give me an idea on how to open the ports or if any.
UPD: sorry, I just rebased the source into "master". It was in the "springboot" branch.
best regards thanks in advance
I fail to see any "REST endpoint" exposed by your "application"
package com.nttdata.sse;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class JmeterSseApplication {
public static void main(String[] args) {
SpringApplication.run(JmeterSseApplication.class, args);
}
}
This is just an empty Spring Boot command-line app if I'm reading the correct branch
If you want to continue with Spring Boot command line application I would suggest:
If you want to run an "endpoint" in JMeter you can just do it using a suitable JSR223 Test Element and few lines of Groovy code, there is no need to bring the whole Spring Boot beast there, moreover it will be quite tricky to initialize it properly inside JMeter sampler:
import com.sun.net.httpserver.HttpServer
int PORT = 8080
HttpServer.create(new InetSocketAddress(PORT), /*max backlog*/ 0).with {
println "Server is listening on ${PORT}, hit Ctrl+C to exit."
createContext("/") { http ->
http.responseHeaders.add("Content-type", "text/plain")
http.sendResponseHeaders(200, 0)
http.responseBody.withWriter { out ->
out << "Hello ${http.remoteAddress.hostName}!\n"
}
println "Hit from Host: ${http.remoteAddress.hostName} on port: ${http.remoteAddress.holder.port}"
}
start()
}