【发布时间】:2016-10-19 03:01:33
【问题描述】:
我之前问过一个相关的问题:
How to issue commands on remote hosts in parallel using Fabric without using a fabfile?
我在多个测试主机上并行执行测试时遇到问题。
我的代码如下所示:
@parallel
def run_test(arg_list):
# arg_list is a list of dictionary. Each entry in
# arg_list has a 'ip_address' and a 'test_config_file'
for x in arg_list:
ip_address = x['ip_address']
test_config_file = x['test_config_file']
env['host_string'] = ip_address
# The test program "test_localhost.py" is already on all the Test hosts
cmd = "/root/test_localhost.py --ip_addr=" + ip_address + " --config=" + test_config_file
run(cmd)
if __name__ == '__main__':
env.parallel = True
# Each test host will have unique test_config_files
arg_list = list()
arg_list.append({'ip_address':'10.10.10.10', 'test_config_file': "config_01.json"})
arg_list.append({'ip_address':'10.10.10.11', 'test_config_file': "config_02.json"})
execute(run_test, arg_list)
我已针对 2 个以上的测试主机运行此代码。我有一个脚本可以检查测试是否在测试主机上运行。测试不是并行运行的。
相反,测试是按顺序运行的——“test_localhost.py”首先在 10.10.10.10 上运行,然后在完成后在 10.10.10.11 上运行。
我还需要做些什么来使测试并行运行吗?
注意:我不能使用 fabfile,因为我为每个测试主机发送不同的测试配置文件。
【问题讨论】:
标签: python parallel-processing fabric