Added Kitchen tests and Travis

Change-Id: Ie5620ef3c416df76287d7864dbc46e0b9c66ab79
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..c8edb38
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,56 @@
+---
+driver:
+  name: docker
+  hostname: prometheus.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: prometheus
+  grains:
+    noservices: True
+  state_top:
+    base:
+      "*":
+        - prometheus
+  pillars:
+    top.sls:
+      base:
+        "*":
+          - prometheus
+
+verifier:
+  name: inspec
+  sudo: true
+
+
+platforms:
+  - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+    driver_config:
+      image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+      platform: ubuntu
+
+suites:
+
+  - name: alertmanager
+    provisioner:
+      pillars-from-files:
+        prometheus.sls: tests/pillar/alertmanager.sls
+
+## Pushgateway not ready yet
+  # - name: pushgateway_complex
+  #   provisioner:
+  #     pillars-from-files:
+  #       prometheus.sls: tests/pillar/pushgateway_complex.sls
+
+  - name: server
+    provisioner:
+      pillars-from-files:
+        prometheus.sls: tests/pillar/server.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/README.rst b/README.rst
index 4b6c4bf..4c126b5 100644
--- a/README.rst
+++ b/README.rst
@@ -25,44 +25,41 @@
       external_port: 15010
       target:
         dns:
-          - name: 'pushgateway'
-            domain:
-            - 'tasks.prometheus_pushgateway'
-            type: A
-            port: 9091
-          - name: 'prometheus'
-            domain:
-            - 'tasks.prometheus_server'
-            type: A
-            port: 9090
+          enabled: true
+          endpoint:
+            - name: 'pushgateway'
+              domain:
+              - 'tasks.prometheus_pushgateway'
+              type: A
+              port: 9091
+            - name: 'prometheus'
+              domain:
+              - 'tasks.prometheus_server'
+              type: A
+              port: 9090
         kubernetes:
-          api_ip: ${_param:kubernetes_control_address}
+          enabled: true
+          api_ip: 127.0.0.1
           ssl_dir: /opt/prometheus/config
           cert_name: prometheus-server.crt
           key_name: prometheus-server.key
         etcd:
-          scheme: https
-          ssl_dir: /opt/prometheus/config
-          cert_name: prometheus-server.crt
-          key_name: prometheus-server.key
-          member:
-            - host: ${_param:cluster_node01_address}
-              port: ${_param:cluster_node01_port}
-            - host: ${_param:cluster_node02_address}
-              port: ${_param:cluster_node02_port}
-            - host: ${_param:cluster_node03_address}
-              port: ${_param:cluster_node03_port}
+          endpoint:
+            scheme: https
+            ssl_dir: /opt/prometheus/config
+            cert_name: prometheus-server.crt
+            key_name: prometheus-server.key
+            member:
+              - host: ${_param:cluster_node01_address}
+                port: ${_param:cluster_node01_port}
+              - host: ${_param:cluster_node02_address}
+                port: ${_param:cluster_node02_port}
+              - host: ${_param:cluster_node03_address}
+                port: ${_param:cluster_node03_port}
       recording:
-        - name: 'instance:fd_utilization'
+        instance:fd_utilization:
           query: >-
             process_open_fds / process_max_fds
-      alert:
-        PrometheusTargetDown:
-          if: 'up != 1'
-          labels:
-            severity: down
-          annotations:
-            summary: 'Prometheus target down'
       storage:
         local:
           engine: "persisted"
diff --git a/prometheus/alertmanager.sls b/prometheus/alertmanager.sls
index 6f83334..6e1481d 100644
--- a/prometheus/alertmanager.sls
+++ b/prometheus/alertmanager.sls
@@ -7,6 +7,7 @@
   file.managed:
   - source: salt://prometheus/files/alertmanager.yml
   - template: jinja
+  - makedirs: True
 
 {%- endif %}
 {%- endif %}
diff --git a/prometheus/server.sls b/prometheus/server.sls
index e4dfb5c..b324435 100644
--- a/prometheus/server.sls
+++ b/prometheus/server.sls
@@ -7,11 +7,13 @@
   file.managed:
   - source: salt://prometheus/files/prometheus.yml
   - template: jinja
+  - makedirs: True
 
 {{server.dir.config}}/alerts.yml:
   file.managed:
   - source: salt://prometheus/files/alerts.yml
   - template: jinja
+  - makedirs: True
 
 {%- endif %}
 {%- endif %}
diff --git a/tests/pillar/prometheus_alertmanager.sls b/tests/pillar/alertmanager.sls
similarity index 81%
rename from tests/pillar/prometheus_alertmanager.sls
rename to tests/pillar/alertmanager.sls
index 48a9d5d..092e788 100644
--- a/tests/pillar/prometheus_alertmanager.sls
+++ b/tests/pillar/alertmanager.sls
@@ -1,9 +1,12 @@
 prometheus:
   alertmanager:
     enabled: true
