Operations 7 min read

Multi‑Chain Performance Testing Demo Using FunTester

This article presents a practical demo for multi‑chain performance testing with FunTester, describing the overall workflow, custom multithreaded implementation, Java code example, and sample console output to illustrate how to execute and analyze load tests across multiple request paths.

FunTester
FunTester
FunTester
Multi‑Chain Performance Testing Demo Using FunTester

In recent days the author completed basic browser request replay functionality and now shares a multi‑chain performance testing demo that also resolves the ordering issue of multiple interface requests during replay.

Overall approach :

Copy requests from different chains into separate files.

Use the FileUtil utility to retrieve all files in a directory.

Convert each file into a List<HttpRequestBase> using CurlUtil .

Feed the resulting list into the multithreaded FunTester performance‑testing framework.

Because each chain has varying response times, the demo adopts a fixed‑duration (fixed‑time) testing model with a fixed number of threads rather than a fixed request count or fixed QPS.

The implementation requires writing a custom multithreaded class that repeatedly fetches HttpRequestBase objects from the list and executes them.

Demo code (Java) :

package com.okayqa;

import com.alibaba.fastjson.JSONObject;
import com.fun.base.constaint.ThreadLimitTimeCount;
import com.fun.base.exception.FailException;
import com.fun.base.interfaces.MarkThread;
import com.fun.frame.httpclient.FanLibrary;
import com.fun.utils.FileUtil;
import com.okayqa.common.Common;
import com.okayqa.composer.base.OkayBase;
import org.apache.http.client.methods.HttpRequestBase;

import static com.fun.utils.CurlUtil.getRequests;

class TTT extends OkayBase {

    public static void main(String[] args) {
        // path is the absolute directory + filename
        String path = "";
        // time is the test duration in seconds
        int time = 1000;
        // description, keep within 20 characters
        String desc = "FunTester multi‑chain load test Demo";
        // retrieve all log files
        def file = FileUtil.getAllFile(path);
        def tasks = [];
        file.each {
            tasks << new FunTester(it, time, null);
        }
        new Concurrent(tasks, desc).start();
        FanLibrary.testOver();
    }

    /**
     * FunTester test class
     */
    static class FunTester extends ThreadLimitTimeCount
{
        List
reqs;

        FunTester(String s, int time, MarkThread markThread) {
            super(s, time, markThread);
            reqs = getRequests(s);
        }

        @Override
        void before() {
            super.before();
            // initialize thread mark to avoid NPE
            threadmark = threadmark == null ? EMPTY : threadName;
        }

        @Override
        protected void doing() throws Exception {
            reqs.each {
                it.removeHeaders(Common.REQUEST_ID.getName());
                def header = Common.getRequestIdHeader();
                it.addHeader(header);
                threadmark << header + CONNECTOR;
                JSONObject simple = FanLibrary.executeSimlple(it);
                if (!isRight(simple))
                    FailException.fail("Response error!" + it.getURI().toString());
            }
        }
    }
}

The author adds initialization for threadmark and handles marking inside the doing() method, along with a generic response validation step. Users can extend the validation logic for specific interfaces as needed.

Console output example (truncated):

INFO-> 当前用户:fv,IP:10.60.193.37,工作目录:/Users/fv/Documents/workspace/okay_test/,系统编码格式:UTF-8,系统Mac OS X版本:10.16
INFO-> FunTester多链路压测Demo进度:▍▍▍▍▍▍▍▍▍▍▍  16.41%
... (progress updates) ...
INFO-> 总计50个线程,共用时:31.121 s,执行总数:1917,错误数:0,失败数:0
INFO-> 数据保存成功!文件名:/Users/fv/Documents/workspace/okay_test/long/data/FunTester多链路压测Demo031618,50
... JSON result ...
{"rt":796,"total":1917,"qps":62.814,"failRate":0.0,"threads":50,"startTime":"2021-02-03 16:18:14","endTime":"2021-02-03 16:18:45","errorRate":0.0,"executeTotal":1917,"mark":"FunTester多链路压测Demo031618","table":"..."}

Links to the source code repositories are provided (Gitee and GitHub), along with references to related articles on FunTester, fixed‑QPS testing, IoT testing, and automated testing lifecycle.

Javaperformance testingload testingHTTPmultithreadingFunTester
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.