| OLD | NEW |
| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 self.assertNotIn(u'caches', dimensions) | 332 self.assertNotIn(u'caches', dimensions) |
| 333 break | 333 break |
| 334 | 334 |
| 335 def gen_expected(self, **kwargs): | 335 def gen_expected(self, **kwargs): |
| 336 return gen_expected(bot_dimensions=self.dimensions, **kwargs) | 336 return gen_expected(bot_dimensions=self.dimensions, **kwargs) |
| 337 | 337 |
| 338 def test_raw_bytes(self): | 338 def test_raw_bytes(self): |
| 339 # A string of a letter 'A', UTF-8 BOM then UTF-16 BOM then UTF-EDBCDIC then | 339 # A string of a letter 'A', UTF-8 BOM then UTF-16 BOM then UTF-EDBCDIC then |
| 340 # invalid UTF-8 and the letter 'B'. It is double escaped so it can be passed | 340 # invalid UTF-8 and the letter 'B'. It is double escaped so it can be passed |
| 341 # down the shell. | 341 # down the shell. |
| 342 # |
| 343 # Also confirm that a bot can run with multiple keys. Assume there's at |
| 344 # least 2 'os' values. |
| 342 invalid_bytes = 'A\\xEF\\xBB\\xBF\\xFE\\xFF\\xDD\\x73\\x66\\x73\\xc3\\x28B' | 345 invalid_bytes = 'A\\xEF\\xBB\\xBF\\xFE\\xFF\\xDD\\x73\\x66\\x73\\xc3\\x28B' |
| 343 args = [ | 346 args = [ |
| 347 '--dimension', 'os', self.dimensions[u'os'][0], |
| 348 '--dimension', 'os', self.dimensions[u'os'][1], |
| 344 '-T', 'non_utf8', '--', | 349 '-T', 'non_utf8', '--', |
| 345 'python', '-u', '-c', 'print(\'' + invalid_bytes + '\')', | 350 'python', '-u', '-c', 'print(\'' + invalid_bytes + '\')', |
| 346 ] | 351 ] |
| 352 tags = [ |
| 353 u'os:%s' % self.dimensions[u'os'][0], |
| 354 u'os:%s' % self.dimensions[u'os'][1], |
| 355 u'pool:default', |
| 356 u'priority:100', |
| 357 u'service_account:none', |
| 358 u'user:joe@localhost', |
| 359 ] |
| 347 summary = self.gen_expected( | 360 summary = self.gen_expected( |
| 348 name=u'non_utf8', | 361 name=u'non_utf8', |
| 349 # The string is mostly converted to 'Replacement Character'. | 362 # The string is mostly converted to 'Replacement Character'. |
| 350 outputs=[u'A\ufeff\ufffd\ufffd\ufffdsfs\ufffd(B\n']) | 363 outputs=[u'A\ufeff\ufffd\ufffd\ufffdsfs\ufffd(B\n'], |
| 364 tags=tags) |
| 351 self.assertOneTask(args, summary, {}) | 365 self.assertOneTask(args, summary, {}) |
| 352 | 366 |
| 353 def test_invalid_command(self): | 367 def test_invalid_command(self): |
| 354 args = ['-T', 'invalid', '--', 'unknown_invalid_command'] | 368 args = ['-T', 'invalid', '--', 'unknown_invalid_command'] |
| 355 summary = self.gen_expected( | 369 summary = self.gen_expected( |
| 356 name=u'invalid', | 370 name=u'invalid', |
| 357 exit_codes=[1], | 371 exit_codes=[1], |
| 358 failure=True, | 372 failure=True, |
| 359 outputs=re.compile( | 373 outputs=re.compile( |
| 360 u'^<The executable does not exist or a dependent library is ' | 374 u'^<The executable does not exist or a dependent library is ' |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 u'initial_number_items': u'0', | 620 u'initial_number_items': u'0', |
| 607 u'initial_size': u'0', | 621 u'initial_size': u'0', |
| 608 u'items_cold': sorted([len(hello_world), 199]), | 622 u'items_cold': sorted([len(hello_world), 199]), |
| 609 u'items_hot': [], | 623 u'items_hot': [], |
| 610 }, | 624 }, |
| 611 u'isolated_upload': { | 625 u'isolated_upload': { |
| 612 u'items_cold': [], | 626 u'items_cold': [], |
| 613 u'items_hot': [], | 627 u'items_hot': [], |
| 614 }, | 628 }, |
| 615 }, | 629 }, |
| 630 # Intentionally hardcode the hash here to confirm consistency in the |
| 631 # hashing mechanism. |
| 616 properties_hash = | 632 properties_hash = |
| 617 u'082928de84d0a65839d227dcea2f5a947898929c77c1602b68c46d7d4588c1f5', | 633 u'7340823890f29ffa64f81448517c541ebf4fc7b9ce5541bab05f3edda0cadafe', |
| 618 ) | 634 ) |
| 619 task_id = self._run_isolated( | 635 task_id = self._run_isolated( |
| 620 hello_world, 'idempotent_reuse', ['--idempotent'], expected_summary, {}) | 636 hello_world, 'idempotent_reuse', ['--idempotent'], expected_summary, {}) |
| 621 expected_summary[u'costs_usd'] = None | 637 expected_summary[u'costs_usd'] = None |
| 622 expected_summary.pop('performance_stats') | 638 expected_summary.pop('performance_stats') |
| 623 expected_summary[u'cost_saved_usd'] = 0.02 | 639 expected_summary[u'cost_saved_usd'] = 0.02 |
| 624 expected_summary[u'deduped_from'] = task_id[:-1] + '1' | 640 expected_summary[u'deduped_from'] = task_id[:-1] + '1' |
| 625 expected_summary[u'try_number'] = 0 | 641 expected_summary[u'try_number'] = 0 |
| 626 expected_summary[u'properties_hash'] = None | 642 expected_summary[u'properties_hash'] = None |
| 627 self._run_isolated( | 643 self._run_isolated( |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 if bot is not None and bot.poll() is None: | 940 if bot is not None and bot.poll() is None: |
| 925 bot.kill() | 941 bot.kill() |
| 926 bot.wait() | 942 bot.wait() |
| 927 finally: | 943 finally: |
| 928 cleanup(bot, client, servers, failed or verbose, leak) | 944 cleanup(bot, client, servers, failed or verbose, leak) |
| 929 return int(failed) | 945 return int(failed) |
| 930 | 946 |
| 931 | 947 |
| 932 if __name__ == '__main__': | 948 if __name__ == '__main__': |
| 933 sys.exit(main()) | 949 sys.exit(main()) |
| OLD | NEW |