英文:
Passing a variable from Taurus yaml file to Jmeter script to switch JDBC connection
问题
我目前有一个 JMeter 脚本,我想通过在运行时通过 taurus yaml 传递变量来切换脚本中的 JDBC 连接。
目标是通过在 yaml 中设置变量来切换环境。
根据 Taurus 提供的指南,我在 yaml 文件的设置部分创建了一个环境变量,如下所示:
> settings:
env:
ENV_VARIABLE: randomvariabletest
然后使用这个变量,在 JMeter 脚本中调用如下:
我希望 JDBC 请求能够调用我命名为 randomvariabletest 的 JDBC 连接。我原以为 JDBC 请求会读取我传递的值。
但实际情况并非如此,因为我遇到了以下错误:
java.lang.IllegalArgumentException: 在 GET MAX ORDER ID 中变量名称不得为空
我在这里做错了什么?帮助将不胜感激。
英文:
I currently have a jmeter script which I would like to switch it's jdbc connections in the script, by passing a variable at runtime through the taurus yaml.
The aim is to switch environment by setting the variable in the yaml.
Using the guide provided by Taurus, I created an environment variable under settings in the yaml file as follows:
> settings:
env:
ENV_VARIABLE: randomvariabletest
Then using the variable, I call on that in the Jmeter script as follows
I want the JDBC request to then call the JDBC connection which I have named as randomvariabletest. I was expecting that the JDBC request would read the value which I passed in.
This doesn't work as expected as I am getting the following error:
java.lang.IllegalArgumentException: Variable Name must not be null in GET MAX ORDER ID
What am I doing wrong here, any help would be appreciated.
答案1
得分: 2
你正在使用错误的函数,__P() 函数 用于读取 JMeter 属性,如果你计划使用 JMeter 属性进行参数化,你需要按照 本章节 中的说明操作。
如果你计划继续使用环境变量,你可以选择:
-
要么使用类似
${__env(ENV_VARIABLE,,)}
的 __env() 自定义 JMeter 函数 -
要么使用类似
${__groovy(System.getenv('ENV_VARIABLE'),)}
的 __groovy() 内置函数
英文:
You're using wrong function, __P() function reads a JMeter Property and if you plan to use JMeter Properties for parameterization you need to follow this chapter
If you plan to continue using environment variables you either need to:
- either use __env() custom JMeter Function like
${__env(ENV_VARIABLE,,)}
- or go for __groovy() built-in function like
${__groovy(System.getenv('ENV_VARIABLE'),)}
答案2
得分: -1
连接池的变量名 在JDBC连接配置元素中必须与[JDBC连接配置中声明的池的变量名]相匹配**2。**
连接和JDBC请求是使用此变量连接的。
英文:
Variable Name for connection pool in JDBC Connection Configuration elements must match with the Variable Name of Pool declared in JDBC Connection Configuration in JDBC Request
Connections and JDBC Requests are connected using this variable.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论