@@ 168-201 (lines=34) @@ | ||
165 | with open(pending_commands_file, 'w') as pending_commands: |
|
166 | pending_commands.write("\n".join(commands[1::2]) + "\n") |
|
167 | ||
168 | # Actual test (should move running commands back to pending). |
|
169 | exit_status = call(self.resume_command.format(batch_uid), shell=True) |
|
170 | ||
171 | # Test validation |
|
172 | assert_equal(exit_status, 0) |
|
173 | assert_true(os.path.isdir(self.logs_dir)) |
|
174 | assert_equal(len(os.listdir(self.logs_dir)), 1) |
|
175 | assert_equal(len(open(running_commands_file).readlines()), 0) |
|
176 | assert_equal(len(open(pending_commands_file).readlines()), len(commands)) |
|
177 | ||
178 | def test_main_resume_by_expanding_pool_default(self): |
|
179 | # Create SMART_DISPATCH_LOGS structure. |
|
180 | call(self.launch_command, shell=True) |
|
181 | batch_uid = os.listdir(self.logs_dir)[0] |
|
182 | ||
183 | # Simulate that some commands are in the running state. |
|
184 | nb_commands_files = 2 # 'commands.txt' and 'running_commands.txt' |
|
185 | path_job_commands = os.path.join(self.logs_dir, batch_uid, "commands") |
|
186 | pending_commands_file = pjoin(path_job_commands, "commands.txt") |
|
187 | running_commands_file = pjoin(path_job_commands, "running_commands.txt") |
|
188 | commands = open(pending_commands_file).read().strip().split("\n") |
|
189 | with open(running_commands_file, 'w') as running_commands: |
|
190 | running_commands.write("\n".join(commands[::2]) + "\n") |
|
191 | with open(pending_commands_file, 'w') as pending_commands: |
|
192 | pending_commands.write("\n".join(commands[1::2]) + "\n") |
|
193 | ||
194 | # Remove PBS files so we can check that new ones are going to be created. |
|
195 | for f in os.listdir(path_job_commands): |
|
196 | if f.startswith('job_commands_') and f.endswith('.sh'): |
|
197 | os.remove(pjoin(path_job_commands, f)) |
|
198 | ||
199 | # Should NOT move running commands back to pending but should add new workers. |
|
200 | command_line = self.resume_command.format(batch_uid) |
|
201 | command_line += " --expandPool" |
|
202 | exit_status = call(command_line, shell=True) |
|
203 | ||
204 | # Test validation |
|
@@ 134-166 (lines=33) @@ | ||
131 | call(self.launch_command, shell=True) |
|
132 | batch_uid = os.listdir(self.logs_dir)[0] |
|
133 | ||
134 | # Simulate that some commands are in the running state. |
|
135 | path_job_commands = os.path.join(self.logs_dir, batch_uid, "commands") |
|
136 | pending_commands_file = pjoin(path_job_commands, "commands.txt") |
|
137 | running_commands_file = pjoin(path_job_commands, "running_commands.txt") |
|
138 | commands = open(pending_commands_file).read().strip().split("\n") |
|
139 | with open(running_commands_file, 'w') as running_commands: |
|
140 | running_commands.write("\n".join(commands[::2]) + "\n") |
|
141 | with open(pending_commands_file, 'w') as pending_commands: |
|
142 | pending_commands.write("\n".join(commands[1::2]) + "\n") |
|
143 | ||
144 | # Actual test (should move running commands back to pending). |
|
145 | exit_status = call(self.resume_command.format(batch_uid), shell=True) |
|
146 | ||
147 | # Test validation |
|
148 | assert_equal(exit_status, 0) |
|
149 | assert_true(os.path.isdir(self.logs_dir)) |
|
150 | assert_equal(len(os.listdir(self.logs_dir)), 1) |
|
151 | assert_equal(len(open(running_commands_file).readlines()), 0) |
|
152 | assert_equal(len(open(pending_commands_file).readlines()), len(commands)) |
|
153 | ||
154 | # Test when batch_uid is a path instead of a jobname. |
|
155 | # Setup |
|
156 | batch_uid = os.path.join(self.logs_dir, os.listdir(self.logs_dir)[0]) |
|
157 | ||
158 | # Simulate that some commands are in the running state. |
|
159 | path_job_commands = os.path.join(self.logs_dir, batch_uid, "commands") |
|
160 | pending_commands_file = pjoin(path_job_commands, "commands.txt") |
|
161 | running_commands_file = pjoin(path_job_commands, "running_commands.txt") |
|
162 | commands = open(pending_commands_file).read().strip().split("\n") |
|
163 | with open(running_commands_file, 'w') as running_commands: |
|
164 | running_commands.write("\n".join(commands[::2]) + "\n") |
|
165 | with open(pending_commands_file, 'w') as pending_commands: |
|
166 | pending_commands.write("\n".join(commands[1::2]) + "\n") |
|
167 | ||
168 | # Actual test (should move running commands back to pending). |
|
169 | exit_status = call(self.resume_command.format(batch_uid), shell=True) |