Add Kitchen test + Travis CI [WIP] (#6)
* Add Kitchen test + Travis CI
* update ci configs
* Update openstack repos for kitchen
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..5ef8ebf
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,57 @@
+---
+driver:
+ name: docker
+ hostname: nova.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: nova
+ grains:
+ noservices: True
+ dependencies:
+ - name: linux
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-linux
+ state_top:
+ base:
+ "*":
+ - linux.system
+ - nova
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - linux_repo_openstack
+ - nova
+ pillars-from-files:
+ linux_repo_openstack.sls: tests/pillar/repo_mcp_openstack.sls
+
+verifier:
+ name: inspec
+ sudo: true
+
+platforms:
+ - name: <%= ENV['PLATFORM'] || 'ubuntu-xenial' %>
+ driver_config:
+ image: <%= ENV['PLATFORM'] || 'trevorj/salty-whales:xenial' %>
+ platform: ubuntu
+
+suites:
+
+ - name: compute_cluster
+ provisioner:
+ pillars-from-files:
+ nova.sls: tests/pillar/compute_cluster.sls
+
+ - name: control_cluster
+ provisioner:
+ pillars-from-files:
+ nova.sls: tests/pillar/control_cluster.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..08d84af
--- /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/nova/compute.sls b/nova/compute.sls
index 315d53b..a599fcf 100644
--- a/nova/compute.sls
+++ b/nova/compute.sls
@@ -181,6 +181,7 @@
- template: jinja
- require:
- pkg: nova_compute_packages
+{%- if not grains.get('noservices', False) %}
- watch_in:
- service: {{ compute.libvirt_service }}
@@ -196,6 +197,7 @@
{%- endif %}
{%- endif %}
+{%- endif %}
/etc/libvirt/qemu.conf:
file.managed:
@@ -218,6 +220,7 @@
- pkg: nova_compute_packages
- onlyif: "virsh net-list | grep default"
+{%- if not grains.get('noservices', False) %}
{{ compute.libvirt_service }}:
service.running:
- enable: true
@@ -227,6 +230,7 @@
- watch:
- file: /etc/libvirt/{{ compute.libvirt_config }}
- file: /etc/libvirt/qemu.conf
+{%- endif %}
{%- if grains.get('init', None) == "upstart" %}
# MOS9 libvirt fix for upstart
diff --git a/nova/controller.sls b/nova/controller.sls
index fc00db8..b6916ec 100644
--- a/nova/controller.sls
+++ b/nova/controller.sls
@@ -3,6 +3,12 @@
{%- if controller.enabled %}
{%- if grains.os_family == 'Debian' %}
+debconf-set-prerequisite:
+ pkg.installed:
+ - name: debconf-utils
+ - require_in:
+ - debconf: nova_consoleproxy_debconf
+
nova_consoleproxy_debconf:
debconf.set:
- name: nova-consoleproxy
diff --git a/nova/files/liberty/nova-compute.conf.Debian b/nova/files/liberty/nova-compute.conf.Debian
index bcc6307..90a3297 100644
--- a/nova/files/liberty/nova-compute.conf.Debian
+++ b/nova/files/liberty/nova-compute.conf.Debian
@@ -108,8 +108,8 @@
notify_on_state_change = vm_and_task_state
{%- endif %}
-{%- if compute.notification is defined %}
-notification_driver = {{ compute.notification.driver }}
+{%- if compute.notification is mapping %}
+notification_driver = {{ compute.notification.get('driver', 'messagingv2') }}
{%- if compute.notification.topics is defined %}
notification_topics = {{ compute.notification.topics }}
@@ -121,8 +121,13 @@
{%- endfor %}
{%- endif %}
+{%- elif compute.notification %}
+notification_driver = messagingv2
{%- endif %}
+
+
+
{%- if compute.identity.get('version', 2) == 2 %}
[keystone_authtoken]
diff --git a/nova/map.jinja b/nova/map.jinja
index a8baab8..10577d5 100644
--- a/nova/map.jinja
+++ b/nova/map.jinja
@@ -7,7 +7,7 @@
{% set controller = salt['grains.filter_by']({
'Debian': {
- 'pkgs': ['nova-consoleproxy', 'novnc', 'nova-api', 'nova-cert', 'nova-conductor', 'nova-consoleauth', 'nova-doc', 'nova-scheduler', 'python-novaclient', 'python-memcache', 'gettext-base', 'python-pycadf'],
+ 'pkgs': ['nova-common', 'nova-consoleproxy', 'novnc', 'nova-api', 'nova-cert', 'nova-conductor', 'nova-consoleauth', 'nova-doc', 'nova-scheduler', 'python-novaclient', 'python-memcache', 'gettext-base', 'python-pycadf'],
'services': ['nova-api', 'nova-cert', 'nova-consoleauth', 'nova-scheduler', 'nova-conductor', 'nova-novncproxy'],
'debug': false,
'notification': false,
@@ -38,7 +38,7 @@
{% set compute = salt['grains.filter_by']({
'Debian': {
- 'pkgs': ['nova-compute-kvm', 'python-novaclient', 'pm-utils', 'sysfsutils', 'sg3-utils', 'libvirt-bin', 'python-memcache', 'qemu-kvm','python-guestfs', 'gettext-base'],
+ 'pkgs': ['nova-common', 'nova-compute-kvm', 'python-novaclient', 'pm-utils', 'sysfsutils', 'sg3-utils', 'libvirt-bin', 'python-memcache', 'qemu-kvm','python-guestfs', 'gettext-base'],
'services': ['nova-compute'],
'libvirt_config': 'libvirtd.conf',
'libvirt_bin': '/etc/default/libvirt-bin',
diff --git a/tests/pillar/compute_cluster.sls b/tests/pillar/compute_cluster.sls
index 3c4b6bc..635dcd2 100644
--- a/tests/pillar/compute_cluster.sls
+++ b/tests/pillar/compute_cluster.sls
@@ -49,6 +49,11 @@
host: 127.0.0.1
port: 9696
extension_sync_interval: 600
+ user: nova
+ password: password
+ tenant: service
+ metadata:
+ password: metadata
cache:
engine: memcached
members:
diff --git a/tests/pillar/compute_single.sls b/tests/pillar/compute_single.sls
index b7bb345..8eb2d4c 100644
--- a/tests/pillar/compute_single.sls
+++ b/tests/pillar/compute_single.sls
@@ -41,6 +41,7 @@
region: RegionOne
host: 127.0.0.1
port: 9696
+ password: password
cache:
engine: memcached
members:
diff --git a/tests/pillar/control_cluster.sls b/tests/pillar/control_cluster.sls
index 6e42906..163b4e3 100644
--- a/tests/pillar/control_cluster.sls
+++ b/tests/pillar/control_cluster.sls
@@ -50,6 +50,9 @@
host: 127.0.0.1
port: 9696
mtu: 1500
+ user: nova
+ password: password
+ tenant: service
metadata:
password: metadata
audit:
diff --git a/tests/pillar/control_single.sls b/tests/pillar/control_single.sls
index fb1bbf0..8234bf3 100644
--- a/tests/pillar/control_single.sls
+++ b/tests/pillar/control_single.sls
@@ -48,6 +48,7 @@
host: 127.0.0.1
port: 9696
mtu: 1500
+ password: password
metadata:
password: password
cache:
diff --git a/tests/pillar/repo_mcp_openstack.sls b/tests/pillar/repo_mcp_openstack.sls
new file mode 100644
index 0000000..2f48718
--- /dev/null
+++ b/tests/pillar/repo_mcp_openstack.sls
@@ -0,0 +1,44 @@
+linux:
+ system:
+ enabled: true
+ repo:
+ mirantis_openstack_repo:
+ 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/run_tests.sh b/tests/run_tests.sh
index 8c07e58..a4cac88 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -44,6 +44,7 @@
[ ! -d ${SALT_PILLAR_DIR} ] && mkdir -p ${SALT_PILLAR_DIR}
echo "base:" > ${SALT_PILLAR_DIR}/top.sls
for pillar in ${PILLARDIR}/*; do
+ grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
state_name=$(basename ${pillar%.sls})
echo -e " ${state_name}:\n - ${state_name}" >> ${SALT_PILLAR_DIR}/top.sls
done
@@ -56,6 +57,7 @@
echo "base:" > ${SALT_FILE_DIR}/top.sls
for pillar in ${PILLARDIR}/*.sls; do
+ grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
state_name=$(basename ${pillar%.sls})
echo -e " ${state_name}:\n - ${FORMULA_NAME}" >> ${SALT_FILE_DIR}/top.sls
done
@@ -126,6 +128,7 @@
run() {
for pillar in ${PILLARDIR}/*.sls; do
+ grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
state_name=$(basename ${pillar%.sls})
salt_run --id=${state_name} state.show_sls ${FORMULA_NAME} || (log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1)
done