Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b59cbf6

Browse files
authoredMay 10, 2021
Set kubeVersion and added chart-verifier tests (#510)
Set min kubeVersion in Chart.yaml to 1.14. Added a chart-verifier bats test, and configured to run it in CI. Some verification tests that haven't been addressed yet are skipped.
1 parent dcb4b10 commit b59cbf6

File tree

5 files changed

+122
-2
lines changed

5 files changed

+122
-2
lines changed
 

‎.circleci/config.yml

+24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@ jobs:
1010
steps:
1111
- checkout
1212
- run: bats ./test/unit -t
13+
14+
chart-verifier:
15+
docker:
16+
- image: docker.mirror.hashicorp.services/cimg/go:1.16
17+
environment:
18+
BATS_VERSION: "1.3.0"
19+
# Note: the commit SHA is used here since the repo doesn't use release tags
20+
CHART_VERIFIER_VERSION: "190d532246a5936dc6a7125e2da917d04e38a672"
21+
steps:
22+
- checkout
23+
- run:
24+
name: install chart-verifier
25+
command: go get github.com/redhat-certification/chart-verifier@${CHART_VERIFIER_VERSION}
26+
- run:
27+
name: install bats
28+
command: |
29+
curl -sSL https://github.com/bats-core/bats-core/archive/v${BATS_VERSION}.tar.gz -o /tmp/bats.tgz
30+
tar -zxf /tmp/bats.tgz -C /tmp
31+
sudo /bin/bash /tmp/bats-core-${BATS_VERSION}/install.sh /usr/local
32+
- run:
33+
name: run chart-verifier tests
34+
command: bats ./test/chart -t
35+
1336
acceptance:
1437
docker:
1538
# This image is build from test/docker/Test.dockerfile
@@ -66,6 +89,7 @@ workflows:
6689
build_and_test:
6790
jobs:
6891
- bats-unit-test
92+
- chart-verifier
6993
- acceptance:
7094
requires:
7195
- bats-unit-test

‎Chart.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: v2
22
name: vault
33
version: 0.11.0
44
appVersion: 1.7.0
5+
kubeVersion: ">= 1.14"
56
description: Official HashiCorp Vault Chart
67
home: https://www.vaultproject.io
78
icon: https://github.com/hashicorp/vault/raw/f22d202cde2018f9455dec755118a9b84586e082/Vault_PrimaryLogo_Black.png

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ The versions required are:
2222

2323
* **Helm 3.0+** - This is the earliest version of Helm tested. It is possible
2424
it works with earlier versions but this chart is untested for those versions.
25-
* **Kubernetes 1.9+** - This is the earliest version of Kubernetes tested.
25+
* **Kubernetes 1.14+** - This is the earliest version of Kubernetes tested.
2626
It is possible that this chart works with earlier versions but it is
27-
untested. Other versions verified are Kubernetes 1.10, 1.11.
27+
untested.
2828

2929
## Usage
3030

‎test/chart/_helpers.bash

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# chart_dir returns the directory for the chart
2+
chart_dir() {
3+
echo ${BATS_TEST_DIRNAME}/../..
4+
}
5+
6+
# check_result checks if the specified test passed
7+
# results schema example:
8+
# {
9+
# "check": "has-minkubeversion",
10+
# "type": "Mandatory",
11+
# "outcome": "PASS",
12+
# "reason": "Minimum Kubernetes version specified"
13+
# }
14+
check_result() {
15+
local -r var="$1"
16+
local check=$(cat $VERIFY_OUTPUT | jq -r ".results[] | select(.check==\"${var}\").outcome")
17+
[ "$check" = "PASS" ]
18+
}

‎test/chart/verifier.bats

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bats
2+
3+
load _helpers
4+
5+
setup_file() {
6+
cd `chart_dir`
7+
export VERIFY_OUTPUT="/$BATS_RUN_TMPDIR/verify.json"
8+
export CHART_VOLUME=vault-helm-chart-src
9+
# Note: currently `latest` is the only tag available in the chart-verifier repo.
10+
local IMAGE="quay.io/redhat-certification/chart-verifier:latest"
11+
12+
local run_cmd="chart-verifier"
13+
local chart_src="."
14+
15+
if [ ! -e $USE_DOCKER ]; then
16+
chart_src="/chart"
17+
# Create a dummy container which will hold a volume with chart source
18+
docker create -v $chart_src --name $CHART_VOLUME alpine:3 /bin/true
19+
# Copy the chart source into this volume
20+
docker cp . $CHART_VOLUME:$chart_src
21+
# Make sure we have the latest version of chart-verifier
22+
docker pull $IMAGE
23+
# Start chart-verifier using this volume
24+
run_cmd="docker run --rm --volumes-from $CHART_VOLUME $IMAGE"
25+
fi
26+
27+
$run_cmd verify --output json $chart_src 2>&1 | tee $VERIFY_OUTPUT
28+
}
29+
30+
teardown_file() {
31+
if [ ! -e $USE_DOCKER ]; then
32+
docker rm $CHART_VOLUME
33+
fi
34+
}
35+
36+
@test "has-minkubeversion" {
37+
check_result has-minkubeversion
38+
}
39+
40+
@test "is-helm-v3" {
41+
check_result is-helm-v3
42+
}
43+
44+
@test "not-contains-crds" {
45+
check_result not-contains-crds
46+
}
47+
48+
@test "helm-lint" {
49+
check_result helm-lint
50+
}
51+
52+
@test "not-contain-csi-objects" {
53+
check_result not-contain-csi-objects
54+
}
55+
56+
@test "has-readme" {
57+
check_result has-readme
58+
}
59+
60+
@test "contains-values" {
61+
check_result contains-values
62+
}
63+
64+
@test "images-are-certified" {
65+
skip "Skipping until this has been addressed"
66+
check_result images-are-certified
67+
}
68+
69+
@test "contains-test" {
70+
skip "Skipping until this has been addressed"
71+
check_result contains-test
72+
}
73+
74+
@test "contains-values-schema" {
75+
skip "Skipping until this has been addressed"
76+
check_result contains-values-schema
77+
}

0 commit comments

Comments
 (0)
Please sign in to comment.