Browse Source

Added Kitchen tests and travis

feature/additional_users
Martin Polreich 7 years ago
parent
commit
8933a6c7e2
9 changed files with 170 additions and 8 deletions
  1. +60
    -0
      .kitchen.yml
  2. +39
    -0
      .travis.yml
  3. +21
    -4
      galera/map.jinja
  4. +20
    -0
      galera/master.sls
  5. +2
    -1
      galera/server.sls
  6. +15
    -0
      galera/slave.sls
  7. +2
    -2
      metadata.yml
  8. +1
    -1
      tests/pillar/master_cluster.sls
  9. +10
    -0
      tests/pillar/repo_galeracluster.sls

+ 60
- 0
.kitchen.yml View File

---
driver:
name: docker
hostname: galera.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: galera
grains:
noservices: True
state_top:
base:
"*":
- linux
- galera
pillars:
top.sls:
base:
"*":
- galera
- galeracluster_debian_repo
pillars-from-files:
galeracluster_debian_repo.sls: tests/pillar/repo_galeracluster.sls
dependencies:
- name: mysql
repo: git
source: https://github.com/salt-formulas/salt-formula-mysql.git
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: master_cluster
provisioner:
pillars-from-files:
galera.sls: tests/pillar/master_cluster.sls

- name: slave_cluster
provisioner:
pillars-from-files:
galera.sls: tests/pillar/slave_cluster.sls
# vim: ft=yaml sw=2 ts=2 sts=2 tw=125

+ 39
- 0
.travis.yml View File

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

+ 21
- 4
galera/map.jinja View File



