Merge pull request #13 from Martin819/master

Update Kitchen test suites and Travis settings
diff --git a/.kitchen.yml b/.kitchen.yml
index 52aeb8b..42ec81a 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -14,12 +14,6 @@
   formula: opencontrail
   grains:
     noservices: True
-  vendor_repo:
-    - type: apt
-      url: http://apt-mk.mirantis.com/trusty
-      key_url: http://apt-mk.mirantis.com/public.gpg
-      components: oc303 extra
-      distribution: nightly
   dependencies:
     - name: linux
       repo: git
@@ -33,6 +27,8 @@
     top.sls:
       base:
         "*":
+          - linux_repo_openstack
+          - linux_repo_opencontrail
           - linux_repo_cassandra
           - linux_repo_mos
           - linux
@@ -43,83 +39,28 @@
         system:
           enabled: true
           name: opencontrail
-        network:
-          enabled: true
-          hostname: opencontrail
-          interface:
-            vhost0:
-              enabled: True
-              type: eth
     opencontrail_juniper.sls: {}
   pillars-from-files:
     linux_repo_mos.sls: tests/pillar/repo_mos8.sls
     linux_repo_cassandra.sls: tests/pillar/repo_cassandra.sls
+    linux_repo_opencontrail.sls: tests/pillar/repo_opencontrail.sls
+    linux_repo_openstack.sls: tests/pillar/repo_openstack.sls
 
 verifier:
   name: inspec
   sudo: true
 
 platforms:
-  - name: <%= ENV['PLATFORM'] || 'ubuntu-trusty' %>
+  - name: <%= ENV['PLATFORM'] || 'ubuntu-xenial' %>
     driver_config:
-      image: <%= ENV['PLATFORM'] || 'trevorj/salty-whales:trusty' %>
+      image: <%= ENV['PLATFORM'] || 'trevorj/salty-whales:xenial' %>
       platform: ubuntu
 
 suites:
 
-  - name: analytics
+  - name: <%= ENV['SUITE'] || 'single' %>
     provisioner:
       pillars-from-files:
-        opencontrail.sls: tests/pillar/analytics.sls
-
-  - name: cluster
-    provisioner:
-      pillars-from-files:
-        opencontrail.sls: tests/pillar/cluster.sls
-
-  - name: control
-    provisioner:
-      pillars-from-files:
-        opencontrail.sls: tests/pillar/control.sls
-
-  - name: single
-    provisioner:
-      pillars-from-files:
-        opencontrail.sls: tests/pillar/single.sls
-
-
-# Note: require juniper contrail repo available
-  - name: vendor-juniper
-    provisioner:
-      vendor_repo:
-        - type: apt
-          url: http://aptly.local/contrail
-          key_url: http://aptly.local/public.gpg
-          components: main
-          distribution: trusty
-      pillars-from-files:
-        opencontrail.sls: tests/pillar/control.sls
-      pillars:
-        opencontrail_juniper.sls:
-          opencontrail:
-            common:
-              vendor: juniper
-
-# Note: Following suites not pass on docker platform
-#       the scope of the test may be limited.
-  - name: tor
-    provisioner:
-      pillars-from-files:
-        opencontrail.sls: tests/pillar/tor.sls
-
-  - name: vrouter_kubernetes
-    provisioner:
-      pillars-from-files:
-        opencontrail.sls: tests/pillar/vrouter_kubernetes.sls
-
-  - name: vrouter
-    provisioner:
-      pillars-from-files:
-        opencontrail.sls: tests/pillar/vrouter.sls
+        opencontrail.sls: tests/pillar/<%= ENV['SUITE'] || 'single' %>.sls
 
 # vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
index bc2d556..4dd9d20 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,9 +14,7 @@
     gem 'kitchen-vagrant'
     gem 'kitchen-inspec'
     gem 'inspec'
-    gem 'kitchen-salt', :git => 'https://github.com/epcim/kitchen-salt.git', :branch => 'dependencis-pkg-repo2'
-    #Waiting for PR#78
-    #gem 'kitchen-salt', '>=0.2.25'
+    gem 'kitchen-salt', :git => 'https://github.com/salt-formulas/kitchen-salt.git'
   - bundle install
 
 env:
@@ -25,18 +23,30 @@
    - SUITE=control
    - SUITE=cluster
    - SUITE=single
-   #- SUITE=vendor-juniper
-   #- SUITE=tor
-   #- SUITE=vrouter_kubernetes
-   #- SUITE=vrouter
-   #- PLATFORM=trevorj/salty-whales:xenial SUITE=analytics
-   #- PLATFORM=trevorj/salty-whales:xenial SUITE=control
-   #- PLATFORM=trevorj/salty-whales:xenial SUITE=cluster
-   #...
+   - SUITE=tor
+   - SUITE=vrouter
+   - PLATFORM=trevorj/salty-whales:trusty SUITE=analytics
+   - PLATFORM=trevorj/salty-whales:trusty SUITE=control
+   - PLATFORM=trevorj/salty-whales:trusty SUITE=cluster
+   - PLATFORM=trevorj/salty-whales:trusty SUITE=single
+   - PLATFORM=trevorj/salty-whales:trusty SUITE=tor
+   - PLATFORM=trevorj/salty-whales:trusty SUITE=vrouter
 
 before_script:
