From 7e9225b88073f84c24a9da80d4655e397eb1f3c7 Mon Sep 17 00:00:00 2001 From: vokockis <228085+DeathBorn@users.noreply.github.com> Date: Fri, 12 Jun 2020 10:09:13 +0300 Subject: [PATCH] init_dbsql_sql_postfix base resource attribute to enable multiple init_db.sql files --- CHANGELOG.md | 2 ++ libraries/base_service.rb | 3 ++- metadata.rb | 2 +- test/integration/cluster/helpers.rb | 4 ++++ test/integration/cluster/mysql_spec.rb | 8 ++++++++ test/integration/cookbooks/test-vitess/recipes/cluster.rb | 1 + 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0236f91..ef9ac69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,3 +50,5 @@ Initial release. # 4.3.4 - [FIX] `schema_swap_admin_query_timeout`, `schema_swap_backup_concurrency`, `schema_swap_delay_between_errors`, `schema_swap_reparent_timeout` are no longer used with vtctld +# 4.4.0 +- [FEATURE] base resource now includes `init_dbsql_sql_postfix` to enable having multiple `init_db.sql` files diff --git a/libraries/base_service.rb b/libraries/base_service.rb index ecc8919..4f3f2f0 100644 --- a/libraries/base_service.rb +++ b/libraries/base_service.rb @@ -83,6 +83,7 @@ class VitessBaseService < Chef::Resource attribute(:mycnf, kind_of: Hash, default: lazy { node['vitess']['mycnf'] }) # Cookbook + attribute(:init_dbsql_sql_postfix, kind_of: String, default: '') attribute(:init_dbsql_sql_cookbook, kind_of: String, default: 'vitess') attribute(:init_dbsql_sql_variables, kind_of: Hash, default: {}) end @@ -149,7 +150,7 @@ def install_mycnf_config end def init_dbsql_path - @init_dbsql_path ||= "#{vt_config_path}/init_db.sql" + @init_dbsql_path ||= "#{vt_config_path}/init_db#{new_resource.init_dbsql_sql_postfix}.sql" end def install_init_dbsql diff --git a/metadata.rb b/metadata.rb index 6579b07..a195cac 100644 --- a/metadata.rb +++ b/metadata.rb @@ -7,7 +7,7 @@ issues_url 'https://github.com/vinted/chef-vitess/issues' source_url 'https://github.com/vinted/chef-vitess' chef_version '>= 12.1' if respond_to?(:chef_version) -version '4.3.4' +version '4.4.0' supports 'redhat' supports 'centos' diff --git a/test/integration/cluster/helpers.rb b/test/integration/cluster/helpers.rb index 95e70a6..0e2f9a0 100644 --- a/test/integration/cluster/helpers.rb +++ b/test/integration/cluster/helpers.rb @@ -3,3 +3,7 @@ vttablet0 vttablet1 vttablet2 vtctld vtgate vtworker ] + +INIT_DB_SQL_FILES = %w[ + init_dbmysqlctld0.sql init_dbmysqlctld1.sql init_dbmysqlctld2.sql +] diff --git a/test/integration/cluster/mysql_spec.rb b/test/integration/cluster/mysql_spec.rb index 67afd69..d5e0b75 100644 --- a/test/integration/cluster/mysql_spec.rb +++ b/test/integration/cluster/mysql_spec.rb @@ -10,3 +10,11 @@ it { should be_installed } end end + +INIT_DB_SQL_FILES.each do |init_db_file| + describe file("/var/lib/vt/config/#{init_db_file}") do + its('owner') { should eq 'vitess' } + its('group') { should eq 'vitess' } + it { should exist } + end +end diff --git a/test/integration/cookbooks/test-vitess/recipes/cluster.rb b/test/integration/cookbooks/test-vitess/recipes/cluster.rb index d96ecc7..789e561 100644 --- a/test/integration/cookbooks/test-vitess/recipes/cluster.rb +++ b/test/integration/cookbooks/test-vitess/recipes/cluster.rb @@ -44,6 +44,7 @@ mysqlctld_service "mysqlctld instance #{index}" do args mysqlctld service_name "mysqlctld#{index}" + init_dbsql_sql_postfix "mysqlctld#{index}" end end