OLD | NEW |
1 import os, select | 1 import os, select |
2 import kvm_utils, kvm_vm, kvm_subprocess | 2 import kvm_utils, kvm_vm, kvm_subprocess |
3 | 3 |
4 | 4 |
5 class scheduler: | 5 class scheduler: |
6 """ | 6 """ |
7 A scheduler that manages several parallel test execution pipelines on a | 7 A scheduler that manages several parallel test execution pipelines on a |
8 single host. | 8 single host. |
9 """ | 9 """ |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 test_iterations = int(test.get("iterations", 1)) | 67 test_iterations = int(test.get("iterations", 1)) |
68 status = run_test_func("kvm", params=test, | 68 status = run_test_func("kvm", params=test, |
69 tag=test.get("shortname"), | 69 tag=test.get("shortname"), |
70 iterations=test_iterations) | 70 iterations=test_iterations) |
71 w.write("done %s %s\n" % (test_index, status)) | 71 w.write("done %s %s\n" % (test_index, status)) |
72 w.write("ready\n") | 72 w.write("ready\n") |
73 | 73 |
74 # The scheduler wants this worker to free its used resources | 74 # The scheduler wants this worker to free its used resources |
75 elif cmd[0] == "cleanup": | 75 elif cmd[0] == "cleanup": |
76 env_filename = os.path.join(self.bindir, self_dict["env"]) | 76 env_filename = os.path.join(self.bindir, self_dict["env"]) |
77 env = kvm_utils.load_env(env_filename, {}) | 77 env = kvm_utils.Env(env_filename) |
78 for obj in env.values(): | 78 for obj in env.values(): |
79 if isinstance(obj, kvm_vm.VM): | 79 if isinstance(obj, kvm_vm.VM): |
80 obj.destroy() | 80 obj.destroy() |
81 elif isinstance(obj, kvm_subprocess.kvm_spawn): | 81 elif isinstance(obj, kvm_subprocess.Spawn): |
82 obj.close() | 82 obj.close() |
83 kvm_utils.dump_env(env, env_filename) | 83 env.save() |
84 w.write("cleanup_done\n") | 84 w.write("cleanup_done\n") |
85 w.write("ready\n") | 85 w.write("ready\n") |
86 | 86 |
87 # There's no more work for this worker | 87 # There's no more work for this worker |
88 elif cmd[0] == "terminate": | 88 elif cmd[0] == "terminate": |
89 break | 89 break |
90 | 90 |
91 | 91 |
92 def scheduler(self): | 92 def scheduler(self): |
93 """ | 93 """ |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 self.s2w_w[worker].write("cleanup\n") | 221 self.s2w_w[worker].write("cleanup\n") |
222 idle_workers.remove(worker) | 222 idle_workers.remove(worker) |
223 closing_workers.append(worker) | 223 closing_workers.append(worker) |
224 | 224 |
225 # If there are no more new tests to run, terminate the workers and | 225 # If there are no more new tests to run, terminate the workers and |
226 # the scheduler | 226 # the scheduler |
227 if len(idle_workers) == self.num_workers: | 227 if len(idle_workers) == self.num_workers: |
228 for worker in idle_workers: | 228 for worker in idle_workers: |
229 self.s2w_w[worker].write("terminate\n") | 229 self.s2w_w[worker].write("terminate\n") |
230 break | 230 break |
OLD | NEW |