| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 # FIXME: We don't have a good way to coordinate the workers so that | 109 # FIXME: We don't have a good way to coordinate the workers so that |
| 110 # they don't try to run the shards that need a lock if we don't actually | 110 # they don't try to run the shards that need a lock if we don't actually |
| 111 # have the lock. The easiest solution at the moment is to grab the | 111 # have the lock. The easiest solution at the moment is to grab the |
| 112 # lock at the beginning of the run, and then run all of the locked | 112 # lock at the beginning of the run, and then run all of the locked |
| 113 # shards first. This minimizes the time spent holding the lock, but | 113 # shards first. This minimizes the time spent holding the lock, but |
| 114 # means that we won't be running tests while we're waiting for the lock. | 114 # means that we won't be running tests while we're waiting for the lock. |
| 115 # If this becomes a problem in practice we'll need to change this. | 115 # If this becomes a problem in practice we'll need to change this. |
| 116 | 116 |
| 117 all_shards = locked_shards + unlocked_shards | 117 all_shards = locked_shards + unlocked_shards |
| 118 self._remaining_locked_shards = locked_shards | 118 self._remaining_locked_shards = locked_shards |
| 119 if self._port.requires_http_server() or (locked_shards and self._options
.http): | 119 if self._port.requires_http_server() or locked_shards: |
| 120 self.start_servers_with_lock(2 * min(num_workers, len(locked_shards)
)) | 120 self.start_servers_with_lock(2 * min(num_workers, len(locked_shards)
)) |
| 121 | 121 |
| 122 num_workers = min(num_workers, len(all_shards)) | 122 num_workers = min(num_workers, len(all_shards)) |
| 123 self._printer.print_workers_and_shards(num_workers, len(all_shards), len
(locked_shards)) | 123 self._printer.print_workers_and_shards(num_workers, len(all_shards), len
(locked_shards)) |
| 124 | 124 |
| 125 if self._options.dry_run: | 125 if self._options.dry_run: |
| 126 return run_results | 126 return run_results |
| 127 | 127 |
| 128 self._printer.write_update('Starting %s ...' % grammar.pluralize('worker
', num_workers)) | 128 self._printer.write_update('Starting %s ...' % grammar.pluralize('worker
', num_workers)) |
| 129 | 129 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 def split_at(seq, index): | 569 def split_at(seq, index): |
| 570 return (seq[:index], seq[index:]) | 570 return (seq[:index], seq[index:]) |
| 571 | 571 |
| 572 num_old_per_new = divide_and_round_up(len(old_shards), max_new_shards) | 572 num_old_per_new = divide_and_round_up(len(old_shards), max_new_shards) |
| 573 new_shards = [] | 573 new_shards = [] |
| 574 remaining_shards = old_shards | 574 remaining_shards = old_shards |
| 575 while remaining_shards: | 575 while remaining_shards: |
| 576 some_shards, remaining_shards = split_at(remaining_shards, num_old_p
er_new) | 576 some_shards, remaining_shards = split_at(remaining_shards, num_old_p
er_new) |
| 577 new_shards.append(TestShard('%s_%d' % (shard_name_prefix, len(new_sh
ards) + 1), extract_and_flatten(some_shards))) | 577 new_shards.append(TestShard('%s_%d' % (shard_name_prefix, len(new_sh
ards) + 1), extract_and_flatten(some_shards))) |
| 578 return new_shards | 578 return new_shards |
| OLD | NEW |