From 593e930d71c10022ed0edd7d6d940455c4868112 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Tue, 2 May 2017 16:31:20 +0200 Subject: [PATCH] Fix beaker on xenial Since the beaker jobs are being run on xenial, we need a special nodeset for it, otherwise beaker gives an error: beaker-hostgenerator was not able to use this value as input. Exiting with an Error. We also want to install puppet from the Ubuntu repos rather than from puppetlabs, since puppetlabs doesn't support puppet 3 for Xenial. For centos we can keep the install process the same. This patch includes additional fixes for issues that were probably present when the tests were first merged: - make sure the irc pip package is installed by the puppet class - use double quotes for the channels.yaml fixture so properly render the newline characters - add "access" and "global" sections to the channels.yaml fixture since accessbot will otherwise be unable to parse the file - remove spec assertions about the accessbot process, because if it was successful it should have exited during the puppet run, and in fact if it didn't exit the puppet run would have failed. - correct the group name the spec is asserting of the config file Additionally, out of band from this patch, the nick 'accessbot-test' is nowregistered on freenode. If it's not registered, it becomes stuck in the irc infinite loop without performing any actions. This does not mean it has any permissions to make any real access changes. Change-Id: Ifd2244ae9dd212b2475f9cd6adb994bc058a4769 Depends-On: I23d0a9c0f4b6ecbb3403447adb03e845d2695366 --- manifests/init.pp | 8 +++++++- spec/acceptance/basic_spec.rb | 11 +---------- spec/acceptance/fixtures/default.pp | 2 +- spec/acceptance/nodesets/nodepool-xenial.yml | 10 ++++++++++ spec/spec_helper_acceptance.rb | 10 +++++++++- 5 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 spec/acceptance/nodesets/nodepool-xenial.yml diff --git a/manifests/init.pp b/manifests/init.pp index 9b70287..a220594 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -28,6 +28,11 @@ class accessbot( } } + package { 'irc': + ensure => installed, + provider => openstack_pip, + } + exec { 'run_accessbot' : command => '/usr/local/bin/accessbot -c /etc/accessbot/accessbot.config -l /etc/accessbot/channels.yaml >> /var/log/accessbot/accessbot.log 2>&1', path => '/usr/local/bin:/usr/bin:/bin/', @@ -36,7 +41,8 @@ class accessbot( subscribe => File['/etc/accessbot/channels.yaml'], require => [File['/etc/accessbot/channels.yaml'], File['/etc/accessbot/accessbot.config'], - File['/usr/local/bin/accessbot']], + File['/usr/local/bin/accessbot'], + Package['irc']], } file { '/etc/accessbot': diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 8b96041..27ea995 100755 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -33,16 +33,7 @@ describe 'basic accessbot' do it { should be_file } it { should be_owned_by 'root' } it { should be_mode 440 } - it { should be_grouped_into 'accessbo' } - end - - end - - context 'main proccess' do - - describe process("accessbot") do - its(:user) { should eq "accessbot" } - its(:args) { should match /-c accessbot.config/ } + it { should be_grouped_into 'accessbot' } end end diff --git a/spec/acceptance/fixtures/default.pp b/spec/acceptance/fixtures/default.pp index 79ce4db..f0745a4 100644 --- a/spec/acceptance/fixtures/default.pp +++ b/spec/acceptance/fixtures/default.pp @@ -1,6 +1,6 @@ file { '/etc/channels.yaml': ensure => file, - content => 'channels:\n - name: openstack-rainbow-unicorn-pals', + content => "access:\n nobody: +v\nglobal:\n nobody:\n - nobody\nchannels:\n - name: openstack-rainbow-unicorn-pals", } class { '::accessbot': 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 7a5efa1..de96291 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -2,7 +2,15 @@ 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']}" end