From 17bff7d7b49a1a8c1e78200612aa85baeff014f8 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Tue, 2 May 2017 16:26:16 +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. Also run django.setup() since django >=1.7 now requires it[1]. Finally, correct the cron check string in the spec tests. [1] http://django.readthedocs.io/en/latest/releases/1.7.html#backwards-incompatible-changes-in-1-7 Change-Id: Ifd2244ae9dd212b2475f9cd6adb994bc058a4769 Depends-On: I02729bc2d49f10a37e9314632b229fbbe72d0b0b --- files/graphite-init-db.py | 3 +++ spec/acceptance/basic_spec.rb | 2 +- spec/acceptance/nodesets/nodepool-xenial.yml | 10 ++++++++++ spec/spec_helper_acceptance.rb | 10 +++++++++- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 spec/acceptance/nodesets/nodepool-xenial.yml diff --git a/files/graphite-init-db.py b/files/graphite-init-db.py index 45e01d5..119572a 100644 --- a/files/graphite-init-db.py +++ b/files/graphite-init-db.py @@ -20,9 +20,12 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "graphite.settings") import sys import ConfigParser +import django from django.core import management from django.contrib.auth import models as auth_models +django.setup() + config = ConfigParser.ConfigParser() config.read(os.path.expanduser(sys.argv[1])) diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 0fc78f3..6552149 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -155,6 +155,6 @@ describe 'puppet-graphite module', :if => ['debian', 'ubuntu'].include?(os[:fami end describe cron do - it { should have_entry('0 2 * * * find /var/lib/graphite/storage/whisper -type f -mtime +270 -name \\\\*.wsp -delete; find /var/lib/graphite/storage/whisper -depth -type d -empty -delete > /dev/null').with_user('root') } + it { should have_entry('0 2 * * * find /var/lib/graphite/storage/whisper -type f -mtime +270 -name \*.wsp -delete; find /var/lib/graphite/storage/whisper -depth -type d -empty -delete > /dev/null').with_user('root') } end end 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