Skip to content

Commit

Permalink
Merge pull request #22 from vinted/feature/multi_init_db_sql_files
Browse files Browse the repository at this point in the history
Feature/init_dbsql_sql_postfix base resource attribute
  • Loading branch information
DeathBorn authored Jun 12, 2020
2 parents 9d09fa1 + 7e9225b commit f3c0509
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion libraries/base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions test/integration/cluster/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
vttablet0 vttablet1 vttablet2
vtctld vtgate vtworker
]

INIT_DB_SQL_FILES = %w[
init_dbmysqlctld0.sql init_dbmysqlctld1.sql init_dbmysqlctld2.sql
]
8 changes: 8 additions & 0 deletions test/integration/cluster/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions test/integration/cookbooks/test-vitess/recipes/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
mysqlctld_service "mysqlctld instance #{index}" do
args mysqlctld
service_name "mysqlctld#{index}"
init_dbsql_sql_postfix "mysqlctld#{index}"
end
end

Expand Down

0 comments on commit f3c0509

Please sign in to comment.