Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZKAPAuthorizer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
ZKAPAuthorizer
Commits
04d0da75
Commit
04d0da75
authored
3 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Consistently use `self.clock` so less synchronization is required
parent
ec2c31a9
Branches
Branches containing commit
No related tags found
2 merge requests
!231
Remove `renew_lease` from our storage protocol
,
!229
Set up CI for Tahoe 1.16.x
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/_zkapauthorizer/tests/test_storage_protocol.py
+18
-15
18 additions, 15 deletions
src/_zkapauthorizer/tests/test_storage_protocol.py
with
18 additions
and
15 deletions
src/_zkapauthorizer/tests/test_storage_protocol.py
+
18
−
15
View file @
04d0da75
...
@@ -560,6 +560,10 @@ class ShareTests(TestCase):
...
@@ -560,6 +560,10 @@ class ShareTests(TestCase):
# Hypothesis might want to try a case where time is further in the
# Hypothesis might want to try a case where time is further in the
# past than an earlier case - so we possibly rewind the clock here.
# past than an earlier case - so we possibly rewind the clock here.
synchronize_clocks
(
from_clock
=
clock
,
to_clock
=
self
.
clock
)
synchronize_clocks
(
from_clock
=
clock
,
to_clock
=
self
.
clock
)
# Throw away the Hypothesis-supplied clock now that we've adopted its
# time. This prevents us from accidentally using it instead of
# self.clock later on.
del
clock
# anonymous_storage_server uses time.time() before Tahoe-LAFS 1.16,
# anonymous_storage_server uses time.time() before Tahoe-LAFS 1.16,
# unfortunately. For Tahoe-LAFS 1.16, AnonymousStorageServer will
# unfortunately. For Tahoe-LAFS 1.16, AnonymousStorageServer will
...
@@ -567,7 +571,7 @@ class ShareTests(TestCase):
...
@@ -567,7 +571,7 @@ class ShareTests(TestCase):
# monkey-patching.
# monkey-patching.
#
#
# And useFixture does not interact very well with Hypothesis.
# And useFixture does not interact very well with Hypothesis.
patch
=
MonkeyPatch
(
"
time.time
"
,
clock
.
seconds
)
patch
=
MonkeyPatch
(
"
time.time
"
,
self
.
clock
.
seconds
)
try
:
try
:
patch
.
setUp
()
patch
.
setUp
()
# Create a share we can toy with.
# Create a share we can toy with.
...
@@ -592,7 +596,7 @@ class ShareTests(TestCase):
...
@@ -592,7 +596,7 @@ class ShareTests(TestCase):
expected
=
[{
expected
=
[{
sharenum
:
ShareStat
(
sharenum
:
ShareStat
(
size
=
size
,
size
=
size
,
lease_expiration
=
int
(
clock
.
seconds
()
+
LEASE_INTERVAL
),
lease_expiration
=
int
(
self
.
clock
.
seconds
()
+
LEASE_INTERVAL
),
),
),
}]
}]
self
.
assertThat
(
self
.
assertThat
(
...
@@ -790,7 +794,9 @@ class ShareTests(TestCase):
...
@@ -790,7 +794,9 @@ class ShareTests(TestCase):
# See the comment in `_stat_shares_immutable_test` for an explanation
# See the comment in `_stat_shares_immutable_test` for an explanation
# of clock handling and time.time monkey-patching.
# of clock handling and time.time monkey-patching.
synchronize_clocks
(
from_clock
=
clock
,
to_clock
=
self
.
clock
)
synchronize_clocks
(
from_clock
=
clock
,
to_clock
=
self
.
clock
)
patch
=
MonkeyPatch
(
"
time.time
"
,
clock
.
seconds
)
del
clock
patch
=
MonkeyPatch
(
"
time.time
"
,
self
.
clock
.
seconds
)
try
:
try
:
patch
.
setUp
()
patch
.
setUp
()
# Create a share we can toy with.
# Create a share we can toy with.
...
@@ -820,7 +826,7 @@ class ShareTests(TestCase):
...
@@ -820,7 +826,7 @@ class ShareTests(TestCase):
vectors
.
write_vector
,
vectors
.
write_vector
,
vectors
.
new_length
,
vectors
.
new_length
,
),
),
lease_expiration
=
int
(
clock
.
seconds
()
+
LEASE_INTERVAL
),
lease_expiration
=
int
(
self
.
clock
.
seconds
()
+
LEASE_INTERVAL
),
)
)
for
(
sharenum
,
vectors
)
for
(
sharenum
,
vectors
)
in
test_and_write_vectors_for_shares
.
items
()
in
test_and_write_vectors_for_shares
.
items
()
...
@@ -1014,6 +1020,11 @@ class ShareTests(TestCase):
...
@@ -1014,6 +1020,11 @@ class ShareTests(TestCase):
# up between iterations.
# up between iterations.
cleanup_storage_server
(
self
.
anonymous_storage_server
)
cleanup_storage_server
(
self
.
anonymous_storage_server
)
# See the comment in `_stat_shares_immutable_test` for an explanation
# of clock handling and time.time monkey-patching.
synchronize_clocks
(
from_clock
=
clock
,
to_clock
=
self
.
clock
)
del
clock
secrets
=
(
write_enabler
,
renew_secret
,
cancel_secret
)
secrets
=
(
write_enabler
,
renew_secret
,
cancel_secret
)
def
write
():
def
write
():
...
@@ -1028,10 +1039,7 @@ class ShareTests(TestCase):
...
@@ -1028,10 +1039,7 @@ class ShareTests(TestCase):
r_vector
=
[],
r_vector
=
[],
)
)
# See the comment in `_stat_shares_immutable_test` for an explanation
patch
=
MonkeyPatch
(
"
time.time
"
,
self
.
clock
.
seconds
)
# of clock handling and time.time monkey-patching.
synchronize_clocks
(
from_clock
=
clock
,
to_clock
=
self
.
clock
)
patch
=
MonkeyPatch
(
"
time.time
"
,
clock
.
seconds
)
try
:
try
:
patch
.
setUp
()
patch
.
setUp
()
...
@@ -1040,12 +1048,7 @@ class ShareTests(TestCase):
...
@@ -1040,12 +1048,7 @@ class ShareTests(TestCase):
# Advance time by more than a lease period so the lease is no
# Advance time by more than a lease period so the lease is no
# longer valid.
# longer valid.
clock
.
advance
(
self
.
server
.
LEASE_PERIOD
.
total_seconds
()
+
1
)
self
.
clock
.
advance
(
self
.
server
.
LEASE_PERIOD
.
total_seconds
()
+
1
)
# Since we just changed the Hypothesis-supplied clock we need to
# update the other clock (the one StorageServer is looking at)
# too. :/
synchronize_clocks
(
from_clock
=
clock
,
to_clock
=
self
.
clock
)
self
.
assertThat
(
write
(),
is_successful_write
())
self
.
assertThat
(
write
(),
is_successful_write
())
finally
:
finally
:
...
@@ -1061,7 +1064,7 @@ class ShareTests(TestCase):
...
@@ -1061,7 +1064,7 @@ class ShareTests(TestCase):
test_and_write_vectors_for_shares
[
num
].
write_vector
,
test_and_write_vectors_for_shares
[
num
].
write_vector
,
test_and_write_vectors_for_shares
[
num
].
new_length
,
test_and_write_vectors_for_shares
[
num
].
new_length
,
),
),
lease_expiration
=
int
(
clock
.
seconds
()
+
self
.
server
.
LEASE_PERIOD
.
total_seconds
()),
lease_expiration
=
int
(
self
.
clock
.
seconds
()
+
self
.
server
.
LEASE_PERIOD
.
total_seconds
()),
)
)
for
num
for
num
in
test_and_write_vectors_for_shares
in
test_and_write_vectors_for_shares
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment