Skip to content

Commit

Permalink
added values json schema (hashicorp#513)
Browse files Browse the repository at this point in the history
Generated the schema using the helm schema-gen plugin, and added extra
data types to fields that allow it, such as annotations, tolerations,
enabled, etc. Enabled the "contains-value-schema" chart-verifier test.

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>
  • Loading branch information
2 people authored and illegalnumbers committed Mar 16, 2022
1 parent cd9ba84 commit dcc1e5f
Show file tree
Hide file tree
Showing 4 changed files with 722 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ CLOUDSDK_CORE_PROJECT?=vault-helm-dev-246514
# set to run a single test - e.g acceptance/server-ha-enterprise-dr.bats
ACCEPTANCE_TESTS?=acceptance

# Generate json schema for chart values. See test/README.md for more details.
values-schema:
helm schema-gen values.yaml > values.schema.json

test-image:
@docker build --rm -t $(TEST_IMAGE) -f $(CURDIR)/test/docker/Test.dockerfile $(CURDIR)

Expand Down Expand Up @@ -62,4 +66,4 @@ provision-cluster:
destroy-cluster:
terraform destroy -auto-approve

.PHONY: test-image test-unit test-bats test test-acceptance test-destroy test-provision acceptance provision-cluster destroy-cluster
.PHONY: values-schema test-image test-unit test-bats test test-acceptance test-destroy test-provision acceptance provision-cluster destroy-cluster
28 changes: 26 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Running Vault Helm Acceptance tests
# Vault Helm Tests

## Running Vault Helm Acceptance tests

The Makefile at the top level of this repo contains a few target that should help with running acceptance tests in your own GKE instance.

Expand All @@ -7,4 +9,26 @@ The Makefile at the top level of this repo contains a few target that should hel
* Run `make test-provision` to provision the GKE cluster using terraform.
* Run `make test-acceptance` to run the acceptance tests in this already provisioned cluster.
* You can choose to only run certain tests by setting the ACCEPTANCE_TESTS variable and re-running the above target.
* Run `make test-destroy` when you have finished testing and want to tear-down and remove the cluster.
* Run `make test-destroy` when you have finished testing and want to tear-down and remove the cluster.

## Running chart verification tests

If [chart-verifier](https://github.com/redhat-certification/chart-verifier) is built and available in your PATH, run:

bats test/chart/verifier.bats

Or if you'd rather use the latest chart-verifier docker container, set
USE_DOCKER:

USE_DOCKER=true bats test/chart/verifier.bats

## Generating the values json schema

There is a make target for generating values.schema.json:

make values-schema

It relies on the helm [schema-gen plugin][schema-gen]. Note that some manual
editing will be required, since several properties accept multiple data types.

[schema-gen]: https://github.com/karuppiah7890/helm-schema-gen
9 changes: 4 additions & 5 deletions test/chart/verifier.bats
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ teardown_file() {
check_result contains-values
}

@test "contains-values-schema" {
check_result contains-values-schema
}

@test "images-are-certified" {
skip "Skipping until this has been addressed"
check_result images-are-certified
Expand All @@ -70,8 +74,3 @@ teardown_file() {
skip "Skipping until this has been addressed"
check_result contains-test
}

@test "contains-values-schema" {
skip "Skipping until this has been addressed"
check_result contains-values-schema
}
Loading

0 comments on commit dcc1e5f

Please sign in to comment.