Mercurial > public > mercurial-scm > hg
comparison mercurial/streamclone.py @ 46986:faa43f09ad98
streamclone: remove sleep based "synchronisation" in tests
Sleep based test synchronisation does not work.
Variation in machine performance and load can make the two process miss their
windows. Instead we migrate to explicit signaling through the file system as
other tests file are using.
Differential Revision: https://phab.mercurial-scm.org/D10478
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 19 Apr 2021 19:12:28 +0200 |
parents | 6085b7f1536d |
children | aed6ceaad6d7 |
comparison
equal
deleted
inserted
replaced
46985:52cee44aa1a0 | 46986:faa43f09ad98 |
---|---|
245 repo.ui.debug(b'scanning\n') | 245 repo.ui.debug(b'scanning\n') |
246 for file_type, name, ename, size in _walkstreamfiles(repo): | 246 for file_type, name, ename, size in _walkstreamfiles(repo): |
247 if size: | 247 if size: |
248 entries.append((name, size)) | 248 entries.append((name, size)) |
249 total_bytes += size | 249 total_bytes += size |
250 _test_sync_point_walk_1(repo) | |
251 _test_sync_point_walk_2(repo) | |
250 | 252 |
251 repo.ui.debug( | 253 repo.ui.debug( |
252 b'%d files, %d bytes to transfer\n' % (len(entries), total_bytes) | 254 b'%d files, %d bytes to transfer\n' % (len(entries), total_bytes) |
253 ) | 255 ) |
254 | 256 |
591 yield chunk | 593 yield chunk |
592 finally: | 594 finally: |
593 fp.close() | 595 fp.close() |
594 | 596 |
595 | 597 |
598 def _test_sync_point_walk_1(repo): | |
599 """a function for synchronisation during tests""" | |
600 | |
601 | |
602 def _test_sync_point_walk_2(repo): | |
603 """a function for synchronisation during tests""" | |
604 | |
605 | |
596 def generatev2(repo, includes, excludes, includeobsmarkers): | 606 def generatev2(repo, includes, excludes, includeobsmarkers): |
597 """Emit content for version 2 of a streaming clone. | 607 """Emit content for version 2 of a streaming clone. |
598 | 608 |
599 the data stream consists the following entries: | 609 the data stream consists the following entries: |
600 1) A char representing the file destination (eg: store or cache) | 610 1) A char representing the file destination (eg: store or cache) |
633 entries.append((_srccache, name, _filefull, None)) | 643 entries.append((_srccache, name, _filefull, None)) |
634 | 644 |
635 chunks = _emit2(repo, entries, totalfilesize) | 645 chunks = _emit2(repo, entries, totalfilesize) |
636 first = next(chunks) | 646 first = next(chunks) |
637 assert first is None | 647 assert first is None |
648 _test_sync_point_walk_1(repo) | |
649 _test_sync_point_walk_2(repo) | |
638 | 650 |
639 return len(entries), totalfilesize, chunks | 651 return len(entries), totalfilesize, chunks |
640 | 652 |
641 | 653 |
642 @contextlib.contextmanager | 654 @contextlib.contextmanager |