|
@@ 302-328 (lines=27) @@
|
| 299 |
|
''' |
| 300 |
|
sf = create_submission_file() |
| 301 |
|
sub = create_validatable_submission( |
| 302 |
|
self.user, self.validated_assignment, sf) |
| 303 |
|
test_machine = self._register_executor() |
| 304 |
|
sub.assignment.test_machines.add(test_machine) |
| 305 |
|
return sub |
| 306 |
|
|
| 307 |
|
def test_register_executor_explicit(self): |
| 308 |
|
machine_count = TestMachine.objects.all().count() |
| 309 |
|
assert(self._register_executor().pk) |
| 310 |
|
self.assertEqual(machine_count + 1, TestMachine.objects.all().count()) |
| 311 |
|
|
| 312 |
|
@override_settings(JOB_EXECUTOR_SECRET='foo') |
| 313 |
|
def test_invalid_secret(self): |
| 314 |
|
self.assertNotEqual(True, self._run_executor()) |
| 315 |
|
|
| 316 |
|
def test_everything_already_tested(self): |
| 317 |
|
create_validated_submission(self.user, self.validated_assignment) |
| 318 |
|
assert(self._register_executor().pk) |
| 319 |
|
self.assertEqual(False, self._run_executor()) |
| 320 |
|
|
| 321 |
|
def test_parallel_executors_test(self): |
| 322 |
|
NUM_PARALLEL = 3 |
| 323 |
|
self.validated_assignment.test_machines.add(self._register_executor()) |
| 324 |
|
subs = [] |
| 325 |
|
for i in range(1, NUM_PARALLEL + 1): |
| 326 |
|
stud = create_user(get_student_dict(i)) |
| 327 |
|
self.course.participants.add(stud.profile) |
| 328 |
|
self.course.save() |
| 329 |
|
sf = create_submission_file() |
| 330 |
|
subs.append(create_validatable_submission( |
| 331 |
|
stud, self.validated_assignment, sf)) |
|
@@ 330-354 (lines=25) @@
|
| 327 |
|
self.course.participants.add(stud.profile) |
| 328 |
|
self.course.save() |
| 329 |
|
sf = create_submission_file() |
| 330 |
|
subs.append(create_validatable_submission( |
| 331 |
|
stud, self.validated_assignment, sf)) |
| 332 |
|
|
| 333 |
|
# Span a number of threads, each triggering the executor |
| 334 |
|
# This only creates a real test case if executor serialization |
| 335 |
|
# is off (see tests/executor.cfg) |
| 336 |
|
return_codes = utils.run_parallel(len(subs), self._run_executor) |
| 337 |
|
self.assertEqual( |
| 338 |
|
len(list(filter((lambda x: x is True), return_codes))), |
| 339 |
|
len(subs)) |
| 340 |
|
|
| 341 |
|
for sub in subs: |
| 342 |
|
results = SubmissionTestResult.objects.filter( |
| 343 |
|
kind=SubmissionTestResult.VALIDITY_TEST |
| 344 |
|
) |
| 345 |
|
self.assertEqual(NUM_PARALLEL, len(results)) |
| 346 |
|
self.assertNotEqual(0, len(results[0].result)) |
| 347 |
|
|
| 348 |
|
def test_too_long_validation(self): |
| 349 |
|
from django.core import mail |
| 350 |
|
|
| 351 |
|
grading = create_pass_fail_grading() |
| 352 |
|
assignment = create_validated_assignment( |
| 353 |
|
self.course, grading, "/submfiles/validation/d000fff/", "validator_run.py") |
| 354 |
|
assignment.attachment_test_timeout = 1 |
| 355 |
|
assignment.save() |
| 356 |
|
sf = create_submission_file("/submfiles/validation/d000fff/helloworld.c") |
| 357 |
|
sub = create_validatable_submission( |