Added Kitchen tests and Travis
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..3f7ad13
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,52 @@
+---
+driver:
+ name: docker
+ hostname: influxdb.ci.local
+ use_sudo: false
+
+provisioner:
+ name: salt_solo
+ salt_install: bootstrap
+ salt_bootstrap_url: https://bootstrap.saltstack.com
+ salt_version: latest
+ require_chef: false
+ log_level: error
+ formula: influxdb
+ grains:
+ noservices: True
+ state_top:
+ base:
+ "*":
+ - influxdb
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - influxdb
+ dependencies:
+ - name: linux
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-linux.git
+
+verifier:
+ name: inspec
+ sudo: true
+
+platforms:
+ - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+ driver_config:
+ image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+ platform: ubuntu
+
+suites:
+
+ - name: cluster
+ provisioner:
+ pillars-from-files:
+ influxdb.sls: tests/pillar/cluster.sls
+
+ - name: single
+ provisioner:
+ pillars-from-files:
+ influxdb.sls: tests/pillar/single.sls
+# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7a77247
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,39 @@
+sudo: required
+services:
+ - docker
+
+install:
+ - pip install PyYAML
+ - pip install virtualenv
+ - |
+ test -e Gemfile || cat <<EOF > Gemfile
+ source 'https://rubygems.org'
+ gem 'rake'
+ gem 'test-kitchen'
+ gem 'kitchen-docker'
+ gem 'kitchen-inspec'
+ gem 'inspec'
+ gem 'kitchen-salt', :git => 'https://github.com/salt-formulas/kitchen-salt.git'
+ - bundle install
+
+env:
+ - PLATFORM=trevorj/salty-whales:trusty
+ - PLATFORM=trevorj/salty-whales:xenial
+
+before_script:
+ - set -o pipefail
+ - make test | tail
+
+script:
+ - test ! -e .kitchen.yml || bundle exec kitchen test -t tests/integration
+
+notifications:
+ webhooks:
+ urls:
+ - https://webhooks.gitter.im/e/6123573504759330786b
+ on_success: change # options: [always|never|change] default: always
+ on_failure: never # options: [always|never|change] default: always
+ on_start: never # options: [always|never|change] default: always
+ on_cancel: never # options: [always|never|change] default: always
+ on_error: never # options: [always|never|change] default: always
+ email: false
diff --git a/influxdb/server.sls b/influxdb/server.sls
index c77ec82..4276a8e 100644
--- a/influxdb/server.sls
+++ b/influxdb/server.sls
@@ -1,6 +1,15 @@
{%- from "influxdb/map.jinja" import server with context %}
+{% from "linux/map.jinja" import system with context %}
+
{%- if server.enabled %}
+linux_packages:
+ pkg.installed:
+ - pkgs: {{ system.pkgs }}
+
+include:
+ - linux.system.repo
+
influxdb_packages:
pkg.installed:
- names: {{ server.pkgs }}
@@ -21,6 +30,8 @@
- require:
- pkg: influxdb_packages
+{%- if not grains.get('noservices', False) %}
+
influxdb_service:
service.running:
- enable: true
@@ -32,6 +43,8 @@
- file: influxdb_config
- file: influxdb_default
+{%- endif %}
+
{% set url_for_query = "http://{}:{}/query".format(server.http.bind.address, server.http.bind.port) %}
{% set admin_created = false %}
@@ -41,8 +54,10 @@
influxdb_create_admin:
cmd.run:
- name: curl -f -S -POST "{{ url_for_query }}" {{ query_create_admin }} || curl -f -S -POST "{{ admin_url }}" {{ query_create_admin }}
+ {%- if not grains.get('noservices', False) %}
- require:
- service: influxdb_service
+ {%- endif %}
{% set url_for_query = admin_url %}
{% set admin_created = true %}
{%- endif %}
diff --git a/tests/pillar/cluster.sls b/tests/pillar/cluster.sls
index 19911cb..2de3ef4 100644
--- a/tests/pillar/cluster.sls
+++ b/tests/pillar/cluster.sls
@@ -2,11 +2,19 @@
server:
enabled: true
meta:
+ enabled: true
bind:
address: 0.0.0.0
port: 8088
http_address: 0.0.0.0
http_port: 8091
+ admin:
+ enabled: true
+ bind:
+ address: 0.0.0.0
+ port: 8081
+ http_address: 0.0.0.0
+ http_port: 8083
cluster:
members:
- host: idb01.local
@@ -15,3 +23,11 @@
port: 8091
- host: idb03.local
port: 8091
+linux:
+ system:
+ enabled: true
+ repo:
+ docker:
+ source: 'deb https://repos.influxdata.com/ubuntu {{ grains.get('oscodename') }} stable'
+ key_url: https://repos.influxdata.com/influxdb.key
+ file: /etc/apt/sources.list
diff --git a/tests/pillar/single.sls b/tests/pillar/single.sls
index 21c12b0..c6a9124 100644
--- a/tests/pillar/single.sls
+++ b/tests/pillar/single.sls
@@ -1,3 +1,11 @@
influxdb:
server:
enabled: true
+linux:
+ system:
+ enabled: true
+ repo:
+ docker:
+ source: 'deb https://repos.influxdata.com/ubuntu {{ grains.get('oscodename') }} stable'
+ key_url: https://repos.influxdata.com/influxdb.key
+ file: /etc/apt/sources.list