oliverlloyd / jmeter-ec2

Automates running Apache JMeter on Amazon EC2
GNU General Public License v3.0
464 stars 187 forks source link

Can't get StringFromFile working? #67

Closed nateuni closed 8 years ago

nateuni commented 8 years ago

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!

oliverlloyd commented 8 years ago

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

nateuni commented 8 years ago

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)?

oliverlloyd commented 8 years ago

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.

nateuni commented 8 years ago

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

oliverlloyd commented 8 years ago

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.

oliverlloyd commented 8 years ago

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.

nateuni commented 8 years ago

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
oliverlloyd commented 8 years ago

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.

nateuni commented 8 years ago

Ok thanks for your help!