Skip to content

Commit

Permalink
Updating instructions for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
petems committed Nov 20, 2021
1 parent 16916f9 commit 49f4d58
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
/convert_report.txt
/update_report.txt
.DS_Store
vault.zip
29 changes: 21 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,29 @@ To run a specific spec test set the `SPEC` variable:

bundle exec rake spec SPEC=spec/foo_spec.rb:123

The tests require a version of `vault` to be avaliable on the command-line.

```
#!/bin/bash
VAULT_VERSION=1.3.0
cd /tmp/
curl -sLo vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
unzip vault.zip
mkdir -p /usr/local/bin
mv vault /usr/local/bin
export PATH="/usr/local/bin:$PATH"
```

## Integration tests
### Docker enviroment for tests

The unit tests just check the code runs, not that it does exactly what
we want on a real machine. For that we're using
[beaker](https://github.com/puppetlabs/beaker).
If you want a quick Docker lab to run the tests on, we have a `docker-compose` environment setup:

This fires up a simple Docker cluster and runs a series of
simple tests against it after applying the module. You can run this
with:
```
docker-compose up --build
```

bundle exec rake acceptance
If you have any errors, you can create and then attach to the container with run:

```
docker-compose run hiera_vault /bin/bash
```
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM ruby:2.7.3

RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends build-essential zip unzip libpq-dev libaio1 libaio-dev nodejs

ENV APP_HOME=/usr/src/module
ENV BUNDLE_PATH /gems
ENV VAULT_VERSION=1.3.0

COPY . $APP_HOME

RUN echo "gem: --no-rdoc --no-ri" >> ~/.gemrc

WORKDIR $APP_HOME
RUN gem update --system
RUN gem install bundler
RUN bundle install

RUN curl -sLo vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip \
&& unzip vault.zip \
&& mkdir -p /usr/local/bin \
&& mv vault /usr/local/bin

CMD ["sleep 1"]
11 changes: 0 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ GEM
faraday-rack (1.0.0)
fast_gettext (1.1.2)
ffi (1.15.4)
ffi (1.15.4-java)
fiber-local (1.0.0)
gettext (3.2.9)
locale (>= 2.0.5)
Expand All @@ -99,7 +98,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (2.6.1)
json (2.6.1-java)
json-schema (2.8.1)
addressable (>= 2.4)
json_pure (2.6.1)
Expand All @@ -118,7 +116,6 @@ GEM
multipart-post (2.1.1)
netrc (0.11.0)
nio4r (2.5.8)
nio4r (2.5.8-java)
octokit (4.21.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
Expand All @@ -140,10 +137,6 @@ GEM
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry (0.14.1-java)
coderay (~> 1.1)
method_source (~> 1.0)
spoon (~> 0.0)
public_suffix (4.0.6)
puppet (6.25.1)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -230,20 +223,16 @@ GEM
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
spdx-licenses (1.3.0)
spoon (0.0.6)
ffi
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
text (1.3.1)
thor (1.1.0)
thread_safe (0.3.6)
thread_safe (0.3.6-java)
timers (4.3.3)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf (0.1.4-java)
unf_ext (0.0.8)
unicode-display_width (2.1.0)
vault (0.16.0)
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: '2'
services:
hiera_vault:
build: .
command: bundle exec rake spec
8 changes: 8 additions & 0 deletions download_vault.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
VAULT_VERSION=1.3.0
cd /tmp/
curl -sLo vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
unzip vault.zip
mkdir -p /usr/local/bin
mv vault /usr/local/bin
echo 'Now run: export PATH="/usr/local/bin:$PATH"'
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,3 @@ def self.create_function(_name, &block)
config.warnings = false
end
end

require 'puppetlabs_spec_helper/module_spec_helper'

0 comments on commit 49f4d58

Please sign in to comment.