You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adopting according to new readability and code style (#553)
* Adopting according to new readability and code style
* Removing whitespace
* Making shellcheck happy
* chore(test): revert previous styling changes
See: #553 (comment)
* chore(test): wrap variables in double quotes
This would be picked up by `shellcheck` in CI if the script wasn't
inlined. We should consider moving test scripts out of yaml files.
* chore(test): use bash strict mode
According to [kuttl docs], scripts are executed via `sh -c`. The docs do
not suggest if strict mode is enabled, so we should set it. There also
doesn't seem to be a way to choose the shell (whithout calling a shell
youself from within the script).
Without strict mode on, only the final commands exist status is
considered - meaning assertions before the last could fail and never be
picked up.
[kuttl docs]: https://kuttl.dev/docs/testing/steps.html#shell-scripts
* chore(test): add comments to tests
It might seem trivial, but it can help reviewers quickly understand what
the command line is for, and quickly assert whether that lines up with
what the command line is actually doing.
* chore(test): make assertions more precise with exact matching with grep
We should test exact matches with grep.
By default, `yq` will output strings with double quotes, so those should
be removed with `-r` or `--unwrapScalar` for yq-go (the python yq which
has the same options as jq can use `-r` or `--raw-output`).
Note: I just leart about the `-w` option, which would remove the need
for '^$'.
* chore(test): split long commands into multi-line commands, split label options into multiple args
Instead of splitting by line-length, I am:
- Splitting by pipe
- Splitting by flag/option
This is to make reviews simpler when using split panes
(side-by-side).
* chore(test): suggestion: use long-options where possible
I went to town on this one. You could argue that trivial cases (eg: `sed -e`) are ok.
This is just for demonstration.
* chore(test): fix yamllint
* Revert "chore(test): suggestion: use long-options where possible"
This reverts commit fc6fd79.
* chore(test): fix yamllint
* chore(test): remove -o pipefail bash option
* chore(test): undo ORed labels
---------
Co-authored-by: Nick Larsen <[email protected]>
Copy file name to clipboardExpand all lines: tests/templates/kuttl/overrides/31-assert.yaml
+97-16Lines changed: 97 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -3,23 +3,104 @@ apiVersion: kuttl.dev/v1beta1
3
3
kind: TestAssert
4
4
timeout: 30
5
5
commands:
6
+
# master, default RG
6
7
- script: |
7
-
POD=$(kubectl -n $NAMESPACE get pod -l app.kubernetes.io/component=master,app.kubernetes.io/role-group=default -o name | head -n 1 | sed -e 's#pod/##')
8
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MASTER").value' | grep 'MASTER'
9
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MRG").value' | grep 'MASTER'
10
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep 'MASTER_RG'
POD=$(kubectl -n $NAMESPACE get pod -l app.kubernetes.io/component=regionserver,app.kubernetes.io/role-group=resources-from-role -o name | head -n 1 | sed -e 's#pod/##')
13
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' | grep 'REGIONSERVER'
14
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFR").value' | grep 'REGIONSERVER'
15
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep 'REGIONSERVER_RFR'
POD=$(kubectl -n $NAMESPACE get pod -l app.kubernetes.io/component=regionserver,app.kubernetes.io/role-group=resources-from-role-group -o name | head -n 1 | sed -e 's#pod/##')
18
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' | grep 'REGIONSERVER'
19
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFRG").value' | grep 'REGIONSERVER'
20
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep 'REGIONSERVER_RFRG'
POD=$(kubectl -n $NAMESPACE get pod -l app.kubernetes.io/component=restserver,app.kubernetes.io/role-group=default -o name | head -n 1 | sed -e 's#pod/##')
23
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST").value' | grep 'RESTSERVER'
24
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST_RG").value' | grep 'RESTSERVER'
25
-
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep 'RESTSERVER_RG'
0 commit comments