空手道加特林:设置本地地址

Karate-gatling: set local addresses

我有用于测试 API 的简单空手道功能文件,我想使用此功能文件进行负载测试。因此,我使用 Gatling 来执行空手道功能文件:https://github.com/intuit/karate/tree/master/karate-gatling

但是,当我启动多个用户时,我想使用我配置的不同 ip 别名提交请求。

使用 Gatling,我可以使用 localAddress 绑定到套接字

val protocol = http.localAddresses(ip)

但在 Karate-Gatling 中,使用的是 karateProtocol

val protocol = karateProtocol()

并且自述文件指出 "Karate is responsible for making HTTP requests while Gatling is only measuring the timings and managing threads"。

这意味着无法通过 Gatling 更改 HTTP 请求和 localAddress 绑定,但我想知道是否有通过 Karate 的解决方法,以便不同的 ip 别名可以用于不同的请求。

这听起来像是需要一个功能请求来告诉 HTTP 客户端(例如 Apache)使用本地地址。

如果您能帮助贡献和测试,那就太好了,一种设置 localAddress 的方法是在代码中 here

    RequestConfig.Builder configBuilder = RequestConfig.custom()
            .setCookieSpec(LenientCookieSpec.KARATE)
            .setConnectTimeout(config.getConnectTimeout())
            .setSocketTimeout(config.getReadTimeout());
    String localIp = "1.2.3.4";
    try {            
        InetAddress localAddress = InetAddress.getByName(localIp);
        configBuilder.setLocalAddress(localAddress);
    } catch (Exception e) {
        context.logger.error("failed to resolve local address: {}", localIp);
    }