From adf1ec9fa8b4b270f28b5047075ee02c339c38f0 Mon Sep 17 00:00:00 2001 From: ZhongShengping Date: Thu, 2 Nov 2017 10:11:59 +0800 Subject: [PATCH] Switch to Zuul v3 testing Change-Id: Ia369a6b9089033bc081c88ea2d61089737661926 --- .zuul.yaml | 5 ++ Gemfile | 43 ++--------------- Rakefile | 87 +--------------------------------- bindep.txt | 11 +++++ manifests/agent/run.pp | 12 ++--- spec/spec_helper_acceptance.rb | 6 +-- 6 files changed, 27 insertions(+), 137 deletions(-) create mode 100644 .zuul.yaml create mode 100644 bindep.txt diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..fc098b3 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,5 @@ +- project: + name: openstack/puppet-midonet + templates: + - puppet-openstack-check-jobs + - puppet-module-unit-jobs diff --git a/Gemfile b/Gemfile index 742769d..caddc65 100644 --- a/Gemfile +++ b/Gemfile @@ -1,44 +1,7 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +source ENV['GEM_SOURCE'] || "https://rubygems.org" -def location_for(place, fake_version = nil) - if place =~ /^(git:[^#]*)#(.*)/ - [fake_version, { :git => $1, :branch => $2, :require => false }].compact - elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] - else - [place, { :require => false }] - end -end - -group :development, :unit_tests do - gem 'nokogiri', '1.6.8.1', :require => false - gem 'rspec-puppet', '~> 2.4', :require => false - gem 'fast_gettext', '1.1.0', :require => false - gem 'rspec-core', '3.5', :require => false - gem 'puppetlabs_spec_helper', '1.1.1', :require => false - gem 'puppet-lint', '2.0.2', :require => false - gem 'metadata-json-lint', :require => false - gem 'faraday', :require => false - # addressable 2.5.0 pulls in public_suffix >= 2.0 requires ruby >= 2.0 - gem 'addressable', ['< 2.5.0'] - # json_pure 2.0.2 requires ruby >= 2.0 and we don't have it on Ubuntu Trusty - gem 'json_pure', ['2.0.1'] -end - -group :system_tests do - - gem 'beaker-hostgenerator', '0.8.1' - gem 'beaker' , '< 3.0.0' - if beaker_version = ENV['BEAKER_VERSION'] - ## TODO - Remove hardcoded version as soon as BKR-885 is fixed - ## https://tickets.puppetlabs.com/browse/BKR-885 - # gem 'beaker', *location_for(beaker_version) - end - gem 'beaker-rspec', '5.6.0', :require => false - - gem 'serverspec', '2.37.2', :require => false - gem 'beaker-puppet_install_helper' ,'0.5.0', :require => false - gem 'r10k', :require => false +group :development, :test, :system_tests do + gem 'puppet-openstack_spec_helper', :require => 'false', :git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper' end if facterversion = ENV['FACTER_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index 46916a1..168d108 100644 --- a/Rakefile +++ b/Rakefile @@ -1,86 +1 @@ -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppet-syntax/tasks/puppet-syntax' -require 'json' - -modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1] - -PuppetSyntax.exclude_paths ||= [] -PuppetSyntax.exclude_paths << "spec/fixtures/**/*" -PuppetSyntax.exclude_paths << "pkg/**/*" -PuppetSyntax.exclude_paths << "vendor/**/*" - -Rake::Task[:lint].clear -PuppetLint::RakeTask.new :lint do |config| - config.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"] - config.fail_on_warnings = true - config.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}' - config.disable_checks = ["80chars", "class_inherits_from_params_class", "only_variable_string"] -end - -desc "Run acceptance tests" -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' -end - -Rake::Task[:spec_prep].clear -desc 'Create the fixtures directory' -task :spec_prep do - # Allow to test the module with custom dependencies - # like you could do with .fixtures file - ENV['PUPPETFILE']="#{Dir.pwd}/Puppetfile" - if ENV['PUPPETFILE'] - puppetfile = ENV['PUPPETFILE'] - if ENV['GEM_HOME'] - gem_home = ENV['GEM_HOME'] - gem_bin_dir = "#{gem_home}" + '/bin/' - else - gem_bin_dir = '' - end - r10k = ['env'] - r10k += ["PUPPETFILE=#{puppetfile}"] - r10k += ["PUPPETFILE_DIR=#{Dir.pwd}/spec/fixtures/modules"] - r10k += ["#{gem_bin_dir}r10k"] - r10k += ['puppetfile', 'install', '-v'] - sh(*r10k) - else - # otherwise, use official OpenStack Puppetfile - zuul_ref = ENV['ZUUL_REF'] - zuul_branch = ENV['ZUUL_BRANCH'] - zuul_url = ENV['ZUUL_URL'] - repo = 'openstack/puppet-openstack-integration' - rm_rf(repo) - if File.exists?('/usr/zuul-env/bin/zuul-cloner') - zuul_clone_cmd = ['/usr/zuul-env/bin/zuul-cloner'] - zuul_clone_cmd += ['--cache-dir', '/opt/git'] - zuul_clone_cmd += ['--zuul-ref', "#{zuul_ref}"] - zuul_clone_cmd += ['--zuul-branch', "#{zuul_branch}"] - zuul_clone_cmd += ['--zuul-url', "#{zuul_url}"] - zuul_clone_cmd += ['git://git.openstack.org', "#{repo}"] - sh(*zuul_clone_cmd) - else - sh("git clone https://git.openstack.org/#{repo} #{repo}") - end - script = ['env'] - script += ["PUPPETFILE_DIR=#{Dir.pwd}/spec/fixtures/modules"] - script += ["ZUUL_REF=#{zuul_ref}"] - script += ["ZUUL_BRANCH=#{zuul_branch}"] - script += ["ZUUL_URL=#{zuul_url}"] - script += ['bash', "#{repo}/install_modules_unit.sh"] - sh(*script) - end - rm_rf("spec/fixtures/modules/#{modname}") - ln_s(Dir.pwd, "spec/fixtures/modules/#{modname}") - mkdir_p('spec/fixtures/manifests') - touch('spec/fixtures/manifests/site.pp') -end - -Rake::Task[:spec_clean].clear -desc 'Clean up the fixtures directory' -task :spec_clean do - rm_rf('spec/fixtures/modules') - rm_rf('openstack') - if File.zero?('spec/fixtures/manifests/site.pp') - rm_f('spec/fixtures/manifests/site.pp') - end -end +require 'puppet-openstack_spec_helper/rake_tasks' diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..245e54a --- /dev/null +++ b/bindep.txt @@ -0,0 +1,11 @@ +# This is a cross-platform list tracking distribution packages needed by tests; +# see https://docs.openstack.org/infra/bindep/ for additional information. + +libxml2-devel [test platform:rpm] +libxml2-dev [test platform:dpkg] +libxslt-devel [test platform:rpm] +libxslt1-dev [test platform:dpkg] +ruby-devel [test platform:rpm] +ruby-dev [test platform:dpkg] +zlib1g-dev [test platform:dpkg] +zlib-devel [test platform:rpm] diff --git a/manifests/agent/run.pp b/manifests/agent/run.pp index e84984e..5efcd81 100644 --- a/manifests/agent/run.pp +++ b/manifests/agent/run.pp @@ -92,24 +92,23 @@ class midonet::agent::run ( exec { '/bin/bash /tmp/mn-agent_config.sh': } + Package['midolman'] ~> File['agent_config'] + file { 'agent_config': ensure => present, path => $agent_config_path, content => template('midonet/agent/midolman.conf.erb'), - require => Package['midolman'], notify => Service['midolman'], before => File['/tmp/mn-agent_config.sh'], } if !defined(File['set_config']) { + Package['midolman'] ~> File['set_config'] + File['midonet folder'] ~> File['set_config'] file { 'set_config': ensure => present, path => $midonet_config_path, content => template('midonet/agent/midolman.conf.erb'), - require => [ - Package['midolman'], - File['midonet folder'] - ], notify => Service['midolman'], before => File['/tmp/mn-agent_config.sh'], } @@ -123,11 +122,12 @@ class midonet::agent::run ( } } + Package['midolman'] ~> File['jvm_config'] + file { 'jvm_config': ensure => present, path => $jvm_config_path, content => template('midonet/agent/midolman-env.sh.erb'), - require => Package['midolman'], notify => Service['midolman'], } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index c54d0c2..1736cdb 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -20,9 +20,7 @@ RSpec.configure do |c| install_package host, 'git' install_package host, 'ruby' - zuul_ref = ENV['ZUUL_REF'] zuul_branch = ENV['ZUUL_BRANCH'] - zuul_url = ENV['ZUUL_URL'] repo = 'openstack/puppet-midonet' @@ -33,16 +31,14 @@ RSpec.configure do |c| if r.exit_code == 0 zuul_clone_cmd = '/usr/zuul-env/bin/zuul-cloner ' zuul_clone_cmd += '--cache-dir /opt/git ' - zuul_clone_cmd += "--zuul-ref #{zuul_ref} " zuul_clone_cmd += "--zuul-branch #{zuul_branch} " - zuul_clone_cmd += "--zuul-url #{zuul_url} " zuul_clone_cmd += "git://git.openstack.org #{repo}" on host, zuul_clone_cmd else on host, "git clone https://git.openstack.org/#{repo} #{repo}" end - on host, "ZUUL_REF=#{zuul_ref} ZUUL_BRANCH=#{zuul_branch} ZUUL_URL=#{zuul_url} bash #{repo}/spec/files/install_modules.sh" + on host, "ZUUL_BRANCH=#{zuul_branch} bash #{repo}/spec/files/install_modules.sh" # Install the module being tested on host, "rm -fr /etc/puppet/modules/#{modname}"