In our JMeter project, for the JDBC configuration item's JDBC URL, we need to specify a certificate and its path as a JDBC URL, e.g.
jdbc:snowflake://xx.snowflakecomputing.com:443/?db=xx&warehouse=xx&schema=xx&role=xx&private_key_file_pwd=xx&private_key_file=C%3A%5CUsers%yy%5Crsa_key_aes.p8
where here we have URL encoded an Windows absolute path to rsa_key_aes.p8
(works locally but won't work on Unix).
What we need is a relative path and OS-independent separator which will work on the target Unix server, as well as in the local Windows JMeter GUI.
I have tried URL encoding ~/rsa_key_aes.p8
, ~\rsa_key_aes.p8
, etc., and putting the key in the home dir of Unix and Windows, but neither work on Windows (it can't read the file due to the path), although one may work on Unix.
I also tried:
dbc:snowflake://xx.snowflakecomputing.com:443/?db=xx&warehouse=xx&schema=xx&role=xx&private_key_file_pwd=xx&private_key_file=${__BeanShell(${__P(user.dir)}/rsa_key_aes.pem,,)}
This gives: 'Error occurred compiling the tree: - see log file' with nothing in the log file.
dbc:snowflake://xx.snowflakecomputing.com:443/?db=xx&warehouse=xx&schema=xx&role=xx&private_key_file_pwd=xx&private_key_file=${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir())}/rsa_key_aes.p8
Which gives the error "no suitable driver", either because the Windows path has spaces in it which are not URL encoded, or the separator (or both).
dbc:snowflake://xx.snowflakecomputing.com:443/?db=xx&warehouse=xx&schema=xx&role=xx&private_key_file_pwd=xx&private_key_file=${__urlencode(${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir())}/rsa_key_aes.p8)}
This works on Windows, but when you copy the JMX file to Linux and run it, Linux tries to use the Windows user's home path for some reason - it should not even know about the Windows path unless it's hard coded in the JMX file somewhere, in which case it's a bit pointless.
I created connections in two places, and didn't edit them both.
The solution is to create a top level "user defined variables" thus:
Name: CERT_FILE
Value: ${__urlencode(${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir())}/rsa_key_aes.p8)}
then in each JDBC connection:
dbc:snowflake://xx.snowflakecomputing.com:443/?db=xx&warehouse=xx&schema=xx&role=xx&private_key_file_pwd=xx&private_key_file=${CERT_PATH}
Now it works on Unix and Windows.