Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/swarming_test.py

Issue 25549003: Fix running 'import run_isolated' at python interactive prompt. (Closed) Base URL: https://chromium.googlesource.com/a/chromium/tools/swarm_client@1_update_item
Patch Set: Added comment Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « swarming.py ('k') | utils/net.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import hashlib 6 import hashlib
7 import json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import StringIO 10 import StringIO
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 409 }
410 ] 410 ]
411 411
412 412
413 def generate_expected_json( 413 def generate_expected_json(
414 shards, 414 shards,
415 slave_os, 415 slave_os,
416 working_dir, 416 working_dir,
417 isolate_server, 417 isolate_server,
418 profile): 418 profile):
419 retrieval_url = isolate_server + u'/content/retrieve/default/'
420 os_value = unicode(swarming.PLATFORM_MAPPING_SWARMING[slave_os]) 419 os_value = unicode(swarming.PLATFORM_MAPPING_SWARMING[slave_os])
421 expected = { 420 expected = {
422 u'cleanup': u'root', 421 u'cleanup': u'root',
423 u'configurations': [ 422 u'configurations': [
424 { 423 {
425 u'config_name': os_value, 424 u'config_name': os_value,
426 u'dimensions': { 425 u'dimensions': {
427 u'os': os_value, 426 u'os': os_value,
428 }, 427 },
429 u'min_instances': shards, 428 u'min_instances': shards,
430 }, 429 },
431 ], 430 ],
432 u'data': [[retrieval_url, u'swarm_data.zip']], 431 u'data': [],
433 u'env_vars': {}, 432 u'env_vars': {},
434 u'restart_on_failure': True, 433 u'restart_on_failure': True,
435 u'test_case_name': TEST_NAME, 434 u'test_case_name': TEST_NAME,
436 u'tests': chromium_tasks(isolate_server), 435 u'tests': chromium_tasks(isolate_server),
437 u'working_dir': unicode(working_dir), 436 u'working_dir': unicode(working_dir),
438 u'priority': 101, 437 u'priority': 101,
439 } 438 }
440 if shards > 1: 439 if shards > 1:
441 expected[u'env_vars'][u'GTEST_SHARD_INDEX'] = u'%(instance_index)s' 440 expected[u'env_vars'][u'GTEST_SHARD_INDEX'] = u'%(instance_index)s'
442 expected[u'env_vars'][u'GTEST_TOTAL_SHARDS'] = u'%(num_instances)s' 441 expected[u'env_vars'][u'GTEST_TOTAL_SHARDS'] = u'%(num_instances)s'
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 def _check_output(self, out, err): 474 def _check_output(self, out, err):
476 self.assertEqual(out, sys.stdout.getvalue()) 475 self.assertEqual(out, sys.stdout.getvalue())
477 self.assertEqual(err, sys.stderr.getvalue()) 476 self.assertEqual(err, sys.stderr.getvalue())
478 477
479 # Flush their content by mocking them again. 478 # Flush their content by mocking them again.
480 self.mock(sys, 'stdout', StringIO.StringIO()) 479 self.mock(sys, 'stdout', StringIO.StringIO())
481 self.mock(sys, 'stderr', StringIO.StringIO()) 480 self.mock(sys, 'stderr', StringIO.StringIO())
482 481
483 def test_basic_manifest(self): 482 def test_basic_manifest(self):
484 manifest = swarming.Manifest( 483 manifest = swarming.Manifest(
485 manifest_hash=FILE_HASH, 484 isolated_hash=FILE_HASH,
486 test_name=TEST_NAME, 485 test_name=TEST_NAME,
487 shards=2, 486 shards=2,
488 test_filter='*', 487 test_filter='*',
489 slave_os='win32', 488 slave_os='Windows',
490 working_dir='swarm_tests', 489 working_dir='swarm_tests',
491 isolate_server='http://localhost:8081', 490 isolate_server='http://localhost:8081',
492 verbose=False, 491 verbose=False,
493 profile=False, 492 profile=False,
494 priority=101, 493 priority=101,
495 algo=ALGO) 494 algo=ALGO)
496 495
497 swarming.chromium_setup(manifest) 496 swarming.chromium_setup(manifest)
498 manifest_json = json.loads(manifest.to_json()) 497 manifest_json = json.loads(manifest.to_json())
499 498
500 expected = generate_expected_json( 499 expected = generate_expected_json(
501 shards=2, 500 shards=2,
502 slave_os='win32', 501 slave_os='win32',
503 working_dir='swarm_tests', 502 working_dir='swarm_tests',
504 isolate_server=u'http://localhost:8081', 503 isolate_server=u'http://localhost:8081',
505 profile=False) 504 profile=False)
506 self.assertEqual(expected, manifest_json) 505 self.assertEqual(expected, manifest_json)
507 506
508 def test_basic_linux(self): 507 def test_basic_linux(self):
509 """A basic linux manifest test to ensure that windows specific values 508 """A basic linux manifest test to ensure that windows specific values
510 aren't used. 509 aren't used.
511 """ 510 """
512 manifest = swarming.Manifest( 511 manifest = swarming.Manifest(
513 manifest_hash=FILE_HASH, 512 isolated_hash=FILE_HASH,
514 test_name=TEST_NAME, 513 test_name=TEST_NAME,
515 shards=1, 514 shards=1,
516 test_filter='*', 515 test_filter='*',
517 slave_os='linux2', 516 slave_os='Linux',
518 working_dir='swarm_tests', 517 working_dir='swarm_tests',
519 isolate_server='http://localhost:8081', 518 isolate_server='http://localhost:8081',
520 verbose=False, 519 verbose=False,
521 profile=False, 520 profile=False,
522 priority=101, 521 priority=101,
523 algo=ALGO) 522 algo=ALGO)
524 523
525 swarming.chromium_setup(manifest) 524 swarming.chromium_setup(manifest)
526 manifest_json = json.loads(manifest.to_json()) 525 manifest_json = json.loads(manifest.to_json())
527 526
528 expected = generate_expected_json( 527 expected = generate_expected_json(
529 shards=1, 528 shards=1,
530 slave_os='linux2', 529 slave_os='linux2',
531 working_dir='swarm_tests', 530 working_dir='swarm_tests',
532 isolate_server=u'http://localhost:8081', 531 isolate_server=u'http://localhost:8081',
533 profile=False) 532 profile=False)
534 self.assertEqual(expected, manifest_json) 533 self.assertEqual(expected, manifest_json)
535 534
536 def test_basic_linux_profile(self): 535 def test_basic_linux_profile(self):
537 manifest = swarming.Manifest( 536 manifest = swarming.Manifest(
538 manifest_hash=FILE_HASH, 537 isolated_hash=FILE_HASH,
539 test_name=TEST_NAME, 538 test_name=TEST_NAME,
540 shards=1, 539 shards=1,
541 test_filter='*', 540 test_filter='*',
542 slave_os='linux2', 541 slave_os='Linux',
543 working_dir='swarm_tests', 542 working_dir='swarm_tests',
544 isolate_server='http://localhost:8081', 543 isolate_server='http://localhost:8081',
545 verbose=False, 544 verbose=False,
546 profile=True, 545 profile=True,
547 priority=101, 546 priority=101,
548 algo=ALGO) 547 algo=ALGO)
549 548
550 swarming.chromium_setup(manifest) 549 swarming.chromium_setup(manifest)
551 manifest_json = json.loads(manifest.to_json()) 550 manifest_json = json.loads(manifest.to_json())
552 551
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 'Usage: swarming.py trigger [options]\n\n' 620 'Usage: swarming.py trigger [options]\n\n'
622 'swarming.py: error: At least one --task is required.\n') 621 'swarming.py: error: At least one --task is required.\n')
623 622
624 623
625 if __name__ == '__main__': 624 if __name__ == '__main__':
626 logging.basicConfig( 625 logging.basicConfig(
627 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 626 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
628 if '-v' in sys.argv: 627 if '-v' in sys.argv:
629 unittest.TestCase.maxDiff = None 628 unittest.TestCase.maxDiff = None
630 unittest.main() 629 unittest.main()
OLDNEW
« no previous file with comments | « swarming.py ('k') | utils/net.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698