Skip to content

Commit 41478b4

Browse files
committed
#13 - Updated tests to use inspec
1 parent 18c2ce3 commit 41478b4

File tree

8 files changed

+49
-56
lines changed

8 files changed

+49
-56
lines changed

docker/centos7/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ ENV TERM=xterm
55
RUN yum install -y epel-release \
66
&& yum install -y \
77
ansible \
8-
git \
9-
iproute \
10-
java-1.8.0-openjdk \
11-
ruby \
12-
sudo \
13-
tar \
8+
wget \
9+
coreutils \
10+
net-tools \
1411
&& yum clean all
1512

16-
RUN gem install serverspec
13+
## https://downloads.chef.io/inspec/1.24.0
14+
RUN wget -q https://packages.chef.io/files/stable/inspec/1.24.0/el/7/inspec-1.24.0-1.el7.x86_64.rpm \
15+
&& echo "c3b739f4262a56ad1626a4c46465a9905d3ab2d36514c4cfdc998cd2dae24f90 inspec-1.24.0-1.el7.x86_64.rpm" \
16+
| sha256sum -c \
17+
&& yum install -y inspec-1.24.0-1.el7.x86_64.rpm \
18+
&& rm inspec-1.24.0-1.el7.x86_64.rpm

docker/jessie64/Dockerfile

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
11
# vim: set ft=dockerfile:
22

3-
# Requires Ansible 1.8+ from jessie-backports.
4-
FROM debian:jessie-backports
3+
FROM debian:jessie
54

65
# Colour output.
76
ENV TERM=xterm
87

9-
# Defaults to graphical.target.
10-
RUN systemctl set-default multi-user.target
11-
12-
RUN apt-get update -y \
8+
RUN echo deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main >> /etc/apt/sources.list \
9+
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 \
10+
&& apt-get update -y \
1311
&& apt-get --no-install-recommends install -y \
14-
default-jdk \
15-
gcc \
16-
git \
17-
libffi-dev \
18-
libssl-dev \
12+
software-properties-common \
13+
ansible \
14+
wget \
15+
coreutils \
1916
net-tools \
20-
python-dev \
21-
python-pip \
22-
ruby \
23-
sudo \
24-
tar \
2517
&& apt-get autoremove \
2618
&& apt-get clean \
2719
&& rm -rf /var/lib/apt/lists/*
2820

29-
RUN pip install -U setuptools
30-
31-
# A newish version of ansible is required, so install from pip instead of from
32-
# the old Debian package.
33-
RUN pip install ansible
34-
35-
RUN gem install serverspec
21+
## https://downloads.chef.io/inspec/1.24.0
22+
RUN wget -q https://packages.chef.io/files/stable/inspec/1.24.0/ubuntu/14.04/inspec_1.24.0-1_amd64.deb \
23+
&& echo "33e8ab3dd4ed7eb2285310ae9d0a32e0cc45d5b6d057a29541f93870c2f9e30a inspec_1.24.0-1_amd64.deb" \
24+
| sha256sum -c \
25+
&& dpkg -i inspec_1.24.0-1_amd64.deb \
26+
&& rm inspec_1.24.0-1_amd64.deb

docker/trusty64/Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ RUN apt-get update -y \
1111
&& apt-get update -y \
1212
&& apt-get --no-install-recommends install -y \
1313
ansible \
14-
default-jdk \
15-
git \
14+
wget \
15+
coreutils \
1616
net-tools \
17-
ruby2.0 \
18-
sudo \
19-
tar \
2017
&& apt-get autoremove \
2118
&& apt-get clean \
2219
&& rm -rf /var/lib/apt/lists/*
2320

24-
RUN gem2.0 install serverspec
21+
## https://downloads.chef.io/inspec/1.24.0
22+
RUN wget -q https://packages.chef.io/files/stable/inspec/1.24.0/ubuntu/14.04/inspec_1.24.0-1_amd64.deb \
23+
&& echo "33e8ab3dd4ed7eb2285310ae9d0a32e0cc45d5b6d057a29541f93870c2f9e30a inspec_1.24.0-1_amd64.deb" \
24+
| sha256sum -c \
25+
&& dpkg -i inspec_1.24.0-1_amd64.deb \
26+
&& rm inspec_1.24.0-1_amd64.deb

docker/xenial64/Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ RUN apt-get update -y \
1111
&& apt-get update -y \
1212
&& apt-get --no-install-recommends install -y \
1313
ansible \
14+
wget \
15+
coreutils \
1416
net-tools \
15-
ruby2.3 \
1617
&& apt-get autoremove \
1718
&& apt-get clean \
1819
&& rm -rf /var/lib/apt/lists/*
1920

20-
RUN gem2.3 install serverspec
21+
## https://downloads.chef.io/inspec/1.24.0
22+
RUN wget -q https://packages.chef.io/files/stable/inspec/1.24.0/ubuntu/16.04/inspec_1.24.0-1_amd64.deb \
23+
&& echo "33e8ab3dd4ed7eb2285310ae9d0a32e0cc45d5b6d057a29541f93870c2f9e30a inspec_1.24.0-1_amd64.deb" \
24+
| sha256sum -c \
25+
&& dpkg -i inspec_1.24.0-1_amd64.deb \
26+
&& rm inspec_1.24.0-1_amd64.deb

scripts/ci.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ function main() {
6767
sleep 30
6868

6969
# Run tests.
70-
docker exec -t "${container}" rspec "${WORKSPACE}/tests/spec/${SERVER}_spec.rb"
70+
docker exec -t "${container}" inspec exec "${WORKSPACE}/tests/spec/${SERVER}_spec.rb"
71+
7172
}
7273

7374
[[ -z "${CI:-}" ]] && trap debug ERR

tests/spec/minecraft_spec.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require_relative 'spec_helper'
2-
31
describe user 'minecraft' do
42
it { should exist }
53
end
@@ -44,16 +42,15 @@
4442
it { should be_installed }
4543
end
4644

47-
describe process 'java' do
48-
its(:user) { should eq 'minecraft' }
49-
its(:args) { should match /java -Xmx1024M -Xms1024M -jar minecraft_server\.jar nogui/ }
45+
describe processes(Regexp.new("java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui")) do
46+
its('users') { should cmp 'minecraft' }
5047
end
5148

52-
describe port 25565 do
49+
describe port(25565) do
5350
it { should be_listening }
5451
end
5552

56-
describe port 25564 do
53+
describe port(25564) do
5754
it { should be_listening }
5855
end
5956

tests/spec/spec_helper.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/spec/spigot_spec.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require_relative 'spec_helper'
2-
31
describe user 'spigot' do
42
it { should exist }
53
end
@@ -44,16 +42,15 @@
4442
it { should be_installed }
4543
end
4644

47-
describe process 'java' do
48-
its(:user) { should eq 'spigot' }
49-
its(:args) { should match /java -Xmx1024M -Xms1024M -jar spigot\.jar nogui/ }
45+
describe processes(Regexp.new("java -Xmx1024M -Xms1024M -jar spigot.jar nogui")) do
46+
its('users') { should cmp 'spigot' }
5047
end
5148

52-
describe port 25565 do
49+
describe port(25565) do
5350
it { should be_listening }
5451
end
5552

56-
describe port 25564 do
53+
describe port(25564) do
5754
it { should be_listening }
5855
end
5956

0 commit comments

Comments
 (0)