From f5a5fede0b906eec554a8596f5c72a6cb27f3391 Mon Sep 17 00:00:00 2001 From: Richard Pijnenburg Date: Thu, 9 Jul 2015 16:29:06 +0200 Subject: [PATCH] Initial commit for acceptance testing Uses Kitchen-CI, kitchen-ansible and kitchen-docker components Also uses serverspec. Currently supports: - CentOS 6, 7 - Debian 7, 8 - Ubuntu 14.04 --- .gitignore | 6 +++ .kitchen.yml | 49 +++++++++++++++++++ Gemfile | 5 ++ test/integration/default.yml | 9 ++++ test/integration/default/default.yaml | 2 + .../default/serverspec/default_spec.rb | 27 ++++++++++ .../default/serverspec/spec_helper.rb | 2 + 7 files changed, 100 insertions(+) create mode 100644 .gitignore create mode 100644 .kitchen.yml create mode 100644 Gemfile create mode 100644 test/integration/default.yml create mode 100644 test/integration/default/default.yaml create mode 100644 test/integration/default/serverspec/default_spec.rb create mode 100644 test/integration/default/serverspec/spec_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..625f5a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.kitchen/ +.kitchen.local.yml +*.lock +.vendor +.bundle +Converging diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 0000000..35ac376 --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,49 @@ +--- +driver: + name: docker + +provisioner: + name: ansible_playbook + hosts: localhost + roles_path: ../ + require_ansible_repo: true + ansible_verbose: true + +platforms: + - name: ubuntu-14.04 + driver_config: + image: electrical/ubuntu:14.04 + privileged: true + provision_command: apt-get -y -q install ansible python-apt python-pycurl ruby + - name: debian-7 + driver_config: + image: electrical/debian:7.3 + privileged: true + provision_command: + - echo 'deb http://http.debian.net/debian/ wheezy-backports main' >> /etc/apt/sources.list + - apt-get update + - apt-get install -y -q ansible ruby + - name: debian-8 + driver_config: + image: electrical/debian:8 + privileged: true + provision_command: apt-get -y -q install ansible ruby + - name: centos-6 + driver_config: + image: electrical/centos:6.4 + privileged: true + - name: centos-7 + driver_config: + image: electrical/centos:7 + provision_command: + - sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config + - sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config + privileged: true + +verifier: + ruby_bindir: '/usr/bin' + +suites: + - name: default + run_list: + attributes: diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a6d7691 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'test-kitchen' +gem "kitchen-docker" +gem 'kitchen-ansible' diff --git a/test/integration/default.yml b/test/integration/default.yml new file mode 100644 index 0000000..27b5bc6 --- /dev/null +++ b/test/integration/default.yml @@ -0,0 +1,9 @@ +--- +- name: wrapper playbook for kitchen testing "elasticsearch" + hosts: localhost + roles: + - elasticsearch + vars: + es_plugins: + - plugin: lmenezes/elasticsearch-kopf + version: master diff --git a/test/integration/default/default.yaml b/test/integration/default/default.yaml new file mode 100644 index 0000000..a3c37e1 --- /dev/null +++ b/test/integration/default/default.yaml @@ -0,0 +1,2 @@ +--- +- host: test-kitchen diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb new file mode 100644 index 0000000..c067acb --- /dev/null +++ b/test/integration/default/serverspec/default_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +context "basic tests" do + + describe user('elasticsearch') do + it { should exist } + end + + describe service('elasticsearch') do + it { should be_running } + end + + describe package('elasticsearch') do + it { should be_installed } + end + + describe file('/etc/elasticsearch/elasticsearch.yml') do + it { should be_file } + end + + describe command('curl localhost:9200/_nodes/?plugin | grep kopf') do + its(:stdout) { should match /kopf/ } + its(:exit_status) { should eq 0 } + end + +end + diff --git a/test/integration/default/serverspec/spec_helper.rb b/test/integration/default/serverspec/spec_helper.rb new file mode 100644 index 0000000..590c2fa --- /dev/null +++ b/test/integration/default/serverspec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'serverspec' +set :backend, :exec