{%- set master = salt['grains.filter_by']({ {%- set master = salt['grains.filter_by']({
'Debian': { 'Debian': {
'pkgs': ['mysql-server-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
'pkgs': ['mysql-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
'service': 'mysql', 'service': 'mysql',
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so', 'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
'log_file': '/var/log/mysql.log', 'log_file': '/var/log/mysql.log',


{%- set slave = salt['grains.filter_by']({ {%- set slave = salt['grains.filter_by']({
'Debian': { 'Debian': {
'pkgs': ['mysql-server-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
'pkgs': ['mysql-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
'service': 'mysql', 'service': 'mysql',
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so', 'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
'log_file': '/var/log/mysql.log', 'log_file': '/var/log/mysql.log',
'log_file': '/var/log/mariadb/mariadb.log', 'log_file': '/var/log/mariadb/mariadb.log',
'socket': '/var/run/mariadb/mysqld.sock', 'socket': '/var/run/mariadb/mysqld.sock',
'config': '/etc/my.cnf', 'config': '/etc/my.cnf',
},
}, merge=pillar.galera.get('slave', {})) %}
},
}, merge=salt['grains.filter_by']({
'trusty': {
'pkgs': ['mysql-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
'service': 'mysql',
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
'log_file': '/var/log/mysql.log',
'socket': '/var/run/mysqld/mysqld.sock',
'config': '/etc/mysql/my.cnf',
},
'xenial': {
'pkgs': ['mysql-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient-dev', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
'service': 'mysql',
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
'log_file': '/var/log/mysql.log',
'socket': '/var/run/mysqld/mysqld.sock',
'config': '/etc/mysql/my.cnf',
},
}, grain='oscodename', merge=pillar.galera.get('slave', {}))) %}

+ 20
- 0
galera/master.sls View File

pkg.installed: pkg.installed:
- names: {{ master.pkgs }} - names: {{ master.pkgs }}
- refresh: true - refresh: true
- force_yes: True


galera_log_dir: galera_log_dir:
file.directory: file.directory:
- require_in: - require_in:
- pkg: galera_packages - pkg: galera_packages


{%- if not grains.get('noservices', False) %}

galera_init_start_service: galera_init_start_service:
cmd.run: cmd.run:
- name: /usr/local/sbin/galera_init.sh - name: /usr/local/sbin/galera_init.sh
galera_bootstrap_stop_service: galera_bootstrap_stop_service:
service.dead: service.dead:
- name: {{ master.service }} - name: {{ master.service }}
{%- if not grains.get('noservices', False) %}
- require: - require:
- cmd: mysql_bootstrap_update_maint_password - cmd: mysql_bootstrap_update_maint_password
{%- endif %}

{%- endif %}


galera_bootstrap_init_config: galera_bootstrap_init_config:
file.managed: file.managed:
- source: salt://galera/files/my.cnf.init - source: salt://galera/files/my.cnf.init
- mode: 644 - mode: 644
- template: jinja - template: jinja
{%- if not grains.get('noservices', False) %}
- require: - require:
- service: galera_bootstrap_stop_service - service: galera_bootstrap_stop_service
{%- endif %}

{%- if not grains.get('noservices', False) %}


galera_bootstrap_start_service_final: galera_bootstrap_start_service_final:
cmd.run: cmd.run:
- file: galera_bootstrap_init_config - file: galera_bootstrap_init_config
- file: galera_bootstrap_script - file: galera_bootstrap_script


{%- endif %}

galera_bootstrap_finish_flag: galera_bootstrap_finish_flag:
file.touch: file.touch:
- name: /var/lib/mysql/.galera_bootstrap - name: /var/lib/mysql/.galera_bootstrap
{%- if not grains.get('noservices', False) %}
- require: - require:
- cmd: galera_bootstrap_start_service_final - cmd: galera_bootstrap_start_service_final
{%- endif %}
- watch_in: - watch_in:
- file: galera_config - file: galera_config


- source: salt://galera/files/my.cnf - source: salt://galera/files/my.cnf
- mode: 644 - mode: 644
- template: jinja - template: jinja
{%- if not grains.get('noservices', False) %}
- require_in: - require_in:
- service: galera_service - service: galera_service
{%- endif %}

{%- if not grains.get('noservices', False) %}


galera_service: galera_service:
service.running: service.running:
- reload: true - reload: true


{%- endif %} {%- endif %}
{%- endif %}

+ 2
- 1
galera/server.sls View File



{%- endfor %} {%- endfor %}


{%- if not grains.get('noservices', False) %}
{%- for user in server.get('users', []) %} {%- for user in server.get('users', []) %}


mysql_user_{{ user.name }}_{{ user.host }}: mysql_user_{{ user.name }}_{{ user.host }}:
{%- endif %} {%- endif %}


{%- endfor %} {%- endfor %}
{%- endif %}
{%- endif %} {%- endif %}

+ 15
- 0
galera/slave.sls View File

pkg.installed: pkg.installed:
- names: {{ slave.pkgs }} - names: {{ slave.pkgs }}
- refresh: true - refresh: true
- force_yes: True


galera_log_dir: galera_log_dir:
file.directory: file.directory:
- require_in: - require_in:
- pkg: galera_packages - pkg: galera_packages


{%- if not grains.get('noservices', False) %}

galera_init_start_service: galera_init_start_service:
cmd.run: cmd.run:
- name: /usr/local/sbin/galera_init.sh - name: /usr/local/sbin/galera_init.sh
- require: - require:
- cmd: mysql_bootstrap_update_maint_password - cmd: mysql_bootstrap_update_maint_password


{%- endif %}

galera_bootstrap_init_config: galera_bootstrap_init_config:
file.managed: file.managed:
- name: {{ slave.config }} - name: {{ slave.config }}
- source: salt://galera/files/my.cnf - source: salt://galera/files/my.cnf
- mode: 644 - mode: 644
- template: jinja - template: jinja
{%- if not grains.get('noservices', False) %}
- require: - require:
- service: galera_bootstrap_stop_service - service: galera_bootstrap_stop_service
{%- endif %}

{%- if not grains.get('noservices', False) %}


galera_bootstrap_start_service_final: galera_bootstrap_start_service_final:
cmd.run: cmd.run:
- file: galera_config - file: galera_config


{%- endif %} {%- endif %}
{%- endif %}


galera_config: galera_config:
file.managed: file.managed:
- source: salt://galera/files/my.cnf - source: salt://galera/files/my.cnf
- mode: 644 - mode: 644
- template: jinja - template: jinja
{%- if not grains.get('noservices', False) %}
- require_in: - require_in:
- service: galera_service - service: galera_service
{%- endif %}

{%- if not grains.get('noservices', False) %}


galera_service: galera_service:
service.running: service.running:
- reload: true - reload: true


{%- endif %} {%- endif %}
{%- endif %}

+ 2
- 2
metadata.yml View File

name: "galera" name: "galera"
version: "1.0" version: "1.0"
source: "https://github.com/tcpcloud/salt-formula-galera"
source: "https://github.com/salt-formulas/salt-formula-galera"
dependencies: dependencies:
- name: mysql - name: mysql
source: "https://github.com/tcpcloud/salt-formula-mysql"
source: "https://github.com/salt-formulas/salt-formula-mysql"

+ 1
- 1
tests/pillar/master_cluster.sls View File

- name: haproxy - name: haproxy
host: '%' host: '%'
- name: haproxy - name: haproxy
host: 127.0.0.1
host: 127.0.0.1

+ 10
- 0
tests/pillar/repo_galeracluster.sls View File

linux:
system:
enabled: true
repo:
galeracluster:
source: 'deb http://releases.galeracluster.com/ubuntu {{ grains.get('oscodename') }} main'
key_id: BC19DDBA
key_server: hkp://p80.pool.sks-keyservers.net:80
mitaka-staging_PPA:
source: "deb http://ppa.launchpad.net/ubuntu-cloud-archive/mitaka-staging/ubuntu trusty main"

Loading…
Cancel
Save