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
Tom Prince
PrivateStorageio
Commits
58749af8
Commit
58749af8
authored
3 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Pull the Tahoe test code out of the Nix test module
parent
09adcab5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
nixos/lib/testing.nix
+23
-0
23 additions, 0 deletions
nixos/lib/testing.nix
nixos/tests/tahoe.nix
+7
-48
7 additions, 48 deletions
nixos/tests/tahoe.nix
nixos/tests/test_tahoe.py
+45
-0
45 additions, 0 deletions
nixos/tests/test_tahoe.py
with
75 additions
and
48 deletions
nixos/lib/testing.nix
0 → 100644
+
23
−
0
View file @
58749af8
{
/* Returns a string that runs tests from the Python code at the given path.
The Python code is loaded using *execfile* and the *test* global it
defines is called with the given keyword arguments.
Type: makeTestScript :: Path -> AttrSet -> String
Example:
testScript = (makeTestScript ./test_foo.py { x = "y"; });
*/
makeTestScript
=
{
testpath
,
kwargs
?
{}
}:
''
# The driver runs pyflakes on this script before letting it
# run... Convince pyflakes that there is a `test` name.
test = None
with open("
${
testpath
}
") as testfile:
exec(testfile.read(), globals())
# For simple types, JSON is compatible with Python syntax!
test(**
${
builtins
.
toJSON
kwargs
}
)
''
;
}
This diff is collapsed.
Click to expand it.
nixos/tests/tahoe.nix
+
7
−
48
View file @
58749af8
{
...
}:
{
let
makeTestScript
=
(
import
../lib/testing.nix
)
.
makeTestScript
;
in
{
nodes
=
{
storage
=
{
config
,
pkgs
,
ourpkgs
,
...
}:
{
imports
=
[
...
...
@@ -23,50 +25,7 @@
};
};
};
testScript
=
''
start_all()
# After the service starts, destroy the "created" marker to force it to
# re-create its internal state.
storage.wait_for_open_port(4001)
storage.succeed("systemctl stop tahoe.storage")
storage.succeed("rm /var/db/tahoe-lafs/storage.created")
storage.succeed("systemctl start tahoe.storage")
# After it starts up again, verify it has consistent internal state and a
# backup of the prior state.
storage.wait_for_open_port(4001)
storage.succeed("[ -e /var/db/tahoe-lafs/storage ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.created ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.1 ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.1/private/node.privkey ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.1/private/node.pem ]")
storage.succeed("[ ! -e /var/db/tahoe-lafs/storage.2 ]")
# Stop it again, once again destroy the "created" marker, and this time also
# jam some partial state in the way that will need cleanup.
storage.succeed("systemctl stop tahoe.storage")
storage.succeed("rm /var/db/tahoe-lafs/storage.created")
storage.succeed("mkdir -p /var/db/tahoe-lafs/storage.atomic/partial")
try:
storage.succeed("systemctl start tahoe.storage")
except:
x, y = storage.execute("journalctl -u tahoe.storage")
storage.log(y)
raise
# After it starts up again, verify it has consistent internal state and
# backups of the prior two states. It also has no copy of the inconsistent
# state because it could never have been used.
storage.wait_for_open_port(4001)
storage.succeed("[ -e /var/db/tahoe-lafs/storage ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.created ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.1 ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.2 ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.2/private/node.privkey ]")
storage.succeed("[ -e /var/db/tahoe-lafs/storage.2/private/node.pem ]")
storage.succeed("[ ! -e /var/db/tahoe-lafs/storage.atomic ]")
storage.succeed("[ ! -e /var/db/tahoe-lafs/storage/partial ]")
storage.succeed("[ ! -e /var/db/tahoe-lafs/storage.3 ]")
''
;
testScript
=
makeTestScript
{
testpath
=
./test_tahoe.py
;
};
}
This diff is collapsed.
Click to expand it.
nixos/tests/test_tahoe.py
0 → 100644
+
45
−
0
View file @
58749af8
def
test
():
start_all
()
# After the service starts, destroy the "created" marker to force it to
# re-create its internal state.
storage
.
wait_for_open_port
(
4001
)
storage
.
succeed
(
"
systemctl stop tahoe.storage
"
)
storage
.
succeed
(
"
rm /var/db/tahoe-lafs/storage.created
"
)
storage
.
succeed
(
"
systemctl start tahoe.storage
"
)
# After it starts up again, verify it has consistent internal state and a
# backup of the prior state.
storage
.
wait_for_open_port
(
4001
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.created ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.1 ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.1/private/node.privkey ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.1/private/node.pem ]
"
)
storage
.
succeed
(
"
[ ! -e /var/db/tahoe-lafs/storage.2 ]
"
)
# Stop it again, once again destroy the "created" marker, and this time also
# jam some partial state in the way that will need cleanup.
storage
.
succeed
(
"
systemctl stop tahoe.storage
"
)
storage
.
succeed
(
"
rm /var/db/tahoe-lafs/storage.created
"
)
storage
.
succeed
(
"
mkdir -p /var/db/tahoe-lafs/storage.atomic/partial
"
)
try
:
storage
.
succeed
(
"
systemctl start tahoe.storage
"
)
except
:
x
,
y
=
storage
.
execute
(
"
journalctl -u tahoe.storage
"
)
storage
.
log
(
y
)
raise
# After it starts up again, verify it has consistent internal state and
# backups of the prior two states. It also has no copy of the inconsistent
# state because it could never have been used.
storage
.
wait_for_open_port
(
4001
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.created ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.1 ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.2 ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.2/private/node.privkey ]
"
)
storage
.
succeed
(
"
[ -e /var/db/tahoe-lafs/storage.2/private/node.pem ]
"
)
storage
.
succeed
(
"
[ ! -e /var/db/tahoe-lafs/storage.atomic ]
"
)
storage
.
succeed
(
"
[ ! -e /var/db/tahoe-lafs/storage/partial ]
"
)
storage
.
succeed
(
"
[ ! -e /var/db/tahoe-lafs/storage.3 ]
"
)
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