繁体   English   中英

如何在 Gatling session 中从“exec”块传递和获取属性

[英]How to pass and get attributes in Gatling session from and to "exec" blocks

我是 Scala/Gatling 的新手,所以如果您看到反模式或错误,请原谅我,我有一个 Gatling 场景,我必须运行一些 bash 外部脚本,并且必须保存一些变量以供在另一个中使用exec 块(我尝试在“exec(session => {...”块之后立即调用 the.exec,并尝试将其作为另一个 object 中的方法调用。

 exec(session => {
            val scriptOutput = s"src/main/resources/thepath/myscript.sh ${arg1} ${arg2}".!!
            val x_variable = "123" + scriptOutput
            session.set("x_variable",x_variable)
        })
        .exec(MyClient.calling)

在“MyClient”中,我需要使用“x_variable”的值,我目前有这样的东西:

    def calling() = {
        exec(http("POST to ${x_variable}")
                .post("/${x_variable}"))
    }

但是当这样做时,它不起作用,进行了 Post 调用但变量“x_variable”为空。 总而言之,问题是如何将该“会话”信息传递给任何下一个“exec”块(紧随其后或在另一个对象中),以及如何从该“会话”中使用它?

所描述的代码现在正在运行,似乎我在环境中有一些“垃圾”,在执行mvn clean install后它按预期工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM