Skip to content

Commit fbd53bd

Browse files
davpratgmarciani
authored andcommitted
Fix MySQL validation tests
Signed-off-by: David Pratt <[email protected]>
1 parent 0b39579 commit fbd53bd

File tree

4 files changed

+43
-33
lines changed

4 files changed

+43
-33
lines changed

attributes/default.rb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,24 +264,30 @@
264264
# MySQL Validation
265265
if arm_instance?
266266
default['cluster']['mysql']['repository']['packages'] = value_for_platform(
267-
'default' => %w(mysql-community-devel mysql-community-libs mysql-community-common mysql-community-client-plugins),
267+
'default' => %w(mysql-community-devel mysql-community-libs mysql-community-common mysql-community-client-plugins mysql-community-libs-compat),
268268
'ubuntu' => {
269-
'default' => %w(libmysqlclient-dev libmysqlclient21 mysql-common),
270-
'18.04' => %w(libmysqlclient-dev libmysqlclient20 mysql-common),
269+
'default' => %w(libmysqlclient-dev libmysqlclient21),
270+
'18.04' => %w(libmysqlclient-dev libmysqlclient20),
271271
}
272272
)
273-
default['cluster']['mysql']['repository']['expected']['source'] = value_for_platform(
274-
'default' => "mysql80-community",
275-
'ubuntu' => { 'default' => "http://#{node['cluster']['region']}.ec2.ports.ubuntu.com/ubuntu-ports" }
273+
default['cluster']['mysql']['repository']['expected']['version'] = value_for_platform(
274+
'default' => "8.0.31",
275+
'ubuntu' => {
276+
'20.04' => "8.0.30-0ubuntu0.20.04.2",
277+
'18.04' => "5.7.39-0ubuntu0.18.04.2"
278+
}
276279
)
277280
else
278281
default['cluster']['mysql']['repository']['packages'] = value_for_platform(
279-
'default' => %w(mysql-community-devel mysql-community-libs mysql-community-common mysql-community-client-plugins),
282+
'default' => %w(mysql-community-devel mysql-community-libs mysql-community-common mysql-community-client-plugins mysql-community-libs-compat),
280283
'ubuntu' => { 'default' => %w(libmysqlclient-dev libmysqlclient21 mysql-common mysql-community-client-plugins) }
281284
)
282-
default['cluster']['mysql']['repository']['expected']['source'] = value_for_platform(
283-
'default' => "mysql80-community",
284-
'ubuntu' => { 'default' => "http://repo.mysql.com/apt/ubuntu" }
285+
default['cluster']['mysql']['repository']['expected']['version'] = value_for_platform(
286+
'default' => "8.0.31",
287+
'ubuntu' => {
288+
'20.04' => "8.0.31-1ubuntu20.04",
289+
'18.04' => "8.0.31-1ubuntu18.04"
290+
}
285291
)
286292
end
287293

cookbooks/aws-parallelcluster-test/libraries/helpers.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,27 @@ def validate_package_source(package, expected_source)
259259
TEST
260260
end
261261
end
262+
263+
def validate_package_version(package, expected_version)
264+
case node['platform']
265+
when 'amazon', 'centos'
266+
test_expression = "$(yum info #{package} | grep 'Version' | awk '{print $3}')"
267+
when 'ubuntu'
268+
test_expression = "$(apt show #{package} | grep 'Version:' | awk '{print $2}')"
269+
else
270+
raise "Platform not supported: #{node['platform']}"
271+
end
272+
273+
bash "Check that package #{package} v#{expected_version} is installed" do
274+
cwd Chef::Config[:file_cache_path]
275+
code <<-TEST
276+
echo "Testing package #{package} version"
277+
actual_version=#{test_expression}
278+
if [ "#{expected_version}" != "${actual_version}" ]; then
279+
echo "ERROR Expected package source #{expected_version} for #{package} does not match actual source: ${actual_version}"
280+
exit 1
281+
fi
282+
echo "#{package} correctly installed version #{expected_version}"
283+
TEST
284+
end
285+
end

cookbooks/aws-parallelcluster-test/recipes/validate_mysql.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
#
1919
# Check the repository source of a package
2020
#
21-
unless arm_instance? && platform?('ubuntu')
22-
Chef::Log.info("Checking for MySql implementation on #{node['platform']}:#{node['kernel']['machine']}")
23-
node['cluster']['mysql']['repository']['packages'].each do |pkg|
24-
validate_package_source(pkg, node['cluster']['mysql']['repository']['expected']['source'])
25-
end
21+
Chef::Log.info("Checking for MySql implementation on #{node['platform']}:#{node['kernel']['machine']}")
22+
node['cluster']['mysql']['repository']['packages'].each do |pkg|
23+
validate_package_version(pkg, node['cluster']['mysql']['repository']['expected']['version'])
2624
end

recipes/post_install.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)