+    dir:
+      config: /srv/volumes/prometheus
     bind:
       address: 0.0.0.0
       port: 9093
+    external_port: 15011
     config:
       global:
         resolve_timeout: 5m
@@ -34,3 +37,12 @@
           webhook_configs:
             - url: http://127.0.0.1
               send_resolved: true
+docker:
+  host:
+    enabled: true
+    experimental: true
+    insecure_registries:
+      - 127.0.0.1
+    log:
+      engine: json-file
+      size: 50m
\ No newline at end of file
diff --git a/tests/pillar/prometheus_server.sls b/tests/pillar/prometheus_server.sls
deleted file mode 100644
index c967b8f..0000000
--- a/tests/pillar/prometheus_server.sls
+++ /dev/null
@@ -1,30 +0,0 @@
-prometheus:
-  server:
-    enabled: true
-    bind:
-      port: 9090
-      address: 0.0.0.0
-    storage:
-      local:
-        engine: "persisted"
-        retention: "360h"
-        memory_chunks: 1048576
-        max_chunks_to_persist: 524288
-        num_fingerprint_mutexes: 4096
-    alertmanager:
-      notification_queue_capacity: 10000
-    config:
-      global:
-        scrape_interval: "15s"
-        scrape_timeout: "15s"
-        evaluation_interval: "1m"
-        external_labels:
-          region: 'region1'
-    alert:
-      PrometheusTargetDownKubernetesNodes:
-        if: 'up{job="kubernetes-nodes"} != 1'
-        labels:
-          severity: down
-          service: prometheus
-        annotations:
-          summary: 'Prometheus target down'
diff --git a/tests/pillar/prometheus_pushgateway.sls b/tests/pillar/pushgateway.sls
similarity index 79%
rename from tests/pillar/prometheus_pushgateway.sls
rename to tests/pillar/pushgateway.sls
index 873daa2..583fcde 100644
--- a/tests/pillar/prometheus_pushgateway.sls
+++ b/tests/pillar/pushgateway.sls
@@ -4,3 +4,4 @@
     bind:
       address: 0.0.0.0
       port: 9091
+    external_port: 15012
diff --git a/tests/pillar/server.sls b/tests/pillar/server.sls
new file mode 100644
index 0000000..9882410
--- /dev/null
+++ b/tests/pillar/server.sls
@@ -0,0 +1,79 @@
+prometheus:
+  server:
+    enabled: true
+    dir:
+      config: /srv/volumes/prometheus
+      config_in_container: /opt/prometheus/config
+    bind:
+      port: 9090
+      address: 0.0.0.0
+    external_port: 15010
+    target:
+      dns:
+        enabled: true
+        endpoint:
+          - name: 'pushgateway'
+            domain:
+            - 'tasks.prometheus_pushgateway'
+            type: A
+            port: 9091
+          - name: 'prometheus'
+            domain:
+            - 'tasks.prometheus_server'
+            type: A
+            port: 9090
+      kubernetes:
+        enabled: true
+        api_ip: 127.0.0.1
+        ssl_dir: /opt/prometheus/config
+        cert_name: prometheus-server.crt
+        key_name: prometheus-server.key
+      etcd:
+        endpoint:
+          scheme: https
+          ssl_dir: /opt/prometheus/config
+          cert_name: prometheus-server.crt
+          key_name: prometheus-server.key
+          member:
+            - host: ${_param:cluster_node01_address}
+              port: ${_param:cluster_node01_port}
+            - host: ${_param:cluster_node02_address}
+              port: ${_param:cluster_node02_port}
+            - host: ${_param:cluster_node03_address}
+              port: ${_param:cluster_node03_port}
+    recording:
+      instance:fd_utilization:
+        query: >-
+          process_open_fds / process_max_fds
+    alert:
+      PrometheusTargetDown:
+        if: 'up != 1'
+        labels:
+          severity: down
+        annotations:
+          summary: 'Prometheus target down'
+    storage:
+      local:
+        engine: "persisted"
+        retention: "360h"
+        memory_chunks: 1048576
+        max_chunks_to_persist: 524288
+        num_fingerprint_mutexes: 4096
+    alertmanager:
+      notification_queue_capacity: 10000
+    config:
+      global:
+        scrape_interval: "15s"
+        scrape_timeout: "15s"
+        evaluation_interval: "1m"
+        external_labels:
+          region: 'region1'
+docker:
+  host:
+    enabled: true
+    experimental: true
+    insecure_registries:
+      - 127.0.0.1
+    log:
+      engine: json-file
+      size: 50m
\ No newline at end of file