Skip to content

Commit

Permalink
testsuite: test named config support for --conf option
Browse files Browse the repository at this point in the history
Problem: The tests in t2716-python-cli-batch-conf.t do not test named
config file support.

Add a set of tests to exercise this functionality.
  • Loading branch information
grondo committed Jun 7, 2023
1 parent af8cf6a commit 8c25eaf
Showing 1 changed file with 58 additions and 5 deletions.
63 changes: 58 additions & 5 deletions t/t2716-python-cli-batch-conf.t
Expand Up @@ -49,11 +49,64 @@ test_expect_success 'flux-batch --conf=FILE detects invalid syntax' '
test_debug "cat parse-error.out" &&
grep "parse error" parse-error.out
'
test_expect_success 'flux-batch --conf=NAME raises NotImplemented' '
test_must_fail flux batch --conf=named -n1 --dry-run \
--wrap hostname >named.out 2>&1 &&
test_debug "cat named.out" &&
grep "no named config support" named.out
test_expect_success 'flux-batch --conf=noexist fails' '
test_must_fail flux batch --conf=noexist -n1 --dry-run \
--wrap hostname >noexist.out 2>&1 &&
test_debug "cat noexist.out" &&
grep "named config.*not found" noexist.out
'
test_expect_success 'flux-batch --conf=NAME works with XDG_CONFIG_HOME' '
mkdir -p d/flux/config &&
cat <<-EOF >d/flux/config/test.toml &&
[resource]
noverify = true
exclude = "0"
EOF
XDG_CONFIG_HOME="$(pwd)/d" \
flux batch --conf=test -n1 --dry-run --wrap hostname \
>named-test.json &&
jq -e ".attributes.system.files[\"conf.json\"].data.resource.noverify" \
<named-test.json &&
jq -e ".attributes.system.files[\"conf.json\"].data.resource.exclude == \"0\"" \
<named-test.json
'
test_expect_success 'flux-batch --conf=NAME works with JSON config' '
cat <<-EOF >d/flux/config/test2.json &&
{"resource": {"exclude": "1"}}
EOF
XDG_CONFIG_HOME="$(pwd)/d" \
flux batch --conf=test2 -n1 --dry-run --wrap hostname \
>named-json.json &&
jq -e ".attributes.system.files[\"conf.json\"].data.resource.exclude == \"1\"" \
<named-json.json
'
test_expect_success 'flux-batch --conf=NAME works with XDG_CONFIG_DIRS' '
mkdir -p d2/flux/config &&
cat <<-EOF >d2/flux/config/test.toml &&
[resource]
noverify = false
exclude = "1"
EOF
XDG_CONFIG_DIRS="$(pwd)/d2:$(pwd)/d" \
flux batch --conf=test -n1 --dry-run --wrap hostname \
>named2-test.json &&
jq -e ".attributes.system.files[\"conf.json\"].data.resource.noverify == false" \
<named2-test.json &&
jq -e ".attributes.system.files[\"conf.json\"].data.resource.exclude == \"1\"" \
<named2-test.json
'
test_expect_success 'flux-batch parse error in named config is caught' '
mkdir -p d3/flux/config &&
cat <<-EOF >d3/flux/config/test.toml &&
[resource]
noverify = foo
EOF
XDG_CONFIG_DIRS="$(pwd)/d3:$(pwd)/d2:$(pwd)/d" \
test_must_fail \
flux batch --conf=test -n1 --dry-run --wrap hostname \
>named-parse-error.out 2>&1 &&
test_debug "cat named-parse-error.out" &&
grep 'conf=test:.*test.toml' named-parse-error.out
'
test_expect_success 'flux-batch --conf=KEY=VAL works' '
flux batch --conf=resource.noverify=true -n1 --dry-run \
Expand Down

0 comments on commit 8c25eaf

Please sign in to comment.