Question

I am writing a test script for a website and we have two servers running the script. I would like be able to access the name of the server to set which username should be used within the script.

My properties file says:

   grinder.hostID = 1

My script says:

   if grinder.hostID:
       offset = 1

When I go to run the script, it tells me that it is unable to find hostID. Am I missing a basic functionality of the hostID? How am I able to access the properties file's hostID within my script?

Thanks!

Was it helpful?

Solution

Might be more reliable to get info about the host you are running on programmatically. That way you don't need to worry about accidentally setting identical (or otherwise incorrect) values for grinder.hostid on your various agents. You could use something like this:

import socket
# ...
host_id = socket.gethostname()
# or alternately
host_id = socket.gethostname().split('.')[0]

OTHER TIPS

Are you sure that your properties is being imported in your script

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top