Add kitchen tests + travis ci
- add dependencies, req. for CI (make test)
- spec. mysql version per platform
- keystone client to create endpoints
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..29774f4
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,96 @@
+---
+driver:
+ name: docker
+ hostname: keystone.ci.local
+ use_sudo: true
+
+provisioner:
+ name: salt_solo
+ salt_install: bootstrap
+ salt_bootstrap_url: https://bootstrap.saltstack.com
+ salt_version: latest
+ require_chef: false
+ log_level: info
+ formula: keystone
+ grains:
+ noservices: False
+ dependencies:
+ - name: linux
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-linux
+ - name: mysql
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-mysql
+ - name: apache
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-apache
+ - name: memcached
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-memcached
+ - name: cadf
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-cadf
+ - name: rabbitmq
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-rabbitmq
+ state_top:
+ base:
+ "*":
+ - linux
+ - mysql
+ - keystone
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - linux_repo_openstack
+ - keystone
+ - mysql_platform_specific
+ mysql_platform_specific.sls: {}
+ pillars-from-files:
+ linux_repo_openstack.sls: tests/pillar/repo_mos9.sls
+
+verifier:
+ name: inspec
+ sudo: true
+
+platforms:
+ - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+ driver_config:
+ image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+ platform: ubuntu
+ provisioner:
+ pillars:
+ mysql_platform_specific.sls:
+ mysql:
+ server:
+ # workaround, formula not yet handle platform default version
+ version: "<%=ENV['MYSQL_VERSION'] || '5.7'%>"
+
+suites:
+
+ - name: single
+ provisioner:
+ pillars-from-files:
+ keystone.sls: tests/pillar/single.sls
+
+ - name: single_fernet
+ provisioner:
+ pillars-from-files:
+ keystone.sls: tests/pillar/single_fernet.sls
+
+ - name: under-apache
+ provisioner:
+ grains:
+ noservices: True
+ pillars-from-files:
+ keystone.sls: tests/pillar/apache_wsgi.sls
+ state_top:
+ base:
+ "*":
+ - linux
+ - mysql
+ - apache
+ - keystone
+
+# 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..7be15b6
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,32 @@
+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/epcim/kitchen-salt.git', :branch => 'dependencis-pkg-repo2'
+ #Waiting for PR#78
+ #gem 'kitchen-salt', '>=0.2.25'
+ - bundle install
+
+env:
+ - PLATFORM=trevorj/salty-whales:trusty MYSQL_VERSION='5.5'
+ - PLATFORM=trevorj/salty-whales:xenial MYSQL_VERSION='5.7'
+
+before_script:
+ - make test | tail
+
+script:
+ - bundle exec kitchen verify single -t tests/integration
+ - bundle exec kitchen converge under-apache | tail
+ - bundle exec kitchen exec under-apache -c "sudo service mysql start && sudo service apache2 start && keystone-manage db_sync && sleep 1"
+ - bundle exec kitchen verify under-apache -t tests/integration
diff --git a/keystone/server.sls b/keystone/server.sls
index cf54fb4..84f0dc6 100644
--- a/keystone/server.sls
+++ b/keystone/server.sls
@@ -59,8 +59,10 @@
- template: jinja
- require:
- pkg: keystone_packages
+ {%- if not grains.get('noservices', False) %}
- watch_in:
- service: keystone_service
+ {%- endif %}
{% if server.websso is defined %}
@@ -69,8 +71,10 @@
- source: salt://keystone/files/sso_callback_template.html
- require:
- pkg: keystone_packages
+ {%- if not grains.get('noservices', False) %}
- watch_in:
- service: keystone_service
+ {%- endif %}
{%- endif %}
@@ -140,7 +144,9 @@
- unless: source /root/keystonercv3 && openstack domain list | grep " {{ domain_name }}"
- require:
- file: /root/keystonercv3
+ {%- if not grains.get('noservices', False) %}
- service: keystone_service
+ {%- endif %}
{%- endif %}
{%- endfor %}
diff --git a/metadata.yml b/metadata.yml
index 1cafe29..6a22fb3 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,3 +1,8 @@
name: "keystone"
version: "2016.4.1"
-source: "https://github.com/openstack/salt-formula-keystone"
+source: "https://github.com/salt-formulas/salt-formula-keystone"
+dependencies:
+ - name: apache
+ source: "https://github.com/salt-formulas/salt-formula-apache"
+ - name: mysql
+ source: "https://github.com/salt-formulas/salt-formula-mysql"
diff --git a/tests/pillar/apache_wsgi.sls b/tests/pillar/apache_wsgi.sls
new file mode 100644
index 0000000..e518a61
--- /dev/null
+++ b/tests/pillar/apache_wsgi.sls
@@ -0,0 +1,182 @@
+
+keystone:
+# Server state
+ server:
+ enabled: true
+ version: liberty
+ service_name: apache2
+ service_token: RANDOMSTRINGTOKEN
+ service_tenant: service
+ admin_tenant: admin
+ admin_name: admin
+ admin_password: passw0rd
+ admin_email: root@localhost
+ bind:
+ address: 0.0.0.0
+ private_address: 127.0.0.1
+ private_port: 35357
+ public_address: 127.0.0.1
+ public_port: 5000
+ region: RegionOne
+ database:
+ engine: mysql
+ host: localhost
+ name: keystone
+ password: passw0rd
+ user: keystone
+ tokens:
+ engine: cache
+ expiration: 86400
+ location: /etc/keystone/fernet-keys/
+ notification: false
+ notification_format: cadf
+ #message_queue:
+ #engine: rabbitmq
+ #host: 127.0.0.1
+ #port: 5672
+ #user: openstack
+ #password: password
+ #virtual_host: '/openstack'
+ #ha_queues: true
+# Client state
+ client:
+ enabled: false
+ server:
+ identity:
+ admin:
+ host: localhost
+ port: 35357
+ token: RANDOMSTRINGTOKEN
+ roles:
+ - admin
+ - Member
+ project:
+ service:
+ description: "OpenStack Service tenant"
+ admin:
+ description: "OpenStack Admin tenant"
+ user:
+ admin:
+ is_admin: true
+ password: passw0rd
+ email: admin@localhost
+ service:
+ keystone3:
+ type: identity
+ description: OpenStack Identity Service v3
+ endpoints:
+ - region: RegionOne
+ public_address: keystone
+ public_protocol: http
+ public_port: 5000
+ public_path: '/v3'
+ internal_address: keystone
+ internal_port: 5000
+ internal_path: '/v3'
+ admin_address: keystone
+ admin_port: 35357
+ admin_path: '/v3'
+ keystone:
+ type: identity
+ description: OpenStack Identity Service
+ endpoints:
+ - region: RegionOne
+ public_address: keystone
+ public_protocol: http
+ public_port: 5000
+ public_path: '/v2.0'
+ internal_address: keystone
+ internal_port: 5000
+ internal_path: '/v2.0'
+ admin_address: keystone
+ admin_port: 35357
+ admin_path: '/v2.0'
+ #keystone3:
+ #name: keystone3
+ #type: identity
+ #description: OpenStack Identity Service v3
+ #endpoints:
+ #- region: RegionTwo
+ #public_address: keystone
+ #public_protocol: http
+ #public_port: 5000
+ #public_path: '/v3'
+ #internal_address: keystone
+ #internal_port: 5000
+ #internal_path: '/v3'
+ #admin_address: keystone
+ #admin_port: 35357
+ #admin_path: '/v3'
+ #keystone:
+ #name: keystone
+ #type: identity
+ #description: OpenStack Identity Service
+ #endpoints:
+ #- region: RegionTwo
+ #public_address: keystone
+ #public_protocol: http
+ #public_port: 5000
+ #public_path: '/v2.0'
+ #internal_address: keystone
+ #internal_port: 5000
+ #internal_path: '/v2.0'
+ #admin_address: keystone
+ #admin_port: 35357
+ #admin_path: '/v2.0'
+# CI related dependencies
+apache:
+ server:
+ enabled: true
+ default_mpm: event
+ mpm:
+ prefork:
+ enabled: true
+ servers:
+ start: 5
+ spare:
+ min: 2
+ max: 10
+ max_requests: 0
+ max_clients: 20
+ limit: 20
+ site:
+ keystone:
+ enabled: true
+ type: keystone
+ name: wsgi
+ host:
+ name: localhost
+ pkgs:
+ - apache2
+ modules:
+ - wsgi
+mysql:
+ client:
+ enabled: true
+ version: '5.7'
+ admin:
+ host: localhost
+ port: 3306
+ user: admin
+ password: password
+ encoding: utf8
+ server:
+ enabled: true
+ version: "5.7"
+ force_encoding: utf8
+ bind:
+ address: 0.0.0.0
+ port: 3306
+ protocol: tcp
+ database:
+ keystone:
+ encoding: utf8
+ users:
+ - host: '%'
+ name: keystone
+ password: passw0rd
+ rights: all
+ - host: 127.0.0.1
+ name: keystone
+ password: passw0rd
+ rights: all
diff --git a/tests/pillar/cluster.sls b/tests/pillar/cluster.sls
index d3538b9..898b6ae 100644
--- a/tests/pillar/cluster.sls
+++ b/tests/pillar/cluster.sls
@@ -6,10 +6,10 @@
service_tenant: service
admin_tenant: admin
admin_name: admin
- admin_password: password
- admin_email: root@domain.com
+ admin_password: passw0rd
+ admin_email: root@localhost
bind:
- address: 127.0.0.1
+ address: 0.0.0.0
private_address: 127.0.0.1
private_port: 35357
public_address: 127.0.0.1
@@ -19,20 +19,20 @@
engine: mysql
host: 127.0.0.1
name: keystone
- password: password
+ password: passw0rd
user: keystone
tokens:
engine: cache
expiration: 86400
location: /etc/keystone/fernet-keys/
- notification: true
+ notification: false
notification_format: cadf
message_queue:
engine: rabbitmq
host: 127.0.0.1
port: 5672
user: openstack
- password: password
+ password: passw0rd
virtual_host: '/openstack'
ha_queues: true
cache:
diff --git a/tests/pillar/repo_mos9.sls b/tests/pillar/repo_mos9.sls
new file mode 100644
index 0000000..64d75b8
--- /dev/null
+++ b/tests/pillar/repo_mos9.sls
@@ -0,0 +1,8 @@
+linux:
+ system:
+ enabled: true
+ repo:
+ mirantis_openstack:
+ 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/single.sls b/tests/pillar/single.sls
index 3e7c49d..e2721d3 100644
--- a/tests/pillar/single.sls
+++ b/tests/pillar/single.sls
@@ -1,12 +1,13 @@
keystone:
+# Server state
server:
enabled: true
version: liberty
- service_token: token
+ service_token: RANDOMSTRINGTOKEN
service_tenant: service
admin_tenant: admin
admin_name: admin
- admin_password: password
+ admin_password: passw0rd
admin_email: root@localhost
bind:
address: 0.0.0.0
@@ -17,25 +18,122 @@
region: RegionOne
database:
engine: mysql
- host: 'localhost'
- name: 'keystone'
- password: 'password'
- user: 'keystone'
- notification: true
- message_queue:
- engine: rabbitmq
- host: 127.0.0.1
- port: 5672
- user: openstack
- password: password
- virtual_host: '/openstack'
- ha_queues: true
+ host: localhost
+ name: keystone
+ password: passw0rd
+ user: keystone
tokens:
engine: cache
expiration: 86400
location: /etc/keystone/fernet-keys/
- cache:
- engine: memcached
- members:
- - host: localhost
- port: 11211
+ notification: false
+ notification_format: cadf
+ #message_queue:
+ #engine: rabbitmq
+ #host: 127.0.0.1
+ #port: 5672
+ #user: openstack
+ #password: password
+ #virtual_host: '/openstack'
+ #ha_queues: true
+# Client state
+ client:
+ enabled: false
+ server:
+ identity:
+ admin:
+ host: localhost
+ port: 35357
+ token: RANDOMSTRINGTOKEN
+ roles:
+ - admin
+ - Member
+ project:
+ service:
+ description: "OpenStack Service tenant"
+ admin:
+ description: "OpenStack Admin tenant"
+ user:
+ admin:
+ is_admin: true
+ password: passw0rd
+ email: admin@localhost
+ service:
+ keystone3:
+ type: identity
+ description: OpenStack Identity Service v3
+ endpoints:
+ - region: RegionOne
+ public_address: keystone
+ public_protocol: http
+ public_port: 5000
+ public_path: '/v3'
+ internal_address: keystone
+ internal_port: 5000
+ internal_path: '/v3'
+ admin_address: keystone
+ admin_port: 35357
+ admin_path: '/v3'
+ keystone:
+ type: identity
+ description: OpenStack Identity Service
+ endpoints:
+ - region: RegionOne
+ public_address: keystone
+ public_protocol: http
+ public_port: 5000
+ public_path: '/v2.0'
+ internal_address: keystone
+ internal_port: 5000
+ internal_path: '/v2.0'
+ admin_address: keystone
+ admin_port: 35357
+ admin_path: '/v2.0'
+ # TODO: enable once salt keystone module/states are fixed
+ #keystoneR2:
+ #service: keystone
+ #type: identity
+ #description: OpenStack Identity Service
+ #endpoints:
+ #- region: RegionTwo
+ #public_address: keystone
+ #public_protocol: http
+ #public_port: 5000
+ #public_path: '/v2.0'
+ #internal_address: keystone
+ #internal_port: 5000
+ #internal_path: '/v2.0'
+ #admin_address: keystone
+ #admin_port: 35357
+ #admin_path: '/v2.0'
+# CI related dependencies
+mysql:
+ client:
+ enabled: true
+ version: '5.7'
+ admin:
+ host: localhost
+ port: 3306
+ user: admin
+ password: password
+ encoding: utf8
+ server:
+ enabled: true
+ version: "5.7"
+ force_encoding: utf8
+ bind:
+ address: 0.0.0.0
+ port: 3306
+ protocol: tcp
+ database:
+ keystone:
+ encoding: utf8
+ users:
+ - host: '%'
+ name: keystone
+ password: passw0rd
+ rights: all
+ - host: 127.0.0.1
+ name: keystone
+ password: passw0rd
+ rights: all
diff --git a/tests/pillar/single_fernet.sls b/tests/pillar/single_fernet.sls
index 7077876..90c0dc1 100644
--- a/tests/pillar/single_fernet.sls
+++ b/tests/pillar/single_fernet.sls
@@ -6,7 +6,7 @@
service_tenant: service
admin_tenant: admin
admin_name: admin
- admin_password: password
+ admin_password: passw0rd
admin_email: root@localhost
bind:
address: 0.0.0.0
@@ -17,17 +17,45 @@
region: RegionOne
database:
engine: mysql
- host: 'localhost'
- name: 'keystone'
- password: 'password'
- user: 'keystone'
+ host: localhost
+ name: keystone
+ password: passw0rd
+ user: keystone
tokens:
engine: fernet
expiration: 86400
location: /etc/keystone/fernet-keys/
max_active_keys: 4
- cache:
- engine: memcached
- members:
- - host: localhost
- port: 11211
+ notification: false
+ notification_format: cadf
+# CI related dependencies
+mysql:
+ client:
+ enabled: false
+ version: '5.7'
+ admin:
+ host: localhost
+ port: 3306
+ user: admin
+ password: password
+ encoding: utf8
+ server:
+ enabled: true
+ version: "5.7"
+ force_encoding: utf8
+ bind:
+ address: 0.0.0.0
+ port: 3306
+ protocol: tcp
+ database:
+ keystone:
+ encoding: utf8
+ users:
+ - host: '%'
+ name: keystone
+ password: passw0rd
+ rights: all
+ - host: 127.0.0.1
+ name: keystone
+ password: passw0rd
+ rights: all
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 8c07e58..f44058c 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
@@ -144,20 +147,22 @@
}
## Main
-trap _atexit INT TERM EXIT
+[[ "$0" != "$BASH_SOURCE" ]] || {
+ trap _atexit INT TERM EXIT
-case $1 in
- clean)
- clean
- ;;
- prepare)
- prepare
- ;;
- run)
- run
- ;;
- *)
- prepare
- run
- ;;
-esac
+ case $1 in
+ clean)
+ clean
+ ;;
+ prepare)
+ prepare
+ ;;
+ run)
+ run
+ ;;
+ *)
+ prepare
+ run
+ ;;
+ esac
+}