Can't get StringFromFile working?
nateuni opened this issue · 9 comments
Sorry, I am new to jmeter, so maybe this is a silly question. I have the files in the correct directory and they upload to the remote host, but I am getting ERR in my tests as it does not seem to be loading the files correctly. I am using: /${_StringFromFile()}
, to pass in content dynamically. Any idea why this wouldn't be working? Am I missing a jar file or something?
Also: Thanks for this repo.. sure beats the distributed jmeter!
You can't pass in the path to a file using jmeter vars. These must be hardcoded I'm afraid. See here: https://github.com/oliverlloyd/jmeter-ec2#limitations
Not sure if we are meaning the same thing. I want to read urls and user_id out of two different text files:
As can be seen here
If I can't do that, where do I hard code them (there are about 20 urls and 1000 usernames)?
I think what you want to do is use a CSV Data Set Config. Point this to the absolute path of the csv file and then build the path
value in your HTTP Request accordingly. E.g.: /things/${thingId}/view
or just ${url}
.
That said, if what you're doing works locally then in theory it should work using this script but to be honest I've never seen reading from a file done this way so I can't say for sure.But typically the way to access data in a file is using the CSV component I mentioned above so maybe just try that and see what happens.
The reason why I want to do it like this is it is random. And along as I start jmeter in the same directory as the file that I am trying to load in strings from, then it works. The error I am getting in kafka after using your script is one like: "message":"52.xx.xx.xx - - [09/May/2016:10:52:07 +0000] "GET /ERR?user=ERR HTTP/1.1", because it can't find the file.
Can you tell me what is the full path of the directory that the uploaded files will be placed in? Thanks
Sure. The script copies the contents of the /data
directory and places them in REMOTE_HOME
. The value of this var is /home/ubuntu/
See here. This is also the same location that the script is run from.
Note. If you were to use a CSV Data Set Config then this is automatically handled in the script here.
Also, checking the docs for StringFromFile()
it sounds like this behaves much the same as the CSV Data Set. From what I can see neither offers random selection but the generally accepted method to get this is to randomise the order of the file prior to test execution. It's a nice idea to have dynamic random access but if you had a file with a million records then choosing values at random (whilst still giving unique values to each user) would be very expensive; I suspect this is why it isn't available.
The script hangs and when I ssh in I can see this error in the log:
Any ideas how I fix it?
2016/05/09 15:46:02 ERROR - jmeter.JMeter: Error in NonGUIDriver java.lang.RuntimeException: Could not find the TestPlan class!
at org.apache.jmeter.engine.StandardJMeterEngine.configure(StandardJMeterEngine.java:171)
at org.apache.jmeter.JMeter.runNonGui(JMeter.java:799)
at org.apache.jmeter.JMeter.startNonGui(JMeter.java:737)
at org.apache.jmeter.JMeter.start(JMeter.java:395)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.jmeter.NewDriver.main(NewDriver.java:264)
And when I Ctrl-C out:
processing results...(standard_in) 2: parse error
/usr/local/jmeter-ec2/jmeter-ec2.sh: line 862: [: : integer expression expected
That sounds like a different issue. It also sounds like something is wrong with the jmx although that's just a guess based on googling that error msg.
The CTRL-C thing is a bug but because it only happens after certain errors it's low on the list.
Ok thanks for your help!