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
9386c5b7
Commit
9386c5b7
authored
3 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
black and isort
parent
df9a9227
Branches
Branches containing commit
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/_zkapauthorizer/_storage_server.py
+4
-7
4 additions, 7 deletions
src/_zkapauthorizer/_storage_server.py
src/_zkapauthorizer/tests/test_lease_maintenance.py
+15
-11
15 additions, 11 deletions
src/_zkapauthorizer/tests/test_lease_maintenance.py
with
19 additions
and
18 deletions
src/_zkapauthorizer/_storage_server.py
+
4
−
7
View file @
9386c5b7
...
@@ -33,12 +33,9 @@ from struct import calcsize, unpack
...
@@ -33,12 +33,9 @@ from struct import calcsize, unpack
import
attr
import
attr
from
allmydata.interfaces
import
RIStorageServer
from
allmydata.interfaces
import
RIStorageServer
from
allmydata.storage.common
import
storage_index_to_dir
from
allmydata.storage.common
import
storage_index_to_dir
from
allmydata.storage.shares
import
get_share_file
from
allmydata.storage.immutable
import
ShareFile
from
allmydata.storage.immutable
import
ShareFile
from
allmydata.storage.mutable
import
MutableShareFile
from
allmydata.storage.mutable
import
MutableShareFile
from
allmydata.storage.shares
import
get_share_file
from
allmydata.util.base32
import
b2a
from
allmydata.util.base32
import
b2a
from
attr.validators
import
instance_of
,
provides
from
attr.validators
import
instance_of
,
provides
from
challenge_bypass_ristretto
import
SigningKey
,
TokenPreimage
,
VerificationSignature
from
challenge_bypass_ristretto
import
SigningKey
,
TokenPreimage
,
VerificationSignature
...
@@ -642,6 +639,7 @@ def stat_slot(storage_server, slot, sharepath):
...
@@ -642,6 +639,7 @@ def stat_slot(storage_server, slot, sharepath):
lease_expiration
=
get_lease_expiration
(
sharepath
),
lease_expiration
=
get_lease_expiration
(
sharepath
),
)
)
def
get_lease_expiration
(
sharepath
):
def
get_lease_expiration
(
sharepath
):
# type: (str) -> Optional[int]
# type: (str) -> Optional[int]
"""
"""
...
@@ -651,14 +649,13 @@ def get_lease_expiration(sharepath):
...
@@ -651,14 +649,13 @@ def get_lease_expiration(sharepath):
:param sharepath: The path to the share file to inspect.
:param sharepath: The path to the share file to inspect.
"""
"""
leases
=
list
(
leases
=
list
(
lease
.
get_expiration_time
()
lease
.
get_expiration_time
()
for
lease
in
get_share_file
(
sharepath
).
get_leases
()
for
lease
in
get_share_file
(
sharepath
).
get_leases
()
)
)
if
leases
:
if
leases
:
return
max
(
leases
)
return
max
(
leases
)
return
None
return
None
def
get_slot_share_size
(
sharepath
):
def
get_slot_share_size
(
sharepath
):
"""
"""
Get the size of a share belonging to a slot (a mutable share).
Get the size of a share belonging to a slot (a mutable share).
...
...
This diff is collapsed.
Click to expand it.
src/_zkapauthorizer/tests/test_lease_maintenance.py
+
15
−
11
View file @
9386c5b7
...
@@ -34,10 +34,10 @@ from hypothesis.strategies import (
...
@@ -34,10 +34,10 @@ from hypothesis.strategies import (
floats
,
floats
,
integers
,
integers
,
just
,
just
,
tuples
,
lists
,
lists
,
sets
,
randoms
,
randoms
,
sets
,
tuples
,
)
)
from
testtools
import
TestCase
from
testtools
import
TestCase
from
testtools.matchers
import
(
from
testtools.matchers
import
(
...
@@ -66,7 +66,13 @@ from ..lease_maintenance import (
...
@@ -66,7 +66,13 @@ from ..lease_maintenance import (
visit_storage_indexes_from_root
,
visit_storage_indexes_from_root
,
)
)
from
.matchers
import
Provides
,
between
,
leases_current
from
.matchers
import
Provides
,
between
,
leases_current
from
.strategies
import
clocks
,
posix_timestamps
,
node_hierarchies
,
storage_indexes
,
sharenums
from
.strategies
import
(
clocks
,
node_hierarchies
,
posix_timestamps
,
sharenums
,
storage_indexes
,
)
def
interval_means
():
def
interval_means
():
...
@@ -100,17 +106,12 @@ class DummyStorageServer(object):
...
@@ -100,17 +106,12 @@ class DummyStorageServer(object):
"""
"""
clock
=
attr
.
ib
()
clock
=
attr
.
ib
()
buckets
=
attr
.
ib
()
# type: Dict[bytes, Dict[int, ShareStat]]
buckets
=
attr
.
ib
()
# type: Dict[bytes, Dict[int, ShareStat]]
lease_seed
=
attr
.
ib
()
lease_seed
=
attr
.
ib
()
def
stat_shares
(
self
,
storage_indexes
):
def
stat_shares
(
self
,
storage_indexes
):
# type: (List[bytes]) -> Deferred[List[Dict[int, ShareStat]]]
# type: (List[bytes]) -> Deferred[List[Dict[int, ShareStat]]]
return
succeed
(
return
succeed
(
list
(
self
.
buckets
.
get
(
idx
,
{})
for
idx
in
storage_indexes
))
list
(
self
.
buckets
.
get
(
idx
,
{})
for
idx
in
storage_indexes
)
)
def
get_lease_seed
(
self
):
def
get_lease_seed
(
self
):
return
self
.
lease_seed
return
self
.
lease_seed
...
@@ -440,6 +441,7 @@ def lists_of_buckets():
...
@@ -440,6 +441,7 @@ def lists_of_buckets():
share numbers to lease expiration times (as posix timestamps). Any given
share numbers to lease expiration times (as posix timestamps). Any given
storage index will appear only once in the overall result.
storage index will appear only once in the overall result.
"""
"""
def
add_expiration_times
(
sharenums
):
def
add_expiration_times
(
sharenums
):
return
builds
(
return
builds
(
lambda
nums
,
expires
:
dict
(
zip
(
nums
,
expires
)),
lambda
nums
,
expires
:
dict
(
zip
(
nums
,
expires
)),
...
@@ -634,7 +636,9 @@ class MaintainLeasesFromRootTests(TestCase):
...
@@ -634,7 +636,9 @@ class MaintainLeasesFromRootTests(TestCase):
for
node
in
root_node
.
flatten
():
for
node
in
root_node
.
flatten
():
for
server
in
storage_broker
.
get_connected_servers
():
for
server
in
storage_broker
.
get_connected_servers
():
try
:
try
:
shares
=
server
.
get_storage_server
().
buckets
[
node
.
get_storage_index
()]
shares
=
server
.
get_storage_server
().
buckets
[
node
.
get_storage_index
()
]
except
KeyError
:
except
KeyError
:
continue
continue
else
:
else
:
...
...
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