+  - set -o pipefail
   - make test | tail
 
 script:
-  - test ! -e .kitchen.yml || bundle exec kitchen verify $SUITE
+  - test ! -e .kitchen.yml || bundle exec kitchen converge $SUITE || true
+  - test ! -e .kitchen.yml || bundle exec kitchen verify $SUITE -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/opencontrail/collector.sls b/opencontrail/collector.sls
index b8525fb..4439d3c 100644
--- a/opencontrail/collector.sls
+++ b/opencontrail/collector.sls
@@ -40,6 +40,7 @@
 {{ collector.redis_config }}:
   file.managed:
   - source: salt://opencontrail/files/{{ collector.version }}/collector/redis.conf
+  - makedirs: True
   - require:
     - pkg: opencontrail_collector_packages
 
@@ -69,6 +70,7 @@
 /etc/contrail/supervisord_analytics_files/contrail-analytics-nodemgr.ini:
   file.managed:
   - source: salt://opencontrail/files/{{ collector.version }}/collector/contrail-analytics-nodemgr.ini
+  - makedirs: True
   - require:
     - pkg: opencontrail_collector_packages
 {%- if not grains.get('noservices', False) %}
diff --git a/opencontrail/compute.sls b/opencontrail/compute.sls
index 53eb3fd..a7d67c4 100644
--- a/opencontrail/compute.sls
+++ b/opencontrail/compute.sls
@@ -14,13 +14,19 @@
   pkg.installed:
   - names: {{ compute.pkgs }}
 
