Add mock server to JMeter sources
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
### Use case
Fine-tuning HTTP samplers requires runing a server that could respond fast with minimal resource utilization.
What do you think if we integrate a small mock server into JMeter sources?
I guess it would simplify to test performance-related changes.
### Possible solution
I tried the following, and I got ~88K/sec for HTTPClient4 implementation and ~60K/sec for Java implementation (~8 threads, Java 17, M1 Max)
```kotlin
import io.undertow.Undertow
import io.undertow.util.Headers
fun main() {
val server = Undertow.builder()
.addHttpListener(3000, "0.0.0.0")
.setHandler { exchange ->
// Sets the return Content-Type to text/html
exchange.responseHeaders
.put(Headers.CONTENT_TYPE, "application/json")
// Returns a hard-coded HTML document
exchange.responseSender
.send("""{"result":"ok"}""")
}.build()
// Boot the web server
server.start()
}
```
I guess we could predefined several routes (e.g. chunked encoding, large response, small response, etc).
The drawback would be to version churn (Renovate bot would ask us upgrading the versions as they release)
WDYT?
### Possible workarounds
_No response_
### JMeter Version
5.5
### Java Version
_No response_
### OS Version
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.