diff options
| author | Stuart Clark <stuart.clark@Jahingo.com> | 2017-08-03 01:23:08 +0100 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2017-08-02 20:23:08 -0400 |
| commit | ab59ea091a2374653ea8aeb5ed7675de61c08461 (patch) | |
| tree | d9f6da8b3cb65c620adf0604ed8633f5cdc3be5f /test | |
| parent | c0e706dc97240446494f7cdb5b907d358697b285 (diff) | |
Add Consul & BoltDB datasource support (#178)
* Add libkv support
* Add vendoring
Diffstat (limited to 'test')
| -rw-r--r-- | test/integration/Dockerfile | 6 | ||||
| -rw-r--r-- | test/integration/config.db | bin | 0 -> 32768 bytes | |||
| -rw-r--r-- | test/integration/datasources_boltdb.bats | 27 | ||||
| -rw-r--r-- | test/integration/datasources_consul.bats | 35 | ||||
| -rwxr-xr-x | test/integration/test.sh | 4 |
5 files changed, 72 insertions, 0 deletions
diff --git a/test/integration/Dockerfile b/test/integration/Dockerfile index da792ad6..bdacd19e 100644 --- a/test/integration/Dockerfile +++ b/test/integration/Dockerfile @@ -1,6 +1,7 @@ FROM alpine:edge ENV VAULT_VER 0.7.0 +ENV CONSUL_VER 0.9.0 RUN apk add --no-cache \ curl \ bash \ @@ -10,6 +11,10 @@ RUN apk add --no-cache \ && unzip /tmp/vault.zip \ && mv vault /bin/vault \ && rm /tmp/vault.zip \ + && curl -L -o /tmp/consul.zip https://releases.hashicorp.com/consul/${CONSUL_VER}/consul_${CONSUL_VER}_linux_amd64.zip \ + && unzip /tmp/consul.zip \ + && mv consul /bin/consul \ + && rm /tmp/consul.zip \ && apk del curl RUN mkdir /lib64 \ @@ -20,5 +25,6 @@ COPY mirror /bin/mirror COPY *.sh /tests/ COPY *.bash /tests/ COPY *.bats /tests/ +COPY *.db /test/integration/ CMD ["/tests/test.sh"] diff --git a/test/integration/config.db b/test/integration/config.db Binary files differnew file mode 100644 index 00000000..e68a29c6 --- /dev/null +++ b/test/integration/config.db diff --git a/test/integration/datasources_boltdb.bats b/test/integration/datasources_boltdb.bats new file mode 100644 index 00000000..8260cbf6 --- /dev/null +++ b/test/integration/datasources_boltdb.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +load helper + +tmpdir=$(mktemp -u) + +function setup () { + mkdir -p $tmpdir +} + +function teardown () { + rm -rf $tmpdir || true +} + +@test "supports BoltDB datasource file" { + cp test/integration/config.db $tmpdir/config.db + gomplate -d config=boltdb://$tmpdir/config.db#Bucket1 -i '{{(datasource "config" "foo")}}' + [ "$status" -eq 0 ] + [[ "${output}" == "bar" ]] +} + +@test "supports multi-bucket BoltDB datasource file" { + cp test/integration/config.db $tmpdir/config.db + gomplate -d config=boltdb://$tmpdir/config.db#Bucket1 -d config2=boltdb://$tmpdir/config.db#Bucket2 -i '{{(datasource "config" "foo")}}-{{(datasource "config2" "foobar")}}' + [ "$status" -eq 0 ] + [[ "${output}" == "bar-baz" ]] +} diff --git a/test/integration/datasources_consul.bats b/test/integration/datasources_consul.bats new file mode 100644 index 00000000..383bed9a --- /dev/null +++ b/test/integration/datasources_consul.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats + +load helper + +function setup () { + tmpdir=$(mktemp -d) +} + +function teardown () { + rm -rf $tmpdir + consul kv delete foo +} + +@test "Testing consul" { + consul kv put foo "$BATS_TEST_DESCRIPTION" + gomplate -d consul=consul:// -i '{{(datasource "consul" "foo")}}' + [ "$status" -eq 0 ] + [[ "${output}" == "$BATS_TEST_DESCRIPTION" ]] +} + +@test "Consul datasource works with hostname in URL" { + consul kv put foo "$BATS_TEST_DESCRIPTION" + unset CONSUL_HTTP_ADDR + gomplate -d consul=consul+http://localhost:8500/ -i '{{(datasource "consul" "foo")}}' + [ "$status" -eq 0 ] + [[ "${output}" == "$BATS_TEST_DESCRIPTION" ]] +} + +@test "Consul datasource works with consul+http scheme" { + consul kv put foo "$BATS_TEST_DESCRIPTION" + unset CONSUL_HTTP_ADDR + gomplate -d consul=consul+http:// -i '{{(datasource "consul" "foo")}}' + [ "$status" -eq 0 ] + [[ "${output}" == "$BATS_TEST_DESCRIPTION" ]] +} diff --git a/test/integration/test.sh b/test/integration/test.sh index 270c1cda..298d1a35 100755 --- a/test/integration/test.sh +++ b/test/integration/test.sh @@ -13,4 +13,8 @@ export VAULT_ROOT_TOKEN=00000000-1111-2222-3333-444455556666 # fire up vault in dev mode for the vault tests vault server -dev -dev-root-token-id=${VAULT_ROOT_TOKEN} -log-level=err >&/dev/null & +export CONSUL_HTTP_ADDR=http://127.0.0.1:8500 + +consul agent -dev -log-level=err >&/dev/null & + bats $(dirname $0) |