+{%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
+
 net.ipv4.ip_local_reserved_ports:
   sysctl.present:
     - value: 8085,9090
     - require:
       - pkg: opencontrail_compute_packages
+    {%- if not grains.get('noservices', False)%}
     - require_in:
       - service: opencontrail_compute_services
+    {%- endif %}
+
+{%- endif %}
 
 /etc/contrail/contrail-vrouter-nodemgr.conf:
   file.managed:
@@ -28,8 +34,10 @@
   - template: jinja
   - require:
     - pkg: opencontrail_compute_packages
+  {%- if not grains.get('noservices', False)%}
   - watch_in:
     - service: opencontrail_compute_services
+  {%- endif %}
 
 /etc/contrail/vrouter_nodemgr_param:
   file.managed:
@@ -51,8 +59,10 @@
   - template: jinja
   - require:
     - pkg: opencontrail_compute_packages
+  {%- if not grains.get('noservices', False)%}
   - watch_in:
     - service: opencontrail_compute_services
+  {%- endif %}
 
 /usr/local/bin/findns:
   file.managed:
@@ -66,12 +76,15 @@
   - source: salt://opencontrail/files/{{ compute.version }}/contrail-vrouter-nodemgr.ini
   - require:
     - pkg: opencontrail_compute_packages
+  {%- if not grains.get('noservices', False)%}
   - require_in:
     - service: opencontrail_compute_services
+  {%- endif %}
 
 /etc/udev/rules.d/vhost-net.rules:
   file.managed:
   - contents: 'KERNEL=="vhost-net", GROUP="kvm", MODE="0660"'
+  - makedirs: True
 
 /etc/modules:
   file.append:
@@ -99,8 +112,10 @@
   - require:
     - pkg: opencontrail_compute_packages
     - pkg: opencontrail_vrouter_package
+  {%- if not grains.get('noservices', False)%}
   - require_in:
     - service: opencontrail_compute_services
+  {%- endif %}
 
 modules_dpdk:
   file.append:
@@ -128,6 +143,7 @@
   - contents: "options vrouter vr_flow_entries=2097152"
 
 {%- if network.interface.get('vhost0', {}).get('enabled', False) %}
+{%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
 
 contrail_load_vrouter_kernel_module:
   cmd.run:
@@ -138,27 +154,14 @@
     - pkg: opencontrail_compute_packages
 
 {%- endif %}
-
 {%- endif %}
+{%- endif %}
+
+{%- if not grains.get('noservices', False)%}
 
 opencontrail_compute_services:
   service.enabled:
   - names: {{ compute.services }}
 
-{%- if compute.get('engine', 'openstack') == 'kubernetes' %}
-
-kubernetes_packages:
-  pkg.installed:
-    - names:
-      - bridge-utils
-      - ethtool
-      - opencontrail-kubelet
-
-/usr/libexec/kubernetes/kubelet-plugins/net/exec/opencontrail/opencontrail:
-  file.symlink:
-    - target: /usr/bin/opencontrail-kubelet-plugin
-    - makedirs: true
-
 {%- endif %}
-
 {%- endif %}
diff --git a/opencontrail/config.sls b/opencontrail/config.sls
index 6105e64..e7e28e0 100644
--- a/opencontrail/config.sls
+++ b/opencontrail/config.sls
@@ -45,6 +45,7 @@
 /etc/contrail/supervisord_config_files/contrail-api.ini:
   file.managed:
   - source: salt://opencontrail/files/{{ config.version }}/config/contrail-api.ini
+  - makedirs: true
   - require:
     - pkg: opencontrail_config_packages
 
diff --git a/opencontrail/control.sls b/opencontrail/control.sls
index 6c1b9ac..98bd146 100644
--- a/opencontrail/control.sls
+++ b/opencontrail/control.sls
@@ -48,6 +48,7 @@
 /etc/contrail/supervisord_control_files/contrail-control-nodemgr.ini:
   file.managed:
   - source: salt://opencontrail/files/{{ control.version }}/control/contrail-control-nodemgr.ini
+  - makedirs: true
   - require:
     - pkg: opencontrail_control_packages
 {%- if not grains.get('noservices', False) %}
diff --git a/opencontrail/map.jinja b/opencontrail/map.jinja
index e2f662d..36baef3 100644
--- a/opencontrail/map.jinja
+++ b/opencontrail/map.jinja
@@ -65,8 +65,13 @@
          ['contrail-control', 'supervisor-control']
 database:
   Debian:
+    {%- if grains.get('oscodename', 'xenial')%}
+    pkgs:
+         ['cassandra', 'zookeeper', 'supervisor', 'openjdk-8-jre-headless', 'contrail-database']
+    {%- else %}
     pkgs:
          ['cassandra', 'zookeeper', 'supervisor', 'openjdk-7-jre-headless', 'contrail-database']
+    {%- endif %}
     cassandra_config: '/etc/cassandra/'
     services:
          ['supervisord-contrail-database', 'zookeeper']
@@ -79,7 +84,7 @@
 web:
   Debian:
     pkgs:
-         ['contrail-web-controller', 'nodejs-legacy', 'gettext-base']
+         ['contrail-web-controller', 'gettext-base']
     services:
          ['contrail-webui-webserver', 'contrail-webui-jobserver']
     database:
diff --git a/tests/pillar/repo_cassandra.sls b/tests/pillar/repo_cassandra.sls
index 8ece8a8..d6c454d 100644
--- a/tests/pillar/repo_cassandra.sls
+++ b/tests/pillar/repo_cassandra.sls
@@ -1,9 +1,10 @@
 linux:
   system:
+    enabled: true
     repo:
       cassandra-21x:
         source: "deb [arch=amd64] http://www.apache.org/dist/cassandra/debian 21x main"
         architectures: amd64
-        key_server: pool.sks-keyservers.net
+        key_server: hkp://p80.pool.sks-keyservers.net:80
         key_id: A278B781FE4B2BDA
 
diff --git a/tests/pillar/repo_mos8.sls b/tests/pillar/repo_mos8.sls
index 3b53e53..1033cb4 100644
--- a/tests/pillar/repo_mos8.sls
+++ b/tests/pillar/repo_mos8.sls
@@ -1,7 +1,8 @@
 linux:
   system:
+    enabled: true
     repo:
-      mirantis_openstack:
+      mirantis_openstack_mos8:
         source: "deb [arch=amd64] http://mirror.fuel-infra.org/mos-repos/ubuntu/8.0-mu-3/ mos8.0 main restricted"
         architectures: amd64
         key_url: "http://mirror.fuel-infra.org/mos-repos/ubuntu/8.0-mu-3/archive-mos8.0.key"
diff --git a/tests/pillar/repo_mos9.sls b/tests/pillar/repo_mos9.sls
index 90df22d..8316770 100644
--- a/tests/pillar/repo_mos9.sls
+++ b/tests/pillar/repo_mos9.sls
@@ -1,7 +1,7 @@
 linux:
   system:
     repo:
-      mirantis_openstack:
+      mirantis_openstack_mos9:
         source: "deb [arch=amd64] http://mirror.fuel-infra.org/mos-repos/ubuntu/9.0/ mos9.0 main restricted"
         architectures: amd64
         key_url: "http://mirror.fuel-infra.org/mos-repos/ubuntu/9.0/archive-mos9.0.key"
diff --git a/tests/pillar/repo_opencontrail.sls b/tests/pillar/repo_opencontrail.sls
new file mode 100644
index 0000000..79cf4d0
--- /dev/null
+++ b/tests/pillar/repo_opencontrail.sls
@@ -0,0 +1,20 @@
+linux:
+  system:
+    enabled: true
+    repo:
+      mcp_opencontrail_repo:
+        source: "deb [arch=amd64] http://apt-mk.mirantis.com/{{ grains.get('oscodename') }}/ stable oc311 extra"
+        architectures: amd64
+        key_url: "http://apt-mk.mirantis.com/public.gpg"
+        pin:
+        - pin: 'release a=stable'
+          priority: 1100
+          package: '*'
+      opencontrail_team:
+        source: "deb http://ppa.launchpad.net/opencontrail/ppa/ubuntu {{ grains.get('oscodename') }} main"
+      opencontrail_extra:
+        source: "deb http://ppa.launchpad.net/mirantis-opencontrail/extra/ubuntu trusty main"
+      openjdk-r_repo:
+        source: "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu {{ grains.get('oscodename') }} main"
+      opencontrail_311:
+        source: "deb http://ppa.launchpad.net/mirantis-opencontrail/opencontrail-3.1.1/ubuntu {{ grains.get('oscodename') }} main "
diff --git a/tests/pillar/repo_openstack.sls b/tests/pillar/repo_openstack.sls
new file mode 100644
index 0000000..c3d858d
--- /dev/null
+++ b/tests/pillar/repo_openstack.sls
@@ -0,0 +1,44 @@
+linux:
+  system:
+    enabled: true
+    repo:
+      mirantis_openstack:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }} mitaka main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }}/archive-mcp1.0.key"
+        pin:
+        - pin: 'release a=mitaka'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_hotfix:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }} mitaka-hotfix main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }}/archive-mcp1.0.key"
+        pin:
+        - pin: 'release a=mitaka-hotfix'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_security:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }} mitaka-security main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }}/archive-mcp1.0.key"
+        pin:
+        - pin: 'release a=mitaka-security'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_updates:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }} mitaka-updates main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }}/archive-mcp1.0.key"
+        pin:
+        - pin: 'release a=mitaka-uptades'
+          priority: 1050
+          package: '*'
+      mirantis_openstack_holdback:
+        source: "deb http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }} mitaka-holdback main"
+        architectures: amd64
+        key_url: "http://mirror.fuel-infra.org/mcp-repos/1.0/{{ grains.get('oscodename') }}/archive-mcp1.0.key"
+        pin:
+        - pin: 'release a=mitaka-holdback'
+          priority: 1050
+          package: '*'
diff --git a/tests/pillar/tor.sls b/tests/pillar/tor.sls
index 04ecba0..39009ce 100644
--- a/tests/pillar/tor.sls
+++ b/tests/pillar/tor.sls
@@ -33,3 +33,11 @@
       mask: /24
       dns: 127.0.0.1
       mtu: 9000
