Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PrivateStorageio
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
Show more breadcrumbs
PrivateStorage
PrivateStorageio
Commits
90d9a492
Commit
90d9a492
authored
5 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Add system test for mutable data (a directory)
It fails
parent
ce345971
Branches
Branches containing commit
No related tags found
1 merge request
!13
Fix Foolscap protocol issues
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nixos/modules/tests/exercise-storage.py
+34
-9
34 additions, 9 deletions
nixos/modules/tests/exercise-storage.py
nixos/modules/tests/private-storage.nix
+1
-1
1 addition, 1 deletion
nixos/modules/tests/private-storage.nix
with
35 additions
and
10 deletions
nixos/modules/tests/exercise-storage.py
+
34
−
9
View file @
90d9a492
...
@@ -12,6 +12,7 @@ from subprocess import check_output
...
@@ -12,6 +12,7 @@ from subprocess import check_output
from
io
import
BytesIO
from
io
import
BytesIO
import
requests
import
requests
import
hyperlink
def
main
():
def
main
():
(
clientDir
,)
=
argv
[
1
:]
(
clientDir
,)
=
argv
[
1
:]
...
@@ -19,28 +20,52 @@ def main():
...
@@ -19,28 +20,52 @@ def main():
someData
=
urandom
(
2
**
16
)
someData
=
urandom
(
2
**
16
)
api_root
=
get_api_root
(
clientDir
)
api_root
=
get_api_root
(
clientDir
)
cap
=
put
(
api_root
,
someData
)
dataReadBack
=
get
(
api_root
,
cap
)
exercise_immutable
(
api_root
,
someData
)
exercise_mkdir
(
api_root
)
def
exercise_immutable
(
api_root
,
someData
):
cap
=
tahoe_put
(
api_root
,
someData
)
dataReadBack
=
tahoe_get
(
api_root
,
cap
)
assert
someData
==
dataReadBack
assert
someData
==
dataReadBack
return
cap
def
exercise_mkdir
(
api_root
):
cap
=
tahoe_mkdir
(
api_root
)
info
=
tahoe_stat
(
api_root
,
cap
)
assert
info
def
get_api_root
(
path
):
def
get_api_root
(
path
):
with
open
(
path
+
u
"
/node.url
"
)
as
f
:
with
open
(
path
+
u
"
/node.url
"
)
as
f
:
return
f
.
read
().
strip
()
return
hyperlink
.
URL
.
from_text
(
f
.
read
().
strip
())
def
put
(
api_root
,
data
):
def
tahoe_
put
(
api_root
,
data
,
**
kwargs
):
response
=
requests
.
put
(
api_root
+
u
"
uri
"
,
BytesIO
(
data
))
response
=
requests
.
put
(
api_root
.
child
(
u
"
uri
"
)
,
BytesIO
(
data
))
response
.
raise_for_status
()
response
.
raise_for_status
()
return
response
.
text
return
response
.
text
def
tahoe_get
(
api_root
,
cap
):
def
get
(
api_root
,
cap
):
response
=
requests
.
get
(
api_root
.
child
(
u
"
uri
"
,
cap
),
stream
=
True
)
response
=
requests
.
get
(
api_root
+
u
"
uri/
"
+
cap
,
stream
=
True
)
response
.
raise_for_status
()
response
.
raise_for_status
()
return
response
.
raw
.
read
()
return
response
.
raw
.
read
()
def
tahoe_mkdir
(
api_root
):
response
=
requests
.
post
(
api_root
.
child
(
u
"
uri
"
).
replace
(
query
=
{
u
"
t
"
:
u
"
mkdir
"
,
u
"
format
"
:
u
"
mdmf
"
}))
response
.
raise_for_status
()
return
response
.
text
def
tahoe_link
(
api_root
,
dir_cap
,
name
,
subject_cap
):
response
=
requests
.
post
(
api_root
.
child
(
u
"
uri
"
,
dir_cap
,
name
).
replace
(
query
=
{
u
"
t
"
:
u
"
uri
"
}),
BytesIO
(
subject_cap
),
)
response
.
raise_for_status
()
return
response
.
text
def
tahoe_stat
(
api_root
,
cap
):
response
=
requests
.
post
(
api_root
.
child
(
u
"
uri
"
,
cap
).
replace
(
query
=
{
u
"
t
"
:
u
"
json
"
}))
response
.
raise_for_status
()
return
response
.
json
if
__name__
==
u
'
__main__
'
:
if
__name__
==
u
'
__main__
'
:
main
()
main
()
This diff is collapsed.
Click to expand it.
nixos/modules/tests/private-storage.nix
+
1
−
1
View file @
90d9a492
...
@@ -53,7 +53,7 @@ import <nixpkgs/nixos/tests/make-test.nix> {
...
@@ -53,7 +53,7 @@ import <nixpkgs/nixos/tests/make-test.nix> {
# plugin.
# plugin.
pspkgs
.
privatestorage
pspkgs
.
privatestorage
# Support for the tests we'll run.
# Support for the tests we'll run.
(
pkgs
.
python3
.
withPackages
(
ps
:
[
ps
.
requests
]))
(
pkgs
.
python3
.
withPackages
(
ps
:
[
ps
.
requests
ps
.
hyperlink
]))
];
];
}
//
networkConfig
;
}
//
networkConfig
;
...
...
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