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

Side by Side Diff: appengine/swarming/local_smoke_test.py

Issue 2636993002: swarming: Fix named cache support. (Closed)
Patch Set: Fix swarming_test.py Created 3 years, 11 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 | « no previous file | appengine/swarming/tools/start_bot.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 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """Integration test for the Swarming server, Swarming bot and Swarming client. 6 """Integration test for the Swarming server, Swarming bot and Swarming client.
7 7
8 It starts both a Swarming server and a Swarming bot and triggers tasks with the 8 It starts both a Swarming server and a Swarming bot and triggers tasks with the
9 Swarming client to ensure the system works end to end. 9 Swarming client to ensure the system works end to end.
10 """ 10 """
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 os.write(h, 'foobar') 573 os.write(h, 'foobar')
574 os.close(h) 574 os.close(h)
575 try: 575 try:
576 self._run_isolated( 576 self._run_isolated(
577 hello_world, 'secret_bytes', 577 hello_world, 'secret_bytes',
578 ['--secret-bytes-path', tmp, '--', '${ISOLATED_OUTDIR}'], 578 ['--secret-bytes-path', tmp, '--', '${ISOLATED_OUTDIR}'],
579 expected_summary, {os.path.join('0', 'sekret'): 'foobar\n'}) 579 expected_summary, {os.path.join('0', 'sekret'): 'foobar\n'})
580 finally: 580 finally:
581 os.remove(tmp) 581 os.remove(tmp)
582 582
583 def test_local_cache(self):
584 # First task creates the cache, second copy the content to the output
585 # directory. Each time it's the exact same script.
586 script = '\n'.join((
587 'import os, shutil, sys',
588 'if not os.path.islink("p/b"):',
589 ' print("p/b is not a symlink")',
590 ' sys.exit(1)',
591 'p = "p/b/a.txt"',
592 'if not os.path.isfile(p):',
593 ' with open(p, "wb") as f:',
594 ' f.write("Yo!")',
595 'else:',
596 ' shutil.copy(p, sys.argv[1])',
597 'print "hi"'))
598 sizes = sorted([len(script), 200])
599 expected_summary = self.gen_expected(
600 name=u'cache_first',
601 performance_stats={
602 u'isolated_download': {
603 u'initial_number_items': u'0',
604 u'initial_size': u'0',
605 u'items_cold': sizes,
606 u'items_hot': [],
607 },
608 u'isolated_upload': {
609 u'items_cold': [],
610 u'items_hot': [],
611 },
612 },
613 )
614 self._run_isolated(
615 script, 'cache_first',
616 ['--named-cache', 'fuu', 'p/b', '--', '${ISOLATED_OUTDIR}/yo'],
617 expected_summary, {})
618
619 # Second run with a cache available.
620 out = {
621 u'isolated': u'63fc667fd217ebabdf60ca143fe25998b5ea5c77',
622 u'isolatedserver': u'http://localhost:10050',
623 u'namespace': u'default-gzip',
624 u'view_url':
625 u'http://localhost:10050/browse?namespace=default-gzip'
626 u'&hash=63fc667fd217ebabdf60ca143fe25998b5ea5c77',
627 }
628 expected_summary = self.gen_expected(
629 name=u'cache_second',
630 isolated_out=out,
631 outputs_ref=out,
632 performance_stats={
633 u'isolated_download': {
634 u'initial_number_items': unicode(len(sizes)),
635 u'initial_size': unicode(sum(sizes)),
636 u'items_cold': [],
637 u'items_hot': sizes,
638 },
639 u'isolated_upload': {
640 u'items_cold': [3, 110],
641 u'items_hot': [],
642 },
643 },
644 )
645 self._run_isolated(
646 script, 'cache_second',
647 ['--named-cache', 'fuu', 'p/b', '--', '${ISOLATED_OUTDIR}/yo'],
648 expected_summary,
649 {'0/yo': 'Yo!'})
650
583 def _run_isolated(self, hello_world, name, args, expected_summary, 651 def _run_isolated(self, hello_world, name, args, expected_summary,
584 expected_files): 652 expected_files):
585 # Shared code for all test_isolated_* test cases. 653 # Shared code for all test_isolated_* test cases.
586 tmpdir = tempfile.mkdtemp(prefix='swarming_smoke') 654 tmpdir = tempfile.mkdtemp(prefix='swarming_smoke')
587 try: 655 try:
588 isolate_path = os.path.join(tmpdir, 'i.isolate') 656 isolate_path = os.path.join(tmpdir, 'i.isolate')
589 isolated_path = os.path.join(tmpdir, 'i.isolated') 657 isolated_path = os.path.join(tmpdir, 'i.isolated')
590 with open(isolate_path, 'wb') as f: 658 with open(isolate_path, 'wb') as f:
591 json.dump(ISOLATE_HELLO_WORLD, f) 659 json.dump(ISOLATE_HELLO_WORLD, f)
592 with open(os.path.join(tmpdir, 'hello_world.py'), 'wb') as f: 660 with open(os.path.join(tmpdir, 'hello_world.py'), 'wb') as f:
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 if bot is not None and bot.poll() is None: 812 if bot is not None and bot.poll() is None:
745 bot.kill() 813 bot.kill()
746 bot.wait() 814 bot.wait()
747 finally: 815 finally:
748 cleanup(bot, client, servers, failed or verbose, leak) 816 cleanup(bot, client, servers, failed or verbose, leak)
749 return int(failed) 817 return int(failed)
750 818
751 819
752 if __name__ == '__main__': 820 if __name__ == '__main__':
753 sys.exit(main()) 821 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/tools/start_bot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698