+linux:
+  network:
+    enabled: true
+    hostname: opencontrail
+    interface:
+      vhost0:
+        enabled: True
+        type: eth
diff --git a/tests/pillar/vrouter_dpdk.sls b/tests/pillar/vrouter-dpdk.sls
similarity index 82%
rename from tests/pillar/vrouter_dpdk.sls
rename to tests/pillar/vrouter-dpdk.sls
index 8a6c17f..8004bac 100644
--- a/tests/pillar/vrouter_dpdk.sls
+++ b/tests/pillar/vrouter-dpdk.sls
@@ -31,4 +31,11 @@
       mask: /24
       dns: 127.0.0.1
       mtu: 9000
-
+linux:
+  network:
+    enabled: true
+    hostname: opencontrail
+    interface:
+      vhost0:
+        enabled: True
+        type: eth
diff --git a/tests/pillar/vrouter.sls b/tests/pillar/vrouter.sls
index 45418a0..8ddbdc6 100644
--- a/tests/pillar/vrouter.sls
+++ b/tests/pillar/vrouter.sls
@@ -25,3 +25,11 @@
       mask: /24
       dns: 127.0.0.1
       mtu: 9000
+linux:
+  network:
+    enabled: true
+    hostname: opencontrail
+    interface:
+      vhost0:
+        enabled: True
+        type: eth
diff --git a/tests/pillar/vrouter_kubernetes.sls b/tests/pillar/vrouter_kubernetes.sls
deleted file mode 100644
index bc5bcc6..0000000
--- a/tests/pillar/vrouter_kubernetes.sls
+++ /dev/null
@@ -1,18 +0,0 @@
-opencontrail:
-  common:
-    version: 3.0
-    identity:
-      engine: kubernetes
-  compute:
-    engine: kubernetes
-    version: 3.0
-    enabled: True
-    discovery:
-      host: 127.0.0.1
-    interface:
-      address: 127.0.0.1
-      dev: eth0
-      gateway: 127.0.0.1
-      mask: /24
-      dns: 127.0.0.1
-      mtu: 9000