소스 검색

Added Kitchen tests and travis

pull/24/head
Martin Polreich 7 년 전
부모
커밋
8933a6c7e2
9개의 변경된 파일170개의 추가작업 그리고 8개의 파일을 삭제
  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 파일 보기

@@ -0,0 +1,60 @@
---
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 파일 보기

@@ -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

+ 21
- 4
galera/map.jinja 파일 보기

@@ -1,7 +1,7 @@

{%- set master = salt['grains.filter_by']({
'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',
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
'log_file': '/var/log/mysql.log',
@@ -21,7 +21,7 @@

{%- set slave = salt['grains.filter_by']({
'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',
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
'log_file': '/var/log/mysql.log',
@@ -36,5 +36,22 @@
'log_file': '/var/log/mariadb/mariadb.log',
'socket': '/var/run/mariadb/mysqld.sock',
'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 파일 보기

@@ -25,6 +25,7 @@ galera_packages:
pkg.installed:
- names: {{ master.pkgs }}
- refresh: true
- force_yes: True

galera_log_dir:
file.directory:
@@ -106,6 +107,8 @@ galera_pre_config:
- require_in:
- pkg: galera_packages

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

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

{%- endif %}

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

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

galera_bootstrap_start_service_final:
cmd.run:
@@ -147,11 +158,15 @@ galera_bootstrap_start_service_final:
- file: galera_bootstrap_init_config
- file: galera_bootstrap_script

{%- endif %}

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

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

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

galera_service:
service.running:
@@ -173,3 +192,4 @@ galera_service:
- reload: true

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

+ 2
- 1
galera/server.sls 파일 보기

@@ -54,6 +54,7 @@ restore_mysql_database_{{ database_name }}:

{%- endfor %}

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

mysql_user_{{ user.name }}_{{ user.host }}:
@@ -67,5 +68,5 @@ mysql_user_{{ user.name }}_{{ user.host }}:
{%- endif %}

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

+ 15
- 0
galera/slave.sls 파일 보기

@@ -25,6 +25,7 @@ galera_packages:
pkg.installed:
- names: {{ slave.pkgs }}
- refresh: true
- force_yes: True

galera_log_dir:
file.directory:
@@ -106,6 +107,8 @@ galera_pre_config:
- require_in:
- pkg: galera_packages

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

galera_init_start_service:
cmd.run:
- name: /usr/local/sbin/galera_init.sh
@@ -131,14 +134,20 @@ galera_bootstrap_stop_service:
- require:
- cmd: mysql_bootstrap_update_maint_password

{%- endif %}

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

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

galera_bootstrap_start_service_final:
cmd.run:
@@ -156,6 +165,7 @@ galera_bootstrap_finish_flag:
- file: galera_config

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

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

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

galera_service:
service.running:
@@ -173,3 +187,4 @@ galera_service:
- reload: true

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

+ 2
- 2
metadata.yml 파일 보기

@@ -1,6 +1,6 @@
name: "galera"
version: "1.0"
source: "https://github.com/tcpcloud/salt-formula-galera"
source: "https://github.com/salt-formulas/salt-formula-galera"
dependencies:
- 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 파일 보기

@@ -24,4 +24,4 @@
- name: haproxy
host: '%'
- name: haproxy
host: 127.0.0.1
host: 127.0.0.1

+ 10
- 0
tests/pillar/repo_galeracluster.sls 파일 보기

@@ -0,0 +1,10 @@
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…
취소
저장