summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-09 17:47:58 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-09 17:47:58 +0300
commita742941804dd6f4b1ea3f39dfe3c7072b4b50e6b (patch)
tree286d2c03c2346b195c2989488d4da1e967a7c2e9
parentd0b0245edbb2f6ed8285358d83b98f3334bf1b12 (diff)
downloadobnam2-a742941804dd6f4b1ea3f39dfe3c7072b4b50e6b.tar.gz
refactor: make tests install a config in the default location
This way, every step doesn't need to specify a --config option to the Obnam client.
-rw-r--r--obnam.md84
-rw-r--r--subplot/client.py33
-rw-r--r--subplot/client.yaml4
3 files changed, 55 insertions, 66 deletions
diff --git a/obnam.md b/obnam.md
index 7e07c50..e5a5447 100644
--- a/obnam.md
+++ b/obnam.md
@@ -1153,7 +1153,7 @@ given an installed obnam
and a running chunk server
and a client config based on ca-required.yaml
and a file live/data.dat containing some random data
-when I try to run obnam --config ca-required.yaml backup
+when I try to run obnam backup
then command fails
then stderr contains "self signed certificate"
~~~
@@ -1182,11 +1182,11 @@ and a running chunk server
and a client config based on smoke.yaml
and a file live/data.dat containing some random data
and a manifest of the directory live in live.yaml
-when I run obnam --config smoke.yaml backup
+when I run obnam backup
then backup generation is GEN
-when I run obnam --config smoke.yaml list
+when I run obnam list
then generation list contains <GEN>
-when I invoke obnam --config smoke.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
given a manifest of the directory live restored in rest in rest.yaml
then manifests live.yaml and rest.yaml match
~~~
@@ -1221,9 +1221,9 @@ and a running chunk server
and a client config based on metadata.yaml
and a file live/data.dat containing some random data
and a manifest of the directory live in live.yaml
-when I run obnam --config metadata.yaml backup
+when I run obnam backup
then backup generation is GEN
-when I invoke obnam --config metadata.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
given a manifest of the directory live restored in rest in rest.yaml
then manifests live.yaml and rest.yaml match
~~~
@@ -1240,9 +1240,9 @@ and a client config based on metadata.yaml
and a file live/data.dat containing some random data
and file live/data.dat has mode 464
and a manifest of the directory live in live.yaml
-when I run obnam --config metadata.yaml backup
+when I run obnam backup
then backup generation is GEN
-when I invoke obnam --config metadata.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
given a manifest of the directory live restored in rest in rest.yaml
then manifests live.yaml and rest.yaml match
~~~
@@ -1259,9 +1259,9 @@ and a file live/data.dat containing some random data
and symbolink link live/link that points at data.dat
and symbolink link live/broken that points at does-not-exist
and a manifest of the directory live in live.yaml
-when I run obnam --config metadata.yaml backup
+when I run obnam backup
then backup generation is GEN
-when I invoke obnam --config metadata.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
given a manifest of the directory live restored in rest in rest.yaml
then manifests live.yaml and rest.yaml match
~~~
@@ -1277,7 +1277,7 @@ given an installed obnam
given a running chunk server
given a client config based on tiny-chunk-size.yaml
given a file live/data.dat containing "abc"
-when I run obnam --config tiny-chunk-size.yaml backup
+when I run obnam backup
then server has 3 file chunks
~~~
@@ -1305,8 +1305,8 @@ and a running chunk server
and a client config based on smoke.yaml
and a file live/data.dat containing some random data
and a manifest of the directory live in live.yaml
-when I run obnam --config smoke.yaml backup
-when I run obnam --config smoke.yaml list-files
+when I run obnam backup
+when I run obnam list-files
then file live/data.dat was backed up because it was new
~~~
@@ -1321,9 +1321,9 @@ and a running chunk server
and a client config based on smoke.yaml
and a file live/data.dat containing some random data
and a manifest of the directory live in live.yaml
-when I run obnam --config smoke.yaml backup
-when I run obnam --config smoke.yaml backup
-when I run obnam --config smoke.yaml list-files
+when I run obnam backup
+when I run obnam backup
+when I run obnam list-files
then file live/data.dat was not backed up because it was unchanged
~~~
@@ -1338,10 +1338,10 @@ and a running chunk server
and a client config based on smoke.yaml
and a file live/data.dat containing some random data
and a manifest of the directory live in live.yaml
-when I run obnam --config smoke.yaml backup
+when I run obnam backup
given a file live/data.dat containing some random data
-when I run obnam --config smoke.yaml backup
-when I run obnam --config smoke.yaml list-files
+when I run obnam backup
+when I run obnam list-files
then file live/data.dat was backed up because it was changed
~~~
@@ -1356,12 +1356,12 @@ given an installed obnam
and a running chunk server
and a client config based on smoke.yaml
and a file live/data.dat containing some random data
-when I run obnam --config smoke.yaml backup
+when I run obnam backup
then backup generation is GEN
-when I invoke obnam --config smoke.yaml get-chunk <GEN>
+when I invoke obnam get-chunk <GEN>
then exit code is 0
when chunk <GEN> on chunk server is replaced by an empty file
-when I invoke obnam --config smoke.yaml get-chunk <GEN>
+when I invoke obnam get-chunk <GEN>
then command fails
~~~
@@ -1381,8 +1381,8 @@ and a file live/data.dat containing some random data
and a Unix socket live/socket
and a named pipe live/pipe
and a manifest of the directory live in live.yaml
-when I run obnam --config smoke.yaml backup
-when I run obnam --config smoke.yaml restore latest rest
+when I run obnam backup
+when I run obnam restore latest rest
given a manifest of the directory live restored in rest in rest.yaml
then manifests live.yaml and rest.yaml match
~~~
@@ -1400,9 +1400,9 @@ and a running chunk server
and a client config based on metadata.yaml
and a file in live with a non-UTF8 filename
and a manifest of the directory live in live.yaml
-when I run obnam --config metadata.yaml backup
+when I run obnam backup
then backup generation is GEN
-when I invoke obnam --config metadata.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
given a manifest of the directory live restored in rest in rest.yaml
then manifests live.yaml and rest.yaml match
~~~
@@ -1422,9 +1422,9 @@ and a client config based on smoke.yaml
and a file live/data.dat containing some random data
and a file live/bad.dat containing some random data
and file live/bad.dat has mode 000
-when I run obnam --config smoke.yaml backup
+when I run obnam backup
then backup generation is GEN
-when I invoke obnam --config smoke.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
then file live/data.dat is restored to rest
then file live/bad.dat is not restored to rest
~~~
@@ -1440,10 +1440,10 @@ and a running chunk server
and a client config based on smoke.yaml
and a file live/unreadable/data.dat containing some random data
and file live/unreadable has mode 000
-when I run obnam --config smoke.yaml backup
+when I run obnam backup
then stdout contains "live/unreadable"
then backup generation is GEN
-when I invoke obnam --config smoke.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
then file live/unreadable is restored to rest
then file live/unreadable/data.dat is not restored to rest
~~~
@@ -1459,10 +1459,10 @@ and a running chunk server
and a client config based on smoke.yaml
and a file live/dir/data.dat containing some random data
and file live/dir has mode 600
-when I run obnam --config smoke.yaml backup
+when I run obnam backup
then stdout contains "live/dir"
then backup generation is GEN
-when I invoke obnam --config smoke.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
then file live/dir is restored to rest
then file live/dir/data.dat is not restored to rest
~~~
@@ -1479,13 +1479,13 @@ and a running chunk server
and a client config based on metadata.yaml
given a file live/data.dat containing some random data
-when I run obnam --config metadata.yaml backup
+when I run obnam backup
given a file live/more.dat containing some random data
and a manifest of the directory live in second.yaml
-when I run obnam --config metadata.yaml backup
+when I run obnam backup
-when I run obnam --config metadata.yaml restore latest rest
+when I run obnam restore latest rest
given a manifest of the directory live restored in rest in rest.yaml
then manifests second.yaml and rest.yaml match
~~~
@@ -1504,9 +1504,9 @@ and a file live/one/data.dat containing some random data
and a file live/two/data.dat containing some random data
and a manifest of the directory live/one in one.yaml
and a manifest of the directory live/two in two.yaml
-when I run obnam --config roots.yaml backup
+when I run obnam backup
then backup generation is GEN
-when I invoke obnam --config roots.yaml restore <GEN> rest
+when I invoke obnam restore <GEN> rest
given a manifest of the directory live/one restored in rest in rest-one.yaml
given a manifest of the directory live/two restored in rest in rest-two.yaml
then manifests one.yaml and rest-one.yaml match
@@ -1538,7 +1538,7 @@ and a running chunk server
and a client config based on encryption.yaml
and a file live/data.dat containing some random data
and a manifest of the directory live in live.yaml
-when I try to run obnam --config encryption.yaml backup
+when I try to run obnam backup
then command fails
then stderr contains "obnam init"
~~~
@@ -1560,10 +1560,10 @@ and a running chunk server
and a client config based on encryption.yaml
and a file live/data.dat containing some random data
and a manifest of the directory live in live.yaml
-when I run obnam --config encryption.yaml init --insecure-passphrase=hunter2
-then file passwords.yaml exists
-then file passwords.yaml is only readable by owner
-then file passwords.yaml does not contain "hunter2"
+when I run obnam init --insecure-passphrase=hunter2
+then file .config/obnam/passwords.yaml exists
+then file .config/obnam/passwords.yaml is only readable by owner
+then file .config/obnam/passwords.yaml does not contain "hunter2"
~~~
## A passphrase stored insecurely is rejected
diff --git a/subplot/client.py b/subplot/client.py
index 90642f3..1ddc772 100644
--- a/subplot/client.py
+++ b/subplot/client.py
@@ -26,38 +26,27 @@ def configure_client(ctx, filename=None):
config["server_url"] = ctx["server_url"]
logging.debug(f"client config {filename}: {config}")
+ dirname = os.path.expanduser("~/.config/obnam")
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+ filename = os.path.join(dirname, "obnam.yaml")
+ logging.debug(f"configure_client: filename={filename}")
with open(filename, "w") as f:
yaml.safe_dump(config, stream=f)
-def run_obnam_restore(ctx, filename=None, genid=None, todir=None):
- genid = ctx["vars"][genid]
- run_obnam_restore_with_genref(ctx, filename=filename, genref=genid, todir=todir)
+def run_obnam_restore(ctx, genid=None, todir=None):
+ runcmd_run = globals()["runcmd_run"]
+ genref = ctx["vars"][genid]
+ runcmd_run(ctx, ["env", "RUST_LOG=obnam", "obnam", "restore", genref, todir])
-def run_obnam_restore_with_genref(ctx, filename=None, genref=None, todir=None):
- runcmd_run = globals()["runcmd_run"]
- runcmd_run(
- ctx,
- [
- "env",
- "RUST_LOG=obnam",
- "obnam",
- "--config",
- filename,
- "restore",
- genref,
- todir,
- ],
- )
-
-
-def run_obnam_get_chunk(ctx, filename=None, gen_id=None, todir=None):
+def run_obnam_get_chunk(ctx, gen_id=None, todir=None):
runcmd_run = globals()["runcmd_run"]
gen_id = ctx["vars"][gen_id]
logging.debug(f"run_obnam_get_chunk: gen_id={gen_id}")
- runcmd_run(ctx, ["obnam", "--config", filename, "get-chunk", gen_id])
+ runcmd_run(ctx, ["obnam", "get-chunk", gen_id])
def capture_generation_id(ctx, varname=None):
diff --git a/subplot/client.yaml b/subplot/client.yaml
index eba9212..8c76e9f 100644
--- a/subplot/client.yaml
+++ b/subplot/client.yaml
@@ -5,10 +5,10 @@
- given: "a client config based on {filename}"
function: configure_client
-- when: "I invoke obnam --config {filename} restore <{genid}> {todir}"
+- when: "I invoke obnam restore <{genid}> {todir}"
function: run_obnam_restore
-- when: "I invoke obnam --config {filename} get-chunk <{gen_id}>"
+- when: "I invoke obnam get-chunk <{gen_id}>"
function: run_obnam_get_chunk
- then: "backup generation is {varname}"