| OLD | NEW |
| 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 """Triggers a ton of fake jobs to test its handling under high load. | 6 """Triggers a ton of fake jobs to test its handling under high load. |
| 7 | 7 |
| 8 Generates an histogram with the latencies to process the tasks and number of | 8 Generates an histogram with the latencies to process the tasks and number of |
| 9 retries. | 9 retries. |
| 10 """ | 10 """ |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 """Triggers a Swarming job and collects results. | 57 """Triggers a Swarming job and collects results. |
| 58 | 58 |
| 59 Returns the total amount of time to run a task remotely, including all the | 59 Returns the total amount of time to run a task remotely, including all the |
| 60 overhead. | 60 overhead. |
| 61 """ | 61 """ |
| 62 name = 'load-test-%d-%s' % (index, unique) | 62 name = 'load-test-%d-%s' % (index, unique) |
| 63 start = time.time() | 63 start = time.time() |
| 64 | 64 |
| 65 logging.info('trigger') | 65 logging.info('trigger') |
| 66 manifest = swarming.Manifest( | 66 manifest = swarming.Manifest( |
| 67 None, name, 1, None, 'Comodor64', '', 'http://localhost:1', False, False, | 67 None, name, 1, None, swarming_load_test_bot.OS_NAME, '', |
| 68 100, None) | 68 'http://localhost:1', False, False, 100, None) |
| 69 data = {'request': manifest.to_json()} | 69 data = {'request': manifest.to_json()} |
| 70 response = net.url_open(swarming_url + '/test', data=data) | 70 response = net.url_open(swarming_url + '/test', data=data) |
| 71 if not response: | 71 if not response: |
| 72 # Failed to trigger. Return a failure. | 72 # Failed to trigger. Return a failure. |
| 73 return 'failed_trigger' | 73 return 'failed_trigger' |
| 74 result = json.load(response) | 74 result = json.load(response) |
| 75 test_key = result['test_keys'][0].pop('test_key') | 75 test_key = result['test_keys'][0].pop('test_key') |
| 76 assert test_key | 76 assert test_key |
| 77 expected = { | 77 expected = { |
| 78 'test_case_name': name, | 78 'test_case_name': name, |
| 79 'test_keys': [ | 79 'test_keys': [ |
| 80 { | 80 { |
| 81 'config_name': 'Comodor64', | 81 'config_name': swarming_load_test_bot.OS_NAME, |
| 82 'num_instances': 1, | 82 'num_instances': 1, |
| 83 'instance_index': 0, | 83 'instance_index': 0, |
| 84 }, | 84 }, |
| 85 ], | 85 ], |
| 86 } | 86 } |
| 87 assert result == expected, result | 87 assert result == expected, result |
| 88 progress.update_item('%5d' % index, processing=1) | 88 progress.update_item('%5d' % index, processing=1) |
| 89 try: | 89 try: |
| 90 logging.info('collect') | 90 logging.info('collect') |
| 91 test_keys = swarming.get_test_keys(swarming_url, name) | 91 test_keys = swarming.get_test_keys(swarming_url, name) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 print('') | 217 print('') |
| 218 print_results(results, options.columns, options.buckets) | 218 print_results(results, options.columns, options.buckets) |
| 219 if options.dump: | 219 if options.dump: |
| 220 with open(options.dump, 'w') as f: | 220 with open(options.dump, 'w') as f: |
| 221 json.dump(results, f, separators=(',',':')) | 221 json.dump(results, f, separators=(',',':')) |
| 222 return 0 | 222 return 0 |
| 223 | 223 |
| 224 | 224 |
| 225 if __name__ == '__main__': | 225 if __name__ == '__main__': |
| 226 sys.exit(main()) | 226 sys.exit(main()) |
| OLD | NEW |