Backend Development 9 min read

Extending FunTester Distributed Performance Testing Framework with Docker and Groovy

This article details a practical implementation of the FunTester distributed performance testing framework, covering its master‑slave‑server architecture, Docker image creation with a Groovy base, and full code examples for the master scheduler, slave agent, and test server.

FunTester
FunTester
FunTester
Extending FunTester Distributed Performance Testing Framework with Docker and Groovy

This article documents a practical implementation of the FunTester distributed performance testing framework, describing its three-component architecture (master scheduler, slave test agents, and the server under test) and how to set up the environment using Docker with a Groovy base image.

It provides step‑by‑step Docker commands to build the image, run the container as root, configure network access to the host via host.docker.internal , install vim , and update the Groovy library inside the container.

The master scheduler is implemented as a simple Spring‑Boot‑style service that returns a JSON test case; the source code is shown below.

import com.alibaba.fastjson.JSONObject
import com.funtester.base.bean.Result
import com.funtester.httpclient.FunLibrary
import com.funtester.httpclient.FunRequest
import com.mocofun.moco.MocoServer
import com.sun.deploy.ui.FancyButton
import org.apache.http.client.methods.HttpGet

class DcsServer extends MocoServer {
    public static void main(String[] args) {
        def server = getServer(12345)
        def res = new JSONObject()
        res.times = 1000
        res.thread = 20
        res.mode = "ftt"
        res.desc = "FunTester distributed test Demo"
        res.runup = 10
        String url = "http://192.168.80.169:12345/m"
        def get = FunLibrary.getHttpGet(url)
        def request = FunRequest.initFromRequest(get)
        res.request = request
        output(res)
        server.get(urlStartsWith("/m")).response(obRes(Result.success(res)))
        def run = run(server)
        waitForKey("fun")
        run.stop()
    }
}

The slave agent continuously polls the master endpoint, parses the returned JSON, and executes the load test according to the specified mode, thread count, and ramp‑up time. Its script is also included.

import com.funtester.config.Constant
import com.funtester.frame.execute.Concurrent
import com.funtester.frame.thread.RequestThreadTimes
import com.funtester.httpclient.FunLibrary
import com.funtester.httpclient.FunRequest

class Dcs extends FunLibrary {
    public static void main(String[] args) {
        while (true) {
            String url = "http://host.docker.internal:12345/m"
            def get = getHttpGet(url)
            def response = getHttpResponse(get)
            if (response.getInteger("code") == 0) {
                def data = response.getJSONObject("data")
                def r = data.getString("request")
                def request = FunRequest.initFromString(r).getRequest()
                def times = data.getIntValue("times")
                def mode = data.getString("mode")
                def thread = data.getIntValue("thread")
                def runup = data.getIntValue("runup")
                def desc = data.getString("desc")
                if (mode == "ftt") {
                    Constant.RUNUP_TIME = runup
                    def task = new RequestThreadTimes(request, times)
                    def performanceResultBean = new Concurrent(task, thread, desc).start()
                }
            }
            sleep(5.0)
        }
    }
}

The server under test is a minimal Moco server that simply returns the string “hello funtester!!!”. Its source code and a sample request/response log are provided.

import com.mocofun.moco.MocoServer

class TestDemo extends MocoServer {
    static void main(String[] args) {
        def log = getServer(12345)
        log.response("hello funtester!!!")
        def run = run(log)
        waitForKey("fan")
        run.stop()
    }
}

Overall, the article demonstrates how to combine Docker, Groovy, and the FunTester library to create a lightweight, extensible distributed performance testing setup, suitable for further development and integration into larger CI/CD pipelines.

BackendJavaDockerPerformance TestingDistributed TestingGroovy
FunTester
Written by

FunTester

10k followers, 1k articles | completely useless

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.