mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-22 08:50:07 +00:00
Minor cleanups.
This commit is contained in:
@ -10,6 +10,10 @@ TODO Parameterization (pytest?)
|
|||||||
|
|
||||||
from time import time, process_time
|
from time import time, process_time
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from tempfile import mkdtemp
|
||||||
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from twisted.trial.unittest import TestCase
|
from twisted.trial.unittest import TestCase
|
||||||
|
|
||||||
@ -27,7 +31,9 @@ def timeit(name):
|
|||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
finally:
|
finally:
|
||||||
print(f"{name}: {time() - start:.3f} elapsed, {process_time() - start_cpu:.3f} CPU")
|
print(
|
||||||
|
f"{name}: {time() - start:.3f} elapsed, {process_time() - start_cpu:.3f} CPU"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ImmutableBenchmarks(SystemTestMixin, TestCase):
|
class ImmutableBenchmarks(SystemTestMixin, TestCase):
|
||||||
@ -37,11 +43,9 @@ class ImmutableBenchmarks(SystemTestMixin, TestCase):
|
|||||||
FORCE_FOOLSCAP_FOR_STORAGE = False
|
FORCE_FOOLSCAP_FOR_STORAGE = False
|
||||||
|
|
||||||
@async_to_deferred
|
@async_to_deferred
|
||||||
async def test_upload_and_download_immutable(self):
|
async def setUp(self):
|
||||||
self.basedir = self.mktemp()
|
SystemTestMixin.setUp(self)
|
||||||
|
self.basedir = os.path.join(mkdtemp(), "nodes")
|
||||||
# To test larger files, change this:
|
|
||||||
DATA = b"Some data to upload\n" * 10
|
|
||||||
|
|
||||||
# 2 nodes
|
# 2 nodes
|
||||||
await self.set_up_nodes(2)
|
await self.set_up_nodes(2)
|
||||||
@ -52,6 +56,11 @@ class ImmutableBenchmarks(SystemTestMixin, TestCase):
|
|||||||
c.encoding_params["happy"] = 1
|
c.encoding_params["happy"] = 1
|
||||||
c.encoding_params["n"] = 1
|
c.encoding_params["n"] = 1
|
||||||
|
|
||||||
|
@async_to_deferred
|
||||||
|
async def test_upload_and_download_immutable(self):
|
||||||
|
# To test larger files, change this:
|
||||||
|
DATA = b"Some data to upload\n" * 10
|
||||||
|
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
# 1. Upload:
|
# 1. Upload:
|
||||||
with timeit("upload"):
|
with timeit("upload"):
|
||||||
@ -65,11 +74,8 @@ class ImmutableBenchmarks(SystemTestMixin, TestCase):
|
|||||||
mc = await node.read(MemoryConsumer(), 0, None)
|
mc = await node.read(MemoryConsumer(), 0, None)
|
||||||
self.assertEqual(b"".join(mc.chunks), DATA)
|
self.assertEqual(b"".join(mc.chunks), DATA)
|
||||||
|
|
||||||
|
|
||||||
@async_to_deferred
|
@async_to_deferred
|
||||||
async def test_upload_and_download_mutable(self):
|
async def test_upload_and_download_mutable(self):
|
||||||
self.basedir = self.mktemp()
|
|
||||||
|
|
||||||
# To test larger files, change this:
|
# To test larger files, change this:
|
||||||
DATA = b"Some data to upload\n" * 10
|
DATA = b"Some data to upload\n" * 10
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user