From 87b4f8327355ad38073bdb922685aadaee905bcd Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 19 Mar 2020 13:14:58 -0700 Subject: [PATCH] Stein fixes - Cookstyle fixes - Refactor Berksfile to use groups so we can exclude integration testing cookbooks - Update documentation - Update delivery configuration to exclude integration cookbooks - Fix ChefSpec output - Update Berksfile for cookbook-bind to point to upstream since the PR was merged, but not released (yet). - Ensure systemd-resolved is stopped and disabled Depends-On: https://review.opendev.org/701027 Depends-On: https://review.opendev.org/706158 Depends-On: https://review.opendev.org/706101 Depends-On: https://review.opendev.org/713762 Depends-On: https://review.opendev.org/706157 Depends-On: https://review.opendev.org/713285 Change-Id: I38d8707be687fee53e6f066e6e9bc80587e1e878 --- .delivery/project.toml | 10 +++++++- .rubocop.yml | 14 ------------ Berksfile | 29 +++++++++++------------ README.rst | 12 +++++----- attributes/default.rb | 47 ++++++++++++++++++++++++++++---------- attributes/tempest_conf.rb | 3 ++- metadata.rb | 16 ++++--------- recipes/create_network.rb | 4 +++- recipes/dns.rb | 26 ++++++++++++++++++++- recipes/orchestration.rb | 18 +++++++++++++++ recipes/run_tempest.rb | 4 +++- recipes/setup.rb | 34 +++++++++++++-------------- spec/dns-rhel_spec.rb | 2 +- spec/dns_spec.rb | 7 +++++- spec/setup-redhat_spec.rb | 15 +----------- spec/setup_spec.rb | 9 ++------ spec/spec_helper.rb | 4 ++-- 17 files changed, 149 insertions(+), 105 deletions(-) diff --git a/.delivery/project.toml b/.delivery/project.toml index 6d5e361..4066e55 100644 --- a/.delivery/project.toml +++ b/.delivery/project.toml @@ -1 +1,9 @@ -remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml" +[local_phases] +unit = 'rspec spec/' +lint = 'cookstyle --display-cop-names --extra-details' +syntax = "berks install -e integration" +provision = "echo skipping" +deploy = "echo skipping" +smoke = "echo skipping" +functional = "echo skipping" +cleanup = "echo skipping" diff --git a/.rubocop.yml b/.rubocop.yml index 5e0be9f..5ffd74f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,17 +14,3 @@ AllCops: - .cookbooks/**/* - berks-cookbooks/**/* - .bundle/**/* - -Encoding: - Exclude: - - metadata.rb - - Gemfile - -NumericLiterals: - Enabled: false - -LineLength: - Enabled: false - -WordArray: - MinSize: 3 diff --git a/Berksfile b/Berksfile index 3d11a60..60467fa 100644 --- a/Berksfile +++ b/Berksfile @@ -2,25 +2,26 @@ source 'https://supermarket.chef.io' solver :ruby, :required -%w( - client - -common - -dns - -identity - -image - -network - -ops-database - -ops-messaging -).each do |cookbook| +[ + %w(client dep), + %w(-common dep), + %w(-compute integration), + %w(-dns dep), + %w(-identity dep), + %w(-image dep), + %w(-network dep), + %w(-ops-database integration), + %w(-ops-messaging integration), +].each do |cookbook, group| if Dir.exist?("../cookbook-openstack#{cookbook}") - cookbook "openstack#{cookbook}", path: "../cookbook-openstack#{cookbook}" + cookbook "openstack#{cookbook}", path: "../cookbook-openstack#{cookbook}", group: group else - cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}" + cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group end end -# TODO(ramereth): Remove after this PR is merged +# TODO(ramereth): Remove after this PR is released # https://github.com/joyofhex/cookbook-bind/pull/60 -cookbook 'bind', github: 'ramereth/cookbook-bind', branch: 'fix-notifies-with-delayed-actions' +cookbook 'bind', github: 'joyofhex/cookbook-bind' metadata diff --git a/README.rst b/README.rst index 056432d..c4c1d95 100644 --- a/README.rst +++ b/README.rst @@ -20,9 +20,9 @@ https://docs.openstack.org/tempest/latest/ Requirements ============ -- Chef 14 or higher -- ChefDK 3.2.30 for testing (also includes Berkshelf for cookbook - dependency resolution) +- Chef 15 or higher +- Chef Workstation 0.15.18 for testing (also includes Berkshelf for + cookbook dependency resolution) Cookbooks --------- @@ -31,8 +31,8 @@ The following cookbooks are dependencies: - 'bind', '~> 2.3.1' - 'openstackclient' -- 'openstack-common', '>= 18.0.0' -- 'openstack-image', '>= 18.0.0' +- 'openstack-common', '>= 19.0.0' +- 'openstack-image', '>= 19.0.0' - 'resolver' Recipes @@ -88,7 +88,7 @@ License and Author +-----------------+--------------------------------------------------+ | **Copyright** | Copyright (c) 2014, Rackspace US, Inc. | +-----------------+--------------------------------------------------+ -| **Copyright** | Copyright (c) 2017-2019, Oregon State University | +| **Copyright** | Copyright (c) 2017-2020, Oregon State University | +-----------------+--------------------------------------------------+ Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/attributes/default.rb b/attributes/default.rb index 719c79a..ae0e737 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,9 +1,10 @@ # encoding: UTF-8 # -# Cookbook Name:: openstack-integration-test +# Cookbook:: openstack-integration-test # Attributes:: default # -# Copyright 2014, Rackspace US, Inc. +# Copyright:: 2014, Rackspace US, Inc. +# Copyright:: 2017-2020, Oregon State University # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -65,20 +66,42 @@ default['openstack']['integration-test'] = { case node['platform_family'] when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this default['openstack']['integration-test']['platform'] = { - tempest_packages: %w(git curl libxslt-devel - libxml2-devel python-testrepository - libffi-devel python-devel - python-gabbi python-testscenarios - python-ddt), + tempest_packages: + %w( + git + curl + libxslt-devel + libxml2-devel + python-testrepository + libffi-devel + python-devel + python-gabbi + python-testscenarios + python-ddt + ), package_overrides: '', } when 'debian' default['openstack']['integration-test']['platform'] = { - 'tempest_packages' => %w(git curl libssl-dev libffi-dev python-dev libxml2-dev - libxslt1-dev libpq-dev libxml2-dev libxslt-dev - testrepository python-dev libffi-dev - python-gabbi python-testscenarios - python-ddt), + 'tempest_packages' => + %w( + git + curl + libssl-dev + libffi-dev + python-dev + libxml2-dev + libxslt1-dev + libpq-dev + libxml2-dev + libxslt-dev + testrepository + python-dev + libffi-dev + python-gabbi + python-testscenarios + python-ddt + ), 'package_overrides' => '', } end diff --git a/attributes/tempest_conf.rb b/attributes/tempest_conf.rb index 60771dc..600e342 100644 --- a/attributes/tempest_conf.rb +++ b/attributes/tempest_conf.rb @@ -6,7 +6,8 @@ default['openstack']['integration-test']['conf'].tap do |conf| conf['auth']['default_credentials_domain_name'] = 'Default' conf['auth']['admin_domain_name'] = 'Default' conf['identity']['catalog_type'] = 'identity' - conf['identity']['disable_ssl_certificate_validation'] = node['openstack']['integration-test']['disable_ssl_validation'] + conf['identity']['disable_ssl_certificate_validation'] = + node['openstack']['integration-test']['disable_ssl_validation'] conf['identity']['v3_endpoint_type'] = 'publicURL' conf['identity']['strategy'] = 'keystone' conf['identity']['region'] = 'RegionOne' diff --git a/metadata.rb b/metadata.rb index 523ff62..03be561 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,13 +3,7 @@ maintainer 'openstack-chef' maintainer_email 'openstack-discuss@lists.openstack.org' license 'Apache-2.0' description 'Installs and configures the Tempest Integration Test Suite' -version '18.0.0' - -recipe 'openstack-integration-test::create_network', 'Create a test network and subnet for use in kitchen tests' -recipe 'openstack-integration-test::dns', 'Setup environment for testing designate' -recipe 'openstack-integration-test::orchestration', 'Setup environment for testing heat' -recipe 'openstack-integration-test::run_tempest', 'Run tempest for use in kitchen tests' -recipe 'openstack-integration-test::setup', 'Installs and configures Tempest' +version '19.0.0' %w(ubuntu redhat centos).each do |os| supports os @@ -17,11 +11,11 @@ end depends 'bind', '~> 2.3.1' depends 'openstackclient' -depends 'openstack-common', '>= 18.0.0' -depends 'openstack-dns', '>= 18.0.0' -depends 'openstack-image', '>= 18.0.0' +depends 'openstack-common', '>= 19.0.0' +depends 'openstack-dns', '>= 19.0.0' +depends 'openstack-image', '>= 19.0.0' depends 'resolver' issues_url 'https://launchpad.net/openstack-chef' source_url 'https://opendev.org/openstack/cookbook-openstack-integration-test' -chef_version '>= 14.0' +chef_version '>= 15.0' diff --git a/recipes/create_network.rb b/recipes/create_network.rb index a4ffd47..71fd548 100644 --- a/recipes/create_network.rb +++ b/recipes/create_network.rb @@ -1,8 +1,10 @@ # encoding: UTF-8 # -# Cookbook Name:: openstack-integration-test +# Cookbook:: openstack-integration-test # Recipe:: create_network # +# Copyright:: 2020, Oregon State University +# # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/recipes/dns.rb b/recipes/dns.rb index 7d65702..54c8d50 100644 --- a/recipes/dns.rb +++ b/recipes/dns.rb @@ -1,3 +1,23 @@ +# encoding: UTF-8 +# +# Cookbook:: openstack-integration-test +# Recipe:: dns +# +# Copyright:: 2020, Oregon State University +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class ::Chef::Recipe include ::Openstack include BindCookbook::Helpers @@ -7,6 +27,10 @@ class ::Chef::Resource include BindCookbook::Helpers end +service 'systemd-resolved' do + action [:stop, :disable] +end + # Match what opendev/base-jobs uses for unbound: # https://opendev.org/opendev/base-jobs/src/branch/master/roles/configure-unbound/defaults/main.yaml#L1-L7 node.default['resolver']['search'] = [] @@ -30,7 +54,7 @@ template "#{default_property_for(:sysconfdir, false)}/rndc.key" do cookbook 'openstack-dns' owner default_property_for(:run_user, false) group default_property_for(:run_group, false) - mode 00440 + mode '440' sensitive true variables( secret: rndc_secret diff --git a/recipes/orchestration.rb b/recipes/orchestration.rb index c41426a..8f1d973 100644 --- a/recipes/orchestration.rb +++ b/recipes/orchestration.rb @@ -1,3 +1,21 @@ +# encoding: UTF-8 +# +# Cookbook:: openstack-integration-test +# Recipe:: orchestration +# +# Copyright:: 2020, Oregon State University +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + execute 'bash -c "source /root/openrc && openstack keypair create heat_key > /tmp/heat_key.priv"' do creates '/tmp/heat_key.priv' end diff --git a/recipes/run_tempest.rb b/recipes/run_tempest.rb index 87f11d1..ef58ad9 100644 --- a/recipes/run_tempest.rb +++ b/recipes/run_tempest.rb @@ -1,8 +1,10 @@ # encoding: UTF-8 # -# Cookbook Name:: openstack-integration-test +# Cookbook:: openstack-integration-test # Recipe:: run_tempest # +# Copyright:: 2020, Oregon State University +# # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/recipes/setup.rb b/recipes/setup.rb index c81f7d6..78888e9 100644 --- a/recipes/setup.rb +++ b/recipes/setup.rb @@ -1,9 +1,10 @@ # encoding: UTF-8 # -# Cookbook Name:: openstack-integration-test +# Cookbook:: openstack-integration-test # Recipe:: setup # -# Copyright 2014, Rackspace US, Inc. +# Copyright:: 2014, Rackspace US, Inc. +# Copyright:: 2017-2020, Oregon State university # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -30,12 +31,9 @@ end platform_options = node['openstack']['integration-test']['platform'] service_available = node['openstack']['integration-test']['conf']['service_available'] -platform_options['tempest_packages'].each do |pkg| - package pkg do - options platform_options['package_overrides'] - - action :upgrade - end +package platform_options['tempest_packages'] do + options platform_options['package_overrides'] + action :upgrade end identity_endpoint = internal_endpoint 'identity' @@ -49,11 +47,11 @@ admin_project_domain_name = node['openstack']['identity']['admin_project_domain' endpoint_type = node['openstack']['identity']['endpoint_type'] connection_params = { - openstack_auth_url: auth_url, - openstack_username: admin_user, - openstack_api_key: admin_pass, - openstack_project_name: admin_project, - openstack_domain_name: admin_domain, + openstack_auth_url: auth_url, + openstack_username: admin_user, + openstack_api_key: admin_pass, + openstack_project_name: admin_project, + openstack_domain_name: admin_domain, openstack_endpoint_type: endpoint_type, } @@ -84,6 +82,7 @@ openstack_role node['openstack']['integration-test']['heat_stack_user_role'] do end include_recipe 'openstack-common' +build_essential 'tempest' tempest_path = '/opt/tempest' venv_path = '/opt/tempest-venv' @@ -103,8 +102,7 @@ end # Note(jh): Make sure to keep the constraint definition in sync with # the tempest version tempest_ver = '22.1.0' -constraint = '-c https://opendev.org/openstack/requirements/raw/'\ - 'branch/stable/train/upper-constraints.txt' +constraint = '-c https://opendev.org/openstack/requirements/raw/branch/stable/train/upper-constraints.txt' execute 'install tempest' do action :nothing @@ -124,7 +122,7 @@ template "#{venv_path}/tempest.sh" do source 'tempest.sh.erb' user 'root' group 'root' - mode 0o755 + mode '755' variables( venv_path: venv_path ) @@ -188,7 +186,7 @@ template '/opt/tempest/etc/tempest.conf' do cookbook 'openstack-common' owner 'root' group 'root' - mode 0o0600 + mode '600' variables( service_config: integration_test_conf_options ) @@ -197,7 +195,7 @@ end directory '/opt/tempest/logs' do owner 'root' group 'root' - mode 0755 + mode '755' action :create end diff --git a/spec/dns-rhel_spec.rb b/spec/dns-rhel_spec.rb index 83d133d..63b502c 100644 --- a/spec/dns-rhel_spec.rb +++ b/spec/dns-rhel_spec.rb @@ -38,7 +38,7 @@ describe 'openstack-integration-test::dns' do source: 'rndc.key.erb', owner: 'named', group: 'named', - mode: 00440, + mode: '440', sensitive: true, variables: { secret: 'rndc-key', diff --git a/spec/dns_spec.rb b/spec/dns_spec.rb index cc0dbb3..3fb3bc8 100644 --- a/spec/dns_spec.rb +++ b/spec/dns_spec.rb @@ -11,6 +11,11 @@ describe 'openstack-integration-test::dns' do include_context 'tempest-stubs' + it do + expect(chef_run).to stop_service('systemd-resolved') + expect(chef_run).to disable_service('systemd-resolved') + end + [ /^nameserver 1.0.0.1$/, /^nameserver 8.8.8.8$/, @@ -38,7 +43,7 @@ describe 'openstack-integration-test::dns' do source: 'rndc.key.erb', owner: 'bind', group: 'bind', - mode: 00440, + mode: '440', sensitive: true, variables: { secret: 'rndc-key', diff --git a/spec/setup-redhat_spec.rb b/spec/setup-redhat_spec.rb index 975dfbe..92f7a49 100644 --- a/spec/setup-redhat_spec.rb +++ b/spec/setup-redhat_spec.rb @@ -12,20 +12,7 @@ describe 'openstack-integration-test::setup' do include_context 'tempest-stubs' it 'installs tempest dependencies' do - %w( - curl - git - libffi-devel - libxml2-devel - libxslt-devel - python-ddt - python-devel - python-gabbi - python-testrepository - python-testscenarios - ).each do |pkg| - expect(chef_run).to upgrade_package(pkg) - end + expect(chef_run).to upgrade_package %w(git curl libxslt-devel libxml2-devel python-testrepository libffi-devel python-devel python-gabbi python-testscenarios python-ddt) end end end diff --git a/spec/setup_spec.rb b/spec/setup_spec.rb index 79a529a..1dc97aa 100644 --- a/spec/setup_spec.rb +++ b/spec/setup_spec.rb @@ -21,12 +21,7 @@ describe 'openstack-integration-test::setup' do } it 'installs tempest dependencies' do - packages = %w(git libxml2-dev libxslt-dev testrepository python-dev - libffi-dev) - - packages.each do |pkg| - expect(chef_run).to upgrade_package(pkg) - end + expect(chef_run).to upgrade_package %w(git curl libssl-dev libffi-dev python-dev libxml2-dev libxslt1-dev libpq-dev libxml2-dev libxslt-dev testrepository python-dev libffi-dev python-gabbi python-testscenarios python-ddt) end it 'registers tempest_project1 Project' do @@ -164,7 +159,7 @@ describe 'openstack-integration-test::setup' do expect(chef_run).to create_template(file.name).with( user: 'root', group: 'root', - mode: 0o0600 + mode: '600' ) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f04e749..fa983ec 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,8 +22,8 @@ shared_context 'tempest-stubs' do before do env = { - 'OS_USERNAME' => 'admin', - 'OS_PASSWORD' => 'admin', + 'OS_USERNAME' => 'admin', + 'OS_PASSWORD' => 'admin', 'OS_PROJECT_NAME' => 'admin', 'OS_AUTH_URL' => 'http://127.0.0.1:5000/v3', 'OS_USER_DOMAIN_NAME' => 'default',