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!

有帮助吗?

解决方案

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]

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top