Skip to content

Commit 4cbdbdc

Browse files
authored
Merge pull request #315 from Backblaze/speedup-unittests
Speed up unit tests
2 parents a223ab8 + b94589c commit 4cbdbdc

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
* Introduce a common thread worker pool for all downloads
1212
* Increase http timeout to 20min (for copy using 5GB parts)
1313
* Remove inheritance from object (leftover from python2)
14+
* Run unit tests on all CPUs
1415

1516
### Added
1617
* Add pypy-3.8 to test matrix

noxfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"pytest-mock==3.6.1",
3232
'pytest-lazy-fixture==0.6.3',
3333
'pyfakefs==4.5.6',
34+
'pytest-xdist==2.5.0',
3435
]
3536
REQUIREMENTS_BUILD = ['setuptools>=20.2']
3637

@@ -108,7 +109,7 @@ def unit(session):
108109
"""Run unit tests."""
109110
install_myself(session)
110111
session.install(*REQUIREMENTS_TEST)
111-
args = ['--doctest-modules', '-p', 'pyfakefs']
112+
args = ['--doctest-modules', '-p', 'pyfakefs', '-n', 'auto']
112113
if not SKIP_COVERAGE:
113114
args += ['--cov=b2sdk', '--cov-branch', '--cov-report=xml']
114115
# TODO: Use session.parametrize for apiver

test/unit/bucket/test_bucket.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,8 @@ def test_upload_local_large_file(self):
11671167
self.bucket.upload_local_file(path, 'file1')
11681168
self._check_file_contents('file1', data)
11691169

1170-
def test_upload_local_large_file_over_10k_parts(
1171-
self
1172-
): # TODO: this test is very slow, speed it up?
1170+
def test_upload_local_large_file_over_10k_parts(self):
1171+
pytest.skip('this test is really slow and impedes development') # TODO: fix it
11731172
with TempDir() as d:
11741173
path = os.path.join(d, 'file1')
11751174
data = self._make_data(self.simulator.MIN_PART_SIZE * 10001) # 2MB on the simulator

test/unit/internal/test_emerge_planner.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ def setUp(self):
9494
self.recommended_size = 100 * MEGABYTE
9595
self.min_size = 5 * MEGABYTE
9696
self.max_size = 5 * GIGABYTE
97-
self.planner = EmergePlanner(
97+
self.planner = self._get_emerge_planner()
98+
99+
def _get_emerge_planner(self):
100+
return EmergePlanner(
98101
min_part_size=self.min_size,
99102
recommended_upload_part_size=self.recommended_size,
100103
max_part_size=self.max_size,
@@ -148,6 +151,15 @@ def test_single_multipart_upload(self):
148151
self.split_source_to_part_defs(source, expected_part_sizes),
149152
)
150153

154+
def test_recommended_part_size_decrease(self):
155+
source_upload1 = UploadSource(self.recommended_size * 10001)
156+
157+
write_intents = [
158+
WriteIntent(source_upload1),
159+
]
160+
emerge_plan = self.planner.get_emerge_plan(write_intents)
161+
assert len(emerge_plan.emerge_parts) < 10000
162+
151163
def test_single_multipart_copy(self):
152164
source = CopySource(5 * self.max_size)
153165

0 commit comments

Comments
 (0)