From afb75e352362e2cf70441fa7325f6531f95603c8 Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 11:17:21 +0400 Subject: [PATCH 1/9] updated memcached cookbook --- cookbooks/memcached/.envrc | 1 - cookbooks/memcached/.gitignore | 49 +++++++++++ cookbooks/memcached/Berksfile | 7 -- cookbooks/memcached/CHANGELOG.md | 4 + cookbooks/memcached/chefignore | 115 ------------------------- cookbooks/memcached/kitchen.dokken.yml | 65 -------------- cookbooks/memcached/kitchen.yml | 33 ------- cookbooks/memcached/metadata.rb | 4 +- 8 files changed, 54 insertions(+), 224 deletions(-) delete mode 100644 cookbooks/memcached/.envrc create mode 100644 cookbooks/memcached/.gitignore delete mode 100644 cookbooks/memcached/Berksfile delete mode 100644 cookbooks/memcached/chefignore delete mode 100644 cookbooks/memcached/kitchen.dokken.yml delete mode 100644 cookbooks/memcached/kitchen.yml diff --git a/cookbooks/memcached/.envrc b/cookbooks/memcached/.envrc deleted file mode 100644 index 6ed589ea..00000000 --- a/cookbooks/memcached/.envrc +++ /dev/null @@ -1 +0,0 @@ -use chefworkstation diff --git a/cookbooks/memcached/.gitignore b/cookbooks/memcached/.gitignore new file mode 100644 index 00000000..be3b9a8b --- /dev/null +++ b/cookbooks/memcached/.gitignore @@ -0,0 +1,49 @@ +*.rbc +.config +InstalledFiles +pkg +test/tmp +test/version_tmp +tmp +_Store +*~ +*# +.#* +\#*# +*.un~ +*.tmp +*.bk +*.bkup + +# editor files +.idea +.*.sw[a-z] + +# ruby/bundler/rspec files +.ruby-version +.ruby-gemset +.rvmrc +Gemfile.lock +.bundle +*.gem +coverage +spec/reports + +# YARD / rdoc artifacts +.yardoc +_yardoc +doc/ +rdoc + +# chef infra stuff +Berksfile.lock +.kitchen +kitchen.local.yml +vendor/ +.coverage/ +.zero-knife.rb +Policyfile.lock.json + +# vagrant stuff +.vagrant/ +.vagrant.d/ diff --git a/cookbooks/memcached/Berksfile b/cookbooks/memcached/Berksfile deleted file mode 100644 index e09849c7..00000000 --- a/cookbooks/memcached/Berksfile +++ /dev/null @@ -1,7 +0,0 @@ -source 'https://supermarket.chef.io' - -metadata - -group :integration do - cookbook 'test', path: 'test/fixtures/cookbooks/test' -end diff --git a/cookbooks/memcached/CHANGELOG.md b/cookbooks/memcached/CHANGELOG.md index 8ea16318..416a7e77 100644 --- a/cookbooks/memcached/CHANGELOG.md +++ b/cookbooks/memcached/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 7.0.5 - *2022-12-13* + +Standardise files with files in sous-chefs/repo-management + ## 7.0.4 - *2022-02-08* - Remove delivery folder diff --git a/cookbooks/memcached/chefignore b/cookbooks/memcached/chefignore deleted file mode 100644 index cc170ea7..00000000 --- a/cookbooks/memcached/chefignore +++ /dev/null @@ -1,115 +0,0 @@ -# Put files/directories that should be ignored in this file when uploading -# to a Chef Infra Server or Supermarket. -# Lines that start with '# ' are comments. - -# OS generated files # -###################### -.DS_Store -ehthumbs.db -Icon? -nohup.out -Thumbs.db -.envrc - -# EDITORS # -########### -.#* -.project -.settings -*_flymake -*_flymake.* -*.bak -*.sw[a-z] -*.tmproj -*~ -\#* -REVISION -TAGS* -tmtags -.vscode -.editorconfig - -## COMPILED ## -############## -*.class -*.com -*.dll -*.exe -*.o -*.pyc -*.so -*/rdoc/ -a.out -mkmf.log - -# Testing # -########### -.circleci/* -.codeclimate.yml -.delivery/* -.foodcritic -.kitchen* -.mdlrc -.overcommit.yml -.rspec -.rubocop.yml -.travis.yml -.watchr -.yamllint -azure-pipelines.yml -Dangerfile -examples/* -features/* -Guardfile -kitchen.yml* -mlc_config.json -Procfile -Rakefile -spec/* -test/* - -# SCM # -####### -.git -.gitattributes -.gitconfig -.github/* -.gitignore -.gitkeep -.gitmodules -.svn -*/.bzr/* -*/.git -*/.hg/* -*/.svn/* - -# Berkshelf # -############# -Berksfile -Berksfile.lock -cookbooks/* -tmp - -# Bundler # -########### -vendor/* -Gemfile -Gemfile.lock - -# Policyfile # -############## -Policyfile.rb -Policyfile.lock.json - -# Documentation # -############# -CODE_OF_CONDUCT* -CONTRIBUTING* -documentation/* -TESTING* -UPGRADING* - -# Vagrant # -########### -.vagrant -Vagrantfile diff --git a/cookbooks/memcached/kitchen.dokken.yml b/cookbooks/memcached/kitchen.dokken.yml deleted file mode 100644 index 4f5ed8a4..00000000 --- a/cookbooks/memcached/kitchen.dokken.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -driver: - name: dokken - privileged: true - env: [CHEF_LICENSE=accept] - -transport: - name: dokken - -provisioner: - name: dokken - product_name: chef - product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> - -verifier: - name: inspec - -platforms: - - name: debian-9 - driver: - image: dokken/debian-9 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - - - name: debian-10 - driver: - image: dokken/debian-10 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - - - name: amazonlinux-2 - driver: - image: dokken/amazonlinux-2 - pid_one_command: /usr/lib/systemd/systemd - - - name: centos-7 - driver: - image: dokken/centos-7 - pid_one_command: /usr/lib/systemd/systemd - - - name: centos-8 - driver: - image: dokken/centos-8 - pid_one_command: /usr/lib/systemd/systemd - - - name: centos-stream-8 - driver: - image: dokken/centos-stream-8 - pid_one_command: /usr/lib/systemd/systemd - - - name: ubuntu-18.04 - driver: - image: dokken/ubuntu-18.04 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - - - name: ubuntu-20.04 - driver: - image: dokken/ubuntu-20.04 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update diff --git a/cookbooks/memcached/kitchen.yml b/cookbooks/memcached/kitchen.yml deleted file mode 100644 index 7205a4fb..00000000 --- a/cookbooks/memcached/kitchen.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -driver: - name: vagrant - -provisioner: - name: chef_zero - product_name: chef - product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> - install_strategy: once - -client_rb: - treat_deprecation_warnings_as_errors: true - -verifier: - name: inspec - -platforms: - - name: debian-9 - - name: debian-10 - - name: amazonlinux-2 - - name: centos-7 - - name: centos-8 - - name: centos-stream-8 - - name: ubuntu-18.04 - - name: ubuntu-20.04 - -suites: - - name: default - run_list: - - recipe[test::default] - - name: instance - run_list: - - recipe[test::instance] diff --git a/cookbooks/memcached/metadata.rb b/cookbooks/memcached/metadata.rb index 2b2a44b8..ca6f0a26 100644 --- a/cookbooks/memcached/metadata.rb +++ b/cookbooks/memcached/metadata.rb @@ -3,10 +3,8 @@ maintainer_email 'help@sous-chefs.org' license 'Apache-2.0' description 'Installs memcached and includes memcached_instance resource for setting up memcached instances' -source_url 'https://github.com/sous-chefs/memcached' -issues_url 'https://github.com/sous-chefs/memcached/issues' chef_version '>= 15.3' -version '7.0.4' +version '7.0.5' %w(ubuntu debian redhat centos suse opensuse opensuseleap scientific oracle amazon zlinux).each do |os| supports os From 8e1b948aa89b70c3859d5729f6f26bde4c2bd8cf Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 11:32:32 +0400 Subject: [PATCH 2/9] cleanup on openstack common --- .../openstack-common/.delivery/project.toml | 9 - cookbooks/openstack-common/.rubocop.yml | 6 - cookbooks/openstack-common/.rubocop_todo.yml | 20 -- cookbooks/openstack-common/.zuul.yaml | 3 - cookbooks/openstack-common/Berksfile | 8 - cookbooks/openstack-common/spec/cli_spec.rb | 177 ------------- .../spec/client-redhat_spec.rb | 28 -- .../openstack-common/spec/client_spec.rb | 19 -- .../openstack-common/spec/completions_spec.rb | 27 -- .../spec/config_helpers_spec.rb | 55 ---- .../metadata.rb | 8 - .../recipes/default.rb | 4 - .../spec/database_provider_spec.rb | 73 ------ .../spec/default-redhat_spec.rb | 136 ---------- .../openstack-common/spec/default_spec.rb | 158 ------------ .../openstack-common/spec/endpoints_spec.rb | 241 ------------------ .../openstack-common/spec/logging_spec.rb | 206 --------------- .../openstack-common/spec/network_spec.rb | 218 ---------------- cookbooks/openstack-common/spec/parse_spec.rb | 91 ------- .../openstack-common/spec/password_spec.rb | 121 --------- .../openstack-common/spec/search_spec.rb | 140 ---------- .../openstack-common/spec/spec_helper.rb | 59 ----- .../openstack-common/spec/sysctl_spec.rb | 22 -- cookbooks/openstack-common/spec/uri_spec.rb | 90 ------- .../openstack-common/spec/wrappers_spec.rb | 37 --- 25 files changed, 1956 deletions(-) delete mode 100644 cookbooks/openstack-common/.delivery/project.toml delete mode 100644 cookbooks/openstack-common/.rubocop.yml delete mode 100644 cookbooks/openstack-common/.rubocop_todo.yml delete mode 100644 cookbooks/openstack-common/.zuul.yaml delete mode 100644 cookbooks/openstack-common/Berksfile delete mode 100644 cookbooks/openstack-common/spec/cli_spec.rb delete mode 100644 cookbooks/openstack-common/spec/client-redhat_spec.rb delete mode 100644 cookbooks/openstack-common/spec/client_spec.rb delete mode 100644 cookbooks/openstack-common/spec/completions_spec.rb delete mode 100644 cookbooks/openstack-common/spec/config_helpers_spec.rb delete mode 100644 cookbooks/openstack-common/spec/cookbooks/test-openstack-common-database/metadata.rb delete mode 100644 cookbooks/openstack-common/spec/cookbooks/test-openstack-common-database/recipes/default.rb delete mode 100644 cookbooks/openstack-common/spec/database_provider_spec.rb delete mode 100644 cookbooks/openstack-common/spec/default-redhat_spec.rb delete mode 100644 cookbooks/openstack-common/spec/default_spec.rb delete mode 100644 cookbooks/openstack-common/spec/endpoints_spec.rb delete mode 100644 cookbooks/openstack-common/spec/logging_spec.rb delete mode 100644 cookbooks/openstack-common/spec/network_spec.rb delete mode 100644 cookbooks/openstack-common/spec/parse_spec.rb delete mode 100644 cookbooks/openstack-common/spec/password_spec.rb delete mode 100644 cookbooks/openstack-common/spec/search_spec.rb delete mode 100644 cookbooks/openstack-common/spec/spec_helper.rb delete mode 100644 cookbooks/openstack-common/spec/sysctl_spec.rb delete mode 100644 cookbooks/openstack-common/spec/uri_spec.rb delete mode 100644 cookbooks/openstack-common/spec/wrappers_spec.rb diff --git a/cookbooks/openstack-common/.delivery/project.toml b/cookbooks/openstack-common/.delivery/project.toml deleted file mode 100644 index 4066e559..00000000 --- a/cookbooks/openstack-common/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[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/cookbooks/openstack-common/.rubocop.yml b/cookbooks/openstack-common/.rubocop.yml deleted file mode 100644 index 58c34972..00000000 --- a/cookbooks/openstack-common/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: .rubocop_todo.yml - -Chef/Modernize/FoodcriticComments: - Enabled: true -Chef/Style/CopyrightCommentFormat: - Enabled: true diff --git a/cookbooks/openstack-common/.rubocop_todo.yml b/cookbooks/openstack-common/.rubocop_todo.yml deleted file mode 100644 index ca0d7ae9..00000000 --- a/cookbooks/openstack-common/.rubocop_todo.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2021-10-14 06:25:41 UTC using RuboCop version 1.22.0. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: **/libraries/*.rb -Chef/Modernize/DefinesChefSpecMatchers: - Exclude: - - 'libraries/matchers.rb' - -# Offense count: 2 -Lint/NestedMethodDefinition: - Exclude: - - 'libraries/matchers.rb' diff --git a/cookbooks/openstack-common/.zuul.yaml b/cookbooks/openstack-common/.zuul.yaml deleted file mode 100644 index f5786847..00000000 --- a/cookbooks/openstack-common/.zuul.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- project: - templates: - - openstack-chef-jobs diff --git a/cookbooks/openstack-common/Berksfile b/cookbooks/openstack-common/Berksfile deleted file mode 100644 index 15e7c974..00000000 --- a/cookbooks/openstack-common/Berksfile +++ /dev/null @@ -1,8 +0,0 @@ -source 'https://supermarket.chef.io' - -solver :ruby, :required - -metadata - -# cookbook for testing database provider: -cookbook 'test-openstack-common-database', path: 'spec/cookbooks/test-openstack-common-database' diff --git a/cookbooks/openstack-common/spec/cli_spec.rb b/cookbooks/openstack-common/spec/cli_spec.rb deleted file mode 100644 index 21e5d1c3..00000000 --- a/cookbooks/openstack-common/spec/cli_spec.rb +++ /dev/null @@ -1,177 +0,0 @@ -require_relative 'spec_helper' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'cli' - -describe 'openstack-common::default' do - describe 'Openstack CLI' do - let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - let(:subject) { Object.new.extend(Openstack) } - - include_context 'library-stubs' - - describe 'openstack_command_env' do - before do - node.override['openstack']['endpoints']['public']['identity'] = { - host: '127.0.0.1', - scheme: 'http', - path: '/v3', - port: '5000', - } - end - it 'returns cli enviroment' do - allow(subject).to receive(:get_password).with( - 'user', 'name').and_return('pass') - - expect( - subject.openstack_command_env('name', 'project', 'default', 'default') - ).to eq( - 'OS_USERNAME' => 'name', - 'OS_PASSWORD' => 'pass', - 'OS_PROJECT_NAME' => 'project', - 'OS_USER_DOMAIN_NAME' => 'default', - 'OS_PROJECT_DOMAIN_NAME' => 'default', - 'OS_AUTH_URL' => 'http://127.0.0.1:5000/v3', - 'OS_IDENTITY_API_VERSION' => '3' - ) - end - end - - describe 'openstack_command' do - it 'runs openstack command' do - env = - { - 'OS_USERNAME' => 'name', - 'OS_PASSWORD' => 'pass', - 'OS_PROJECT_NAME' => 'project', - 'OS_USER_DOMAIN_NAME' => 'default', - 'OS_PROJECT_DOMAIN_NAME' => 'default', - 'OS_AUTH_URL' => 'http://127.0.0.1:5000/v3', - 'OS_IDENTITY_API_VERSION' => 3, - } - allow(subject).to receive(:shell_out).with( - %w(openstack user list), - env: env - ).and_return double('shell_out', exitstatus: 0, stdout: 'good', stderr: '') - - result = subject.openstack_command('openstack', 'user list', env) - expect(result).to eq('good') - end - - it 'runs openstack command with args' do - env = - { - 'OS_USERNAME' => 'name', - 'OS_PASSWORD' => 'pass', - 'OS_PROJECT_NAME' => 'project', - 'OS_USER_DOMAIN_NAME' => 'default', - 'OS_PROJECT_DOMAIN_NAME' => 'default', - 'OS_AUTH_URL' => 'http://127.0.0.1:5000/v3', - 'OS_IDENTITY_API_VERSION' => 3, - } - allow(subject).to receive(:shell_out).with( - %w(openstack --key1 value1 --key2 value2 --key3 user list), - env: env - ).and_return double('shell_out', exitstatus: 0, stdout: 'good', stderr: '') - - result = subject.openstack_command('openstack', 'user list', env, 'key1' => 'value1', 'key2' => 'value2', 'key3' => '') - expect(result).to eq('good') - end - - it 'runs openstack command with failure' do - env = - { - 'OS_USERNAME' => 'name', - 'OS_PASSWORD' => 'pass', - 'OS_PROJECT_NAME' => 'project', - 'OS_USER_DOMAIN_NAME' => 'default', - 'OS_PROJECT_DOMAIN_NAME' => 'default', - 'OS_AUTH_URL' => 'http://127.0.0.1:5000/v3', - 'OS_IDENTITY_API_VERSION' => 3, - } - allow(subject).to receive(:shell_out).with( - %w(openstack user list), - env: env - ).and_return double('shell_out', exitstatus: 123, stdout: 'fail', stderr: '') - end - end - - describe 'identity_uuid' do - it 'runs identity command to query uuid' do - env = - { - 'OS_USERNAME' => 'name', - 'OS_PASSWORD' => 'pass', - 'OS_PROJECT_NAME' => 'project', - 'OS_USER_DOMAIN_NAME' => 'default', - 'OS_PROJECT_DOMAIN_NAME' => 'default', - 'OS_AUTH_URL' => 'http://127.0.0.1:5000/v3', - 'OS_IDENTITY_API_VERSION' => 3, - } - allow(subject).to receive(:openstack_command).with( - 'openstack', 'user list', env, {}) - allow(subject).to receive(:prettytable_to_array).and_return( - [{ 'name' => 'user1', 'id' => '1234567890ABCDEFGH' }]) - - result = subject.identity_uuid('user', 'name', 'user1', env) - expect(result).to eq('1234567890ABCDEFGH') - end - end - - describe 'image_id' do - let(:env) do - { - 'OS_USERNAME' => 'name', - 'OS_PASSWORD' => 'pass', - 'OS_PROJECT_NAME' => 'project', - 'OS_USER_DOMAIN_NAME' => 'default', - 'OS_PROJECT_DOMAIN_NAME' => 'default', - 'OS_AUTH_URL' => 'http://127.0.0.1:5000/v3', - 'OS_IDENTITY_API_VERSION' => 3, - } - end - - it 'runs glance command to query valid id' do - allow(subject).to receive(:openstack_command).with( - 'openstack', 'image list', :env, {}) - allow(subject).to receive(:prettytable_to_array).and_return( - [{ 'ID' => '87f38e15-9737-46cc-a612-7c67ee29a24f', 'Name' => 'cirros' }]) - - result = subject.image_id('cirros', :env) - expect(result).to eq('87f38e15-9737-46cc-a612-7c67ee29a24f') - end - - it 'runs glance command to query invalid id' do - allow(subject).to receive(:openstack_command).with( - 'openstack', 'image list', :env, {}).and_raise( - "No image with a name or ID of 'test' exists. (1)") - - expect { subject.image_id('test', :env) }.to raise_error(RuntimeError) - end - end - - describe 'network_uuid' do - it 'runs network command to query uuid' do - env = - { - 'OS_USERNAME' => 'name', - 'OS_PASSWORD' => 'pass', - 'OS_PROJECT_NAME' => 'project', - 'OS_USER_DOMAIN_NAME' => 'default', - 'OS_PROJECT_DOMAIN_NAME' => 'default', - 'OS_AUTH_URL' => 'http://127.0.0.1:5000/v3', - 'OS_IDENTITY_API_VERSION' => 3, - } - allow(subject).to receive(:openstack_command).with( - 'openstack', 'network list', env, {}) - allow(subject).to receive(:prettytable_to_array).and_return( - [{ 'name' => 'net1', 'id' => '1234567890ABCDEFGH' }]) - - result = subject.network_uuid('network', 'name', 'net1', env) - expect(result).to eq('1234567890ABCDEFGH') - end - end - end -end diff --git a/cookbooks/openstack-common/spec/client-redhat_spec.rb b/cookbooks/openstack-common/spec/client-redhat_spec.rb deleted file mode 100644 index 61878ec2..00000000 --- a/cookbooks/openstack-common/spec/client-redhat_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-common::client' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - it 'converges successfully' do - expect { chef_run }.to_not raise_error - end - - case p - when REDHAT_7 - it do - expect(chef_run).to upgrade_package('python-openstackclient') - end - when REDHAT_8 - it do - expect(chef_run).to upgrade_package('python3-openstackclient') - end - end - end - end -end diff --git a/cookbooks/openstack-common/spec/client_spec.rb b/cookbooks/openstack-common/spec/client_spec.rb deleted file mode 100644 index 48a59023..00000000 --- a/cookbooks/openstack-common/spec/client_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-common::client' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - it 'converges successfully' do - expect { chef_run }.to_not raise_error - end - - it do - expect(chef_run).to upgrade_package('python3-openstackclient') - end - end -end diff --git a/cookbooks/openstack-common/spec/completions_spec.rb b/cookbooks/openstack-common/spec/completions_spec.rb deleted file mode 100644 index 4fd038ba..00000000 --- a/cookbooks/openstack-common/spec/completions_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-common::completions' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - it 'converges successfully' do - expect { chef_run }.to_not raise_error - end - it do - expect(chef_run).to install_package('bash-completion') - end - it do - expect(chef_run).to create_directory('/etc/bash_completion.d/').with(mode: '755') - end - it do - expect(chef_run).to run_execute('create OSC bash completions') - .with( - command: 'openstack complete > /etc/bash_completion.d/osc.bash_completion', - creates: '/etc/bash_completion.d/osc.bash_completion' - ) - end - end -end diff --git a/cookbooks/openstack-common/spec/config_helpers_spec.rb b/cookbooks/openstack-common/spec/config_helpers_spec.rb deleted file mode 100644 index 79044d64..00000000 --- a/cookbooks/openstack-common/spec/config_helpers_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require_relative 'spec_helper' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'config_helpers' - -describe 'openstack-common::default' do - describe 'module Openstack config_helpers' do - let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - let(:subject) { Object.new.extend(Openstack) } - include_context 'library-stubs' - before do - node.override['openstack']['anyservice']['conf'] = - { - 'Default' => { 'logfile' => 'file_to_log' }, - 'secret_section' => {}, - 'another_section' => { 'foo' => 'bar', 'baz' => 'yay' }, - 'deep_section' => { - 'foo' => { key: 'bar', value: 'baz' }, - 'baz' => 'yay', - }, - } - node.override['openstack']['anyservice']['conf_secrets'] = - { - 'Default' => { 'secret_log' => 'secret_file_to_log' }, - 'secret_section' => { 'password' => '1234' }, - 'another_section' => { 'secret_foo' => 'secret_bar' }, - 'another_secret_section' => { 'secret_baz' => 'secret_yay' }, - } - end - - describe 'merge_config_options' do - it ' node objects should be duped and be kind of Mash afterwards' do - expect( - subject.merge_config_options('anyservice') - ).to be_a(Mash) - end - it 'duped node objects should be merged correctly' do - expect( - subject.merge_config_options('anyservice') - ).to eq( - 'Default' => { 'logfile' => 'file_to_log', 'secret_log' => 'secret_file_to_log' }, - 'secret_section' => { 'password' => '1234' }, - 'another_section' => { 'foo' => 'bar', 'baz' => 'yay', 'secret_foo' => 'secret_bar' }, - 'another_secret_section' => { 'secret_baz' => 'secret_yay' }, - 'deep_section' => { - 'foo' => { 'key' => 'bar', 'value' => 'baz' }, - 'baz' => 'yay', - } - ) - end - end - end -end diff --git a/cookbooks/openstack-common/spec/cookbooks/test-openstack-common-database/metadata.rb b/cookbooks/openstack-common/spec/cookbooks/test-openstack-common-database/metadata.rb deleted file mode 100644 index 2199f372..00000000 --- a/cookbooks/openstack-common/spec/cookbooks/test-openstack-common-database/metadata.rb +++ /dev/null @@ -1,8 +0,0 @@ -name 'test-openstack-common-database' -maintainer 'openstack-chef' -maintainer_email 'opscode-chef-openstack@googlegroups.com' -license 'Apache-2.0' -description 'Test LWRP openstack_common_databse' -version '1.0.0' - -depends 'openstack-common' diff --git a/cookbooks/openstack-common/spec/cookbooks/test-openstack-common-database/recipes/default.rb b/cookbooks/openstack-common/spec/cookbooks/test-openstack-common-database/recipes/default.rb deleted file mode 100644 index 9e58d984..00000000 --- a/cookbooks/openstack-common/spec/cookbooks/test-openstack-common-database/recipes/default.rb +++ /dev/null @@ -1,4 +0,0 @@ -openstack_database('service') do - user 'db_user' - pass 'db_pass' -end diff --git a/cookbooks/openstack-common/spec/database_provider_spec.rb b/cookbooks/openstack-common/spec/database_provider_spec.rb deleted file mode 100644 index bb2e4bd0..00000000 --- a/cookbooks/openstack-common/spec/database_provider_spec.rb +++ /dev/null @@ -1,73 +0,0 @@ -require_relative 'spec_helper' - -describe 'test-openstack-common-database::default' do - let(:runner) do - ChefSpec::SoloRunner.new(CHEFSPEC_OPTS.dup.merge(step_into: %w(openstack_database))) - end - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['use_databags'] = false - node.override['openstack']['secret']['mysqlroot']['db'] = 'root_pass' - node.override['openstack']['db']['service'] = { service_type: 'mysql', port: 3306, db_name: 'service_db' } - runner.converge(described_recipe) - end - - it 'uses the lwrp openstack_common_database' do - expect(chef_run).to create_openstack_database('service').with(user: 'db_user', pass: 'db_pass') - end - - context 'specific root user db endpoint' do - cached(:chef_run) do - node.override['openstack']['endpoints']['db']['host_for_db_root_user'] = 'localhost123' - node.override['openstack']['use_databags'] = false - node.override['openstack']['secret']['mysqlroot']['db'] = 'root_pass' - node.override['openstack']['db']['service'] = { service_type: 'mysql', port: 3306, db_name: 'service_db' } - runner.converge(described_recipe) - end - it 'connects to the database via a specific endpoint for the root user' do - expect(chef_run).to create_mariadb_database('service_db') - .with( - database_name: 'service_db', - encoding: 'utf8', - password: 'root_pass' - ) - end - end - - it 'creates the database with the database resource' do - expect(chef_run).to create_mariadb_database('service_db') - .with( - database_name: 'service_db', - encoding: 'utf8', - password: 'root_pass' - ) - end - - it 'creates the database use with the database_user resource' do - expect(chef_run).to create_mariadb_user('db_user') - .with( - password: 'db_pass', - database_name: 'service_db', - host: '%', - privileges: [:all], - ctrl_password: 'root_pass' - ) - end - - it 'grants database privileges to the user with the database_user resource' do - expect(chef_run).to grant_mariadb_user('db_user') - .with( - password: 'db_pass', - database_name: 'service_db', - host: '%', - privileges: [:all], - ctrl_password: 'root_pass' - ) - end - - context 'galera' do - before do - node.override['openstack']['db']['service'] = { service_type: 'galera', port: 3306, db_name: 'service_db' } - end - end -end diff --git a/cookbooks/openstack-common/spec/default-redhat_spec.rb b/cookbooks/openstack-common/spec/default-redhat_spec.rb deleted file mode 100644 index 8d89c302..00000000 --- a/cookbooks/openstack-common/spec/default-redhat_spec.rb +++ /dev/null @@ -1,136 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-common::default' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['release'] = 'testrelease' - runner.converge(described_recipe) - end - - it 'converges successfully' do - expect { chef_run }.to_not raise_error - end - - case p - when REDHAT_7 - pkgs = %w(python python2-pip python2-setuptools python-devel python-virtualenv python-wheel) - - it do - expect(chef_run).to upgrade_package('centos-release-qemu-ev') - end - - it do - expect(chef_run).to include_recipe('yum-epel') - end - - it do - expect(chef_run).to_not include_recipe('yum-centos') - end - - it do - expect(chef_run).to create_yum_repository('epel').with( - exclude: 'python2-qpid-proton python2-pyngus qpid-proton-c' - ) - end - when REDHAT_8 - pkgs = %w(python3-pip python3-setuptools python3-virtualenv python3-wheel python36 python36-devel) - - it do - expect(chef_run).to_not upgrade_package('centos-release-qemu-ev') - end - - %w(yum-epel yum-centos).each do |r| - it do - expect(chef_run).to include_recipe(r) - end - end - - it do - expect(chef_run).to create_yum_repository('epel').with(exclude: nil) - end - - %w(powertools centos-rabbitmq).each do |repo| - it do - expect(chef_run).to create_yum_repository(repo).with(enabled: true) - end - end - end - - it do - expect(chef_run).to upgrade_package(pkgs) - end - - context 'enabling RDO with gpgcheck enabled' do - cached(:chef_run) do - node.override['openstack']['release'] = 'testrelease' - node.override['openstack']['yum']['rdo_enabled'] = true - node.override['openstack']['yum']['gpgcheck'] = true - runner.converge(described_recipe) - end - - it do - expect(chef_run).to add_yum_repository('RDO-testrelease').with(gpgcheck: true) - end - end - - context 'enabling RDO with gpgcheck disabled' do - cached(:chef_run) do - node.override['openstack']['release'] = 'testrelease' - node.override['openstack']['yum']['rdo_enabled'] = true - node.override['openstack']['yum']['gpgcheck'] = false - runner.converge(described_recipe) - end - - it do - expect(chef_run).to add_yum_repository('RDO-testrelease').with(gpgcheck: false) - end - end - - context 'disabling RDO deps repo with is_release true' do - cached(:chef_run) do - node.override['openstack']['release'] = 'testrelease' - node.override['openstack']['is_release'] = true - runner.converge(described_recipe) - end - - it 'does not add the RDO deps yum repository' do - expect(chef_run).to_not add_yum_repository('RDO-testrelease-deps') - end - end - - context 'disabling RDO' do - cached(:chef_run) do - node.override['openstack']['release'] = 'testrelease' - node.override['openstack']['yum']['rdo_enabled'] = false - runner.converge(described_recipe) - end - - it 'removes RDO yum repository' do - allow(FileTest).to receive(:exist?).and_call_original - allow(FileTest).to receive(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(true) - expect(chef_run).to remove_yum_repository('RDO-testrelease') - end - - it 'does not create RDO-Manager yum repositories' do - expect(chef_run).to_not create_remote_file('/etc/yum.repos.d/rdo-manager-release.repo') - end - end - - context 'disabling RDO and repo file does not exist' do - cached(:chef_run) do - node.override['openstack']['release'] = 'testrelease' - node.override['openstack']['yum']['rdo_enabled'] = false - runner.converge(described_recipe) - end - it 'does nothing when RDO yum repository does not exist' do - allow(FileTest).to receive(:exist?).and_call_original - allow(FileTest).to receive(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(false) - expect(chef_run).to nothing_yum_repository('RDO-testrelease') - end - end - end - end -end diff --git a/cookbooks/openstack-common/spec/default_spec.rb b/cookbooks/openstack-common/spec/default_spec.rb deleted file mode 100644 index 683ad855..00000000 --- a/cookbooks/openstack-common/spec/default_spec.rb +++ /dev/null @@ -1,158 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-common::default' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:mq_services) { %w(bare_metal block_storage compute database image telemetry network orchestration) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - it 'converges successfully' do - expect { chef_run }.to_not raise_error - end - - context 'update_apt_cache true' do - cached(:chef_run) do - node.override['openstack']['apt']['update_apt_cache'] = true - runner.converge(described_recipe) - end - it 'updates apt cache before installing packages' do - expect(chef_run).to update_apt_update 'default' - end - end - - it do - expect(chef_run).to create_file('/etc/apt/apt.conf.d/confdef') - .with( - owner: 'root', - group: 'root', - mode: '644', - content: "Dpkg::Options {\n \"--force-confdef\";\n \"--force-confold\";\n }" - ) - end - - it 'upgrades ubuntu-cloud-keyring package' do - expect(chef_run).to upgrade_package 'ubuntu-cloud-keyring' - end - - context 'live_updates_enabled true' do - cached(:chef_run) do - node.override['openstack']['apt']['live_updates_enabled'] = true - runner.converge(described_recipe) - end - it 'configures openstack repository' do - # Using cookbook(apt) LWRP custom matcher - # https://github.com/sethvargo/chefspec#packaging-custom-matchers - expect(chef_run).to add_apt_repository('openstack-ppa').with( - uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - distribution: 'bionic-updates/train', - components: ['main'], - cache_rebuild: true - ) - end - end - - context 'live_updates_enabled false' do - cached(:chef_run) do - node.override['openstack']['apt']['live_updates_enabled'] = false - runner.converge(described_recipe) - end - it 'disables openstack live updates' do - expect(chef_run).to_not add_apt_repository('openstack-ppa').with( - uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - distribution: 'bionic-updates/train', - components: ['main'] - ) - end - end - - it 'configures openstack proposed repository' do - expect(chef_run).to add_apt_repository('openstack-ppa-proposed').with( - uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - distribution: 'bionic-proposed/train', - components: ['main'], - cache_rebuild: true - ) - end - - context 'is_release true' do - cached(:chef_run) do - node.override['openstack']['is_release'] = true - runner.converge(described_recipe) - end - it 'disables openstack proposed repository' do - expect(chef_run).to_not add_apt_repository('openstack-ppa-proposed').with( - uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - distribution: 'bionic-proposed/train', - components: ['main'] - ) - end - end - - pkgs = %w(python3 python3-dev python3-pip python3-setuptools python3-virtualenv python3-wheel virtualenv) - - it 'installs python packages' do - expect(chef_run).to upgrade_package(pkgs) - end - - it 'does not install the gem chef-vault by default' do - expect(chef_run).to_not install_chef_gem('chef-vault') - end - - context 'databag_type vault' do - cached(:chef_run) do - node.override['openstack']['databag_type'] = 'vault' - runner.converge(described_recipe) - end - it 'installs the gem chef-vault if databag_type is vault' do - expect(chef_run).to install_chef_gem('chef-vault').with(version: '~> 3.2') - end - end - - context 'rabbit mq' do - rabbit_opts = { - 'userid' => 'openstack', - 'vhost' => '/', - 'port' => '5672', - 'host' => '127.0.0.1', - 'ha' => true, - 'heartbeat_timeout_threshold' => 123, - 'heartbeat_rate' => 123, - 'kombu_ssl_version' => 'TLSv1.2', - 'kombu_ssl_keyfile' => 'key_file', - 'kombu_ssl_certfile' => 'cert_file', - 'kombu_ssl_ca_certs' => 'ca_certs_file', - 'kombu_reconnect_delay' => 123.456, - 'kombu_reconnect_timeout' => 123, - } - cached(:chef_run) do - rabbit_opts.each do |key, value| - node.override['openstack']['mq']['rabbitmq'][key] = value - end - runner.converge(described_recipe) - end - rabbit_opts.each do |key, value| - it "configures rabbit mq #{key}" do - node.override['openstack']['mq']['rabbitmq'][key] = value - mq_services.each do |service| - expect(chef_run.node['openstack']['mq'][service]['rabbit'][key]).to eq(value) - end - end - end - - it 'set rabbit_max_retries to 0 for all services' do - mq_services.each do |svc| - expect(chef_run.node['openstack']['mq'][svc]['rabbit']['rabbit_max_retries']).to eq(0) - end - end - - it 'set rabbit_retry_interval to 1 for all services' do - mq_services.each do |svc| - expect(chef_run.node['openstack']['mq'][svc]['rabbit']['rabbit_retry_interval']).to eq(1) - end - end - end - end -end diff --git a/cookbooks/openstack-common/spec/endpoints_spec.rb b/cookbooks/openstack-common/spec/endpoints_spec.rb deleted file mode 100644 index ac51d1ab..00000000 --- a/cookbooks/openstack-common/spec/endpoints_spec.rb +++ /dev/null @@ -1,241 +0,0 @@ -require_relative 'spec_helper' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'uri' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'endpoints' - -describe 'openstack-common::default' do - describe 'Openstack endpoints' do - let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - let(:subject) { Object.new.extend(Openstack) } - - %w(public internal).each do |ep_type| - describe "#{ep_type}_endpoint" do - it 'fails with a NoMethodError when no openstack.endpoints in node attrs' do - allow(subject).to receive(:node).and_return({}) - expect do - subject.send("#{ep_type}_endpoint", 'someservice') - end.to raise_error(NoMethodError) - end - - it 'fails with a NoMethodError when no endpoint was found' do - allow(subject).to receive(:node).and_return(node) - expect do - subject.send("#{ep_type}_endpoint", 'someservice') - end.to raise_error(NoMethodError) - end - - it 'handles a URI needing escaped' do - uri_hash = { - 'openstack' => { - 'endpoints' => { - ep_type => { - 'compute-api' => { - 'uri' => 'http://localhost:8080/v2/%(tenant_id)s', - }, - }, - }, - }, - } - allow(subject).to receive(:node).and_return(uri_hash) - expect( - subject.send("#{ep_type}_endpoint", 'compute-api').path - ).to eq('/v2/%25(tenant_id)s') - end - - it 'returns endpoint URI object when uri key in endpoint hash' do - uri_hash = { - 'openstack' => { - 'endpoints' => { - ep_type => { - 'compute-api' => { - 'uri' => 'http://localhost:1234/path', - }, - }, - }, - }, - } - allow(subject).to receive(:node).and_return(uri_hash) - expect( - subject.send("#{ep_type}_endpoint", 'compute-api').port - ).to eq(1234) - end - - it 'returns endpoint URI string when uri key in endpoint hash and host also in hash' do - uri_hash = { - 'openstack' => { - 'endpoints' => { - ep_type => { - 'compute-api' => { - 'uri' => 'http://localhost', - 'host' => 'ignored', - }, - }, - }, - }, - } - allow(subject).to receive(:node).and_return(uri_hash) - expect(subject.send("#{ep_type}_endpoint", 'compute-api').to_s).to eq('http://localhost') - end - - it 'returns endpoint URI object when uri key not in endpoint hash but host is in hash' do - expect(subject).to receive(:uri_from_hash).with('host' => 'localhost', 'port' => '1234') - uri_hash = { - 'openstack' => { - 'endpoints' => { - ep_type => { - 'compute-api' => { - 'host' => 'localhost', - 'port' => '1234', - }, - }, - }, - }, - } - allow(subject).to receive(:node).and_return(uri_hash) - subject.send("#{ep_type}_endpoint", 'compute-api') - end - end - end - - describe 'transport_url' do - it do - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:get_password) - .with('user', 'openstack') - .and_return('mypass') - expected = 'rabbit://openstack:mypass@127.0.0.1:5672/' - expect(subject.rabbit_transport_url('compute')).to eq(expected) - end - - context 'non-default mq attributes' do - cached(:chef_run) do - node.override['openstack']['mq']['service_type'] = 'rabbit' - node.override['openstack']['mq']['cluster'] = true - node.override['openstack']['mq']['compute']['rabbit']['userid'] = 'rabbit2' - node.override['openstack']['endpoints']['mq']['port'] = 1234 - node.override['openstack']['mq']['servers'] = %w(10.0.0.1 10.0.0.2 10.0.0.3) - node.override['openstack']['mq']['vhost'] = '/anyhost' - runner.converge(described_recipe) - end - it do - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:get_password) - .with('user', 'rabbit2') - .and_return('mypass2') - expected = 'rabbit://rabbit2:mypass2@10.0.0.1:1234,rabbit2:mypass2@10.0.0.2:1234,rabbit2:mypass2@10.0.0.3:1234/anyhost' - expect(subject.rabbit_transport_url('compute')).to eq(expected) - end - end - end - - describe '#db' do - it 'returns nil when no openstack.db not in node attrs' do - allow(subject).to receive(:node).and_return({}) - expect(subject.db('nonexisting')).to be_nil - end - - it 'returns nil when no such service was found' do - allow(subject).to receive(:node).and_return(chef_run.node) - expect(subject.db('nonexisting')).to be_nil - end - - it 'returns db info hash when service found' do - allow(subject).to receive(:node).and_return(chef_run.node) - expect(subject.db('compute')['host']).to eq('127.0.0.1') - expect(subject.db('compute').key?('uri')).to be_falsey - end - end - - describe '#db_uri' do - it 'returns nil when no openstack.db not in node attrs' do - allow(subject).to receive(:node).and_return({}) - expect(subject.db_uri('nonexisting', 'user', 'pass')).to be_nil - end - - it 'returns nil when no such service was found' do - allow(subject).to receive(:node).and_return(chef_run.node) - expect( - subject.db_uri('nonexisting', 'user', 'pass') - ).to be_nil - end - - it 'returns compute db info hash when service found for default mysql' do - allow(subject).to receive(:node).and_return(chef_run.node) - expected = 'mysql+pymysql://user:pass@127.0.0.1:3306/nova?charset=utf8' - expect( - subject.db_uri('compute', 'user', 'pass') - ).to eq(expected) - end - - context 'sqlite' do - cached(:chef_run) do - node.override['openstack']['db']['service_type'] = 'sqlite' - node.override['openstack']['db']['options'] = { 'sqlite' => '?options' } - node.override['openstack']['db']['network']['path'] = 'path' - runner.converge(described_recipe) - end - it 'returns network db info hash when service found for sqlite with options' do - allow(subject).to receive(:node).and_return(chef_run.node) - expected = 'sqlite:///path?options' - expect( - subject.db_uri('network', 'user', 'pass') - ).to eq(expected) - end - end - - it 'returns compute db info hash when service found for mariadb' do - node.override['openstack']['db']['service_type'] = 'mariadb' - allow(subject).to receive(:node).and_return(chef_run.node) - expected = 'mysql+pymysql://user:pass@127.0.0.1:3306/nova?charset=utf8' - expect( - subject.db_uri('compute', 'user', 'pass') - ).to eq(expected) - end - - %w(galera percona-cluster).each do |db| - it "returns compute db info hash when service found for #{db}" do - node.override['openstack']['db']['service_type'] = db - allow(subject).to receive(:node).and_return(chef_run.node) - expected = 'mysql+pymysql://user:pass@127.0.0.1:3306/nova?charset=utf8' - expect( - subject.db_uri('compute', 'user', 'pass') - ).to eq(expected) - end - end - - it 'returns compute slave db info hash when service found for default mysql' do - node.override['openstack']['endpoints']['db']['enabled_slave'] = true - allow(subject).to receive(:node).and_return(chef_run.node) - expected = 'mysql+pymysql://user:pass@127.0.0.1:3316/nova?charset=utf8' - expect( - subject.db_uri('compute', 'user', 'pass', true) - ).to eq(expected) - end - - it 'returns image slave db info hash when service found for mariadb' do - node.override['openstack']['db']['service_type'] = 'mariadb' - node.override['openstack']['endpoints']['db']['enabled_slave'] = true - allow(subject).to receive(:node).and_return(chef_run.node) - expected = 'mysql+pymysql://user:pass@127.0.0.1:3316/glance?charset=utf8' - expect( - subject.db_uri('image', 'user', 'pass', true) - ).to eq(expected) - end - - %w(galera percona-cluster).each do |db| - it "returns network slave db info hash when service found for #{db}" do - node.override['openstack']['db']['service_type'] = db - node.override['openstack']['endpoints']['db']['enabled_slave'] = true - allow(subject).to receive(:node).and_return(chef_run.node) - expected = 'mysql+pymysql://user:pass@127.0.0.1:3316/neutron?charset=utf8' - expect( - subject.db_uri('network', 'user', 'pass', true) - ).to eq(expected) - end - end - end - end -end diff --git a/cookbooks/openstack-common/spec/logging_spec.rb b/cookbooks/openstack-common/spec/logging_spec.rb deleted file mode 100644 index 72700832..00000000 --- a/cookbooks/openstack-common/spec/logging_spec.rb +++ /dev/null @@ -1,206 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-common::logging' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - describe '/etc/openstack' do - let(:dir) { chef_run.directory('/etc/openstack') } - - it 'should create /etc/openstack' do - expect(chef_run).to create_directory('/etc/openstack').with( - owner: 'root', - group: 'root', - mode: '755' - ) - end - end - - describe 'logging.conf' do - let(:file) { chef_run.template('/etc/openstack/logging.conf') } - - it 'should create /etc/openstack/logging.conf' do - expect(chef_run).to create_template(file.name).with( - owner: 'root', - group: 'root', - mode: '644' - ) - end - - context 'loggers' do - it 'adds default loggers' do - { - 'loggers' => - [ - 'keys=root,ceilometer,cinder,glance,horizon,keystone,nova,'\ - 'neutron,trove,amqplib,sqlalchemy,boto,suds,eventletwsgi,'\ - 'nova_api_openstack_wsgi,nova_osapi_compute_wsgi_server', - ], - 'logger_root' => - [ - 'level=NOTSET', - 'handlers=devel', - ], - 'logger_ceilometer' => - [ - 'level=DEBUG', - 'handlers=prod,debug', - 'qualname=ceilometer', - ], - 'logger_cinder' => - [ - 'level=DEBUG', - 'handlers=prod,debug', - 'qualname=cinder', - ], - 'logger_glance' => - [ - 'level=DEBUG', - 'handlers=prod,debug', - 'qualname=glance', - ], - 'logger_horizon' => - [ - 'level=DEBUG', - 'handlers=prod,debug', - 'qualname=horizon', - ], - 'logger_keystone' => - [ - 'level=DEBUG', - 'handlers=prod,debug', - 'qualname=keystone', - ], - 'logger_nova' => - [ - 'level=DEBUG', - 'handlers=prod,debug', - 'qualname=nova', - ], - 'logger_neutron' => - [ - 'level=DEBUG', - 'handlers=prod,debug', - 'qualname=neutron', - ], - 'logger_trove' => - [ - 'level=DEBUG', - 'handlers=prod,debug', - 'qualname=trove', - ], - 'logger_amqplib' => - [ - 'level=WARNING', - 'handlers=stderr', - 'qualname=amqplib', - ], - 'logger_sqlalchemy' => - [ - 'level=WARNING', - 'handlers=stderr', - 'qualname=sqlalchemy', - ], - 'logger_boto' => - [ - 'level=WARNING', - 'handlers=stderr', - 'qualname=boto', - ], - 'logger_suds' => - [ - 'level=INFO', - 'handlers=stderr', - 'qualname=suds', - ], - 'logger_eventletwsgi' => - [ - 'level=WARNING', - 'handlers=stderr', - 'qualname=eventlet.wsgi.server', - ], - 'logger_nova_api_openstack_wsgi' => - [ - 'level=WARNING', - 'handlers=prod,debug', - 'qualname=nova.api.openstack.wsgi', - ], - 'logger_nova_osapi_compute_wsgi_server' => - [ - 'level=WARNING', - 'handlers=prod,debug', - 'qualname=nova.osapi_compute.wsgi.server', - ], - }.each do |section, content| - content.each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content(section, line) - end - end - end - end - - context 'formatters' do - it 'adds default formatters' do - { - 'formatters' => - 'keys=normal,normal_with_name,debug,syslog_with_name,syslog_debug', - 'formatter_normal' => - 'format=%(asctime)s %(levelname)s %(message)s', - 'formatter_normal_with_name' => - 'format=[%(name)s]: %(asctime)s %(levelname)s %(message)s', - 'formatter_debug' => - 'format=[%(name)s]: %(asctime)s %(levelname)s %(module)s.%(funcName)s %(message)s', - 'formatter_syslog_with_name' => - 'format=%(name)s: %(levelname)s %(message)s', - 'formatter_syslog_debug' => - 'format=%(name)s: %(levelname)s %(module)s.%(funcName)s %(message)s', - }.each do |section, content| - expect(chef_run).to render_config_file(file.name).with_section_content(section, content) - end - end - end - - context 'handlers' do - it 'adds default handlers' do - { - 'handlers' => - ['keys=stderr,devel,prod,debug'], - 'handler_stderr' => - [ - 'args=(sys.stderr,)', - 'class=StreamHandler', - 'formatter=debug', - ], - 'handler_devel' => - [ - 'args=(sys.stdout,)', - 'class=StreamHandler', - 'formatter=debug', - 'level=NOTSET', - ], - 'handler_prod' => - [ - "args=(('/dev/log'), handlers.SysLogHandler.LOG_LOCAL0)", - 'class=handlers.SysLogHandler', - 'formatter=syslog_with_name', - 'level=INFO', - ], - 'handler_debug' => - [ - "args=(('/dev/log'), handlers.SysLogHandler.LOG_LOCAL1)", - 'class=handlers.SysLogHandler', - 'formatter=syslog_debug', - 'level=DEBUG', - ], - }.each do |section, content| - content.each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content(section, line) - end - end - end - end - end - end -end diff --git a/cookbooks/openstack-common/spec/network_spec.rb b/cookbooks/openstack-common/spec/network_spec.rb deleted file mode 100644 index f2f2e3a1..00000000 --- a/cookbooks/openstack-common/spec/network_spec.rb +++ /dev/null @@ -1,218 +0,0 @@ -require_relative 'spec_helper' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'network' - -describe 'openstack-common::default' do - describe 'Openstack address_for and bind_address' do - interfaces = { - 'lo' => { - 'addresses' => { - '127.0.0.1' => { - 'family' => 'inet', - 'prefixlen' => '8', - 'netmask' => '255.0.0.0', - 'scope' => 'Node', - }, - '::1' => { - 'family' => 'inet6', - 'prefixlen' => '128', - 'scope' => 'Node', - }, - '2001:db8::1' => { - 'family' => 'inet6', - 'prefixlen' => '64', - 'scope' => 'Node', - }, - }, - }, - 'eth0' => { - 'addresses' => { - '10.0.0.2' => { - 'family' => 'inet', - 'prefixlen' => '32', - 'netmask' => '255.255.255.255', - 'scope' => 'Node', - }, - '10.0.0.3' => { - 'family' => 'inet', - 'prefixlen' => '24', - 'netmask' => '255.255.255.0', - 'scope' => 'Node', - }, - }, - }, - } - cached(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) } - cached(:node) { runner.node } - cached(:chef_run) do - node.automatic['network']['interfaces'] = interfaces - runner.converge(described_recipe) - end - - let(:subject) { Object.new.extend(Openstack) } - - include_context 'library-stubs' - - describe '#address_for ipv4' do - it 'returns ipv4 address' do - expect( - subject.address_for('lo') - ).to eq('127.0.0.1') - end - - it 'returns first ipv4 address but no virtual ips with prefixlen 32' do - expect( - subject.address_for('eth0', 'inet', node, true) - ).to eq('10.0.0.3') - end - - it 'returns first ipv4 address even if virtual and with prefixlen 32' do - expect( - subject.address_for('eth0', 'inet', node, false) - ).to eq('10.0.0.2') - end - - it 'returns 0.0.0.0 for interface "all"' do - expect( - subject.address_for('all') - ).to eq('0.0.0.0') - end - end - - context '#address_for ipv6' do - cached(:chef_run) do - node.automatic['network']['interfaces'] = interfaces - node.override['openstack']['endpoints']['family'] = 'inet6' - runner.converge(described_recipe) - end - - it 'returns ipv6 address' do - expect( - subject.address_for('lo') - ).to eq('2001:db8::1') - end - - it 'returns ipv6 address' do - expect( - subject.address_for('lo', 'inet6') - ).to eq('2001:db8::1') - end - - it 'returns first ipv6 address and also virtual ips with prefixlen 128' do - expect( - subject.address_for('lo', 'inet6', node, false) - ).to eq('::1') - end - - it 'returns :: for interface "all"' do - expect( - subject.address_for('all', 'inet6') - ).to eq('::') - end - end - describe 'bind_address' do - describe 'mq' do - it 'returns the host' do - expect( - subject.bind_address(node['openstack']['bind_service']['mq']) - ).to eq('127.0.0.1') - end - context 'mq interface set' do - cached(:chef_run) do - node.automatic['network']['interfaces'] = interfaces - node.override['openstack']['endpoints']['family'] = 'inet' - node.override['openstack']['bind_service']['mq']['interface'] = 'eth0' - runner.converge(described_recipe) - end - it 'returns the interface address' do - expect( - subject.bind_address(node['openstack']['bind_service']['mq']) - ).to eq('10.0.0.3') - end - end - end - describe 'db' do - it 'returns the host' do - expect( - subject.bind_address(node['openstack']['bind_service']['db']) - ).to eq('127.0.0.1') - end - context 'interface set' do - cached(:chef_run) do - node.automatic['network']['interfaces'] = interfaces - node.override['openstack']['endpoints']['family'] = 'inet' - node.override['openstack']['bind_service']['db']['interface'] = 'eth0' - runner.converge(described_recipe) - end - it 'returns the interface address' do - expect( - subject.bind_address(node['openstack']['bind_service']['db']) - ).to eq('10.0.0.3') - end - end - end - end - describe '#address_for failures' do - it 'fails when addresses for interface is nil' do - node.automatic['network'] = { - 'interfaces' => { - 'lo' => { - 'addresses' => nil, - }, - }, - } - expect { subject.address_for('lo') } - .to raise_error(RuntimeError, 'Interface lo has no addresses assigned') - end - - it 'fails when no addresses are avaiable for interface' do - node.automatic['network'] = { - 'interfaces' => { - 'lo' => { - 'addresses' => {}, - }, - }, - } - expect { subject.address_for('lo') } - .to raise_error(RuntimeError, 'Interface lo has no addresses assigned') - end - - it 'fails when no address is available for interface family' do - node.automatic['network'] = { - 'interfaces' => { - 'lo' => { - 'addresses' => { - '127.0.0.1' => { - 'family' => 'inet', - 'prefixlen' => '8', - 'netmask' => '255.0.0.0', - 'scope' => 'Node', - }, - }, - }, - }, - } - expect { subject.address_for('lo', 'inet6') } - .to raise_error(RuntimeError, 'No address for family inet6 found') - end - - it 'fails when no address is available after dropping virtual ips' do - node.automatic['network'] = { - 'interfaces' => { - 'lo' => { - 'addresses' => { - '127.0.0.1' => { - 'family' => 'inet', - 'prefixlen' => '32', - 'netmask' => '255.255.255.255', - 'scope' => 'Node', - }, - }, - }, - }, - } - expect { subject.address_for('lo', 'inet') } - .to raise_error(RuntimeError, 'No address for family inet found') - end - end - end -end diff --git a/cookbooks/openstack-common/spec/parse_spec.rb b/cookbooks/openstack-common/spec/parse_spec.rb deleted file mode 100644 index 4f050626..00000000 --- a/cookbooks/openstack-common/spec/parse_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -require_relative 'spec_helper' -require 'uri' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'parse' - -describe 'Openstack parse' do - let(:subject) { Object.new.extend(Openstack) } - - describe '#prettytable_to_array' do - it 'returns [] when no table provided' do - expect( - subject.prettytable_to_array(nil) - ).to eq([]) - end - it 'returns [] when table provided is empty' do - expect( - subject.prettytable_to_array('') - ).to eq([]) - end - it 'returns proper array of hashes when proper table provided' do - table = - '+---------+----------------------------------+----------------------------------+ - | tenant | access | secret | - +---------+----------------------------------+----------------------------------+ - | service | 91af731b3be244beb8f30fc59b7bc96d | ce811442cfb549c39390a203778a4bf5 | - +---------+----------------------------------+----------------------------------+' - expect( - subject.prettytable_to_array(table) - ).to eq( - [{ 'tenant' => 'service', - 'access' => '91af731b3be244beb8f30fc59b7bc96d', - 'secret' => 'ce811442cfb549c39390a203778a4bf5' }] - ) - end - it 'returns proper array of hashes when proper table provided including whitespace' do - table = - '+---------+----------------------------------+----------------------------------+ - | tenant | access | secret | - +---------+----------------------------------+----------------------------------+ - | service | 91af731b3be244beb8f30fc59b7bc96d | ce811442cfb549c39390a203778a4bf5 | - +---------+----------------------------------+----------------------------------+ - - -' - expect( - subject.prettytable_to_array(table) - ).to eq( - [{ 'tenant' => 'service', - 'access' => '91af731b3be244beb8f30fc59b7bc96d', - 'secret' => 'ce811442cfb549c39390a203778a4bf5' }] - ) - end - it 'returns a flatten hash when provided a Property/Value table' do - table = - '+-----------+----------------------------------+ - | Property | Value | - +-----------+----------------------------------+ - | access | 91af731b3be244beb8f30fc59b7bc96d | - | secret | ce811442cfb549c39390a203778a4bf5 | - | tenant_id | 429271dd1cf54b7ca921a0017524d8ea | - | user_id | 1c4fc229560f40689c490c5d0838fd84 | - +-----------+----------------------------------+' - expect( - subject.prettytable_to_array(table) - ).to eq( - [{ 'tenant_id' => '429271dd1cf54b7ca921a0017524d8ea', - 'access' => '91af731b3be244beb8f30fc59b7bc96d', - 'secret' => 'ce811442cfb549c39390a203778a4bf5', - 'user_id' => '1c4fc229560f40689c490c5d0838fd84' }] - ) - end - it 'returns a flatten hash when provided a Property/Value table including whitespace' do - table = - '+-----------+----------------------------------+ - | Property | Value | - +-----------+----------------------------------+ - | access | 91af731b3be244beb8f30fc59b7bc96d | - | secret | ce811442cfb549c39390a203778a4bf5 | - | tenant_id | 429271dd1cf54b7ca921a0017524d8ea | - | user_id | 1c4fc229560f40689c490c5d0838fd84 | - +-----------+----------------------------------+' - expect( - subject.prettytable_to_array(table) - ).to eq( - [{ 'tenant_id' => '429271dd1cf54b7ca921a0017524d8ea', - 'access' => '91af731b3be244beb8f30fc59b7bc96d', - 'secret' => 'ce811442cfb549c39390a203778a4bf5', - 'user_id' => '1c4fc229560f40689c490c5d0838fd84' }] - ) - end - end -end diff --git a/cookbooks/openstack-common/spec/password_spec.rb b/cookbooks/openstack-common/spec/password_spec.rb deleted file mode 100644 index ca6aadb8..00000000 --- a/cookbooks/openstack-common/spec/password_spec.rb +++ /dev/null @@ -1,121 +0,0 @@ -require_relative 'spec_helper' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'passwords' -require 'chef-vault' - -describe 'openstack-common::default' do - describe 'Passwords' do - let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - let(:subject) { Object.new.extend(Openstack) } - - include_context 'library-stubs' - - context 'stored in encrypted data bags by default' do - describe '#secret' do - it 'returns databag' do - value = { 'nova' => 'this' } - allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with( - '/etc/chef/openstack_data_bag_secret').and_return('secret') - allow(Chef::EncryptedDataBagItem).to receive(:load).with( - 'passwords', 'nova', 'secret').and_return(value) - expect(subject.secret('passwords', 'nova')).to eq('this') - end - end - - context 'using chef-vault' do - cached(:chef_run) do - node.override['openstack']['databag_type'] = 'vault' - runner.converge(described_recipe) - end - it 'returns the data from a chef vault item' do - allow(ChefVault::Item).to receive(:load) - .with('vault_passwords', 'nova') - .and_return('nova' => 'novapassword') - expect(subject.secret('passwords', 'nova')).to eq('novapassword') - end - end - - describe '#get_password' do - %w(service db user).each do |type| - it "returns databag value for #{type}" do - value = { 'nova' => 'this' } - allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with( - '/etc/chef/openstack_data_bag_secret').and_return('secret') - allow(Chef::EncryptedDataBagItem).to receive(:load).with( - "#{type}_passwords", 'nova', 'secret').and_return(value) - expect(subject.get_password(type, 'nova')).to eq('this') - end - end - - it 'returns nil for an invalid type' do - expect(subject.get_password('invalid_type', 'nova')).to be_nil - end - - it 'returns tokens from the secrets_data_bag' do - bag_content = { 'nova' => 'mysecret' } - allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with( - '/etc/chef/openstack_data_bag_secret' - ).and_return('secret') - allow(Chef::EncryptedDataBagItem).to receive(:load).with( - 'secrets', 'nova', 'secret' - ).and_return(bag_content) - expect(subject.get_password('token', 'nova')).to eq('mysecret') - end - end - end - - context 'stored in standard data bags' do - cached(:chef_run) do - node.override['openstack']['databag_type'] = 'standard' - runner.converge(described_recipe) - end - describe '#secret' do - it 'returns databag' do - value = { 'nova' => 'this' } - allow(Chef::DataBagItem).to receive(:load) - .with('passwords', 'nova').and_return(value) - expect(subject.secret('passwords', 'nova')).to eq('this') - end - end - - describe '#get_password' do - %w(service db user).each do |type| - it "returns databag value for #{type}" do - value = { 'nova' => 'this' } - allow(Chef::DataBagItem).to receive(:load).with( - "#{type}_passwords", 'nova').and_return(value) - expect(subject.get_password(type, 'nova')).to eq('this') - end - end - - it 'returns nil for an invalid type' do - expect(subject.get_password('invalid_type', 'nova')).to be_nil - end - - it 'returns tokens from the secrets_data_bag' do - bag_content = { 'nova' => 'mysecret' } - allow(Chef::DataBagItem).to receive(:load).with( - 'secrets', 'nova' - ).and_return(bag_content) - expect(subject.get_password('token', 'nova')).to eq('mysecret') - end - end - end - - context 'stored in attributes as an alternative' do - cached(:chef_run) do - node.override['openstack']['use_databags'] = false - runner.converge(described_recipe) - end - - describe '#get_password' do - %w(service db user token).each do |type| - it "returns the set attribute for #{type}" do - expect(subject.get_password(type, 'compute')).to eq("compute-#{type}") - end - end - end - end - end -end diff --git a/cookbooks/openstack-common/spec/search_spec.rb b/cookbooks/openstack-common/spec/search_spec.rb deleted file mode 100644 index 6eabdc22..00000000 --- a/cookbooks/openstack-common/spec/search_spec.rb +++ /dev/null @@ -1,140 +0,0 @@ -require_relative 'spec_helper' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'search' - -describe 'openstack-common::default' do - describe 'Openstack Search' do - let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['mq']['server_role'] = 'openstack-ops-mq' - node.override['openstack']['endpoints']['mq']['port'] = 5672 - # speed up tests - node.override['openstack']['common']['search_count_max'] = 2 - runner.converge(described_recipe) - end - cached(:subject) { Object.new.extend(Openstack) } - - describe '#search_for' do - it 'returns results' do - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:search) - .with(:node, '(chef_environment:_default AND roles:role) OR (chef_environment:_default AND recipes:role)') - .and_return([chef_run.node]) - resp = subject.search_for('role') - expect(resp[0]['fqdn']).to eq('fauxhai.local') - end - - it 'returns empty results' do - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:search) - .with(:node, '(chef_environment:_default AND roles:empty-role) OR (chef_environment:_default AND recipes:empty-role)') - .and_return([]) - expect( - subject.search_for('empty-role') - ).to eq([]) - end - - it 'always returns empty results' do - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:search) - .with(:node, '(chef_environment:_default AND roles:empty-role) OR (chef_environment:_default AND recipes:empty-role)') - .and_return(nil) - expect( - subject.search_for('empty-role') - ).to eq([]) - end - end - - describe '#memcached_servers' do - it 'returns memcached list' do - nodes = [ - { 'memcached' => { 'listen' => '1.1.1.1', 'port' => '11211' } }, - { 'memcached' => { 'listen' => '2.2.2.2', 'port' => '11211' } }, - ] - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:search_for) - .with('role') - .and_return(nodes) - expect( - subject.memcached_servers('role') - ).to eq(['1.1.1.1:11211', '2.2.2.2:11211']) - end - - it 'returns sorted memcached list' do - nodes = [ - { 'memcached' => { 'listen' => '3.3.3.3', 'port' => '11211' } }, - { 'memcached' => { 'listen' => '1.1.1.1', 'port' => '11211' } }, - { 'memcached' => { 'listen' => '2.2.2.2', 'port' => '11211' } }, - ] - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:search_for) - .with('role') - .and_return(nodes) - expect( - subject.memcached_servers('role') - ).to eq(['1.1.1.1:11211', '2.2.2.2:11211', '3.3.3.3:11211']) - end - - it 'returns memcached servers as defined by attributes' do - nodes = { - 'openstack' => { - 'memcached_servers' => ['1.1.1.1:11211', '2.2.2.2:11211'], - }, - } - allow(subject).to receive(:node).and_return(chef_run.node.merge(nodes)) - expect( - subject.memcached_servers('role') - ).to eq(['1.1.1.1:11211', '2.2.2.2:11211']) - end - - it 'returns empty memcached servers as defined by attributes' do - nodes = { - 'openstack' => { - 'memcached_servers' => [], - }, - } - allow(subject).to receive(:node).and_return(chef_run.node.merge(nodes)) - expect( - subject.memcached_servers('empty-role') - ).to eq([]) - end - end - - describe '#rabbit_servers' do - it 'returns rabbit servers' do - nodes = [ - { 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }, - { 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }, - ] - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:search_for) - .and_return(nodes) - expect( - subject.rabbit_servers - ).to eq('1.1.1.1:5672,2.2.2.2:5672') - end - - it 'returns sorted rabbit servers' do - nodes = [ - { 'openstack' => { 'mq' => { 'listen' => '3.3.3.3' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }, - { 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }, - { 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }, - ] - allow(subject).to receive(:node).and_return(chef_run.node) - allow(subject).to receive(:search_for) - .and_return(nodes) - expect( - subject.rabbit_servers - ).to eq('1.1.1.1:5672,2.2.2.2:5672,3.3.3.3:5672') - end - - it 'returns rabbit servers when not searching' do - chef_run.node.override['openstack']['mq']['servers'] = ['1.1.1.1', '2.2.2.2'] - allow(subject).to receive(:node).and_return(chef_run.node) - expect( - subject.rabbit_servers - ).to eq('1.1.1.1:5672,2.2.2.2:5672') - end - end - end -end diff --git a/cookbooks/openstack-common/spec/spec_helper.rb b/cookbooks/openstack-common/spec/spec_helper.rb deleted file mode 100644 index a8d705e2..00000000 --- a/cookbooks/openstack-common/spec/spec_helper.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'chefspec' -require 'chefspec/berkshelf' - -RSpec.configure do |config| - config.color = true - config.formatter = :documentation - config.log_level = :warn -end - -UBUNTU_OPTS = { - platform: 'ubuntu', - version: '18.04', -}.freeze - -REDHAT_7 = { - platform: 'redhat', - version: '7', -}.freeze - -REDHAT_8 = { - platform: 'redhat', - version: '8', -}.freeze - -ALL_RHEL = [ - REDHAT_7, - REDHAT_8, -].freeze - -# We set a default platform for non-platform specific test cases -CHEFSPEC_OPTS = UBUNTU_OPTS - -shared_context 'library-stubs' do - before do - allow(subject).to receive(:node).and_return(chef_run.node) - end -end - -shared_context 'common-stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:search_for) - .with('os-identity').and_return( - [{ - 'openstack' => { - 'identity' => { - 'admin_tenant_name' => 'admin', - 'admin_user' => 'admin', - }, - }, - }] - ) - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return('admin') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin-user-override') - .and_return('admin-user-override') - end -end diff --git a/cookbooks/openstack-common/spec/sysctl_spec.rb b/cookbooks/openstack-common/spec/sysctl_spec.rb deleted file mode 100644 index fa4420e8..00000000 --- a/cookbooks/openstack-common/spec/sysctl_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-common::sysctl' do - describe 'ubuntu' do - sysctl_kv = { - 'sysctl_key1' => 'sysctl_value1', - 'sysctl_key2' => 'sysctl_value2', - } - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['sysctl'] = sysctl_kv - runner.converge(described_recipe) - end - it do - expect(chef_run).to apply_sysctl('sysctl_key1').with(value: 'sysctl_value1') - end - it do - expect(chef_run).to apply_sysctl('sysctl_key2').with(value: 'sysctl_value2') - end - end -end diff --git a/cookbooks/openstack-common/spec/uri_spec.rb b/cookbooks/openstack-common/spec/uri_spec.rb deleted file mode 100644 index f4410ebe..00000000 --- a/cookbooks/openstack-common/spec/uri_spec.rb +++ /dev/null @@ -1,90 +0,0 @@ -require_relative 'spec_helper' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'uri' -require 'uri' - -describe 'Openstack uri' do - let(:subject) { Object.new.extend(Openstack) } - - describe '#uri_from_hash' do - it 'returns uri when uri key found, ignoring other parts' do - uri = 'http://localhost/' - hash = { - 'port' => 8888, - 'path' => '/path', - 'uri' => uri, - } - result = subject.uri_from_hash(hash) - expect(result).to be_a URI - expect(result.to_s).to eq(uri) - end - - it 'constructs from host' do - uri = 'https://localhost:8888/path' - hash = { - 'scheme' => 'https', - 'port' => 8888, - 'path' => '/path', - 'host' => 'localhost', - } - expect( - subject.uri_from_hash(hash).to_s - ).to eq(uri) - end - - it 'constructs with defaults' do - uri = 'https://localhost' - hash = { - 'scheme' => 'https', - 'host' => 'localhost', - } - expect( - subject.uri_from_hash(hash).to_s - ).to eq(uri) - end - - it 'constructs with extraneous keys' do - uri = 'http://localhost' - hash = { - 'host' => 'localhost', - 'network' => 'public', # To emulate the osops-utils::ip_location way... - } - expect( - subject.uri_from_hash(hash).to_s - ).to eq(uri) - end - end - - describe '#uri_join_paths' do - it 'returns nil when no paths are passed in' do - expect(subject.uri_join_paths).to be_nil - end - - it 'preserves absolute path when only absolute path passed in' do - path = '/abspath' - expect( - subject.uri_join_paths(path) - ).to eq(path) - end - - it 'preserves relative path when only relative path passed in' do - path = 'abspath/' - expect( - subject.uri_join_paths(path) - ).to eq(path) - end - - it 'preserves leadng and trailing slashes' do - expected = '/path/to/resource/' - expect( - subject.uri_join_paths('/path', 'to', 'resource/') - ).to eq(expected) - end - - it 'removes extraneous intermediate slashes' do - expected = '/path/to/resource' - expect( - subject.uri_join_paths('/path', '//to/', '/resource') - ).to eq(expected) - end - end -end diff --git a/cookbooks/openstack-common/spec/wrappers_spec.rb b/cookbooks/openstack-common/spec/wrappers_spec.rb deleted file mode 100644 index 8b377c42..00000000 --- a/cookbooks/openstack-common/spec/wrappers_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require_relative 'spec_helper' -require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'wrappers' - -describe 'openstack-common::default' do - describe 'Openstack wrappers' do - let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - let(:subject) { Object.new.extend(Openstack) } - - include_context 'library-stubs' - - describe '#recipe_included' do - it 'returns boolean for recipe list' do - node_hash = { - 'recipes' => 'included_recipe', - } - allow(subject).to receive(:node).and_return(node_hash) - expect(subject.recipe_included?('included_recipe')).to be_truthy - expect(subject.recipe_included?('not_included_recipe')).to be_falsey - end - end - - describe '#role_included' do - it 'returns boolean for role list' do - node_hash_true = double('node', automatic: { 'roles' => 'included_role' }, role?: true) - node_hash_false = double('node', automatic: { 'roles' => 'included_role' }, role?: false) - allow(subject).to receive(:node).and_return(node_hash_true) - expect(subject.role_included?('included_role')).to be_truthy - allow(subject).to receive(:node).and_return(node_hash_false) - expect(subject.role_included?('not_included_role')).to be_falsey - end - end - end -end From f86811386503a83c42559d5c2d0038de4557ad02 Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 11:40:04 +0400 Subject: [PATCH 3/9] clean up on openstack identity cookbook --- cookbooks/openstack-identity/.rubocop.yml | 4 - cookbooks/openstack-identity/.zuul.yaml | 3 - cookbooks/openstack-identity/Berksfile | 22 - cookbooks/openstack-identity/TESTING.md | 30 -- .../spec/cloud_config_spec.rb | 94 ---- .../spec/credential_tokens_spec.rb | 29 -- .../spec/fernet_tokens_spec.rb | 34 -- .../openstack-identity/spec/openrc_spec.rb | 82 ---- .../spec/registration_spec.rb | 37 -- .../spec/server-apache-redhat_spec.rb | 35 -- .../spec/server-apache_spec.rb | 464 ------------------ .../openstack-identity/spec/spec_helper.rb | 96 ---- 12 files changed, 930 deletions(-) delete mode 100644 cookbooks/openstack-identity/.rubocop.yml delete mode 100644 cookbooks/openstack-identity/.zuul.yaml delete mode 100644 cookbooks/openstack-identity/Berksfile delete mode 100644 cookbooks/openstack-identity/TESTING.md delete mode 100644 cookbooks/openstack-identity/spec/cloud_config_spec.rb delete mode 100644 cookbooks/openstack-identity/spec/credential_tokens_spec.rb delete mode 100644 cookbooks/openstack-identity/spec/fernet_tokens_spec.rb delete mode 100644 cookbooks/openstack-identity/spec/openrc_spec.rb delete mode 100644 cookbooks/openstack-identity/spec/registration_spec.rb delete mode 100644 cookbooks/openstack-identity/spec/server-apache-redhat_spec.rb delete mode 100644 cookbooks/openstack-identity/spec/server-apache_spec.rb delete mode 100644 cookbooks/openstack-identity/spec/spec_helper.rb diff --git a/cookbooks/openstack-identity/.rubocop.yml b/cookbooks/openstack-identity/.rubocop.yml deleted file mode 100644 index 389f2700..00000000 --- a/cookbooks/openstack-identity/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -Chef/Modernize/FoodcriticComments: - Enabled: true -Chef/Style/CopyrightCommentFormat: - Enabled: true diff --git a/cookbooks/openstack-identity/.zuul.yaml b/cookbooks/openstack-identity/.zuul.yaml deleted file mode 100644 index f5786847..00000000 --- a/cookbooks/openstack-identity/.zuul.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- project: - templates: - - openstack-chef-jobs diff --git a/cookbooks/openstack-identity/Berksfile b/cookbooks/openstack-identity/Berksfile deleted file mode 100644 index 98e72f9b..00000000 --- a/cookbooks/openstack-identity/Berksfile +++ /dev/null @@ -1,22 +0,0 @@ -source 'https://supermarket.chef.io' - -solver :ruby, :required - -metadata - -[ - %w(client dep), - %w(-common dep), - %w(-dns integration), - %w(-image integration), - %w(-integration-test integration), - %w(-network integration), - %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}", group: group - else - cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group - end -end diff --git a/cookbooks/openstack-identity/TESTING.md b/cookbooks/openstack-identity/TESTING.md deleted file mode 100644 index 1dd45c5a..00000000 --- a/cookbooks/openstack-identity/TESTING.md +++ /dev/null @@ -1,30 +0,0 @@ -# Testing the Cookbook # - -This cookbook uses [chefdk](https://downloads.chef.io/chef-dk/) and [berkshelf](http://berkshelf.com/) to isolate dependencies. Make sure you have chefdk and the header files for `gecode` installed before continuing. Make sure that you're using gecode version 3. More info [here](https://github.com/opscode/dep-selector-libgecode/tree/0bad63fea305ede624c58506423ced697dd2545e#using-a-system-gecode-instead). For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the [openstack-chef-repo](https://github.com/openstack/openstack-chef-repo). - -We have three test suites which you can run either, individually (there are three rake tasks): - - $ chef exec rake lint - $ chef exec rake style - $ chef exec rake unit - -or altogether: - - $ chef exec rake - -The `rake` tasks will take care of installing the needed cookbooks with `berkshelf`. - -## Rubocop ## - -[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits. - -## Foodcritic ## - -[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules: - -* [FC003](http://acrmp.github.io/foodcritic/#FC003) These cookbooks are not intended for Chef Solo. -* [FC023](http://acrmp.github.io/foodcritic/#FC023) Prefer conditional attributes. - -## Chefspec - -[ChefSpec](https://github.com/sethvargo/chefspec) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers. diff --git a/cookbooks/openstack-identity/spec/cloud_config_spec.rb b/cookbooks/openstack-identity/spec/cloud_config_spec.rb deleted file mode 100644 index de9a84d0..00000000 --- a/cookbooks/openstack-identity/spec/cloud_config_spec.rb +++ /dev/null @@ -1,94 +0,0 @@ -require_relative 'spec_helper' -require 'yaml' - -describe 'openstack-identity::cloud_config' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'identity_stubs' - - describe '/root/clouds.yaml' do - let(:file) { chef_run.template('/root/clouds.yaml') } - - it 'creates the /root/clouds.yaml file' do - expect(chef_run).to create_directory('/root').with( - owner: 'root', - group: 'root', - mode: '0700', - recursive: true - ) - expect(chef_run).to create_template(file.name).with( - sensitive: true, - user: 'root', - group: 'root', - mode: '0600', - variables: { - cloud_name: 'default', - identity_endpoint: 'http://127.0.0.1:5000/v3', - password: 'admin', - project: 'admin', - project_domain_name: 'default', - user_domain_name: 'default', - user: 'admin', - } - ) - end - - cloud_yaml = { - 'clouds' => { - 'default' => { - 'auth' => { - 'username' => 'admin', - 'user_domain_name' => 'default', - 'password' => 'admin', - 'project_name' => 'admin', - 'project_domain_name' => 'default', - 'auth_url' => 'http://127.0.0.1:5000/v3', - }, - 'identity_api_version' => 3, - 'region_name' => 'RegionOne', - }, - }, - } - - it 'contains auth environment variables' do - expect(chef_run).to render_file(file.name).with_content(YAML.dump(cloud_yaml)) - end - - context 'override auth environment variables' do - cloud_yaml_override = { - 'clouds' => { - 'cloud-config-override' => { - 'auth' => { - 'username' => 'identity_admin', - 'user_domain_name' => 'admin-domain-override', - 'password' => 'identity_admin_pass', - 'project_name' => 'admin-project-name-override', - 'project_domain_name' => 'admin-domain-name-override', - 'auth_url' => 'https://public.identity:1234/', - }, - 'identity_api_version' => 3, - 'region_name' => 'RegionOne', - }, - }, - } - cached(:chef_run) do - node.override['openstack']['identity']['cloud_config']['cloud_name'] = 'cloud-config-override' - node.override['openstack']['identity']['admin_user'] = 'identity_admin' - node.override['openstack']['identity']['admin_project_domain'] = 'admin-domain-name-override' - node.override['openstack']['identity']['admin_project'] = 'admin-project-name-override' - node.override['openstack']['identity']['admin_domain_name'] = 'admin-domain-override' - node.override['openstack']['endpoints']['public']['identity']['uri'] = 'https://public.identity:1234/' - runner.converge(described_recipe) - end - it 'contains overridden auth environment variables' do - expect(chef_run).to render_file(file.name).with_content(YAML.dump(cloud_yaml_override)) - end - end - end - end -end diff --git a/cookbooks/openstack-identity/spec/credential_tokens_spec.rb b/cookbooks/openstack-identity/spec/credential_tokens_spec.rb deleted file mode 100644 index 3a94d16d..00000000 --- a/cookbooks/openstack-identity/spec/credential_tokens_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ - -require_relative 'spec_helper' - -describe 'openstack-identity::_credential_tokens' do - describe 'ubuntu' do - include_context 'identity_stubs' - - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - it do - expect(chef_run).to create_directory('/etc/keystone/credential-tokens') - .with(owner: 'keystone', user: 'keystone', mode: '700') - end - - [0, 1].each do |key_index| - it do - expect(chef_run).to create_file("/etc/keystone/credential-tokens/#{key_index}") - .with( - content: "thisiscredentialkey#{key_index}", - owner: 'keystone', - group: 'keystone', - mode: '400' - ) - end - end - end -end diff --git a/cookbooks/openstack-identity/spec/fernet_tokens_spec.rb b/cookbooks/openstack-identity/spec/fernet_tokens_spec.rb deleted file mode 100644 index d6024aa1..00000000 --- a/cookbooks/openstack-identity/spec/fernet_tokens_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ - -require_relative 'spec_helper' - -describe 'openstack-identity::_fernet_tokens' do - describe 'ubuntu' do - include_context 'identity_stubs' - - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - it do - expect(chef_run).to create_directory('/etc/keystone/fernet-tokens') - .with(owner: 'keystone', user: 'keystone', mode: '700') - end - - [0, 1].each do |key_index| - it do - expect(chef_run).to create_file("/etc/keystone/fernet-tokens/#{key_index}") - .with( - content: "thisisfernetkey#{key_index}", - owner: 'keystone', - group: 'keystone', - mode: '400' - ) - end - end - it do - expect(chef_run).to run_execute('keystone-manage fernet_setup').with( - command: 'keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone' - ) - end - end -end diff --git a/cookbooks/openstack-identity/spec/openrc_spec.rb b/cookbooks/openstack-identity/spec/openrc_spec.rb deleted file mode 100644 index c6c36b9b..00000000 --- a/cookbooks/openstack-identity/spec/openrc_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-identity::openrc' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'identity_stubs' - - describe '/root/openrc' do - let(:file) { chef_run.template('/root/openrc') } - - it 'creates the /root/openrc file' do - expect(chef_run).to create_directory('/root').with( - owner: 'root', - group: 'root', - mode: '0700', - recursive: true - ) - expect(chef_run).to create_template(file.name).with( - sensitive: true, - user: 'root', - group: 'root', - mode: '0600' - ) - end - - it 'contains auth environment variables' do - [ - /^export OS_USERNAME=admin$/, - /^export OS_USER_DOMAIN_NAME=default$/, - /^export OS_PASSWORD=admin$/, - /^export OS_PROJECT_NAME=admin$/, - /^export OS_PROJECT_DOMAIN_NAME=default$/, - /^export OS_IDENTITY_API_VERSION=3$/, - %r{^export OS_AUTH_URL=http://127.0.0.1:5000/v3$}, - /^export OS_REGION_NAME=RegionOne$/, - ].each do |line| - expect(chef_run).to render_file(file.name).with_content(line) - end - end - - context 'misc_openrc array' do - cached(:chef_run) do - node.override['openstack']['misc_openrc'] = ['export MISC1=OPTION1', 'export MISC2=OPTION2'] - runner.converge(described_recipe) - end - it 'templates misc_openrc array correctly' do - expect(chef_run).to render_file(file.name).with_content( - /^export MISC1=OPTION1$/ - ) - expect(chef_run).to render_file(file.name).with_content( - /^export MISC2=OPTION2$/ - ) - end - end - - context 'override auth environment variables' do - cached(:chef_run) do - node.override['openstack']['identity']['admin_project'] = 'admin-project-name-override' - node.override['openstack']['identity']['admin_user'] = 'identity_admin' - node.override['openstack']['identity']['admin_domain_id'] = 'admin-domain-override' - node.override['openstack']['endpoints']['public']['identity']['uri'] = 'https://public.identity:1234/' - runner.converge(described_recipe) - end - it 'contains overridden auth environment variables' do - [ - /^export OS_USERNAME=identity_admin$/, - /^export OS_PROJECT_NAME=admin-project-name-override$/, - /^export OS_PASSWORD=identity_admin_pass$/, - %r{^export OS_AUTH_URL=https://public.identity:1234/$}, - ].each do |line| - expect(chef_run).to render_file(file.name).with_content(line) - end - end - end - end - end -end diff --git a/cookbooks/openstack-identity/spec/registration_spec.rb b/cookbooks/openstack-identity/spec/registration_spec.rb deleted file mode 100644 index 66806d8e..00000000 --- a/cookbooks/openstack-identity/spec/registration_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ - -require_relative 'spec_helper' - -describe 'openstack-identity::registration' do - describe 'ubuntu' do - let(:node) { runner.node } - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'identity_stubs' - - connection_params = { - openstack_auth_url: 'http://127.0.0.1:5000/v3', - openstack_username: 'admin', - openstack_api_key: 'admin', - openstack_project_name: 'admin', - openstack_domain_id: 'default', - # openstack_endpoint_type: 'internalURL', - } - - describe 'keystone bootstrap' do - context 'default values' do - it do - expect(chef_run).to run_ruby_block('wait for identity endpoint') - end - - it 'create service role' do - expect(chef_run).to create_openstack_role( - 'service' - ).with( - connection_params: connection_params - ) - end - end - end - end -end diff --git a/cookbooks/openstack-identity/spec/server-apache-redhat_spec.rb b/cookbooks/openstack-identity/spec/server-apache-redhat_spec.rb deleted file mode 100644 index e452c03c..00000000 --- a/cookbooks/openstack-identity/spec/server-apache-redhat_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ - -require_relative 'spec_helper' - -describe 'openstack-identity::server-apache' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'identity_stubs' - - it 'upgrades keystone packages' do - expect(chef_run).to upgrade_package('identity cookbook package openstack-keystone') - expect(chef_run).to upgrade_package('identity cookbook package openstack-selinux') - end - - case p - when REDHAT_7 - it 'upgrades python packages' do - expect(chef_run).to upgrade_package('identity cookbook package python-memcached') - expect(chef_run).to upgrade_package('identity cookbook package python2-urllib3') - end - - when REDHAT_8 - it 'upgrades python packages' do - expect(chef_run).to upgrade_package('identity cookbook package python3-memcached') - expect(chef_run).to upgrade_package('identity cookbook package python3-urllib3') - end - end - end - end -end diff --git a/cookbooks/openstack-identity/spec/server-apache_spec.rb b/cookbooks/openstack-identity/spec/server-apache_spec.rb deleted file mode 100644 index d383df10..00000000 --- a/cookbooks/openstack-identity/spec/server-apache_spec.rb +++ /dev/null @@ -1,464 +0,0 @@ - -require_relative 'spec_helper' - -describe 'openstack-identity::server-apache' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include Helpers - include_context 'identity_stubs' - - service_name = 'keystone' - service_user = 'admin' - region = 'RegionOne' - project_name = 'admin' - role_name = 'admin' - password = 'admin' - public_url = 'http://127.0.0.1:5000/v3' - - context 'syslog true' do - cached(:chef_run) do - node.override['openstack']['identity']['syslog']['use'] = true - runner.converge(described_recipe) - end - it 'runs logging recipe if node attributes say to' do - expect(chef_run).to include_recipe('openstack-common::logging') - end - end - - it 'does not run logging recipe' do - expect(chef_run).not_to include_recipe('openstack-common::logging') - end - - it 'upgrades mysql python packages' do - expect(chef_run).to upgrade_package('identity cookbook package python3-mysqldb') - end - - it 'upgrades memcache python packages' do - expect(chef_run).to upgrade_package('identity cookbook package python3-memcache') - end - - it 'upgrades keystone packages' do - expect(chef_run).to upgrade_package('identity cookbook package python3-keystone') - expect(chef_run).to upgrade_package('identity cookbook package keystone') - end - - it do - expect(chef_run).to disable_apache2_site('keystone') - end - - it 'bootstrap with keystone-manage' do - expect(chef_run).to run_execute('bootstrap_keystone').with( - command: "keystone-manage bootstrap \\ - --bootstrap-password #{password} \\ - --bootstrap-username #{service_user} \\ - --bootstrap-project-name #{project_name} \\ - --bootstrap-role-name #{role_name} \\ - --bootstrap-service-name #{service_name} \\ - --bootstrap-region-id #{region} \\ - --bootstrap-admin-url #{public_url} \\ - --bootstrap-public-url #{public_url} \\ - --bootstrap-internal-url #{public_url}", - sensitive: true - ) - end - - describe '/etc/keystone' do - let(:dir) { chef_run.directory('/etc/keystone') } - - it 'creates directory /etc/keystone' do - expect(chef_run).to create_directory(dir.name).with( - user: 'keystone', - group: 'keystone', - mode: '700' - ) - end - end - - describe '/etc/keystone/domains' do - let(:dir) { '/etc/keystone/domains' } - - it 'does not create /etc/keystone/domains by default' do - expect(chef_run).not_to create_directory(dir) - end - - context 'domain_specific_drivers_enabled true' do - cached(:chef_run) do - node.override['openstack']['identity']['domain_specific_drivers_enabled'] = true - runner.converge(described_recipe) - end - it 'creates /etc/keystone/domains when domain_specific_drivers_enabled enabled' do - expect(chef_run).to create_directory(dir).with( - user: 'keystone', - group: 'keystone', - mode: '700' - ) - end - end - end - - it 'deletes keystone.db' do - expect(chef_run).to delete_file('/var/lib/keystone/keystone.db') - end - - context 'service_type sqlite' do - cached(:chef_run) do - node.override['openstack']['db']['identity']['service_type'] = 'sqlite' - runner.converge(described_recipe) - end - it 'does not delete keystone.db when configured to use sqlite' do - expect(chef_run).not_to delete_file('/var/lib/keystone/keystone.db') - end - end - - describe 'keystone.conf' do - let(:path) { '/etc/keystone/keystone.conf' } - let(:resource) { chef_run.template(path) } - describe 'file properties' do - it 'creates /etc/keystone/keystone.conf' do - expect(chef_run).to create_template(resource.name).with( - user: 'keystone', - group: 'keystone', - mode: '640', - sensitive: true - ) - end - end - - it 'has no list_limits by default' do - expect(chef_run).not_to render_config_file(path).with_section_content('DEFAULT', /^list_limit = /) - end - - describe '[DEFAULT] section' do - [ - %r{^log_dir = /var/log/keystone$}, - %r{^public_endpoint = http://127.0.0.1:5000/$}, - %r{^transport_url = rabbit://openstack:mypass@127.0.0.1:5672$}, - ].each do |line| - it do - expect(chef_run).to render_config_file(path).with_section_content('DEFAULT', line) - end - end - - describe 'syslog configuration' do - log_file = %r{^log_dir = /var/log/keystone$} - log_conf = %r{^log_config_append = /\w+} - - it do - expect(chef_run).not_to render_config_file(path).with_section_content('DEFAULT', log_conf) - end - - context 'syslog true' do - cached(:chef_run) do - node.override['openstack']['identity']['syslog']['use'] = true - runner.converge(described_recipe) - end - it do - expect(chef_run).to render_config_file(path).with_section_content('DEFAULT', log_conf) - expect(chef_run).not_to render_config_file(path).with_section_content('DEFAULT', log_file) - end - end - end - end - - describe '[memcache] section' do - it 'has no servers by default' do - # `Openstack#memcached_servers' is stubbed in spec_helper.rb to - # return an empty array, so we expect an empty `servers' list. - r = line_regexp('servers = ') - expect(chef_run).to render_config_file(path).with_section_content('memcache', r) - end - - context 'hostnames are configured' do - cached(:chef_run) do - runner.converge(described_recipe) - end - it 'has servers when hostnames are configured' do - # Re-stub `Openstack#memcached_servers' here - hosts = ['host1:111', 'host2:222'] - r = line_regexp("servers = #{hosts.join(',')}") - - allow_any_instance_of(Chef::Recipe).to receive(:memcached_servers).and_return(hosts) - expect(chef_run).to render_config_file(path).with_section_content('memcache', r) - end - end - end - - describe '[sql] section' do - it 'has a connection' do - r = %r{^connection = mysql\+pymysql://keystone:@127.0.0.1:3306/keystone\?charset=utf8$} - expect(chef_run).to render_config_file(path).with_section_content('database', r) - end - end - - describe '[assignment] section' do - it 'configures driver' do - r = /^driver = sql$/ - expect(chef_run).to render_config_file(path).with_section_content('assignment', r) - end - end - - describe '[policy] section' do - it 'configures driver' do - r = /^driver = sql$/ - expect(chef_run).to render_config_file(path).with_section_content('policy', r) - end - end - describe '[fernet_tokens] section' do - it 'key_repository = /etc/keystone/fernet-tokens' do - r = %r{^key_repository = /etc/keystone/fernet-tokens$} - expect(chef_run).to render_config_file(path).with_section_content('fernet_tokens', r) - end - end - describe '[credential] section' do - it 'key_repository = /etc/keystone/credential-tokens' do - r = %r{^key_repository = /etc/keystone/credential-tokens$} - expect(chef_run).to render_config_file(path).with_section_content('credential', r) - end - end - describe '[cache] section' do - [ - /^enabled = true$/, - /^backend = oslo_cache.memcache_pool$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(path).with_section_content('cache', line) - end - end - end - end - - describe 'db_sync' do - let(:cmd) { 'keystone-manage db_sync' } - - it 'runs migrations' do - expect(chef_run).to run_execute(cmd).with( - user: 'root' - ) - end - - context 'migrate false' do - cached(:chef_run) do - node.override['openstack']['db']['identity']['migrate'] = false - runner.converge(described_recipe) - end - it 'does not run migrations' do - expect(chef_run).not_to run_execute(cmd).with( - user: 'root' - ) - end - end - end - - describe 'keystone-paste.ini as template' do - let(:path) { '/etc/keystone/keystone-paste.ini' } - - it 'has default api pipeline values' do - expect(chef_run).to render_config_file(path).with_section_content( - 'pipeline:api_v3', - /^pipeline = healthcheck cors sizelimit http_proxy_to_wsgi osprofiler url_normalize request_id build_auth_context token_auth json_body ec2_extension_v3 s3_extension service_v3$/ - ) - end - context 'api_v3 service_v3' do - cached(:chef_run) do - node.override['openstack']['identity']['pipeline']['api_v3'] = 'service_v3' - runner.converge(described_recipe) - end - it 'template api pipeline set correct' do - expect(chef_run).to render_config_file(path).with_section_content( - 'pipeline:api_v3', - /^pipeline = service_v3$/ - ) - end - end - context 'misc_paste set' do - cached(:chef_run) do - node.override['openstack']['identity']['misc_paste'] = ['MISC1 = OPTION1', 'MISC2 = OPTION2'] - runner.converge(described_recipe) - end - it 'template misc_paste array correctly' do - expect(chef_run).to render_file(path).with_content( - /^MISC1 = OPTION1$/ - ) - expect(chef_run).to render_file(path).with_content( - /^MISC2 = OPTION2$/ - ) - end - end - end - - context 'keystone-paste.ini as remote file' do - cached(:chef_run) do - node.override['openstack']['identity']['pastefile_url'] = 'http://server/mykeystone-paste.ini' - runner.converge(described_recipe) - end - let(:remote_paste) { chef_run.remote_file('/etc/keystone/keystone-paste.ini') } - - it 'uses a remote file if pastefile_url is specified' do - expect(chef_run).to create_remote_file_if_missing('/etc/keystone/keystone-paste.ini').with( - source: 'http://server/mykeystone-paste.ini', - user: 'keystone', - group: 'keystone', - mode: '644' - ) - end - end - - describe 'apache setup' do - it do - expect(chef_run.template('/etc/keystone/keystone.conf')).to notify('service[apache2]').to(:restart) - end - - it do - expect(chef_run.template('/etc/apache2/sites-available/identity.conf')).to \ - notify('service[apache2]').to(:restart) - end - - it do - expect(chef_run).to install_apache2_install('openstack').with(listen: %w(127.0.0.1:5000)) - end - - it do - expect(chef_run).to create_apache2_mod_wsgi('openstack') - end - - it do - expect(chef_run).to_not enable_apache2_module('ssl') - end - - context 'ssl enabled' do - cached(:chef_run) do - node.override['openstack']['identity']['ssl']['enabled'] = true - runner.converge(described_recipe) - end - it do - expect(chef_run).to enable_apache2_module('ssl') - end - end - - describe 'apache wsgi' do - let(:file) { '/etc/apache2/sites-available/identity.conf' } - - it 'creates identity.conf' do - expect(chef_run).to create_template(file).with( - source: 'wsgi-keystone.conf.erb', - variables: { - group: 'keystone', - log_dir: '/var/log/apache2', - run_dir: '/var/lock', - server_alias: 'identity', - server_entry: '/usr/bin/keystone-wsgi-public', - server_host: '127.0.0.1', - server_port: 5000, - user: 'keystone', - } - ) - end - - it 'does not configure keystone-admin.conf' do - expect(chef_run).not_to render_file('/etc/apache2/sites-available/keystone-admin.conf') - end - - [ - /^$/, - /WSGIDaemonProcess identity processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}$/, - /WSGIProcessGroup identity$/, - %r{WSGIScriptAlias / /usr/bin/keystone-wsgi-public$}, - %r{ErrorLog /var/log/apache2/identity.log$}, - %r{CustomLog /var/log/apache2/identity_access.log combined$}, - %r{WSGISocketPrefix /var/lock$}, - ].each do |line| - it do - expect(chef_run).to render_file(file).with_content(line) - end - end - - context 'custom_template_banner' do - cached(:chef_run) do - node.override['openstack']['identity']['custom_template_banner'] = 'custom_template_banner_value' - runner.converge(described_recipe) - end - [ - /^custom_template_banner_value$/, - ].each do |line| - it do - expect(chef_run).to render_file(file).with_content(line) - end - end - end - - [ - /SSLEngine On$/, - /SSLCertificateFile/, - /SSLCertificateKeyFile/, - /SSLCACertificatePath/, - /SSLCARevocationPath/, - /SSLCARevocationCheck/, - /SSLCertificateChainFile/, - /SSLProtocol/, - /SSLCipherSuite/, - /SSLVerifyClient/, - ].each do |line| - it do - expect(chef_run).not_to render_file(file).with_content(line) - end - end - - context 'Enable SSL' do - let(:file) { '/etc/apache2/sites-available/identity.conf' } - cached(:chef_run) do - node.override['openstack']['identity']['ssl']['enabled'] = true - runner.converge(described_recipe) - end - [ - /SSLEngine On$/, - %r{SSLCertificateFile /etc/keystone/ssl/certs/sslcert.pem$}, - %r{SSLCertificateKeyFile /etc/keystone/ssl/private/sslkey.pem$}, - %r{SSLCACertificatePath /etc/keystone/ssl/certs/$}, - /SSLProtocol All -SSLv2 -SSLv3$/, - ].each do |line| - it do - expect(chef_run).to render_file(file).with_content(line) - end - end - [ - /SSLCARevocationPath/, - /SSLCARevocationCheck/, - /SSLCertificateChainFile/, - /SSLCipherSuite/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).not_to render_file(file).with_content(line) - end - end - context 'Enable ca_revocation_path, chainfile, ciphers & cert_required' do - cached(:chef_run) do - node.override['openstack']['identity']['ssl']['enabled'] = true - node.override['openstack']['identity']['ssl']['ca_revocation_path'] = '/etc/keystone/ssl/crl.d' - node.override['openstack']['identity']['ssl']['chainfile'] = '/etc/keystone/ssl/certs/chainfile.pem' - node.override['openstack']['identity']['ssl']['ciphers'] = 'ciphers_value' - node.override['openstack']['identity']['ssl']['cert_required'] = true - runner.converge(described_recipe) - end - [ - %r{SSLCARevocationPath /etc/keystone/ssl/crl.d$}, - /SSLCARevocationCheck chain$/, - %r{SSLCertificateChainFile /etc/keystone/ssl/certs/chainfile.pem$}, - /SSLCipherSuite ciphers_value$/, - /SSLVerifyClient require$/, - ].each do |line| - it do - expect(chef_run).to render_file(file).with_content(line) - end - end - end - end - end - end - end -end diff --git a/cookbooks/openstack-identity/spec/spec_helper.rb b/cookbooks/openstack-identity/spec/spec_helper.rb deleted file mode 100644 index ec22953e..00000000 --- a/cookbooks/openstack-identity/spec/spec_helper.rb +++ /dev/null @@ -1,96 +0,0 @@ -require 'chefspec' -require 'chefspec/berkshelf' - -RSpec.configure do |config| - config.color = true - config.formatter = :documentation - config.log_level = :warn - config.file_cache_path = '/var/chef/cache' -end - -REDHAT_7 = { - platform: 'redhat', - version: '7', -}.freeze - -REDHAT_8 = { - platform: 'redhat', - version: '8', -}.freeze - -ALL_RHEL = [ - REDHAT_7, - REDHAT_8, -].freeze - -UBUNTU_OPTS = { - platform: 'ubuntu', - version: '18.04', -}.freeze - -# Helper methods -module Helpers - # Create an anchored regex to exactly match the entire line - # (name borrowed from grep --line-regexp) - # - # @param [String] str The whole line to match - # @return [Regexp] The anchored/escaped regular expression - def line_regexp(str) - /^#{Regexp.quote(str)}$/ - end -end - -shared_context 'identity_stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers) - .and_return('rabbit_servers_value') - allow_any_instance_of(Chef::Recipe).to receive(:memcached_servers) - .and_return([]) - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', anything) - .and_return('') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', anything) - .and_return('') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'guest') - .and_return('guest') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'user1') - .and_return('secret1') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'identity_admin') - .and_return('identity_admin_pass') - stub_command('/usr/sbin/apache2 -t') - allow_any_instance_of(Chef::Recipe).to receive(:search_for) - .with('os-identity').and_return( - [{ - 'openstack' => { - 'identity' => { - 'admin_tenant_name' => 'admin', - 'admin_user' => 'admin', - }, - }, - }] - ) - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return('admin') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'credential_key0') - .and_return('thisiscredentialkey0') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'credential_key1') - .and_return('thisiscredentialkey1') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'fernet_key0') - .and_return('thisisfernetkey0') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'fernet_key1') - .and_return('thisisfernetkey1') - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('identity') - .and_return('rabbit://openstack:mypass@127.0.0.1:5672') - stub_command("[ ! -e /etc/httpd/conf/httpd.conf ] && [ -e /etc/redhat-release ] && [ $(/sbin/sestatus | grep -c '^Current mode:.*enforcing') -eq 1 ]").and_return(true) - end -end From 08bb3686d1b5f0439a65ae299d0612c8b8c59b8c Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 12:12:33 +0400 Subject: [PATCH 4/9] cleanup in openstack-images cookbook --- .../openstack-image/.delivery/project.toml | 9 - cookbooks/openstack-image/.rubocop.yml | 4 - cookbooks/openstack-image/.rubocop_todo.yml | 12 - cookbooks/openstack-image/.zuul.yaml | 3 - cookbooks/openstack-image/Berksfile | 22 -- cookbooks/openstack-image/TESTING.md | 30 --- .../openstack-image/spec/api-redhat_spec.rb | 34 --- cookbooks/openstack-image/spec/api_spec.rb | 208 --------------- .../spec/identity_registration_spec.rb | 85 ------ .../openstack-image/spec/image_upload_spec.rb | 110 -------- cookbooks/openstack-image/spec/spec_helper.rb | 249 ------------------ .../spec/swift_store-redhat_spec.rb | 17 -- .../openstack-image/spec/swift_store_spec.rb | 15 -- 13 files changed, 798 deletions(-) delete mode 100644 cookbooks/openstack-image/.delivery/project.toml delete mode 100644 cookbooks/openstack-image/.rubocop.yml delete mode 100644 cookbooks/openstack-image/.rubocop_todo.yml delete mode 100644 cookbooks/openstack-image/.zuul.yaml delete mode 100644 cookbooks/openstack-image/Berksfile delete mode 100644 cookbooks/openstack-image/TESTING.md delete mode 100644 cookbooks/openstack-image/spec/api-redhat_spec.rb delete mode 100644 cookbooks/openstack-image/spec/api_spec.rb delete mode 100644 cookbooks/openstack-image/spec/identity_registration_spec.rb delete mode 100644 cookbooks/openstack-image/spec/image_upload_spec.rb delete mode 100644 cookbooks/openstack-image/spec/spec_helper.rb delete mode 100644 cookbooks/openstack-image/spec/swift_store-redhat_spec.rb delete mode 100644 cookbooks/openstack-image/spec/swift_store_spec.rb diff --git a/cookbooks/openstack-image/.delivery/project.toml b/cookbooks/openstack-image/.delivery/project.toml deleted file mode 100644 index 4066e559..00000000 --- a/cookbooks/openstack-image/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[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/cookbooks/openstack-image/.rubocop.yml b/cookbooks/openstack-image/.rubocop.yml deleted file mode 100644 index 389f2700..00000000 --- a/cookbooks/openstack-image/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -Chef/Modernize/FoodcriticComments: - Enabled: true -Chef/Style/CopyrightCommentFormat: - Enabled: true diff --git a/cookbooks/openstack-image/.rubocop_todo.yml b/cookbooks/openstack-image/.rubocop_todo.yml deleted file mode 100644 index 1c22bb65..00000000 --- a/cookbooks/openstack-image/.rubocop_todo.yml +++ /dev/null @@ -1,12 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2020-05-29 17:16:13 -0700 using RuboCop version 0.82.0. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 2 -# Configuration parameters: CountKeywordArgs. -Metrics/ParameterLists: - Max: 6 diff --git a/cookbooks/openstack-image/.zuul.yaml b/cookbooks/openstack-image/.zuul.yaml deleted file mode 100644 index f5786847..00000000 --- a/cookbooks/openstack-image/.zuul.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- project: - templates: - - openstack-chef-jobs diff --git a/cookbooks/openstack-image/Berksfile b/cookbooks/openstack-image/Berksfile deleted file mode 100644 index 592d7422..00000000 --- a/cookbooks/openstack-image/Berksfile +++ /dev/null @@ -1,22 +0,0 @@ -source 'https://supermarket.chef.io' - -solver :ruby, :required - -[ - %w(client dep), - %w(-common dep), - %w(-dns integration), - %w(-identity dep), - %w(-integration-test integration), - %w(-network integration), - %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}", group: group - else - cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group - end -end - -metadata diff --git a/cookbooks/openstack-image/TESTING.md b/cookbooks/openstack-image/TESTING.md deleted file mode 100644 index 1dd45c5a..00000000 --- a/cookbooks/openstack-image/TESTING.md +++ /dev/null @@ -1,30 +0,0 @@ -# Testing the Cookbook # - -This cookbook uses [chefdk](https://downloads.chef.io/chef-dk/) and [berkshelf](http://berkshelf.com/) to isolate dependencies. Make sure you have chefdk and the header files for `gecode` installed before continuing. Make sure that you're using gecode version 3. More info [here](https://github.com/opscode/dep-selector-libgecode/tree/0bad63fea305ede624c58506423ced697dd2545e#using-a-system-gecode-instead). For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the [openstack-chef-repo](https://github.com/openstack/openstack-chef-repo). - -We have three test suites which you can run either, individually (there are three rake tasks): - - $ chef exec rake lint - $ chef exec rake style - $ chef exec rake unit - -or altogether: - - $ chef exec rake - -The `rake` tasks will take care of installing the needed cookbooks with `berkshelf`. - -## Rubocop ## - -[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits. - -## Foodcritic ## - -[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules: - -* [FC003](http://acrmp.github.io/foodcritic/#FC003) These cookbooks are not intended for Chef Solo. -* [FC023](http://acrmp.github.io/foodcritic/#FC023) Prefer conditional attributes. - -## Chefspec - -[ChefSpec](https://github.com/sethvargo/chefspec) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers. diff --git a/cookbooks/openstack-image/spec/api-redhat_spec.rb b/cookbooks/openstack-image/spec/api-redhat_spec.rb deleted file mode 100644 index 64bd04c4..00000000 --- a/cookbooks/openstack-image/spec/api-redhat_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-image::api' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'image-stubs' - - case p - when REDHAT_7 - it 'does not upgrade keystoneclient package' do - expect(chef_run).not_to upgrade_package('python-keystoneclient') - end - when REDHAT_8 - it 'does not upgrade keystoneclient package' do - expect(chef_run).not_to upgrade_package('python3-keystoneclient') - end - end - - it 'does not upgrade swift packages by default' do - expect(chef_run).not_to upgrade_package('openstack-swift') - end - - it do - expect(chef_run).to enable_service('openstack-glance-api') - end - end - end -end diff --git a/cookbooks/openstack-image/spec/api_spec.rb b/cookbooks/openstack-image/spec/api_spec.rb deleted file mode 100644 index 247dfbb6..00000000 --- a/cookbooks/openstack-image/spec/api_spec.rb +++ /dev/null @@ -1,208 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-image::api' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'image-stubs' - - it do - expect(chef_run).to include_recipe('openstack-common::client') - end - - it do - expect(chef_run).to upgrade_package('glance') - end - - it do - expect(chef_run).to create_directory('/etc/glance') - .with( - user: 'glance', - group: 'glance', - mode: '700' - ) - end - - it do - expect(chef_run).to create_directory('/var/lib/glance/images') - .with( - user: 'glance', - group: 'glance', - mode: '750', - recursive: true - ) - end - - describe 'glance-api.conf' do - let(:file) { chef_run.template('/etc/glance/glance-api.conf') } - it do - expect(chef_run).to create_template(file.name) - .with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - user: 'glance', - group: 'glance', - mode: '640' - ) - end - - [ - %r{^log_file = /var/log/glance/api.log$}, - %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, - /^bind_host = 127.0.0.1$/, - /^bind_port = 9292$/, - /^enabled_backends = file:file,http:http$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content('DEFAULT', line) - end - end - - [ - %r{^filesystem_store_datadir = /var/lib/glance/images$}, - /^default_backend = file$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content('glance_store', line) - end - end - - [ - /^flavor = keystone$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content('paste_deploy', line) - end - end - - [ - /^auth_type = password$/, - /^region_name = RegionOne$/, - /^username = glance$/, - /^project_name = admin$/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^password = glance-pass$/, - /^user_domain_name = Default$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content('keystone_authtoken', line) - end - end - - [ - %r{^connection = mysql\+pymysql://glance:db-pass@127\.0\.0\.1:3306/glance\?charset=utf8$}, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content('database', line) - end - end - end - - describe 'glance-cache.conf' do - let(:file) { chef_run.template('/etc/glance/glance-cache.conf') } - - it 'creates glance-cache.conf' do - expect(chef_run).to create_template(file.name) - .with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - user: 'glance', - group: 'glance', - mode: '640' - ) - end - end - - describe 'glance-scrubber.conf' do - let(:file) { chef_run.template('/etc/glance/glance-scrubber.conf') } - - it 'creates glance-scrubber.conf' do - expect(chef_run).to create_template(file.name) - .with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - user: 'glance', - group: 'glance', - mode: '640' - ) - end - end - - it do - expect(chef_run).to create_cron('glance-cache-pruner') - .with( - command: '/usr/bin/glance-cache-pruner > /dev/null 2>&1', - minute: '*/30' - ) - end - - it do - expect(chef_run).to create_cron('glance-cache-cleaner') - .with( - command: '/usr/bin/glance-cache-cleaner > /dev/null 2>&1', - minute: '01', - hour: '00' - ) - end - - it do - expect(chef_run).to create_directory('/var/lib/glance/image-cache/') - .with( - user: 'glance', - group: 'glance', - mode: '755', - recursive: true - ) - end - - %w(image_api image_cache image_scrubber).each do |service| - it do - expect(chef_run).to run_ruby_block( - "delete all attributes in node['openstack']['#{service}']['conf_secrets']" - ) - end - end - - describe 'db_sync' do - let(:cmd) { 'glance-manage db_sync' } - - it 'runs migrations' do - expect(chef_run).to run_execute(cmd).with(user: 'glance', group: 'glance') - end - - context 'migration set to false' do - cached(:chef_run) do - runner.converge(described_recipe) - end - it 'does not run migrations when openstack/image/db/migrate is false' do - node.override['openstack']['db']['image']['migrate'] = false - expect(chef_run).not_to run_execute(cmd) - end - end - end - - it do - expect(chef_run).to enable_service('glance-api') - end - - it do - expect(chef_run).to start_service('glance-api') - end - - it do - resource = chef_run.service('glance-api') - expect(resource).to subscribe_to('template[/etc/glance/glance-api.conf]').on(:restart).immediately - expect(resource).to subscribe_to('template[/etc/glance/glance-cache.conf]').on(:restart).immediately - expect(resource).to subscribe_to('template[/etc/glance/glance-scrubber.conf]').on(:restart).immediately - end - end -end diff --git a/cookbooks/openstack-image/spec/identity_registration_spec.rb b/cookbooks/openstack-image/spec/identity_registration_spec.rb deleted file mode 100644 index f10bd4d0..00000000 --- a/cookbooks/openstack-image/spec/identity_registration_spec.rb +++ /dev/null @@ -1,85 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-image::identity_registration' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'image-stubs' - - connection_params = { - openstack_auth_url: 'http://127.0.0.1:5000/v3', - openstack_username: 'admin', - openstack_api_key: 'admin-pass', - openstack_project_name: 'admin', - openstack_domain_name: 'default', - # openstack_endpoint_type: 'internalURL', - } - service_name = 'glance' - service_type = 'image' - service_user = 'glance' - url = 'http://127.0.0.1:9292' - region = 'RegionOne' - project_name = 'admin' - role_name = 'admin' - password = 'glance-pass' - domain_name = 'Default' - - it "registers #{project_name} Project" do - expect(chef_run).to create_openstack_project( - project_name - ).with( - connection_params: connection_params - ) - end - - it "registers #{service_name} service" do - expect(chef_run).to create_openstack_service( - service_name - ).with( - connection_params: connection_params, - type: service_type - ) - end - - context "registers #{service_name} endpoint" do - %w(internal public).each do |interface| - it "#{interface} endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - service_type - ).with( - service_name: service_name, - # interface: interface, - url: url, - region: region, - connection_params: connection_params - ) - end - end - end - - it 'registers service user' do - expect(chef_run).to create_openstack_user( - service_user - ).with( - domain_name: domain_name, - project_name: project_name, - password: password, - connection_params: connection_params - ) - end - - it do - expect(chef_run).to grant_role_openstack_user( - service_user - ).with( - project_name: project_name, - role_name: role_name, - password: password, - domain_name: domain_name, - connection_params: connection_params - ) - end -end diff --git a/cookbooks/openstack-image/spec/image_upload_spec.rb b/cookbooks/openstack-image/spec/image_upload_spec.rb deleted file mode 100644 index da4ffd28..00000000 --- a/cookbooks/openstack-image/spec/image_upload_spec.rb +++ /dev/null @@ -1,110 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-image::image_upload' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS.merge(step_into: ['openstack_image_image'])) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'image-stubs' - - it do - stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep cirros').and_return(false) - expect(chef_run).to upgrade_package('curl') - end - - it 'uploads the cirros image' do - stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep cirros').and_return(false) - expect(chef_run).to upload_openstack_image_image('Image setup for cirros').with( - image_url: 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img', - image_name: 'cirros', - image_type: 'qcow', - image_public: true, - image_id: 'e1847f1a-01d2-4957-a067-b56085bf3781', - identity_user: 'admin', - identity_pass: 'admin-pass', - identity_tenant: 'admin', - identity_uri: 'http://127.0.0.1:5000/v3' - ) - end - - context 'raises error for unsupported image extension type' do - cached(:chef_run) do - node.override['openstack']['image']['upload_images'] = ['image1'] - node.override['openstack']['image']['upload_image']['image1'] = 'http://download.net/image.xxx' - runner.converge(described_recipe) - end - it do - expect { chef_run }.to raise_error(ArgumentError) - end - end - - context 'uploads the tar image' do - cached(:chef_run) do - node.override['openstack']['image']['upload_images'] = ['imageName'] - node.override['openstack']['image']['upload_image']['imageName'] = 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-uec.tar.gz' - runner.converge(described_recipe) - end - it do - stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep imageName').and_return(false) - expect(chef_run).to upload_openstack_image_image('Image setup for imageName').with( - image_url: 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-uec.tar.gz', - image_name: 'imageName', - image_type: 'unknown', - image_public: true - ) - expect(chef_run).to run_bash('Uploading AMI image imageName') - end - end - - %w(vhd vmdk vdi iso raw).each do |image_type| - context "uploads the #{image_type} image" do - cached(:chef_run) do - node.override['openstack']['image']['upload_images'] = ["#{image_type}_imageName"] - node.override['openstack']['image']['upload_image']["#{image_type}_imageName"] = "image_file.#{image_type}" - node.override['openstack']['image']['upload_image_type']["#{image_type}_imageName"] = image_type.to_s - runner.converge(described_recipe) - end - it do - stub_command("glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep #{image_type}_imageName").and_return(false) - expect(chef_run).to upload_openstack_image_image("Image setup for #{image_type}_imageName").with( - image_url: "image_file.#{image_type}", - image_name: "#{image_type}_imageName", - image_type: image_type.to_s, - image_public: true - ) - end - end - end - - context 'uploads the raw and vdi images' do - cached(:chef_run) do - node.override['openstack']['image']['upload_images'] = %w(raw_imageName vdi_imageName) - node.override['openstack']['image']['upload_image']['raw_imageName'] = 'image_file.raw' - node.override['openstack']['image']['upload_image_type']['raw_imageName'] = 'raw' - node.override['openstack']['image']['upload_image']['vdi_imageName'] = 'image_file.vdi' - node.override['openstack']['image']['upload_image_type']['vdi_imageName'] = 'vdi' - runner.converge(described_recipe) - end - it do - stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep raw_imageName').and_return(false) - stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep vdi_imageName').and_return(false) - expect(chef_run).to upload_openstack_image_image('Image setup for raw_imageName').with( - image_url: 'image_file.raw', - image_name: 'raw_imageName', - image_type: 'raw', - image_public: true - ) - expect(chef_run).to upload_openstack_image_image('Image setup for vdi_imageName').with( - image_url: 'image_file.vdi', - image_name: 'vdi_imageName', - image_type: 'vdi', - image_public: true - ) - end - end - # TODO(MRV) Need to add provider method testers in here. - end -end diff --git a/cookbooks/openstack-image/spec/spec_helper.rb b/cookbooks/openstack-image/spec/spec_helper.rb deleted file mode 100644 index ebe4bd57..00000000 --- a/cookbooks/openstack-image/spec/spec_helper.rb +++ /dev/null @@ -1,249 +0,0 @@ -require 'chefspec' -require 'chefspec/berkshelf' -require 'chef/application' - -RSpec.configure do |config| - config.color = true - config.formatter = :documentation - config.log_level = :warn -end - -REDHAT_7 = { - platform: 'redhat', - version: '7', -}.freeze - -REDHAT_8 = { - platform: 'redhat', - version: '8', -}.freeze - -ALL_RHEL = [ - REDHAT_7, - REDHAT_8, -].freeze - -UBUNTU_OPTS = { - platform: 'ubuntu', - version: '18.04', -}.freeze - -# Helper methods -module Helpers - # Create an anchored regex to exactly match the entire line - # (name borrowed from grep --line-regexp) - # - # @param [String] str The whole line to match - # @return [Regexp] The anchored/escaped regular expression - def line_regexp(str) - /^#{Regexp.quote(str)}$/ - end -end - -shared_context 'image-stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:address_for) - .with('lo') - .and_return('127.0.1.1') - allow_any_instance_of(Chef::Recipe).to receive(:config_by_role) - .with('rabbitmq-server', 'queue') - .and_return( - 'host' => 'rabbit-host', 'port' => 'rabbit-port' - ) - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers) - .and_return '1.1.1.1:5672,2.2.2.2:5672' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'openstack_identity_bootstrap_token') - .and_return('bootstrap-token') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'openstack_vmware_secret_name') - .and_return 'vmware_secret_name' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'glance') - .and_return('db-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-image') - .and_return('glance-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'guest') - .and_return('mq-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return('admin-pass') - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('image') - .and_return('rabbit://guest:mypass@127.0.0.1:5672') - allow(Chef::Application).to receive(:fatal!) - stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list --id e1847f1a-01d2-4957-a067-b56085bf3781 | grep cirros').and_return('') - end -end - -shared_examples 'common-logging-recipe' do - it 'does not include logging recipe by default' do - expect(chef_run).not_to include_recipe('openstack-common::logging') - end - - it 'includes logging recipe if openstack/image/syslog/use attribute is true' do - node.override['openstack']['image']['syslog']['use'] = true - - expect(chef_run).to include_recipe('openstack-common::logging') - end -end - -shared_examples 'common-packages' do - it 'upgrades curl package' do - expect(chef_run).to upgrade_package 'curl' - end - - it 'upgrades glance package' do - expect(chef_run).to upgrade_package 'glance' - end - - it 'honors the platform name and option package overrides' do - node.override['openstack']['image']['platform']['package_overrides'] = '-o Dpkg::Options:: = \'--force-confold\' -o Dpkg::Options:: = \'--force-confdef\' --force-yes' - node.override['openstack']['image']['platform']['image_packages'] = ['my-glance'] - - expect(chef_run).to upgrade_package('my-glance').with(options: '-o Dpkg::Options:: = \'--force-confold\' -o Dpkg::Options:: = \'--force-confdef\' --force-yes') - end -end - -shared_examples 'image-lib-cache-directory' do - describe '/var/lib/glance/image-cache/' do - let(:dir) { chef_run.directory('/var/lib/glance/image-cache/') } - - it 'creates directory /var/lib/glance/image-cache' do - expect(chef_run).to create_directory(dir.name).with( - user: 'glance', - group: 'glance', - mode: 0o0755, - recursive: true - ) - end - end -end - -shared_examples 'glance-directory' do - describe '/etc/glance' do - let(:dir) { chef_run.directory('/etc/glance') } - - it 'creates directory /etc/glance' do - expect(chef_run).to create_directory(dir.name).with( - user: 'glance', - group: 'glance', - mode: 0o0700 - ) - end - end -end - -shared_examples 'custom template banner displayer' do - it 'shows the custom banner' do - node.override['openstack']['image']['custom_template_banner'] = 'custom_template_banner_value' - expect(chef_run).to render_file(file_name).with_content(/^custom_template_banner_value$/) - end -end - -shared_context 'endpoint-stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-image') - .and_return('admin_password_value') - end -end - -shared_context 'sql-stubs' do - before do - node.override['openstack']['db']['image']['username'] = 'db_username_value' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'glance') - .and_return('db_password_value') - allow_any_instance_of(Chef::Recipe).to receive(:db_uri) - .with('image', 'db_username_value', 'db_password_value') - .and_return('sql_connection_value') - end -end - -shared_examples 'syslog use' do - it 'shows log_config if syslog use is enabled' do - node.override['openstack']['image']['syslog']['use'] = true - expect(chef_run).to render_file(file.name).with_content(%r{^log_config = /etc/openstack/logging.conf$}) - end - - it 'shows log_file if syslog use is disabled' do - node.override['openstack']['image']['syslog']['use'] = false - expect(chef_run).to render_file(file.name).with_content(%r{^log_file = /var/log/glance/#{log_file_name}$}) - end -end - -shared_examples 'keystone attribute setter' do |version| - it 'sets the identity_uri value' do - expect(chef_run).to render_file(file.name).with_content(%r{^identity_uri = http://127.0.0.1:5000/$}) - end - - context 'auth version' do - it 'shows the version attribute if it is different from v3' do - node.override['openstack']['api']['auth']['version'] = 'v3.0' - expect(chef_run).to render_file(file.name).with_content(/^auth_version = v3.0$/) - end - end - - %w(project user).each do |attr| - it "sets the auth admin #{attr} attribute" do - node.override['openstack']["image-#{version}"]['conf']['keystone_authtoken']["admin_#{attr}"] = "service_#{attr}_value" - expect(chef_run).to render_file(file.name).with_content(/^admin_#{attr} = service_#{attr}_value$/) - end - end - - it 'sets the admin password attribute' do - expect(chef_run).to render_file(file.name).with_content(/^admin_password = admin_password_value$/) - end -end - -shared_examples 'messaging' do |version| - context 'messaging' do - before do - node.override['openstack']['image']['notification_driver'] = 'messaging' - end - - it 'sets the notifier_strategy attribute' do - node.override['openstack']["image-#{version}"]['conf']['DEFAULT']['notifier_strategy'] = 'default' - expect(chef_run).to render_file(file.name).with_content(/^notifier_strategy = default$/) - end - - context 'commonly named attributes' do - %w(notification_driver rpc_backend rpc_thread_pool_size - rpc_conn_pool_size rpc_response_timeout control_exchange).each do |attr| - it "sets the #{attr} attribute" do - node.override['openstack']["image-#{version}"]['conf']['DEFAULT'][attr] = "#{attr}_value" - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr} = #{attr}_value$/) - end - end - end - - context 'rabbitmq' do - before do - node.override['openstack']["image-#{version}"]['conf']['DEFAULT']['rpc_backend'] = 'rabbit' - node.override['openstack']["image-#{version}"]['conf']['oslo_messaging_rabbit']['rabbit_userid'] = 'rabbit_userid_value' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'rabbit_userid_value') - .and_return('rabbit_password_value') - end - - %w(host port userid).each do |attr| - it "sets the rabbitmq #{attr} attribute" do - node.override['openstack']["image-#{version}"]['conf']['oslo_messaging_rabbit']["rabbit_#{attr}"] = "rabbit_#{attr}_value" - expect(chef_run).to render_config_file(file_name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr} = rabbit_#{attr}_value$/) - end - end - - it 'sets the rabbitmq password' do - expect(chef_run).to render_config_file(file_name).with_section_content('oslo_messaging_rabbit', /^rabbit_password = mq-pass$/) - end - - it 'sets the rabbitmq vhost' do - node.override['openstack']["image-#{version}"]['conf']['oslo_messaging_rabbit']['rabbit_virtual_host'] = 'rabbit_vhost_value' - expect(chef_run).to render_config_file(file_name).with_section_content('oslo_messaging_rabbit', /^rabbit_virtual_host = rabbit_vhost_value$/) - end - end - end -end diff --git a/cookbooks/openstack-image/spec/swift_store-redhat_spec.rb b/cookbooks/openstack-image/spec/swift_store-redhat_spec.rb deleted file mode 100644 index 6e4d8721..00000000 --- a/cookbooks/openstack-image/spec/swift_store-redhat_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-image::swift_store' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - include_context 'image-stubs' - it do - expect(chef_run).to upgrade_package('openstack-swift') - end - end - end -end diff --git a/cookbooks/openstack-image/spec/swift_store_spec.rb b/cookbooks/openstack-image/spec/swift_store_spec.rb deleted file mode 100644 index dc128d11..00000000 --- a/cookbooks/openstack-image/spec/swift_store_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-image::swift_store' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - include_context 'image-stubs' - it do - expect(chef_run).to upgrade_package('python3-swift') - end - end -end From db68534747838df757a6e4f76357ab24259fde10 Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 12:17:18 +0400 Subject: [PATCH 5/9] cleanup in openstack network cookbook --- .../openstack-network/.delivery/project.toml | 9 -- cookbooks/openstack-network/.rubocop.yml | 4 - cookbooks/openstack-network/.zuul.yaml | 3 - cookbooks/openstack-network/Berksfile | 22 --- cookbooks/openstack-network/CONTRIBUTING.md | 36 ----- cookbooks/openstack-network/TESTING.md | 30 ---- .../spec/_bridge_config_example_spec.rb | 55 ------- .../spec/db_migration_spec.rb | 32 ----- .../spec/default-redhat_spec.rb | 44 ------ .../openstack-network/spec/default_spec.rb | 134 ------------------ .../spec/dhcp_agent-centos_spec.rb | 26 ---- .../openstack-network/spec/dhcp_agent_spec.rb | 90 ------------ .../spec/identity_registration_spec.rb | 77 ---------- .../spec/l3_agent-redhat_spec.rb | 28 ---- .../openstack-network/spec/l3_agent_spec.rb | 89 ------------ .../spec/metadata_agent-rhel_spec.rb | 30 ---- .../spec/metadata_agent_spec.rb | 67 --------- .../spec/metering_agent-rhel_spec.rb | 27 ---- .../spec/metering_agent_spec.rb | 56 -------- .../spec/ml2_linuxbridge-redhat_spec.rb | 54 ------- .../spec/ml2_linuxbridge_spec.rb | 74 ---------- .../spec/ml2_openvswitch_spec.rb | 36 ----- .../spec/openvswitch-rhel_spec.rb | 29 ---- .../spec/openvswitch_agent-rhel_spec.rb | 34 ----- .../spec/openvswitch_agent_spec.rb | 49 ------- .../spec/openvswitch_spec.rb | 34 ----- .../spec/plugin_config_spec.rb | 44 ------ .../spec/server-redhat_spec.rb | 30 ---- .../openstack-network/spec/server_spec.rb | 114 --------------- .../openstack-network/spec/spec_helper.rb | 70 --------- 30 files changed, 1427 deletions(-) delete mode 100644 cookbooks/openstack-network/.delivery/project.toml delete mode 100644 cookbooks/openstack-network/.rubocop.yml delete mode 100644 cookbooks/openstack-network/.zuul.yaml delete mode 100644 cookbooks/openstack-network/Berksfile delete mode 100644 cookbooks/openstack-network/CONTRIBUTING.md delete mode 100644 cookbooks/openstack-network/TESTING.md delete mode 100644 cookbooks/openstack-network/spec/_bridge_config_example_spec.rb delete mode 100644 cookbooks/openstack-network/spec/db_migration_spec.rb delete mode 100644 cookbooks/openstack-network/spec/default-redhat_spec.rb delete mode 100644 cookbooks/openstack-network/spec/default_spec.rb delete mode 100644 cookbooks/openstack-network/spec/dhcp_agent-centos_spec.rb delete mode 100644 cookbooks/openstack-network/spec/dhcp_agent_spec.rb delete mode 100644 cookbooks/openstack-network/spec/identity_registration_spec.rb delete mode 100644 cookbooks/openstack-network/spec/l3_agent-redhat_spec.rb delete mode 100644 cookbooks/openstack-network/spec/l3_agent_spec.rb delete mode 100644 cookbooks/openstack-network/spec/metadata_agent-rhel_spec.rb delete mode 100644 cookbooks/openstack-network/spec/metadata_agent_spec.rb delete mode 100644 cookbooks/openstack-network/spec/metering_agent-rhel_spec.rb delete mode 100644 cookbooks/openstack-network/spec/metering_agent_spec.rb delete mode 100644 cookbooks/openstack-network/spec/ml2_linuxbridge-redhat_spec.rb delete mode 100644 cookbooks/openstack-network/spec/ml2_linuxbridge_spec.rb delete mode 100644 cookbooks/openstack-network/spec/ml2_openvswitch_spec.rb delete mode 100644 cookbooks/openstack-network/spec/openvswitch-rhel_spec.rb delete mode 100644 cookbooks/openstack-network/spec/openvswitch_agent-rhel_spec.rb delete mode 100644 cookbooks/openstack-network/spec/openvswitch_agent_spec.rb delete mode 100644 cookbooks/openstack-network/spec/openvswitch_spec.rb delete mode 100644 cookbooks/openstack-network/spec/plugin_config_spec.rb delete mode 100644 cookbooks/openstack-network/spec/server-redhat_spec.rb delete mode 100644 cookbooks/openstack-network/spec/server_spec.rb delete mode 100644 cookbooks/openstack-network/spec/spec_helper.rb diff --git a/cookbooks/openstack-network/.delivery/project.toml b/cookbooks/openstack-network/.delivery/project.toml deleted file mode 100644 index 4066e559..00000000 --- a/cookbooks/openstack-network/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[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/cookbooks/openstack-network/.rubocop.yml b/cookbooks/openstack-network/.rubocop.yml deleted file mode 100644 index 389f2700..00000000 --- a/cookbooks/openstack-network/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -Chef/Modernize/FoodcriticComments: - Enabled: true -Chef/Style/CopyrightCommentFormat: - Enabled: true diff --git a/cookbooks/openstack-network/.zuul.yaml b/cookbooks/openstack-network/.zuul.yaml deleted file mode 100644 index f5786847..00000000 --- a/cookbooks/openstack-network/.zuul.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- project: - templates: - - openstack-chef-jobs diff --git a/cookbooks/openstack-network/Berksfile b/cookbooks/openstack-network/Berksfile deleted file mode 100644 index 5a774206..00000000 --- a/cookbooks/openstack-network/Berksfile +++ /dev/null @@ -1,22 +0,0 @@ -source 'https://supermarket.chef.io' - -solver :ruby, :required - -[ - %w(client dep), - %w(-common dep), - %w(-dns integration), - %w(-identity dep), - %w(-image integration), - %w(-integration-test integration), - %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}", group: group - else - cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group - end -end - -metadata diff --git a/cookbooks/openstack-network/CONTRIBUTING.md b/cookbooks/openstack-network/CONTRIBUTING.md deleted file mode 100644 index bb03231f..00000000 --- a/cookbooks/openstack-network/CONTRIBUTING.md +++ /dev/null @@ -1,36 +0,0 @@ -Contributing -============ - -How To Get Started ------------------- - -If you would like to contribute to the development of OpenStack Chef Cookbooks, -you must follow the steps in this page: - - http://docs.openstack.org/infra/manual/developers.html - -Gerrit Workflow ---------------- - -Once those steps have been completed, changes to OpenStack -should be submitted for review via the Gerrit tool, following -the workflow documented at: - - http://docs.openstack.org/infra/manual/developers.html#development-workflow - -Pull requests submitted through GitHub will be ignored. - -Bugs ----- - -Bugs should be filed on Launchpad, not GitHub: - - https://bugs.launchpad.net/openstack-chef - -Contacts --------- - -Mailing list: groups.google.com/group/opscode-chef-openstack -IRC: #openstack-chef is our channel on irc.oftc.net -Wiki: https://wiki.openstack.org/wiki/Chef/GettingStarted and https://docs.getchef.com/openstack.html -Twitter: @chefopenstack diff --git a/cookbooks/openstack-network/TESTING.md b/cookbooks/openstack-network/TESTING.md deleted file mode 100644 index 1dd45c5a..00000000 --- a/cookbooks/openstack-network/TESTING.md +++ /dev/null @@ -1,30 +0,0 @@ -# Testing the Cookbook # - -This cookbook uses [chefdk](https://downloads.chef.io/chef-dk/) and [berkshelf](http://berkshelf.com/) to isolate dependencies. Make sure you have chefdk and the header files for `gecode` installed before continuing. Make sure that you're using gecode version 3. More info [here](https://github.com/opscode/dep-selector-libgecode/tree/0bad63fea305ede624c58506423ced697dd2545e#using-a-system-gecode-instead). For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the [openstack-chef-repo](https://github.com/openstack/openstack-chef-repo). - -We have three test suites which you can run either, individually (there are three rake tasks): - - $ chef exec rake lint - $ chef exec rake style - $ chef exec rake unit - -or altogether: - - $ chef exec rake - -The `rake` tasks will take care of installing the needed cookbooks with `berkshelf`. - -## Rubocop ## - -[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits. - -## Foodcritic ## - -[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules: - -* [FC003](http://acrmp.github.io/foodcritic/#FC003) These cookbooks are not intended for Chef Solo. -* [FC023](http://acrmp.github.io/foodcritic/#FC023) Prefer conditional attributes. - -## Chefspec - -[ChefSpec](https://github.com/sethvargo/chefspec) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers. diff --git a/cookbooks/openstack-network/spec/_bridge_config_example_spec.rb b/cookbooks/openstack-network/spec/_bridge_config_example_spec.rb deleted file mode 100644 index 33fd1c80..00000000 --- a/cookbooks/openstack-network/spec/_bridge_config_example_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::_bridge_config_example' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - before do - %w(eth-ext eth-vlan eth-tun).each do |eth| - stub_command("ip link show | grep #{eth}") - end - allow_any_instance_of(Chef::Recipe).to receive(:address_for) - .with('eth-tun') - .and_return('1.2.3.4') - end - - describe 'create ovs external network bridge and port' do - let(:cmd_br) { 'ovs-vsctl --may-exist add-br br-ex' } - let(:cmd_port) { 'ovs-vsctl --may-exist add-port br-ex eth-ext' } - let(:name) { 'create external network bridge' } - - it 'adds external network bridge' do - expect(chef_run).to run_execute(name).with(command: cmd_br) - end - it 'adds external network bridge port' do - expect(chef_run).to run_execute("#{name} port").with(command: cmd_port) - end - end - - describe 'create vlan network bridge and port' do - let(:cmd_br) { 'ovs-vsctl --may-exist add-br br-vlan' } - let(:cmd_port) { 'ovs-vsctl --may-exist add-port br-vlan eth-vlan' } - let(:name) { 'create vlan network bridge' } - - it 'adds vlan network bridge' do - expect(chef_run).to run_execute(name).with(command: cmd_br) - end - it 'adds vlan network bridge port' do - expect(chef_run).to run_execute("#{name} port").with(command: cmd_port) - end - end - - describe 'create tunnel network bridge' do - let(:cmd_br) { 'ovs-vsctl --may-exist add-br br-tun' } - let(:name) { 'create tunnel network bridge' } - - it 'adds tunnel network bridge' do - expect(chef_run).to run_execute(name).with(command: cmd_br) - end - end - end -end diff --git a/cookbooks/openstack-network/spec/db_migration_spec.rb b/cookbooks/openstack-network/spec/db_migration_spec.rb deleted file mode 100644 index a56f3876..00000000 --- a/cookbooks/openstack-network/spec/db_migration_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::db_migration' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - runner.converge(described_recipe) - end - - it 'uses db upgrade head with default timeout for neutron-server' do - expect(chef_run).to run_execute('migrate network database').with( - command: "neutron-db-manage --config-file /etc/neutron/neutron.conf upgrade head\n", - timeout: 3600 - ) - end - - context 'uses db upgrade head with timeout override for neutron-server' do - cached(:chef_run) do - node.override['openstack']['network']['dbsync_timeout'] = 1234 - runner.converge(described_recipe) - end - it do - expect(chef_run).to run_execute('migrate network database').with( - command: "neutron-db-manage --config-file /etc/neutron/neutron.conf upgrade head\n", - timeout: 1234 - ) - end - end - end -end diff --git a/cookbooks/openstack-network/spec/default-redhat_spec.rb b/cookbooks/openstack-network/spec/default-redhat_spec.rb deleted file mode 100644 index e244759c..00000000 --- a/cookbooks/openstack-network/spec/default-redhat_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - pkgs = - %w( - ebtables - iproute - openstack-neutron - openstack-neutron-ml2 - ) - it do - expect(chef_run).to upgrade_package(pkgs) - end - case p - when REDHAT_7 - it do - expect(chef_run).to upgrade_package('MySQL-python') - end - when REDHAT_8 - it do - expect(chef_run).to upgrade_package('python3-PyMySQL') - end - end - it do - expect(chef_run).to create_cookbook_file('/usr/bin/neutron-enable-bridge-firewall.sh').with( - source: 'neutron-enable-bridge-firewall.sh', - owner: 'root', - group: 'wheel', - mode: '0755' - ) - end - end - end -end diff --git a/cookbooks/openstack-network/spec/default_spec.rb b/cookbooks/openstack-network/spec/default_spec.rb deleted file mode 100644 index 776bc6b5..00000000 --- a/cookbooks/openstack-network/spec/default_spec.rb +++ /dev/null @@ -1,134 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - packages = %w(neutron-common python3-neutron) - it do - expect(chef_run).to upgrade_package(packages) - end - - it do - expect(chef_run).to upgrade_package('python3-mysqldb') - end - - it do - expect(chef_run).to_not create_cookbook_file('/usr/bin/neutron-enable-bridge-firewall.sh') - end - - describe '/etc/neutron/rootwrap.conf' do - it do - expect(chef_run).to create_template('/etc/neutron/rootwrap.conf').with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - owner: 'neutron', - group: 'neutron', - mode: '644' - ) - end - let(:file) { chef_run.template('/etc/neutron/rootwrap.conf') } - [ - %r{^filters_path = /etc/neutron/rootwrap\.d,/usr/share/neutron/rootwrap$}, - %r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$}, - /^use_syslog = false$/, - /^syslog_log_facility = syslog$/, - /^syslog_log_level = ERROR$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content('DEFAULT', line) - end - end - end - - describe '/etc/neutron/neutron.conf' do - it do - expect(chef_run).to create_template('/etc/neutron/neutron.conf').with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - owner: 'neutron', - group: 'neutron', - mode: '640', - sensitive: true - ) - end - let(:file) { chef_run.template('/etc/neutron/neutron.conf') } - [ - %r{^log_dir = /var/log/neutron$}, - /^control_exchange = neutron$/, - /^core_plugin = ml2$/, - /^bind_host = 127\.0\.0\.1$/, - /^bind_port = 9696$/, - %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - - [ - %r{^root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf$}, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name).with_section_content('agent', line) - end - end - [ - /^auth_type = password$/, - /^region_name = RegionOne$/, - /^username = neutron$/, - /^user_domain_name = Default/, - /^project_domain_name = Default/, - /^project_name = service$/, - /^auth_version = v3$/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^password = neutron-pass$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', line) - end - end - [ - /^auth_type = password$/, - /^region_name = RegionOne$/, - /^username = nova$/, - /^user_domain_name = Default/, - /^project_name = service$/, - /^project_domain_name = Default/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^password = nova-pass$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name).with_section_content('nova', line) - end - end - [ - %r{^lock_path = /var/lib/neutron/lock$}, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', line) - end - end - [ - %(connection = mysql+pymysql://neutron:neutron@127.0.0.1:3306/neutron?charset=utf8), - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name).with_section_content('database', line) - end - end - end - it do - allow(chef_run).to receive(:"node['openstack']['network']['conf_secrets']").and_return(nil) - end - it do - expect(chef_run).to run_ruby_block("delete all attributes in node['openstack']['network']['conf_secrets']") - end - end -end diff --git a/cookbooks/openstack-network/spec/dhcp_agent-centos_spec.rb b/cookbooks/openstack-network/spec/dhcp_agent-centos_spec.rb deleted file mode 100644 index e4c230b5..00000000 --- a/cookbooks/openstack-network/spec/dhcp_agent-centos_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::dhcp_agent' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - runner.converge(described_recipe) - end - - let(:file_cache_path) { Chef::Config[:file_cache_path] } - - include_context 'neutron-stubs' - - it do - expect(chef_run).to upgrade_package(%w(openstack-neutron iproute)) - end - - it do - expect(chef_run).to upgrade_package('dnsmasq') - end - end - end -end diff --git a/cookbooks/openstack-network/spec/dhcp_agent_spec.rb b/cookbooks/openstack-network/spec/dhcp_agent_spec.rb deleted file mode 100644 index 292c69a7..00000000 --- a/cookbooks/openstack-network/spec/dhcp_agent_spec.rb +++ /dev/null @@ -1,90 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::dhcp_agent' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - runner.converge(described_recipe) - end - include_context 'neutron-stubs' - - it do - expect(chef_run).to include_recipe('openstack-network') - end - - %w( - template[/etc/neutron/neutron.conf] - template[/etc/neutron/dnsmasq.conf] - template[/etc/neutron/dhcp_agent.ini] - ).each do |resource| - it do - expect(chef_run.service('neutron-dhcp-agent')).to subscribe_to(resource).delayed - end - end - - it do - expect(chef_run).to_not upgrade_rpm_package('dnsmasq') - end - - it do - expect(chef_run).to upgrade_package 'neutron-dhcp-agent' - end - - it do - expect(chef_run).to enable_service('neutron-dhcp-agent').with( - service_name: 'neutron-dhcp-agent', - supports: { - restart: true, - status: true, - } - ) - end - - it do - expect(chef_run).to start_service 'neutron-dhcp-agent' - end - describe 'dhcp_agent.ini' do - let(:file) { chef_run.template('/etc/neutron/dhcp_agent.ini') } - - it 'creates dhcp_agent.ini' do - expect(chef_run).to create_template(file.name).with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - user: 'neutron', - group: 'neutron', - mode: '644' - ) - end - [ - /^interface_driver = openvswitch$/, - %r{^dnsmasq_config_file = /etc/neutron/dnsmasq.conf$}, - ].each do |line| - it do - expect(chef_run).to render_config_file('/etc/neutron/dhcp_agent.ini').with_section_content('DEFAULT', line) - end - end - end - describe '/etc/neutron/dnsmasq.conf' do - let(:file) { chef_run.template('/etc/neutron/dnsmasq.conf') } - - it 'creates dnsmasq.conf' do - expect(chef_run).to create_template(file.name).with( - source: 'dnsmasq.conf.erb', - user: 'neutron', - group: 'neutron', - mode: '644' - ) - end - [ - /^server=8.8.8.8$/, - /^server=208.67.222.222$/, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/neutron/dnsmasq.conf').with_content(line) - end - end - end - end -end diff --git a/cookbooks/openstack-network/spec/identity_registration_spec.rb b/cookbooks/openstack-network/spec/identity_registration_spec.rb deleted file mode 100644 index ad4acecf..00000000 --- a/cookbooks/openstack-network/spec/identity_registration_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::identity_registration' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - connection_params = { - openstack_auth_url: 'http://127.0.0.1:5000/v3', - openstack_username: 'admin', - openstack_api_key: 'admin-pass', - openstack_project_name: 'admin', - openstack_domain_name: 'default', - # openstack_endpoint_type: 'internalURL', - } - service_name = 'neutron' - service_type = 'network' - service_user = 'neutron' - url = 'http://127.0.0.1:9696' - region = 'RegionOne' - project_name = 'service' - role_name = 'admin' - password = 'neutron-pass' - domain_name = 'Default' - - it "registers #{project_name} Project" do - expect(chef_run).to create_openstack_project( - project_name - ).with( - connection_params: connection_params - ) - end - - it "registers #{service_name} service" do - expect(chef_run).to create_openstack_service( - service_name - ).with( - connection_params: connection_params, - type: service_type - ) - end - - context "registers #{service_name} endpoint" do - %w(internal public).each do |interface| - it "#{interface} endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - service_type - ).with( - service_name: service_name, - # interface: interface, - url: url, - region: region, - connection_params: connection_params - ) - end - end - end - - it 'registers service user' do - expect(chef_run).to create_openstack_user( - service_user - ).with( - domain_name: domain_name, - project_name: project_name, - role_name: role_name, - password: password, - connection_params: connection_params - ) - end - end -end diff --git a/cookbooks/openstack-network/spec/l3_agent-redhat_spec.rb b/cookbooks/openstack-network/spec/l3_agent-redhat_spec.rb deleted file mode 100644 index cfdb2d28..00000000 --- a/cookbooks/openstack-network/spec/l3_agent-redhat_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::l3_agent' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - stub_command('ovs-vsctl br-exists br-ex').and_return(false) - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - pkgs = - %w( - iproute - keepalived - openstack-neutron - radvd - ) - it do - expect(chef_run).to upgrade_package(pkgs) - end - end - end -end diff --git a/cookbooks/openstack-network/spec/l3_agent_spec.rb b/cookbooks/openstack-network/spec/l3_agent_spec.rb deleted file mode 100644 index a87b8bf0..00000000 --- a/cookbooks/openstack-network/spec/l3_agent_spec.rb +++ /dev/null @@ -1,89 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::l3_agent' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['network_l3']['external_network_bridge_interface'] = 'enp0s8' - runner.converge(described_recipe) - end - describe 'recipe' do - include_context 'neutron-stubs' - - it do - expect(chef_run).to enable_service('neutron-l3-agent').with( - service_name: 'neutron-l3-agent', - supports: { - status: true, - restart: true, - } - ) - end - - it do - expect(chef_run).to start_service('neutron-l3-agent') - end - - it do - expect(chef_run.service('neutron-l3-agent')).to \ - subscribe_to('template[/etc/neutron/neutron.conf]').on(:restart) - end - - pkgs = - %w( - keepalived - neutron-l3-agent - radvd - ) - it do - expect(chef_run).to upgrade_package(pkgs) - end - - describe 'l3_agent.ini' do - let(:file) { chef_run.template('/etc/neutron/l3_agent.ini') } - - it 'creates l3_agent.ini' do - expect(chef_run).to create_template(file.name).with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - user: 'neutron', - group: 'neutron', - mode: '640' - ) - end - - [ - /^interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver$/, - ].each do |line| - it do - expect(chef_run).to render_config_file('/etc/neutron/l3_agent.ini').with_section_content('DEFAULT', line) - end - end - - context 'template contents' do - cached(:chef_run) do - node.override['openstack']['network_l3']['conf']['DEFAULT']['external_network_bridge'] = 'network_l3_external_network_bridge_value' - runner.converge(described_recipe) - end - it_behaves_like 'common network attributes displayer', 'l3' do - let(:file_name) { file.name } - end - - it 'displays the external_network_bridge l3 attribute' do - stub_command('ovs-vsctl br-exists network_l3_external_network_bridge_value').and_return(false) - expect(chef_run).to render_config_file(file.name) - .with_section_content( - 'DEFAULT', - /^external_network_bridge = network_l3_external_network_bridge_value$/ - ) - end - end - - it do - expect(file).to notify('service[neutron-l3-agent]').to(:restart).delayed - end - end - end - end -end diff --git a/cookbooks/openstack-network/spec/metadata_agent-rhel_spec.rb b/cookbooks/openstack-network/spec/metadata_agent-rhel_spec.rb deleted file mode 100644 index 99b5d473..00000000 --- a/cookbooks/openstack-network/spec/metadata_agent-rhel_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::metadata_agent' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - it do - expect(chef_run).to enable_service('neutron-metadata-agent').with( - service_name: 'neutron-metadata-agent', - supports: { - status: true, - restart: true, - } - ) - end - - it do - expect(chef_run).to start_service('neutron-metadata-agent') - end - end - end -end diff --git a/cookbooks/openstack-network/spec/metadata_agent_spec.rb b/cookbooks/openstack-network/spec/metadata_agent_spec.rb deleted file mode 100644 index ef2a536d..00000000 --- a/cookbooks/openstack-network/spec/metadata_agent_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::metadata_agent' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - it do - expect(chef_run).to upgrade_package 'neutron-metadata-agent' - end - - it do - expect(chef_run).to enable_service('neutron-metadata-agent').with( - service_name: 'neutron-metadata-agent', - supports: { - status: true, - restart: true, - } - ) - end - - it do - expect(chef_run).to start_service('neutron-metadata-agent') - end - - %w(template[/etc/neutron/neutron.conf] template[/etc/neutron/metadata_agent.ini]).each do |resource| - it do - expect(chef_run.service('neutron-metadata-agent')).to subscribe_to(resource).delayed - end - end - - describe 'metadata_agent.ini' do - let(:file) { chef_run.template('/etc/neutron/metadata_agent.ini') } - - it 'creates metadata_agent.ini' do - expect(chef_run).to create_template(file.name).with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - user: 'neutron', - group: 'neutron', - mode: '644', - sensitive: true - ) - end - - context 'template contents' do - [ - /^metadata_proxy_shared_secret = metadata-secret$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - end - end - it do - expect(chef_run).to run_ruby_block('delete all attributes in '\ - "node['openstack']['network_metadata']['conf_secrets']") - end - end -end diff --git a/cookbooks/openstack-network/spec/metering_agent-rhel_spec.rb b/cookbooks/openstack-network/spec/metering_agent-rhel_spec.rb deleted file mode 100644 index 2bbbd85d..00000000 --- a/cookbooks/openstack-network/spec/metering_agent-rhel_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::metering_agent' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - it do - expect(chef_run).to upgrade_package('neutron-metering-agent') - end - - it do - expect(chef_run).to enable_service('neutron-metering-agent').with( - service_name: 'neutron-metering-agent', - supports: { - status: true, - restart: true, - } - ) - end - end -end diff --git a/cookbooks/openstack-network/spec/metering_agent_spec.rb b/cookbooks/openstack-network/spec/metering_agent_spec.rb deleted file mode 100644 index fcdc961e..00000000 --- a/cookbooks/openstack-network/spec/metering_agent_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::metering_agent' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - it do - expect(chef_run).to upgrade_package('neutron-metering-agent') - end - - describe 'metering_agent.ini' do - let(:file) { chef_run.template('/etc/neutron/metering_agent.ini') } - it do - expect(chef_run).to create_template(file.name).with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - user: 'neutron', - group: 'neutron', - mode: '640' - ) - end - - it do - [ - /^interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver$/, - /^driver = neutron.services.metering.drivers.iptables.iptables_driver.IptablesMeteringDriver$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - end - it do - expect(chef_run).to enable_service('neutron-metering-agent').with( - service_name: 'neutron-metering-agent', - supports: { - status: true, - restart: true, - } - ) - end - it do - expect(chef_run).to start_service('neutron-metering-agent') - end - %w(template[/etc/neutron/neutron.conf] template[/etc/neutron/metering_agent.ini]).each do |resource| - it do - expect(chef_run.service('neutron-metering-agent')).to subscribe_to(resource).delayed - end - end - end -end diff --git a/cookbooks/openstack-network/spec/ml2_linuxbridge-redhat_spec.rb b/cookbooks/openstack-network/spec/ml2_linuxbridge-redhat_spec.rb deleted file mode 100644 index 87cc0057..00000000 --- a/cookbooks/openstack-network/spec/ml2_linuxbridge-redhat_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::ml2_linuxbridge' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['network']['plugins']['linuxbridge']['path'] = '/etc/neutron/plugins/ml2' - node.override['openstack']['network']['plugins']['linuxbridge']['filename'] = 'linuxbridge_agent.ini' - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - it 'creates the /etc/neutron/plugins/ml2 agent directory' do - expect(chef_run).to create_directory('/etc/neutron/plugins/ml2').with( - owner: 'neutron', - group: 'neutron', - mode: '700' - ) - end - it do - expect(chef_run).to include_recipe('openstack-network::plugin_config') - end - - describe '/etc/neutron/plugins/ml2/linuxbridge_agent.ini' do - let(:file) do - chef_run.template('/etc/neutron/plugins/ml2/linuxbridge_agent.ini') - end - [ - /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content('securitygroup', line) - end - end - end - - it do - expect(chef_run).to upgrade_package(%w(openstack-neutron-linuxbridge iproute)) - end - - it do - expect(chef_run).to enable_service('neutron-linuxbridge-agent') - end - it do - service = chef_run.service('neutron-linuxbridge-agent') - expect(service).to(subscribe_to('template[/etc/neutron/neutron.conf]').on(:restart).delayed) && subscribe_to('template[/etc/neutron/plugins/ml2/linuxbridge_agent.ini]').on(:restart).delayed - end - end - end -end diff --git a/cookbooks/openstack-network/spec/ml2_linuxbridge_spec.rb b/cookbooks/openstack-network/spec/ml2_linuxbridge_spec.rb deleted file mode 100644 index fe6c2d39..00000000 --- a/cookbooks/openstack-network/spec/ml2_linuxbridge_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -# pkg upgrade - -# service - -# Encoding: utf-8 -require_relative 'spec_helper' - -describe 'openstack-network::ml2_linuxbridge' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - node.override['openstack']['network']['plugins']['linuxbridge']['path'] = '/etc/neutron/plugins/linuxbridge' - node.override['openstack']['network']['plugins']['linuxbridge']['filename'] = 'linuxbridge_conf.ini' - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - it do - expect(chef_run).to create_directory('/etc/neutron/plugins/linuxbridge').with( - owner: 'neutron', - group: 'neutron', - mode: '700' - ) - end - - it do - expect(chef_run).to include_recipe('openstack-network::plugin_config') - end - - describe '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini' do - let(:file) do - chef_run.template('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini') - end - - [ - /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/, - ].each do |line| - it "[securitygroup] #{line}" do - expect(chef_run).to render_config_file(file.name).with_section_content('securitygroup', line) - end - end - end - - it do - expect(chef_run).to upgrade_package 'neutron-linuxbridge-agent' - end - - it do - expect(chef_run).to enable_service('neutron-plugin-linuxbridge-agent').with( - service_name: 'neutron-linuxbridge-agent', - supports: { - status: true, - restart: true, - } - ) - end - - it do - expect(chef_run).to start_service('neutron-plugin-linuxbridge-agent') - end - - %w( - template[/etc/neutron/neutron.conf] - template[/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini] - ).each do |resource| - it do - expect(chef_run.service('neutron-plugin-linuxbridge-agent')).to subscribe_to(resource).delayed - end - end - end -end diff --git a/cookbooks/openstack-network/spec/ml2_openvswitch_spec.rb b/cookbooks/openstack-network/spec/ml2_openvswitch_spec.rb deleted file mode 100644 index 99127cd7..00000000 --- a/cookbooks/openstack-network/spec/ml2_openvswitch_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# pkg upgrade - -# service - -# Encoding: utf-8 -require_relative 'spec_helper' - -describe 'openstack-network::ml2_openvswitch' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe, 'openstack-network::plugin_config') - end - - include_context 'neutron-stubs' - - it do - expect(chef_run).to include_recipe('openstack-network::ml2_core_plugin') - end - - describe '/etc/neutron/plugins/ml2/openvswitch_agent.ini' do - let(:file) do - chef_run.template('/etc/neutron/plugins/ml2/openvswitch_agent.ini') - end - - [ - /^integration_bridge = br-int$/, - ].each do |line| - it do - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - end - end -end diff --git a/cookbooks/openstack-network/spec/openvswitch-rhel_spec.rb b/cookbooks/openstack-network/spec/openvswitch-rhel_spec.rb deleted file mode 100644 index 5abf6754..00000000 --- a/cookbooks/openstack-network/spec/openvswitch-rhel_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::openvswitch' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - it do - expect(chef_run).to upgrade_package 'openvswitch' - end - - it do - expect(chef_run).to enable_service('neutron-openvswitch-switch').with( - service_name: 'openvswitch', - supports: { - status: true, - restart: true, - } - ) - end - end - end - end -end diff --git a/cookbooks/openstack-network/spec/openvswitch_agent-rhel_spec.rb b/cookbooks/openstack-network/spec/openvswitch_agent-rhel_spec.rb deleted file mode 100644 index 4211c01c..00000000 --- a/cookbooks/openstack-network/spec/openvswitch_agent-rhel_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::openvswitch_agent' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['network']['openvswitch']['integration_bridge'] = 'br-int' - runner.converge(described_recipe) - end - - include_context 'neutron-stubs' - - before do - stub_command('ovs-vsctl --may-exist add-br br-int') - end - - it do - expect(chef_run).to upgrade_package %w(openstack-neutron-openvswitch iproute) - end - - it do - expect(chef_run).to enable_service('neutron-openvswitch-agent').with( - service_name: 'neutron-openvswitch-agent', - supports: { - status: true, - restart: true, - } - ) - end - end - end -end diff --git a/cookbooks/openstack-network/spec/openvswitch_agent_spec.rb b/cookbooks/openstack-network/spec/openvswitch_agent_spec.rb deleted file mode 100644 index e743991a..00000000 --- a/cookbooks/openstack-network/spec/openvswitch_agent_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::openvswitch_agent' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['network']['openvswitch']['integration_bridge'] = 'br-int' - runner.converge(described_recipe, 'openstack-network::plugin_config') - end - - include_context 'neutron-stubs' - - before do - stub_command('ovs-vsctl --may-exist add-br br-int') - end - - it do - expect(chef_run).to upgrade_package 'neutron-openvswitch-agent' - end - - it do - expect(chef_run).to run_execute('create integration network bridge') - .with(command: 'ovs-vsctl --may-exist add-br br-int') - end - - it do - expect(chef_run).to enable_service('neutron-openvswitch-agent').with( - service_name: 'neutron-openvswitch-agent', - supports: { - status: true, - restart: true, - } - ) - end - - it do - expect(chef_run).to start_service 'neutron-openvswitch-agent' - end - %w( - template[/etc/neutron/neutron.conf] - template[/etc/neutron/plugins/ml2/openvswitch_agent.ini] - ).each do |t| - it t do - expect(chef_run.service('neutron-openvswitch-agent')).to subscribe_to(t).on(:restart) - end - end - end -end diff --git a/cookbooks/openstack-network/spec/openvswitch_spec.rb b/cookbooks/openstack-network/spec/openvswitch_spec.rb deleted file mode 100644 index f34a9cd0..00000000 --- a/cookbooks/openstack-network/spec/openvswitch_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::openvswitch' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe, 'openstack-network::plugin_config') - end - - it do - expect(chef_run).to upgrade_package %w(openvswitch-switch bridge-utils) - end - - it do - expect(chef_run).to enable_service('neutron-openvswitch-switch').with( - service_name: 'openvswitch-switch', - supports: { - status: true, - restart: true, - } - ) - end - - it do - expect(chef_run).to start_service 'neutron-openvswitch-switch' - end - - it do - expect(chef_run.service('neutron-openvswitch-switch')).to \ - subscribe_to('template[/etc/neutron/plugins/ml2/openvswitch_agent.ini]').on(:restart) - end - end -end diff --git a/cookbooks/openstack-network/spec/plugin_config_spec.rb b/cookbooks/openstack-network/spec/plugin_config_spec.rb deleted file mode 100644 index 035d50c9..00000000 --- a/cookbooks/openstack-network/spec/plugin_config_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::plugin_config' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['network']['plugins']['ml2'].tap do |ml2| - ml2['path'] = '/etc/neutron/more_plugins' - ml2['filename'] = 'ml2_conf.ini' - ml2['conf'].tap do |conf| - conf['section']['key'] = 'value' - end - end - node.override['openstack']['network']['plugins']['openvswitch'].tap do |ovs| - ovs['path'] = '/etc/neutron/plugins/' - ovs['filename'] = 'openvswitch_conf.ini' - ovs['conf'].tap do |conf| - conf['section']['key'] = 'value' - end - end - runner.converge(described_recipe) - end - - %w(/etc/neutron/more_plugins /etc/neutron/plugins/).each do |dir| - it do - expect(chef_run).to create_directory(dir) - .with( - recursive: true, - owner: 'neutron', - group: 'neutron', - mode: '700' - ) - end - - %w(ml2_conf.ini openvswitch_conf.ini).each do |conf| - let(:file) { chef_run.template(File.join(dir, conf)) } - it do - expect(chef_run).to render_config_file(file.name).with_section_content('section', 'key = value') - end - end - end - end -end diff --git a/cookbooks/openstack-network/spec/server-redhat_spec.rb b/cookbooks/openstack-network/spec/server-redhat_spec.rb deleted file mode 100644 index 01b25583..00000000 --- a/cookbooks/openstack-network/spec/server-redhat_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::server' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['compute']['network']['service_type'] = 'neutron' - node.override['openstack']['network']['plugins']['ml2']['path'] = '/etc/neutron/plugins/ml2' - node.override['openstack']['network']['plugins']['ml2']['filename'] = 'openvswitch_agent.ini' - runner.converge(described_recipe) - end - include_context 'neutron-stubs' - - it do - expect(chef_run).to upgrade_package %w(ebtables iproute openstack-neutron openstack-neutron-ml2) - end - - it do - expect(chef_run).to enable_service 'neutron-server' - end - - it 'does not upgrade openvswitch package' do - expect(chef_run).not_to upgrade_package 'openvswitch' - expect(chef_run).not_to enable_service 'neutron-openvswitch-agent' - end - end - end -end diff --git a/cookbooks/openstack-network/spec/server_spec.rb b/cookbooks/openstack-network/spec/server_spec.rb deleted file mode 100644 index f37bb417..00000000 --- a/cookbooks/openstack-network/spec/server_spec.rb +++ /dev/null @@ -1,114 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-network::server' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge('openstack-network::ml2_core_plugin', described_recipe) - end - include_context 'neutron-stubs' - - describe 'package and services' do - it do - expect(chef_run).to upgrade_package %w(neutron-server) - end - - context 'allows overriding package names' do - cust_pkgs = %w(my-neutron my-other-neutron) - cached(:chef_run) do - node.override['openstack']['network']['platform']['neutron_server_packages'] = cust_pkgs - runner.converge('openstack-network::ml2_core_plugin', described_recipe) - end - it do - expect(chef_run).to upgrade_package(cust_pkgs) - end - end - - it do - expect(chef_run).to enable_service('neutron-server').with( - service_name: 'neutron-server', - supports: { - status: true, - restart: true, - } - ) - end - - it do - expect(chef_run).to start_service 'neutron-server' - end - - let(:neutron_service) { chef_run.service('neutron-server') } - - it do - expect(neutron_service).to subscribe_to('template[/etc/neutron/neutron.conf]').on(:restart).delayed - end - - it do - expect(neutron_service).to_not subscribe_to('remote_file[/etc/neutron/policy.json]').on(:restart).delayed - end - - context 'set policyfile_url' do - cached(:chef_run) do - node.override['openstack']['network']['policyfile_url'] = 'http://www.someurl.com' - runner.converge('openstack-network::ml2_core_plugin', described_recipe) - end - it do - expect(neutron_service).to subscribe_to('remote_file[/etc/neutron/policy.json]').on(:restart).delayed - end - end - - context 'allows overriding service names' do - cached(:chef_run) do - node.override['openstack']['network']['platform']['neutron_server_service'] = 'my-neutron-server' - runner.converge('openstack-network::ml2_core_plugin', described_recipe) - end - it do - expect(chef_run).to enable_service('neutron-server').with( - service_name: 'my-neutron-server' - ) - end - end - - context 'allows overriding package options' do - cust_opts = ['-o', 'Dpkg::Options::=--force-confold', '-o', 'Dpkg::Options::=--force-confdef', '--force-yes'] - cached(:chef_run) do - node.override['openstack']['network']['platform']['package_overrides'] = cust_opts - runner.converge('openstack-network::ml2_core_plugin', described_recipe) - end - it do - expect(chef_run).to upgrade_package('neutron-server').with(options: cust_opts) - end - end - - it 'does not upgrade openvswitch package or the agent' do - expect(chef_run).not_to upgrade_package 'openvswitch' - expect(chef_run).not_to upgrade_package 'neutron-plugin-openvswitch-agent' - expect(chef_run).not_to enable_service 'neutron-plugin-openvswitch-agent' - end - end - - describe '/etc/default/neutron-server' do - let(:file) { chef_run.template('/etc/default/neutron-server') } - - it 'creates /etc/default/neutron-server' do - expect(chef_run).to create_template(file.name).with( - source: 'neutron-server.erb', - user: 'root', - group: 'root', - mode: '644', - variables: { - core_plugin_config: '/etc/neutron/plugins/ml2/ml2_conf.ini', - } - ) - end - - it do - expect(chef_run).to render_file(file.name).with_content( - %r{^NEUTRON_PLUGIN_CONFIG="/etc/neutron/plugins/ml2/ml2_conf.ini"$} - ) - end - end - end -end diff --git a/cookbooks/openstack-network/spec/spec_helper.rb b/cookbooks/openstack-network/spec/spec_helper.rb deleted file mode 100644 index e38ea61e..00000000 --- a/cookbooks/openstack-network/spec/spec_helper.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'chefspec' -require 'pry' -require 'chefspec/berkshelf' -require 'chef/application' - -RSpec.configure do |config| - config.color = true - config.formatter = :documentation - config.log_level = :warn -end - -REDHAT_7 = { - platform: 'redhat', - version: '7', -}.freeze - -REDHAT_8 = { - platform: 'redhat', - version: '8', -}.freeze - -ALL_RHEL = [ - REDHAT_7, - REDHAT_8, -].freeze - -UBUNTU_OPTS = { - platform: 'ubuntu', - version: '18.04', -}.freeze - -shared_context 'neutron-stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'openstack_identity_bootstrap_token') - .and_return('bootstrap-token') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'neutron_metadata_secret') - .and_return('metadata-secret') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', anything) - .and_return('neutron') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-network') - .and_return('neutron-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'guest') - .and_return('mq-pass') - allow(Chef::Application).to receive(:fatal!) - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-compute') - .and_return('nova-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return('admin-pass') - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('network') - .and_return('rabbit://guest:mypass@127.0.0.1:5672') - end - - shared_examples 'common network attributes displayer' do |plugin| - cached(:chef_run) do - node.override['openstack']["network_#{plugin}"]['conf']['DEFAULT']['interface_driver'] = 'network_interface_driver_value' - runner.converge(described_recipe) - end - it 'displays the interface_driver common attribute' do - expect(chef_run).to render_file(file_name).with_content(/^interface_driver = network_interface_driver_value$/) - end - end -end From 29ab01c3baf7f24bf265339b88359a5938ad28bd Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 12:22:39 +0400 Subject: [PATCH 6/9] cleanup in openstack compute cookbook --- .../openstack-compute/.delivery/project.toml | 9 - cookbooks/openstack-compute/.rubocop.yml | 4 - cookbooks/openstack-compute/.zuul.yaml | 3 - cookbooks/openstack-compute/Berksfile | 23 - cookbooks/openstack-compute/CONTRIBUTING.md | 36 -- cookbooks/openstack-compute/TESTING.md | 30 -- .../spec/_nova_apache_spec.rb | 20 - .../openstack-compute/spec/_nova_cell_spec.rb | 44 -- .../spec/api-metadata-redhat_spec.rb | 28 -- .../spec/api-metadata_spec.rb | 158 ------ .../spec/api-os-compute-redhat_spec.rb | 38 -- .../spec/api-os-compute_spec.rb | 167 ------- .../spec/compute-redhat_spec.rb | 51 -- .../openstack-compute/spec/compute_spec.rb | 89 ---- .../spec/conductor_redhat_spec.rb | 28 -- .../openstack-compute/spec/conductor_spec.rb | 26 - .../spec/identity_registration_spec.rb | 127 ----- .../spec/libvirt-redhat_spec.rb | 71 --- .../openstack-compute/spec/libvirt_spec.rb | 104 ---- .../spec/nova-common-redhat_spec.rb | 38 -- .../spec/nova-common_spec.rb | 462 ------------------ .../openstack-compute/spec/nova-setup_spec.rb | 34 -- .../spec/placement_api-redhat_spec.rb | 25 - .../spec/placement_api_spec.rb | 218 --------- .../spec/scheduler-redhat_spec.rb | 28 -- .../openstack-compute/spec/scheduler_spec.rb | 26 - .../spec/serialproxy-redhat_spec.rb | 28 -- .../spec/serialproxy_spec.rb | 26 - .../openstack-compute/spec/spec_helper.rb | 220 --------- .../spec/spiceproxy-redhat_spec.rb | 28 -- .../openstack-compute/spec/spiceproxy_spec.rb | 26 - .../spec/vncproxy-redhat_spec.rb | 28 -- .../openstack-compute/spec/vncproxy_spec.rb | 26 - 33 files changed, 2269 deletions(-) delete mode 100644 cookbooks/openstack-compute/.delivery/project.toml delete mode 100644 cookbooks/openstack-compute/.rubocop.yml delete mode 100644 cookbooks/openstack-compute/.zuul.yaml delete mode 100644 cookbooks/openstack-compute/Berksfile delete mode 100644 cookbooks/openstack-compute/CONTRIBUTING.md delete mode 100644 cookbooks/openstack-compute/TESTING.md delete mode 100644 cookbooks/openstack-compute/spec/_nova_apache_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/_nova_cell_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/api-metadata-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/api-metadata_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/api-os-compute-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/api-os-compute_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/compute-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/compute_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/conductor_redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/conductor_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/identity_registration_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/libvirt-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/libvirt_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/nova-common-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/nova-common_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/nova-setup_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/placement_api-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/placement_api_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/scheduler-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/scheduler_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/serialproxy-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/serialproxy_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/spec_helper.rb delete mode 100644 cookbooks/openstack-compute/spec/spiceproxy-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/spiceproxy_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/vncproxy-redhat_spec.rb delete mode 100644 cookbooks/openstack-compute/spec/vncproxy_spec.rb diff --git a/cookbooks/openstack-compute/.delivery/project.toml b/cookbooks/openstack-compute/.delivery/project.toml deleted file mode 100644 index 4066e559..00000000 --- a/cookbooks/openstack-compute/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[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/cookbooks/openstack-compute/.rubocop.yml b/cookbooks/openstack-compute/.rubocop.yml deleted file mode 100644 index 389f2700..00000000 --- a/cookbooks/openstack-compute/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -Chef/Modernize/FoodcriticComments: - Enabled: true -Chef/Style/CopyrightCommentFormat: - Enabled: true diff --git a/cookbooks/openstack-compute/.zuul.yaml b/cookbooks/openstack-compute/.zuul.yaml deleted file mode 100644 index f5786847..00000000 --- a/cookbooks/openstack-compute/.zuul.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- project: - templates: - - openstack-chef-jobs diff --git a/cookbooks/openstack-compute/Berksfile b/cookbooks/openstack-compute/Berksfile deleted file mode 100644 index ad495093..00000000 --- a/cookbooks/openstack-compute/Berksfile +++ /dev/null @@ -1,23 +0,0 @@ -source 'https://supermarket.chef.io' - -solver :ruby, :required - -[ - %w(client dep), - %w(-common dep), - %w(-dns integration), - %w(-identity dep), - %w(-image dep), - %w(-integration-test integration), - %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}", group: group - else - cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group - end -end - -metadata diff --git a/cookbooks/openstack-compute/CONTRIBUTING.md b/cookbooks/openstack-compute/CONTRIBUTING.md deleted file mode 100644 index e79f185a..00000000 --- a/cookbooks/openstack-compute/CONTRIBUTING.md +++ /dev/null @@ -1,36 +0,0 @@ -Contributing -============ - -How To Get Started ------------------- - -If you would like to contribute to the development of OpenStack Chef Cookbooks, -you must follow the steps in this page: - - https://docs.openstack.org/infra/manual/developers.html - -Gerrit Workflow ---------------- - -Once those steps have been completed, changes to OpenStack -should be submitted for review via the Gerrit tool, following -the workflow documented at: - - https://docs.openstack.org/infra/manual/developers.html#development-workflow - -Pull requests submitted through GitHub will be ignored. - -Bugs ----- - -Bugs should be filed on Launchpad, not GitHub: - - https://bugs.launchpad.net/openstack-chef - -Contacts --------- - -Mailing list: groups.google.com/group/opscode-chef-openstack -IRC: #openstack-chef is our channel on irc.oftc.net -Wiki: https://wiki.openstack.org/wiki/Chef/GettingStarted and https://docs.getchef.com/openstack.html -Twitter: @chefopenstack diff --git a/cookbooks/openstack-compute/TESTING.md b/cookbooks/openstack-compute/TESTING.md deleted file mode 100644 index 1dd45c5a..00000000 --- a/cookbooks/openstack-compute/TESTING.md +++ /dev/null @@ -1,30 +0,0 @@ -# Testing the Cookbook # - -This cookbook uses [chefdk](https://downloads.chef.io/chef-dk/) and [berkshelf](http://berkshelf.com/) to isolate dependencies. Make sure you have chefdk and the header files for `gecode` installed before continuing. Make sure that you're using gecode version 3. More info [here](https://github.com/opscode/dep-selector-libgecode/tree/0bad63fea305ede624c58506423ced697dd2545e#using-a-system-gecode-instead). For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the [openstack-chef-repo](https://github.com/openstack/openstack-chef-repo). - -We have three test suites which you can run either, individually (there are three rake tasks): - - $ chef exec rake lint - $ chef exec rake style - $ chef exec rake unit - -or altogether: - - $ chef exec rake - -The `rake` tasks will take care of installing the needed cookbooks with `berkshelf`. - -## Rubocop ## - -[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits. - -## Foodcritic ## - -[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules: - -* [FC003](http://acrmp.github.io/foodcritic/#FC003) These cookbooks are not intended for Chef Solo. -* [FC023](http://acrmp.github.io/foodcritic/#FC023) Prefer conditional attributes. - -## Chefspec - -[ChefSpec](https://github.com/sethvargo/chefspec) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers. diff --git a/cookbooks/openstack-compute/spec/_nova_apache_spec.rb b/cookbooks/openstack-compute/spec/_nova_apache_spec.rb deleted file mode 100644 index 78cf6558..00000000 --- a/cookbooks/openstack-compute/spec/_nova_apache_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::_nova_apache' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - - it do - expect(chef_run).to include_recipe('openstack-compute::nova-common') - end - - it do - expect(chef_run.service('apache2')).to \ - subscribe_to('template[/etc/nova/nova.conf]').on(:restart) - end - end -end diff --git a/cookbooks/openstack-compute/spec/_nova_cell_spec.rb b/cookbooks/openstack-compute/spec/_nova_cell_spec.rb deleted file mode 100644 index 6e0680b4..00000000 --- a/cookbooks/openstack-compute/spec/_nova_cell_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::_nova_cell' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_cell_recipe' - - it 'creates the cell0 mapping' do - expect(chef_run).to run_execute('map cell0').with( - user: 'nova', - group: 'nova', - command: 'nova-manage cell_v2 map_cell0 --database_connection mysql+pymysql://nova_cell0:nova_cell0_db_pass@127.0.0.1:3306/nova_cell0?charset=utf8' - ) - end - - it 'creates a new cell' do - expect(chef_run).to run_execute('create cell1').with( - user: 'nova', - group: 'nova', - command: 'nova-manage cell_v2 create_cell --verbose --name cell1' - ) - end - - it 'executes api_db sync' do - expect(chef_run).to run_execute('api db sync').with( - user: 'nova', - group: 'nova', - command: 'nova-manage api_db sync' - ) - end - - it 'executes db sync' do - expect(chef_run).to run_execute('db sync').with(user: 'nova', group: 'nova') - end - - it 'discovers compute hosts' do - expect(chef_run).to run_execute('discover hosts').with(user: 'nova', group: 'nova') - end - end -end diff --git a/cookbooks/openstack-compute/spec/api-metadata-redhat_spec.rb b/cookbooks/openstack-compute/spec/api-metadata-redhat_spec.rb deleted file mode 100644 index e3a27fb4..00000000 --- a/cookbooks/openstack-compute/spec/api-metadata-redhat_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::api-metadata' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_apache_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it 'upgrades metadata api packages' do - expect(chef_run).to upgrade_package 'openstack-nova-api' - end - - it 'disables metadata api on boot' do - expect(chef_run).to disable_service 'nova-api-metadata' - end - - it 'stops metadata api now' do - expect(chef_run).to stop_service 'nova-api-metadata' - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/api-metadata_spec.rb b/cookbooks/openstack-compute/spec/api-metadata_spec.rb deleted file mode 100644 index ef04d955..00000000 --- a/cookbooks/openstack-compute/spec/api-metadata_spec.rb +++ /dev/null @@ -1,158 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::api-metadata' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_apache_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - include_examples 'expect_creates_api_paste_template' - - it do - expect(chef_run).to upgrade_package %w(python3-nova nova-api-metadata) - end - - it do - expect(chef_run).to disable_service 'nova-api-metadata' - expect(chef_run).to stop_service 'nova-api-metadata' - end - - it do - expect(chef_run).to install_apache2_install('openstack').with(listen: %w(127.0.0.1:8775)) - end - - it do - expect(chef_run).to create_apache2_mod_wsgi 'api-metadata' - end - - it do - expect(chef_run).to_not enable_apache2_module('ssl') - end - - it do - expect(chef_run).to create_template('/etc/apache2/sites-available/nova-metadata.conf').with( - source: 'wsgi-template.conf.erb', - variables: { - ca_certs_path: '', - cert_file: '', - cert_required: false, - chain_file: '', - ciphers: '', - daemon_process: 'nova-metadata', - group: 'nova', - key_file: '', - log_dir: '/var/log/apache2', - processes: 2, - protocol: '', - run_dir: '/var/lock', - server_entry: '/usr/bin/nova-metadata-wsgi', - server_host: '127.0.0.1', - server_port: '8775', - threads: 1, - user: 'nova', - use_ssl: false, - } - ) - end - [ - /$/, - /WSGIDaemonProcess nova-metadata processes=2 threads=1 user=nova group=nova display-name=%{GROUP}$/, - /WSGIProcessGroup nova-metadata$/, - %r{WSGIScriptAlias / /usr/bin/nova-metadata-wsgi$}, - /WSGIApplicationGroup %{GLOBAL}$/, - %r{ErrorLog /var/log/apache2/nova-metadata_error.log$}, - %r{CustomLog /var/log/apache2/nova-metadata_access.log combined$}, - %r{WSGISocketPrefix /var/lock$}, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/nova-metadata.conf').with_content(line) - end - end - - [ - /SSLEngine On$/, - /SSLCertificateFile/, - /SSLCertificateKeyFile/, - /SSLCACertificatePath/, - /SSLCertificateChainFile/, - /SSLProtocol/, - /SSLCipherSuite/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to_not render_file('/etc/apache2/sites-available/nova-metadata.conf').with_content(line) - end - end - - context 'Enable SSL' do - cached(:chef_run) do - node.override['openstack']['compute']['metadata']['ssl']['enabled'] = true - node.override['openstack']['compute']['metadata']['ssl']['certfile'] = 'ssl.cert' - node.override['openstack']['compute']['metadata']['ssl']['keyfile'] = 'ssl.key' - node.override['openstack']['compute']['metadata']['ssl']['ca_certs_path'] = 'ca_certs_path' - node.override['openstack']['compute']['metadata']['ssl']['protocol'] = 'ssl_protocol_value' - runner.converge(described_recipe) - end - - it do - expect(chef_run).to enable_apache2_module('ssl') - end - - [ - /SSLEngine On$/, - /SSLCertificateFile ssl.cert$/, - /SSLCertificateKeyFile ssl.key$/, - /SSLCACertificatePath ca_certs_path$/, - /SSLProtocol ssl_protocol_value$/, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/nova-metadata.conf').with_content(line) - end - end - [ - /SSLCipherSuite/, - /SSLCertificateChainFile/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to_not render_file('/etc/apache2/sites-available/nova-metadata.conf').with_content(line) - end - end - context 'Enable chainfile, ciphers & cert_required' do - cached(:chef_run) do - node.override['openstack']['compute']['metadata']['ssl']['enabled'] = true - node.override['openstack']['compute']['metadata']['ssl']['ciphers'] = 'ssl_ciphers_value' - node.override['openstack']['compute']['metadata']['ssl']['chainfile'] = 'chainfile' - node.override['openstack']['compute']['metadata']['ssl']['cert_required'] = true - runner.converge(described_recipe) - end - [ - /SSLCipherSuite ssl_ciphers_value$/, - /SSLCertificateChainFile chainfile$/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/nova-metadata.conf').with_content(line) - end - end - end - end - - it do - expect(chef_run.template('/etc/apache2/sites-available/nova-metadata.conf')).to \ - notify('service[apache2]').to(:restart) - end - - it do - expect(chef_run).to enable_apache2_site('nova-metadata') - end - - it do - expect(chef_run.apache2_site('nova-metadata')).to notify('service[apache2]').to(:restart).immediately - end - end -end diff --git a/cookbooks/openstack-compute/spec/api-os-compute-redhat_spec.rb b/cookbooks/openstack-compute/spec/api-os-compute-redhat_spec.rb deleted file mode 100644 index cb3b3d5a..00000000 --- a/cookbooks/openstack-compute/spec/api-os-compute-redhat_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::api-os-compute' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_apache_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it 'executes nova-manage api_db sync' do - expect(chef_run).to run_execute('nova-manage api_db sync') - .with( - timeout: 3600, - user: 'nova', - group: 'nova', - command: 'nova-manage api_db sync' - ) - end - - it 'upgrades openstack api packages' do - expect(chef_run).to upgrade_package 'openstack-nova-api' - end - - it 'disables openstack api on boot' do - expect(chef_run).to disable_service 'openstack-nova-api' - end - - it 'stops openstack api now' do - expect(chef_run).to stop_service 'openstack-nova-api' - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/api-os-compute_spec.rb b/cookbooks/openstack-compute/spec/api-os-compute_spec.rb deleted file mode 100644 index 19780c4a..00000000 --- a/cookbooks/openstack-compute/spec/api-os-compute_spec.rb +++ /dev/null @@ -1,167 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::api-os-compute' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_apache_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - include_examples 'expect_creates_api_paste_template' - - it do - expect(chef_run).to run_execute('nova-manage api_db sync') - .with( - timeout: 3600, - user: 'nova', - group: 'nova', - command: 'nova-manage api_db sync' - ) - end - - it do - expect(chef_run).to upgrade_package %w(python3-nova nova-api) - end - - it do - expect(chef_run).to disable_service 'nova-api-os-compute' - expect(chef_run).to stop_service 'nova-api-os-compute' - end - it do - expect(chef_run).to install_apache2_install('openstack').with(listen: %w(127.0.0.1:8774)) - end - - it do - expect(chef_run).to create_apache2_mod_wsgi 'api-os-compute' - end - - it do - expect(chef_run).to_not enable_apache2_module('ssl') - end - - it do - expect(chef_run).to create_template('/etc/apache2/sites-available/nova-api.conf').with( - source: 'wsgi-template.conf.erb', - variables: { - ca_certs_path: '', - cert_file: '', - cert_required: false, - chain_file: '', - ciphers: '', - daemon_process: 'nova-api', - group: 'nova', - key_file: '', - log_dir: '/var/log/apache2', - processes: 6, - protocol: '', - run_dir: '/var/lock', - server_entry: '/usr/bin/nova-api-wsgi', - server_host: '127.0.0.1', - server_port: '8774', - threads: 1, - user: 'nova', - use_ssl: false, - } - ) - end - [ - /$/, - /WSGIDaemonProcess nova-api processes=6 threads=1 user=nova group=nova display-name=%{GROUP}$/, - /WSGIProcessGroup nova-api$/, - %r{WSGIScriptAlias / /usr/bin/nova-api-wsgi$}, - /WSGIApplicationGroup %{GLOBAL}$/, - %r{ErrorLog /var/log/apache2/nova-api_error.log$}, - %r{CustomLog /var/log/apache2/nova-api_access.log combined$}, - %r{WSGISocketPrefix /var/lock$}, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/nova-api.conf').with_content(line) - end - end - - [ - /SSLEngine On$/, - /SSLCertificateFile/, - /SSLCertificateKeyFile/, - /SSLCACertificatePath/, - /SSLCertificateChainFile/, - /SSLProtocol/, - /SSLCipherSuite/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to_not render_file('/etc/apache2/sites-available/nova-api.conf').with_content(line) - end - end - - context 'Enable SSL' do - cached(:chef_run) do - node.override['openstack']['compute']['api']['ssl']['enabled'] = true - node.override['openstack']['compute']['api']['ssl']['certfile'] = 'ssl.cert' - node.override['openstack']['compute']['api']['ssl']['keyfile'] = 'ssl.key' - node.override['openstack']['compute']['api']['ssl']['ca_certs_path'] = 'ca_certs_path' - node.override['openstack']['compute']['api']['ssl']['protocol'] = 'ssl_protocol_value' - runner.converge(described_recipe) - end - - it do - expect(chef_run).to enable_apache2_module('ssl') - end - - [ - /SSLEngine On$/, - /SSLCertificateFile ssl.cert$/, - /SSLCertificateKeyFile ssl.key$/, - /SSLCACertificatePath ca_certs_path$/, - /SSLProtocol ssl_protocol_value$/, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/nova-api.conf').with_content(line) - end - end - [ - /SSLCipherSuite/, - /SSLCertificateChainFile/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to_not render_file('/etc/apache2/sites-available/nova-api.conf').with_content(line) - end - end - context 'Enable chainfile, ciphers & cert_required' do - cached(:chef_run) do - node.override['openstack']['compute']['api']['ssl']['enabled'] = true - node.override['openstack']['compute']['api']['ssl']['ciphers'] = 'ssl_ciphers_value' - node.override['openstack']['compute']['api']['ssl']['chainfile'] = 'chainfile' - node.override['openstack']['compute']['api']['ssl']['cert_required'] = true - runner.converge(described_recipe) - end - [ - /SSLCipherSuite ssl_ciphers_value$/, - /SSLCertificateChainFile chainfile$/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/nova-api.conf').with_content(line) - end - end - end - end - - it do - expect(chef_run.template('/etc/apache2/sites-available/nova-api.conf')).to \ - notify('service[apache2]').to(:restart) - end - - it do - expect(chef_run).to enable_apache2_site('nova-api') - end - - it do - expect(chef_run.apache2_site('nova-api')).to notify('service[apache2]').to(:restart).immediately - end - end -end diff --git a/cookbooks/openstack-compute/spec/compute-redhat_spec.rb b/cookbooks/openstack-compute/spec/compute-redhat_spec.rb deleted file mode 100644 index dd048c15..00000000 --- a/cookbooks/openstack-compute/spec/compute-redhat_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::compute' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - include_examples 'expect_creates_nova_instances_dir' - include_examples 'expect_volume_packages' - - context "does not upgrade kvm when virt_type is 'kvm'" do - cached(:chef_run) do - node.override['openstack']['compute']['libvirt']['virt_type'] = 'kvm' - runner.converge(described_recipe) - end - it do - expect(chef_run).to_not upgrade_package('nova-compute-kvm') - end - end - - context "does not upgrade qemu when virt_type is 'qemu'" do - cached(:chef_run) do - node.override['openstack']['compute']['libvirt']['virt_type'] = 'qemu' - runner.converge(described_recipe) - end - it do - expect(chef_run).to_not upgrade_package('nova-compute-qemu') - end - end - - it 'upgrades nova compute package' do - expect(chef_run).to upgrade_package('openstack-nova-compute') - end - - it 'starts nova compute on boot' do - expected = 'openstack-nova-compute' - expect(chef_run).to enable_service(expected) - end - - it 'starts nova compute' do - expect(chef_run).to start_service('openstack-nova-compute') - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/compute_spec.rb b/cookbooks/openstack-compute/spec/compute_spec.rb deleted file mode 100644 index 0e1ac83e..00000000 --- a/cookbooks/openstack-compute/spec/compute_spec.rb +++ /dev/null @@ -1,89 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::compute' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - include_examples 'expect_creates_nova_instances_dir' - - it do - expect(chef_run).to upgrade_package %w(sysfsutils sg3-utils multipath-tools) - end - - it 'does not include the api-metadata recipe' do - expect(chef_run).not_to include_recipe 'openstack-compute::api-metadata' - end - - it 'does not include api-metadata recipe' do - expect(chef_run).not_to include_recipe 'openstack-compute::api-metadata' - end - - it do - expect(chef_run).to upgrade_package %w(python3-nova nova-compute) - end - - context "upgrades kvm when virt_type is 'kvm'" do - cached(:chef_run) do - node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = 'kvm' - runner.converge(described_recipe) - end - it do - expect(chef_run).to upgrade_package %w(python3-nova nova-compute-kvm) - expect(chef_run).not_to upgrade_package %w(python3-nova nova-compute-qemu) - end - end - - context 'upgrades qemu when virt_type is qemu' do - cached(:chef_run) do - node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = 'qemu' - runner.converge(described_recipe) - end - it do - expect(chef_run).to upgrade_package %w(python3-nova nova-compute-qemu) - expect(chef_run).not_to upgrade_package %w(python3-nova nova-compute-kvm) - end - end - - %w(qemu kvm).each do |virt_type| - context "honors the package name platform overrides for #{virt_type}" do - cached(:chef_run) do - node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = virt_type - node.override['openstack']['compute']['platform']["#{virt_type}_compute_packages"] = ["my-nova-#{virt_type}"] - runner.converge(described_recipe) - end - it do - expect(chef_run).to upgrade_package("my-nova-#{virt_type}") - end - end - end - - describe 'nova-compute.conf' do - let(:file) { chef_run.cookbook_file('/etc/nova/nova-compute.conf') } - - it 'creates the file' do - expect(chef_run).to create_cookbook_file(file.name).with( - source: 'nova-compute.conf', - mode: '644' - ) - end - end - - it 'runs libvirt recipe' do - expect(chef_run).to include_recipe 'openstack-compute::libvirt' - end - - it 'starts nova compute on boot' do - expect(chef_run).to enable_service 'nova-compute' - end - - it 'starts nova compute' do - expect(chef_run).to start_service 'nova-compute' - end - end -end diff --git a/cookbooks/openstack-compute/spec/conductor_redhat_spec.rb b/cookbooks/openstack-compute/spec/conductor_redhat_spec.rb deleted file mode 100644 index 48434d6b..00000000 --- a/cookbooks/openstack-compute/spec/conductor_redhat_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::conductor' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it 'upgrades conductor package' do - expect(chef_run).to upgrade_package 'openstack-nova-conductor' - end - - it 'starts nova-conductor on boot' do - expect(chef_run).to enable_service 'openstack-nova-conductor' - end - - it 'starts nova-conductor' do - expect(chef_run).to start_service 'openstack-nova-conductor' - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/conductor_spec.rb b/cookbooks/openstack-compute/spec/conductor_spec.rb deleted file mode 100644 index a130e84b..00000000 --- a/cookbooks/openstack-compute/spec/conductor_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::conductor' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it do - expect(chef_run).to upgrade_package %w(python3-nova nova-conductor) - end - - it 'starts nova-conductor on boot' do - expect(chef_run).to enable_service 'nova-conductor' - end - - it 'starts nova-conductor' do - expect(chef_run).to start_service 'nova-conductor' - end - end -end diff --git a/cookbooks/openstack-compute/spec/identity_registration_spec.rb b/cookbooks/openstack-compute/spec/identity_registration_spec.rb deleted file mode 100644 index b699b29a..00000000 --- a/cookbooks/openstack-compute/spec/identity_registration_spec.rb +++ /dev/null @@ -1,127 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::identity_registration' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - - connection_params = { - openstack_auth_url: 'http://127.0.0.1:5000/v3', - openstack_username: 'admin', - openstack_api_key: 'admin', - openstack_project_name: 'admin', - openstack_domain_name: 'default', - # openstack_endpoint_type: 'internalURL', - } - service_name = 'nova' - service_type = 'compute' - service_user = 'nova' - url = 'http://127.0.0.1:8774/v2.1/%(tenant_id)s' - region = 'RegionOne' - project_name = 'service' - role_name = 'admin' - password = 'nova-pass' - domain_name = 'Default' - placement_service_name = 'nova-placement' - placement_service_type = 'placement' - placement_service_user = 'placement' - placement_password = 'placement-pass' - placement_url = 'http://127.0.0.1:8778' - - it "registers #{project_name} Project" do - expect(chef_run).to create_openstack_project( - project_name - ).with( - connection_params: connection_params - ) - end - - it "registers #{service_name} service" do - expect(chef_run).to create_openstack_service( - service_name - ).with( - connection_params: connection_params, - type: service_type - ) - end - - it 'registers placement service' do - expect(chef_run).to create_openstack_service( - placement_service_name - ).with( - connection_params: connection_params, - type: placement_service_type - ) - end - - context "registers #{service_name} endpoint" do - %w(internal public).each do |interface| - it "creates #{interface} endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - service_type - ).with( - service_name: service_name, - # interface: interface, - url: url, - region: region, - connection_params: connection_params - ) - end - end - end - - context 'registers placement endpoint' do - %w(internal public).each do |interface| - it "creates #{interface} endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - placement_service_type - ).with( - service_name: placement_service_name, - # interface: interface, - url: placement_url, - region: region, - connection_params: connection_params - ) - end - end - end - - it 'registers nova service user' do - expect(chef_run).to create_openstack_user( - service_user - ).with( - project_name: project_name, - password: password, - connection_params: connection_params - ) - end - - it 'registers placement service user' do - expect(chef_run).to create_openstack_user( - placement_service_user - ).with( - domain_name: domain_name, - project_name: project_name, - password: placement_password, - connection_params: connection_params - ) - end - - context 'grants user roles' do - [service_user, placement_service_user].each do |user_name| - it do - expect(chef_run).to grant_role_openstack_user( - user_name - ).with( - project_name: project_name, - role_name: role_name, - connection_params: connection_params - ) - end - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/libvirt-redhat_spec.rb b/cookbooks/openstack-compute/spec/libvirt-redhat_spec.rb deleted file mode 100644 index 76f3a33b..00000000 --- a/cookbooks/openstack-compute/spec/libvirt-redhat_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::libvirt' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - - case p - when REDHAT_7 - it do - expect(chef_run).to upgrade_package %w(libvirt device-mapper python-libguestfs) - end - when REDHAT_8 - it do - expect(chef_run).to upgrade_package %w(libvirt device-mapper python3-libguestfs) - end - end - - it 'creates libvirt group and adds nova as a member' do - expect(chef_run).to create_group('libvirt').with(members: ['nova']) - end - - it 'symlinks qemu-kvm' do - expect(chef_run).to create_link('/usr/bin/qemu-system-x86_64').with(to: '/usr/libexec/qemu-kvm') - end - - it 'starts libvirt' do - expect(chef_run).to start_service 'libvirtd' - end - - it 'starts libvirt on boot' do - expect(chef_run).to enable_service 'libvirtd' - end - - it 'does not create /etc/default/libvirt-bin' do - expect(chef_run).not_to create_template('/etc/default/libvirt-bin') - end - - describe '/etc/sysconfig/libvirtd' do - let(:file) { chef_run.template('/etc/sysconfig/libvirtd') } - - it 'creates the /etc/sysconfig/libvirtd file' do - expect(chef_run).to create_template(file.name).with( - owner: 'root', - group: 'root', - mode: '644' - ) - end - - case p - when REDHAT_7 - it 'template contents' do - expect(chef_run).to render_file(file.name).with_content(/^LIBVIRTD_ARGS="--listen"$/) - end - when REDHAT_8 - it 'template contents' do - expect(chef_run).to_not render_file(file.name).with_content(/^LIBVIRTD_ARGS="--listen"$/) - end - end - - it 'notifies libvirt-bin restart' do - expect(file).to notify('service[libvirt-bin]').to(:restart) - end - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/libvirt_spec.rb b/cookbooks/openstack-compute/spec/libvirt_spec.rb deleted file mode 100644 index 59b3274c..00000000 --- a/cookbooks/openstack-compute/spec/libvirt_spec.rb +++ /dev/null @@ -1,104 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::libvirt' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - - it do - expect(chef_run).to upgrade_package %w(libvirt-bin python3-guestfs) - end - - it 'does not create libvirt group and add to nova' do - expect(chef_run).not_to create_group 'libvirt' - end - - it 'does not symlink qemu-kvm' do - expect(chef_run).not_to create_link '/usr/bin/qemu-system-x86_64' - end - - it 'starts dbus' do - expect(chef_run).to start_service 'dbus' - end - - it 'starts dbus on boot' do - expect(chef_run).to enable_service 'dbus' - end - - it 'starts libvirt' do - expect(chef_run).to start_service 'libvirt-bin' - end - - it 'starts libvirt on boot' do - expect(chef_run).to enable_service 'libvirt-bin' - end - - it 'deletes default libvirt network' do - expect(chef_run).to run_execute('virsh net-destroy default') - end - - describe '/etc/libvirt/libvirtd.conf' do - let(:file) { chef_run.template('/etc/libvirt/libvirtd.conf') } - - it 'creates the /etc/libvirt/libvirtd.conf file' do - expect(chef_run).to create_template(file.name).with( - source: 'libvirtd.conf.erb', - owner: 'root', - group: 'root', - mode: '644' - ) - end - - it 'has proper processing controls' do - [ - /^max_clients = 20$/, - /^max_workers = 20$/, - /^max_requests = 20$/, - /^max_client_requests = 5$/, - ].each do |content| - expect(chef_run).to render_file(file.name).with_content(content) - end - end - - it 'has unix_sock_rw_perms' do - expect(chef_run).to render_file(file.name).with_content(/^unix_sock_rw_perms = "0770"$/) - end - - it 'notifies libvirt-bin restart' do - expect(file).to notify('service[libvirt-bin]').to(:restart) - end - end - - describe '/etc/default/libvirtd' do - let(:file) { chef_run.template('/etc/default/libvirtd') } - - it 'creates the /etc/default/libvirtd file' do - expect(chef_run).to create_template(file.name).with( - owner: 'root', - group: 'root', - mode: '644' - ) - end - - it 'template contents' do - [ - /^start_libvirtd="yes"$/, - /^libvirtd_opts="-l"$/, - ].each do |line| - expect(chef_run).to render_file(file.name).with_content(line) - end - end - - it 'notifies libvirt-bin restart' do - expect(file).to notify('service[libvirt-bin]').to(:restart) - end - end - - it 'does not create /etc/sysconfig/libvirtd' do - expect(chef_run).not_to create_template '/etc/sysconfig/libvirtd' - end - end -end diff --git a/cookbooks/openstack-compute/spec/nova-common-redhat_spec.rb b/cookbooks/openstack-compute/spec/nova-common-redhat_spec.rb deleted file mode 100644 index 5c1e6448..00000000 --- a/cookbooks/openstack-compute/spec/nova-common-redhat_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::nova-common' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it do - expect(chef_run).to upgrade_package %w(openstack-nova-common) - end - - case p - when REDHAT_7 - it do - expect(chef_run).to upgrade_package 'MySQL-python' - end - - it do - expect(chef_run).to upgrade_package 'python-memcached' - end - when REDHAT_8 - it do - expect(chef_run).to upgrade_package 'python3-PyMySQL' - end - - it do - expect(chef_run).to upgrade_package 'python3-memcached' - end - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/nova-common_spec.rb b/cookbooks/openstack-compute/spec/nova-common_spec.rb deleted file mode 100644 index 31cd2f04..00000000 --- a/cookbooks/openstack-compute/spec/nova-common_spec.rb +++ /dev/null @@ -1,462 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::nova-common' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - node.override['openstack']['mq'] = { 'host' => '127.0.0.1' } - node.override['openstack']['mq']['compute']['rabbit']['ha'] = true - runner.converge(described_recipe) - end - - include_context 'compute_stubs' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it do - expect(chef_run).to upgrade_package 'python3-mysqldb' - end - - it do - expect(chef_run).to upgrade_package %w(nova-common python3-nova) - end - - it do - expect(chef_run).to upgrade_package 'python3-memcache' - end - - it 'creates the /etc/nova directory' do - expect(chef_run).to create_directory('/etc/nova').with( - owner: 'nova', - group: 'nova', - mode: '750' - ) - end - - context 'with logging enabled' do - cached(:chef_run) do - node.override['openstack']['compute']['syslog']['use'] = true - runner.converge(described_recipe) - end - - it 'runs logging recipe if node attributes say to' do - expect(chef_run).to include_recipe 'openstack-common::logging' - end - end - - context 'with logging disabled' do - cached(:chef_run) do - node.override['openstack']['compute']['syslog']['use'] = false - runner.converge(described_recipe) - end - - it "doesn't run logging recipe" do - expect(chef_run).not_to include_recipe 'openstack-common::logging' - end - end - - describe 'nova.conf' do - let(:file) { chef_run.template('/etc/nova/nova.conf') } - - it do - expect(chef_run).to create_template(file.name).with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - owner: 'nova', - group: 'nova', - mode: '640', - sensitive: true - ) - end - - it '[DEFAULT]' do - [ - %r{^log_dir = /var/log/nova$}, - %r{^state_path = /var/lib/nova$}, - /^compute_driver = libvirt.LibvirtDriver$/, - %r{^instances_path = /var/lib/nova/instances$}, - /^enabled_apis = osapi_compute,metadata$/, - /^iscsi_helper = tgtadm$/, - /^metadata_listen = 127.0.0.1$/, - /^metadata_listen_port = 8775$/, - %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - - it '[oslo_concurrency]' do - [ - %r{^lock_path = /var/lib/nova/lock$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', line) - end - end - - it 'has default misc config attributes defaults not set' do - [ - /^osapi_compute_link_prefix = /, - /^osapi_glance_link_prefix = /, - ].each do |line| - expect(chef_run).not_to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - - it 'confirms default min value for workers' do - [ - /^osapi_compute_workers = /, - /^metadata_workers = /, - /^workers = /, - ].each do |line| - expect(chef_run).to_not render_file(file.name).with_content(line) - end - end - - it '[keystone_authtoken]' do - [ - /^auth_type = v3password$/, - /^region_name = RegionOne$/, - /^username = nova$/, - /^user_domain_name = Default$/, - /^project_domain_name = Default$/, - /^project_name = service$/, - /^auth_version = v3$/, - /^service_token_roles_required = true$/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - %r{^www_authenticate_uri = http://127.0.0.1:5000/v3$}, - /^password = nova-pass$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', line) - end - end - - it '[libvirt]' do - [ - /^virt_type = kvm$/, - /^images_type = default$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('libvirt', line) - end - end - - it '[neutron]' do - [ - /^auth_type = v3password$/, - /^region_name = RegionOne$/, - /^username = neutron$/, - /^user_domain_name = Default$/, - /^service_metadata_proxy = true$/, - /^project_name = service$/, - /^project_domain_name = Default$/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^password = neutron-pass$/, - /^metadata_proxy_shared_secret = metadata-secret$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('neutron', line) - end - end - - it '[placement]' do - [ - /^auth_type = password$/, - /^region_name = RegionOne$/, - /^username = placement$/, - /^user_domain_name = Default$/, - /^project_domain_name = Default$/, - /^project_name = service$/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^password = placement-pass$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('placement', line) - end - end - - it '[scheduler]' do - [ - /^discover_hosts_in_cells_interval = 300$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('scheduler', line) - end - end - - it '[glance]' do - [ - %r{^api_servers = http://127.0.0.1:9292$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('glance', line) - end - end - - context 'rabbit mq backend' do - describe 'ha rabbit disabled' do - cached(:chef_run) do - # README(galstrom21): There is a order of operations issue here - # if you use node.override, these tests will fail. - node.override['openstack']['mq']['compute']['rabbit']['ha'] = false - runner.converge(described_recipe) - end - - it 'does not have ha rabbit options set' do - [ - /^rabbit_hosts = /, - /^rabbit_ha_queues = /, - ].each do |line| - expect(chef_run).not_to render_config_file(file.name) - .with_section_content('oslo_messaging_rabbit', line) - end - end - end - end - - context 'has default server_* options set' do - cached(:chef_run) do - node.override['openstack']['endpoints']['compute-vnc-bind']['bind_interface'] = 'lo' - runner.converge(described_recipe) - end - it do - [ - /^server_listen = 127.0.0.1$/, - /^server_proxyclient_address = 127.0.0.1$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('vnc', line) - end - end - end - - context 'has override server_* options set' do - cached(:chef_run) do - node.override['openstack']['bind_service']['all']['compute-vnc']['host'] = '1.1.1.1' - node.override['openstack']['bind_service']['all']['compute-vnc-proxy']['host'] = '2.2.2.2' - runner.converge(described_recipe) - end - it do - [ - /^server_listen = 1.1.1.1$/, - /^server_proxyclient_address = 2.2.2.2$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('vnc', line) - end - end - end - - it '[vnc]' do - [ - /^enabled = true$/, - %r{^novncproxy_base_url = http://127.0.0.1:6080/vnc_auto.html$}, - /^novncproxy_host = 127.0.0.1$/, - /^novncproxy_port = 6080$/, - /^server_listen = 127.0.0.1$/, - /^server_proxyclient_address = 127.0.0.1$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('vnc', line) - end - end - - it '[spice]' do - expect(chef_run).not_to render_config_file(file.name).with_section_content('spice', /^enabled = true$/) - end - - context 'with SPICE consoles' do - cached(:chef_run) do - node.override['openstack']['compute']['console_type'] = 'spice' - runner.converge(described_recipe) - end - - it 'disables VNC support' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('vnc', /^enabled = false$/) - end - - it 'sets SPICE options correctly' do - [ - /^enabled = true$/, - %r{^html5proxy_base_url = http://127.0.0.1:6082/spice_auto.html$}, - /^html5proxy_host = 127.0.0.1$/, - /^html5proxy_port = 6082$/, - /^server_listen = 127.0.0.1$/, - /^server_proxyclient_address = 127.0.0.1$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('spice', line) - end - end - end - - context 'has a os_region_name setting' do - cached(:chef_run) do - node.override['openstack']['node'] = 'RegionOne' - runner.converge(described_recipe) - end - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content('cinder', /^os_region_name = RegionOne$/) - end - end - - it 'has no auto_assign_floating_ip' do - expect(chef_run).not_to render_file(file.name).with_content( - 'auto_assign_floating_ip=false' - ) - end - - context 'lvm backend' do - cached(:chef_run) do - node.override['openstack']['compute']['conf']['libvirt']['images_type'] = 'lvm' - node.override['openstack']['compute']['conf']['libvirt']['images_volume_group'] = 'instances' - runner.converge(described_recipe) - end - - it 'sets the lvm options correctly' do - [ - /^images_type = lvm$/, - /^images_volume_group = instances$/, - /^sparse_logical_volumes = false$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('libvirt', line) - end - end - - context 'override settings' do - cached(:chef_run) do - node.override['openstack']['compute']['conf']['libvirt']['images_type'] = 'lvm' - node.override['openstack']['compute']['conf']['libvirt']['images_volume_group'] = 'instances' - node.override['openstack']['compute']['conf']['libvirt']['sparse_logical_volumes'] = true - # node.override['openstack']['compute']['libvirt']['cpu_mode'] = 'none' - runner.converge(described_recipe) - end - - it 'sets the overridden lvm options correctly' do - [ - /^images_type = lvm$/, - /^images_volume_group = instances$/, - /^sparse_logical_volumes = true$/, - # /^cpu_mode = none$/ - ].each do |line| - expect(chef_run).to render_config_file(file.name)\ - .with_section_content('libvirt', line) - end - end - end - end - - context 'serial console' do - it 'sets default serial console options set' do - [ - %r{base_url = ws://127.0.0.1:6083$}, - /^proxyclient_address = 127.0.0.1$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('serial_console', line) - end - end - - context 'sets overide serial console options set' do - cached(:chef_run) do - node.override['openstack']['endpoints']['compute-serial-console-bind']['bind_interface'] = 'lo' - node.override['openstack']['endpoints']['public']['compute-serial-proxy']['scheme'] = 'wss' - node.override['openstack']['endpoints']['public']['compute-serial-proxy']['host'] = '1.1.1.1' - node.override['openstack']['endpoints']['public']['compute-serial-proxy']['port'] = '6082' - runner.converge(described_recipe) - end - it do - [ - %r{base_url = wss://1.1.1.1:6082$}, - /^proxyclient_address = 127.0.0.1$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('serial_console', line) - end - end - end - end - - context 'override compute_api username' do - cached(:chef_run) do - node.override['openstack']['db']['compute_api']['username'] = 'nova_api' - runner.converge(described_recipe) - end - it do - expect(chef_run).to render_config_file(file.name) - .with_section_content( - 'api_database', - %(connection = mysql+pymysql://nova_api:nova_api_db_pass@127.0.0.1:3306/nova_api?charset=utf8) - ) - end - end - - context 'set enabled_slave attribute' do - cached(:chef_run) do - node.override['openstack']['endpoints']['db']['enabled_slave'] = true - node.override['openstack']['endpoints']['db']['slave_host'] = '10.10.1.1' - node.override['openstack']['endpoints']['db']['slave_port'] = '3326' - node.override['openstack']['db']['compute']['username'] = 'nova' - runner.converge(described_recipe) - end - it 'sets overide database enabled_slave attribute as true' do - expect(chef_run).to render_config_file(file.name)\ - .with_section_content( - 'database', - %(slave_connection = mysql+pymysql://nova:nova_db_pass@10.10.1.1:3326/nova?charset=utf8) - ) - end - - context 'sets overide database enabled_slave attribute as false' do - cached(:chef_run) do - node.override['openstack']['endpoints']['db']['enabled_slave'] = false - node.override['openstack']['endpoints']['db']['slave_host'] = '10.10.1.1' - node.override['openstack']['endpoints']['db']['slave_port'] = '3326' - node.override['openstack']['db']['compute']['username'] = 'nova' - runner.converge(described_recipe) - end - it do - expect(chef_run).to_not render_config_file(file.name)\ - .with_section_content( - 'database', - %(slave_connection = mysql+pymysql://nova:nova_db_pass@10.10.1.1:3326/nova?charset=utf8) - ) - end - end - end - end - - describe 'rootwrap.conf' do - let(:file) { chef_run.template('/etc/nova/rootwrap.conf') } - - it 'creates the /etc/nova/rootwrap.conf file' do - expect(chef_run).to create_template(file.name).with( - user: 'root', - group: 'root', - mode: '644' - ) - end - - context 'template contents' do - cached(:chef_run) do - node.override['openstack']['compute']['custom_template_banner'] = 'banner' - runner.converge(described_recipe) - end - it 'shows the custom banner' do - expect(chef_run).to render_file(file.name).with_content(/^banner$/) - end - - it 'sets the default attributes' do - [ - %r{^filters_path = /etc/nova/rootwrap.d,/usr/share/nova/rootwrap$}, - %r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$}, - /^use_syslog = False$/, - /^syslog_log_facility = syslog$/, - /^syslog_log_level = ERROR$/, - ].each do |line| - expect(chef_run).to render_file(file.name).with_content(line) - end - end - end - end - - it do - expect(chef_run).to modify_user('nova').with(shell: '/bin/sh') - end - - it 'cleans up conf_secrets' do - expect(chef_run).to run_ruby_block("delete all attributes in node['openstack']['compute']['conf_secrets']") - end - end -end diff --git a/cookbooks/openstack-compute/spec/nova-setup_spec.rb b/cookbooks/openstack-compute/spec/nova-setup_spec.rb deleted file mode 100644 index eb9fa24a..00000000 --- a/cookbooks/openstack-compute/spec/nova-setup_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::nova-setup' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - - it 'runs db migrations with default timeout' do - expect(chef_run).to run_execute('nova-manage db sync').with( - user: 'nova', - group: 'nova', - timeout: 3600 - ) - end - - context 'runs db migrations with timeout override' do - cached(:chef_run) do - node.override['openstack']['compute']['dbsync_timeout'] = 1234 - runner.converge(described_recipe) - end - it do - expect(chef_run).to run_execute('nova-manage db sync').with( - user: 'nova', - group: 'nova', - timeout: 1234 - ) - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/placement_api-redhat_spec.rb b/cookbooks/openstack-compute/spec/placement_api-redhat_spec.rb deleted file mode 100644 index 73877b14..00000000 --- a/cookbooks/openstack-compute/spec/placement_api-redhat_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::placement_api' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_apache_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it 'upgrades placement packages' do - expect(chef_run).to upgrade_package 'openstack-placement-api' - end - - it do - expect(chef_run).to disable_service 'openstack-placement-api' - expect(chef_run).to stop_service 'openstack-placement-api' - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/placement_api_spec.rb b/cookbooks/openstack-compute/spec/placement_api_spec.rb deleted file mode 100644 index 31049e3c..00000000 --- a/cookbooks/openstack-compute/spec/placement_api_spec.rb +++ /dev/null @@ -1,218 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::placement_api' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - - include_examples 'expect_runs_nova_apache_recipe' - - it do - expect(chef_run).to upgrade_package %w(python3-placement) - end - - it do - expect(chef_run).to run_execute('placement-manage db sync').with( - user: 'placement', - group: 'placement' - ) - end - - it do - expect(chef_run).to disable_service 'placement-api' - expect(chef_run).to stop_service 'placement-api' - end - - it do - expect(chef_run).to install_apache2_install('openstack').with(listen: %w(127.0.0.1:8778)) - end - - it do - expect(chef_run).to create_apache2_mod_wsgi 'placement' - end - - it do - expect(chef_run).to_not enable_apache2_module('ssl') - end - - describe 'placement.conf' do - let(:file) { chef_run.template('/etc/placement/placement.conf') } - it do - expect(chef_run).to create_template(file.name).with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - owner: 'placement', - group: 'placement', - mode: '640', - sensitive: true - ) - end - - it do - expect(chef_run.template('/etc/placement/placement.conf')).to notify('service[apache2]').to(:restart) - end - - it '[DEFAULT]' do - [ - %r{^log_dir = /var/log/placement$}, - %r{^state_path = /var/lib/placement$}, - %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - it '[placement_database]' do - [ - %r{^connection = mysql\+pymysql://placement:placement_db_pass@127.0.0.1:3306/placement\?charset=utf8$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('placement_database', line) - end - end - it '[keystone_authtoken]' do - [ - /^auth_type = password$/, - /^username = placement$/, - /^user_domain_name = Default$/, - /^project_domain_name = Default$/, - /^project_name = service$/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - %r{^www_authenticate_uri = http://127.0.0.1:5000/v3$}, - /^password = placement-pass$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', line) - end - end - it '[api]' do - [ - /^auth_strategy = keystone$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('api', line) - end - end - end - it do - expect(chef_run).to create_template('/etc/apache2/sites-available/placement.conf').with( - source: 'wsgi-template.conf.erb', - variables: { - ca_certs_path: '', - cert_file: '', - cert_required: false, - chain_file: '', - ciphers: '', - daemon_process: 'placement-api', - group: 'placement', - key_file: '', - log_dir: '/var/log/apache2', - processes: 2, - protocol: '', - run_dir: '/var/lock', - server_entry: '/usr/bin/placement-api', - server_host: '127.0.0.1', - server_port: '8778', - threads: 1, - user: 'placement', - use_ssl: false, - } - ) - end - [ - /$/, - /WSGIDaemonProcess placement-api processes=2 threads=1 user=placement group=placement display-name=%{GROUP}$/, - /WSGIProcessGroup placement-api$/, - %r{WSGIScriptAlias / /usr/bin/placement-api$}, - /WSGIApplicationGroup %{GLOBAL}$/, - %r{ErrorLog /var/log/apache2/placement-api_error.log$}, - %r{CustomLog /var/log/apache2/placement-api_access.log combined$}, - %r{WSGISocketPrefix /var/lock$}, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/placement.conf').with_content(line) - end - end - - [ - /SSLEngine On$/, - /SSLCertificateFile/, - /SSLCertificateKeyFile/, - /SSLCACertificatePath/, - /SSLCertificateChainFile/, - /SSLProtocol/, - /SSLCipherSuite/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to_not render_file('/etc/apache2/sites-available/placement.conf').with_content(line) - end - end - - context 'Enable SSL' do - cached(:chef_run) do - node.override['openstack']['placement']['ssl']['enabled'] = true - node.override['openstack']['placement']['ssl']['certfile'] = 'ssl.cert' - node.override['openstack']['placement']['ssl']['keyfile'] = 'ssl.key' - node.override['openstack']['placement']['ssl']['ca_certs_path'] = 'ca_certs_path' - node.override['openstack']['placement']['ssl']['protocol'] = 'ssl_protocol_value' - runner.converge(described_recipe) - end - - it do - expect(chef_run).to enable_apache2_module('ssl') - end - - [ - /SSLEngine On$/, - /SSLCertificateFile ssl.cert$/, - /SSLCertificateKeyFile ssl.key$/, - /SSLCACertificatePath ca_certs_path$/, - /SSLProtocol ssl_protocol_value$/, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/placement.conf').with_content(line) - end - end - [ - /SSLCipherSuite/, - /SSLCertificateChainFile/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to_not render_file('/etc/apache2/sites-available/placement.conf').with_content(line) - end - end - context 'Enable chainfile, ciphers & cert_required' do - cached(:chef_run) do - node.override['openstack']['placement']['ssl']['enabled'] = true - node.override['openstack']['placement']['ssl']['ciphers'] = 'ssl_ciphers_value' - node.override['openstack']['placement']['ssl']['chainfile'] = 'chainfile' - node.override['openstack']['placement']['ssl']['cert_required'] = true - runner.converge(described_recipe) - end - [ - /SSLCipherSuite ssl_ciphers_value$/, - /SSLCertificateChainFile chainfile$/, - /SSLVerifyClient require/, - ].each do |line| - it do - expect(chef_run).to render_file('/etc/apache2/sites-available/placement.conf').with_content(line) - end - end - end - end - - it do - expect(chef_run.template('/etc/apache2/sites-available/placement.conf')).to \ - notify('service[apache2]').to(:restart) - end - - it do - expect(chef_run).to enable_apache2_site('placement') - end - - it do - expect(chef_run.apache2_site('placement')).to notify('service[apache2]').to(:restart).immediately - end - end -end diff --git a/cookbooks/openstack-compute/spec/scheduler-redhat_spec.rb b/cookbooks/openstack-compute/spec/scheduler-redhat_spec.rb deleted file mode 100644 index 7d07d016..00000000 --- a/cookbooks/openstack-compute/spec/scheduler-redhat_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::scheduler' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it 'upgrades nova scheduler package' do - expect(chef_run).to upgrade_package('openstack-nova-scheduler') - end - - it 'starts nova scheduler' do - expect(chef_run).to start_service('openstack-nova-scheduler') - end - - it 'starts nova scheduler on boot' do - expect(chef_run).to enable_service('openstack-nova-scheduler') - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/scheduler_spec.rb b/cookbooks/openstack-compute/spec/scheduler_spec.rb deleted file mode 100644 index d61ec7f8..00000000 --- a/cookbooks/openstack-compute/spec/scheduler_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::scheduler' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it do - expect(chef_run).to upgrade_package %w(python3-nova nova-scheduler) - end - - it 'starts nova scheduler' do - expect(chef_run).to start_service('nova-scheduler') - end - - it 'starts nova scheduler on boot' do - expect(chef_run).to enable_service('nova-scheduler') - end - end -end diff --git a/cookbooks/openstack-compute/spec/serialproxy-redhat_spec.rb b/cookbooks/openstack-compute/spec/serialproxy-redhat_spec.rb deleted file mode 100644 index 9835d99b..00000000 --- a/cookbooks/openstack-compute/spec/serialproxy-redhat_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::serialproxy' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it 'upgrades nova serialproxy package' do - expect(chef_run).to upgrade_package('openstack-nova-serialproxy') - end - - it 'starts nova serialproxy' do - expect(chef_run).to start_service('openstack-nova-serialproxy') - end - - it 'starts nova serialproxy on boot' do - expect(chef_run).to enable_service('openstack-nova-serialproxy') - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/serialproxy_spec.rb b/cookbooks/openstack-compute/spec/serialproxy_spec.rb deleted file mode 100644 index 1257a4e4..00000000 --- a/cookbooks/openstack-compute/spec/serialproxy_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::serialproxy' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it do - expect(chef_run).to upgrade_package %w(python3-nova nova-serialproxy) - end - - it 'starts nova serialproxy' do - expect(chef_run).to start_service('nova-serialproxy') - end - - it 'starts nova serialproxy on boot' do - expect(chef_run).to enable_service('nova-serialproxy') - end - end -end diff --git a/cookbooks/openstack-compute/spec/spec_helper.rb b/cookbooks/openstack-compute/spec/spec_helper.rb deleted file mode 100644 index 1827872f..00000000 --- a/cookbooks/openstack-compute/spec/spec_helper.rb +++ /dev/null @@ -1,220 +0,0 @@ -require 'chefspec' -require 'chefspec/berkshelf' -require 'chef/application' -require 'securerandom' - -RSpec.configure do |config| - config.color = true - config.formatter = :documentation - config.log_level = :warn - config.file_cache_path = '/var/chef/cache' -end - -REDHAT_7 = { - platform: 'redhat', - version: '7', -}.freeze - -REDHAT_8 = { - platform: 'redhat', - version: '8', -}.freeze - -ALL_RHEL = [ - REDHAT_7, - REDHAT_8, -].freeze - -UBUNTU_OPTS = { - platform: 'ubuntu', - version: '18.04', -}.freeze - -shared_context 'compute_stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers) - .and_return '1.1.1.1:5672,2.2.2.2:5672' - allow_any_instance_of(Chef::Recipe).to receive(:address_for) - .with('lo') - .and_return '127.0.1.1' - allow_any_instance_of(Chef::Recipe).to receive(:search_for) - .with('os-identity').and_return( - [{ - 'openstack' => { - 'identity' => { - 'admin_tenant_name' => 'admin', - 'admin_user' => 'admin', - }, - }, - }] - ) - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'openstack_identity_bootstrap_token') - .and_return('bootstrap-token') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'neutron_metadata_secret') - .and_return('metadata-secret') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'openstack_vmware_secret_name') - .and_return 'vmware_secret_name' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'nova') - .and_return('nova_db_pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'nova_api') - .and_return('nova_api_db_pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'nova_cell0') - .and_return('nova_cell0_db_pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'placement') - .and_return('placement_db_pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'guest') - .and_return('mq-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return('admin') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-compute') - .and_return('nova-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-network') - .and_return('neutron-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-placement') - .and_return('placement-pass') - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('compute') - .and_return('rabbit://guest:mypass@127.0.0.1:5672') - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('placement') - .and_return('rabbit://guest:mypass@127.0.0.1:5672') - allow_any_instance_of(Chef::Recipe).to receive(:memcached_servers).and_return [] - allow(Chef::Application).to receive(:fatal!) - allow(SecureRandom).to receive(:hex).and_return('ad3313264ea51d8c6a3d1c5b140b9883') - # stub_command('nova-manage network list | grep 192.168.100.0/24').and_return(false) - # stub_command('nova-manage network list | grep 192.168.200.0/24').and_return(false) - # stub_command("nova-manage floating list |grep -E '.*([0-9]{1,3}[.]){3}[0-9]{1,3}*'").and_return(false) - stub_command('/usr/sbin/apache2 -t').and_return(true) - stub_command('/usr/sbin/httpd -t').and_return(true) - stub_command('virsh net-list | grep -q default').and_return(true) - stub_command('ovs-vsctl br-exists br-int').and_return(true) - stub_command('ovs-vsctl br-exists br-tun').and_return(true) - stub_command('nova-manage api_db sync').and_return(true) - stub_command('nova-manage cell_v2 map_cell0 --database_connection mysql+pymysql://nova_cell0:mypass@127.0.0.1/nova_cell0?charset=utf8').and_return(true) - stub_command('nova-manage cell_v2 create_cell --verbose --name cell1').and_return(true) - stub_command('nova-manage cell_v2 list_cells | grep -q cell0').and_return(false) - stub_command('nova-manage cell_v2 list_cells | grep -q cell1').and_return(false) - stub_command('nova-manage cell_v2 discover_hosts').and_return(true) - stub_command("[ ! -e /etc/httpd/conf/httpd.conf ] && [ -e /etc/redhat-release ] && [ $(/sbin/sestatus | grep -c '^Current mode:.*enforcing') -eq 1 ]").and_return(true) - # identity stubs - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'credential_key0') - .and_return('thisiscredentialkey0') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'credential_key1') - .and_return('thisiscredentialkey1') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'fernet_key0') - .and_return('thisisfernetkey0') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'fernet_key1') - .and_return('thisisfernetkey1') - allow_any_instance_of(Chef::Recipe).to receive(:search_for) - .with('os-identity').and_return( - [{ - 'openstack' => { - 'identity' => { - 'admin_tenant_name' => 'admin', - 'admin_user' => 'admin', - }, - }, - }] - ) - allow_any_instance_of(Chef::Recipe).to receive(:memcached_servers) - .and_return([]) - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('identity') - .and_return('rabbit://openstack:mypass@127.0.0.1:5672') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'keystone') - .and_return('test-passes') - end -end - -shared_examples 'expect_volume_packages' do - it do - expect(chef_run).to upgrade_package %w(sysfsutils sg3_utils device-mapper-multipath) - end -end - -shared_examples 'expect_runs_nova_apache_recipe' do - it 'includes _nova_apache' do - expect(chef_run).to include_recipe 'openstack-compute::_nova_apache' - end -end - -shared_examples 'expect_runs_nova_common_recipe' do - it 'includes nova-common' do - expect(chef_run).to include_recipe 'openstack-compute::nova-common' - end -end - -shared_examples 'expect_runs_nova_cell_recipe' do - it 'includes _nova_cell' do - expect(chef_run).to include_recipe 'openstack-compute::_nova_cell' - end -end - -shared_examples 'expect_creates_nova_state_dir' do - it 'creates the /var/lib/nova/lock directory' do - expect(chef_run).to create_directory('/var/lib/nova').with( - user: 'nova', - group: 'nova', - mode: '755' - ) - end -end - -shared_examples 'expect_creates_nova_lock_dir' do - it 'creates the /var/lib/nova/lock directory' do - expect(chef_run).to create_directory('/var/lib/nova/lock').with( - user: 'nova', - group: 'nova', - mode: '755' - ) - end -end - -shared_examples 'expect_creates_nova_instances_dir' do - it 'creates the /var/lib/nova/instances directory' do - expect(chef_run).to create_directory('/var/lib/nova/instances').with( - user: 'nova', - group: 'nova', - mode: '755' - ) - end -end - -shared_examples 'expect_creates_api_paste_template' do - let(:file) { chef_run.template('/etc/nova/api-paste.ini') } - it 'creates api-paste.ini' do - expect(chef_run).to create_template('/etc/nova/api-paste.ini').with( - user: 'nova', - group: 'nova', - mode: '644' - ) - end - - context 'template contents' do - cached(:chef_run) do - node.override['openstack']['compute']['misc_paste'] = %w(paste1 paste2) - runner.converge(described_recipe) - end - it 'pastes the misc attributes' do - expect(chef_run).to render_file(file.name) - .with_content(/^paste1$/).with_content(/^paste2$/) - end - end -end diff --git a/cookbooks/openstack-compute/spec/spiceproxy-redhat_spec.rb b/cookbooks/openstack-compute/spec/spiceproxy-redhat_spec.rb deleted file mode 100644 index 259fee1c..00000000 --- a/cookbooks/openstack-compute/spec/spiceproxy-redhat_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::spiceproxy' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it do - expect(chef_run).to upgrade_package %w(openstack-nova-spicehtml5proxy spice-html5) - end - - it 'starts nova spicehtml5proxy' do - expect(chef_run).to start_service('openstack-nova-spicehtml5proxy') - end - - it 'starts nova spicehtml5proxy on boot' do - expect(chef_run).to enable_service('openstack-nova-spicehtml5proxy') - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/spiceproxy_spec.rb b/cookbooks/openstack-compute/spec/spiceproxy_spec.rb deleted file mode 100644 index d099ba89..00000000 --- a/cookbooks/openstack-compute/spec/spiceproxy_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::spiceproxy' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it do - expect(chef_run).to upgrade_package %w(nova-spiceproxy spice-html5) - end - - it 'starts nova spiceproxy' do - expect(chef_run).to start_service('nova-spiceproxy') - end - - it 'starts nova spiceproxy on boot' do - expect(chef_run).to enable_service('nova-spiceproxy') - end - end -end diff --git a/cookbooks/openstack-compute/spec/vncproxy-redhat_spec.rb b/cookbooks/openstack-compute/spec/vncproxy-redhat_spec.rb deleted file mode 100644 index 62316ee2..00000000 --- a/cookbooks/openstack-compute/spec/vncproxy-redhat_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::vncproxy' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it 'upgrades nova vncproxy package' do - expect(chef_run).to upgrade_package('openstack-nova-novncproxy') - end - - it 'starts nova vncproxy' do - expect(chef_run).to start_service('openstack-nova-novncproxy') - end - - it 'starts nova vncproxy on boot' do - expect(chef_run).to enable_service('openstack-nova-novncproxy') - end - end - end -end diff --git a/cookbooks/openstack-compute/spec/vncproxy_spec.rb b/cookbooks/openstack-compute/spec/vncproxy_spec.rb deleted file mode 100644 index 8373480e..00000000 --- a/cookbooks/openstack-compute/spec/vncproxy_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-compute::vncproxy' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'compute_stubs' - include_examples 'expect_runs_nova_common_recipe' - include_examples 'expect_creates_nova_state_dir' - include_examples 'expect_creates_nova_lock_dir' - - it do - expect(chef_run).to upgrade_package %w(novnc websockify python3-nova nova-novncproxy) - end - - it 'starts nova vncproxy' do - expect(chef_run).to start_service('nova-novncproxy') - end - - it 'starts nova vncproxy on boot' do - expect(chef_run).to enable_service('nova-novncproxy') - end - end -end From 0d092106757987cba787c7c8fd7a568958ae91f9 Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 12:34:52 +0400 Subject: [PATCH 7/9] cleanup on openstack-block-storage --- .../.delivery/project.toml | 9 - .../openstack-block-storage/.rubocop.yml | 4 - cookbooks/openstack-block-storage/.zuul.yaml | 3 - cookbooks/openstack-block-storage/Berksfile | 23 -- .../openstack-block-storage/CONTRIBUTING.md | 36 --- cookbooks/openstack-block-storage/TESTING.md | 30 --- .../spec/api-redhat_spec.rb | 35 --- .../openstack-block-storage/spec/api_spec.rb | 168 -------------- .../spec/backup-redhat_spec.rb | 41 ---- .../spec/backup_spec.rb | 36 --- .../spec/cinder_common-redhat_spec.rb | 20 -- .../spec/cinder_common_spec.rb | 208 ------------------ .../spec/identity_registration_spec.rb | 110 --------- .../spec/scheduler-redhat_spec.rb | 39 ---- .../spec/scheduler_spec.rb | 32 --- .../spec/spec_helper.rb | 171 -------------- .../spec/volume-redhat_spec.rb | 57 ----- .../spec/volume_spec.rb | 40 ---- 18 files changed, 1062 deletions(-) delete mode 100644 cookbooks/openstack-block-storage/.delivery/project.toml delete mode 100644 cookbooks/openstack-block-storage/.rubocop.yml delete mode 100644 cookbooks/openstack-block-storage/.zuul.yaml delete mode 100644 cookbooks/openstack-block-storage/Berksfile delete mode 100644 cookbooks/openstack-block-storage/CONTRIBUTING.md delete mode 100644 cookbooks/openstack-block-storage/TESTING.md delete mode 100644 cookbooks/openstack-block-storage/spec/api-redhat_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/api_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/backup-redhat_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/backup_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/cinder_common-redhat_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/cinder_common_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/identity_registration_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/scheduler-redhat_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/scheduler_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/spec_helper.rb delete mode 100644 cookbooks/openstack-block-storage/spec/volume-redhat_spec.rb delete mode 100644 cookbooks/openstack-block-storage/spec/volume_spec.rb diff --git a/cookbooks/openstack-block-storage/.delivery/project.toml b/cookbooks/openstack-block-storage/.delivery/project.toml deleted file mode 100644 index 4066e559..00000000 --- a/cookbooks/openstack-block-storage/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[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/cookbooks/openstack-block-storage/.rubocop.yml b/cookbooks/openstack-block-storage/.rubocop.yml deleted file mode 100644 index 389f2700..00000000 --- a/cookbooks/openstack-block-storage/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -Chef/Modernize/FoodcriticComments: - Enabled: true -Chef/Style/CopyrightCommentFormat: - Enabled: true diff --git a/cookbooks/openstack-block-storage/.zuul.yaml b/cookbooks/openstack-block-storage/.zuul.yaml deleted file mode 100644 index f5786847..00000000 --- a/cookbooks/openstack-block-storage/.zuul.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- project: - templates: - - openstack-chef-jobs diff --git a/cookbooks/openstack-block-storage/Berksfile b/cookbooks/openstack-block-storage/Berksfile deleted file mode 100644 index 745aef5e..00000000 --- a/cookbooks/openstack-block-storage/Berksfile +++ /dev/null @@ -1,23 +0,0 @@ -source 'https://supermarket.chef.io' - -solver :ruby, :required - -[ - %w(client dep), - %w(-common dep), - %w(-dns integration), - %w(-identity dep), - %w(-image dep), - %w(-integration-test integration), - %w(-network integration), - %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}", group: group - else - cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group - end -end - -metadata diff --git a/cookbooks/openstack-block-storage/CONTRIBUTING.md b/cookbooks/openstack-block-storage/CONTRIBUTING.md deleted file mode 100644 index bb03231f..00000000 --- a/cookbooks/openstack-block-storage/CONTRIBUTING.md +++ /dev/null @@ -1,36 +0,0 @@ -Contributing -============ - -How To Get Started ------------------- - -If you would like to contribute to the development of OpenStack Chef Cookbooks, -you must follow the steps in this page: - - http://docs.openstack.org/infra/manual/developers.html - -Gerrit Workflow ---------------- - -Once those steps have been completed, changes to OpenStack -should be submitted for review via the Gerrit tool, following -the workflow documented at: - - http://docs.openstack.org/infra/manual/developers.html#development-workflow - -Pull requests submitted through GitHub will be ignored. - -Bugs ----- - -Bugs should be filed on Launchpad, not GitHub: - - https://bugs.launchpad.net/openstack-chef - -Contacts --------- - -Mailing list: groups.google.com/group/opscode-chef-openstack -IRC: #openstack-chef is our channel on irc.oftc.net -Wiki: https://wiki.openstack.org/wiki/Chef/GettingStarted and https://docs.getchef.com/openstack.html -Twitter: @chefopenstack diff --git a/cookbooks/openstack-block-storage/TESTING.md b/cookbooks/openstack-block-storage/TESTING.md deleted file mode 100644 index 1dd45c5a..00000000 --- a/cookbooks/openstack-block-storage/TESTING.md +++ /dev/null @@ -1,30 +0,0 @@ -# Testing the Cookbook # - -This cookbook uses [chefdk](https://downloads.chef.io/chef-dk/) and [berkshelf](http://berkshelf.com/) to isolate dependencies. Make sure you have chefdk and the header files for `gecode` installed before continuing. Make sure that you're using gecode version 3. More info [here](https://github.com/opscode/dep-selector-libgecode/tree/0bad63fea305ede624c58506423ced697dd2545e#using-a-system-gecode-instead). For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the [openstack-chef-repo](https://github.com/openstack/openstack-chef-repo). - -We have three test suites which you can run either, individually (there are three rake tasks): - - $ chef exec rake lint - $ chef exec rake style - $ chef exec rake unit - -or altogether: - - $ chef exec rake - -The `rake` tasks will take care of installing the needed cookbooks with `berkshelf`. - -## Rubocop ## - -[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits. - -## Foodcritic ## - -[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules: - -* [FC003](http://acrmp.github.io/foodcritic/#FC003) These cookbooks are not intended for Chef Solo. -* [FC023](http://acrmp.github.io/foodcritic/#FC023) Prefer conditional attributes. - -## Chefspec - -[ChefSpec](https://github.com/sethvargo/chefspec) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers. diff --git a/cookbooks/openstack-block-storage/spec/api-redhat_spec.rb b/cookbooks/openstack-block-storage/spec/api-redhat_spec.rb deleted file mode 100644 index 43105a20..00000000 --- a/cookbooks/openstack-block-storage/spec/api-redhat_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::api' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - - it do - expect(chef_run).to_not create_file('/etc/apache2/conf-available/cinder-wsgi.conf') - end - - it do - expect(chef_run).to upgrade_package %w(openstack-cinder) - end - - case p - when REDHAT_7 - it 'upgrades mysql python package' do - expect(chef_run).to upgrade_package 'MySQL-python' - end - when REDHAT_8 - it 'upgrades mysql python package' do - expect(chef_run).to upgrade_package 'python3-PyMySQL' - end - end - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/api_spec.rb b/cookbooks/openstack-block-storage/spec/api_spec.rb deleted file mode 100644 index 3719cb1d..00000000 --- a/cookbooks/openstack-block-storage/spec/api_spec.rb +++ /dev/null @@ -1,168 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::api' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - include_examples 'common-logging' - include_examples 'creates_cinder_conf', 'service[apache2]', 'cinder', 'cinder', 'restart' - - it do - expect(chef_run).to create_file('/etc/apache2/conf-available/cinder-wsgi.conf').with( - owner: 'root', - group: 'www-data', - mode: '0640', - content: '# Chef openstack-block-storage: file to block config from package' - ) - end - - it do - expect(chef_run).to upgrade_package %w(python3-cinder cinder-api) - end - - it 'upgrades mysql python3 package' do - expect(chef_run).to upgrade_package('python3-mysqldb') - end - - it 'runs db migrations' do - expect(chef_run).to run_execute('cinder-manage db sync').with(user: 'cinder', group: 'cinder') - end - - describe 'apache wsgi' do - let(:file) { '/etc/apache2/sites-available/cinder-api.conf' } - - it do - expect(chef_run).to create_template(file).with( - source: 'wsgi-template.conf.erb', - variables: { - daemon_process: 'cinder-wsgi', - group: 'cinder', - log_dir: '/var/log/apache2', - run_dir: '/var/lock', - server_entry: '/usr/bin/cinder-wsgi', - server_host: '127.0.0.1', - server_port: '8776', - user: 'cinder', - } - ) - end - it 'configures cinder-api.conf' do - [ - /VirtualHost 127.0.0.1:8776/, - /WSGIDaemonProcess cinder-wsgi processes=2 threads=10 user=cinder group=cinder display-name=%{GROUP}/, - /WSGIProcessGroup cinder-wsgi/, - %r{WSGIScriptAlias / /usr/bin/cinder-wsgi}, - %r{ErrorLog /var/log/apache2/cinder-wsgi_error.log}, - %r{CustomLog /var/log/apache2/cinder-wsgi_access.log combined}, - %r{WSGISocketPrefix /var/lock}, - ].each do |line| - expect(chef_run).to render_file(file).with_content(line) - end - expect(chef_run).to_not render_file(file).with_content(/SSLEngine On/) - end - it do - expect(chef_run.template(file)).to notify('service[apache2]').to(:restart) - end - - it do - expect(chef_run).to install_apache2_install('openstack').with(listen: %w(127.0.0.1:8776)) - end - - it do - expect(chef_run).to create_apache2_mod_wsgi('openstack') - end - - it do - expect(chef_run).to_not enable_apache2_module('ssl') - end - - it do - expect(chef_run).to disable_apache2_conf('cinder-wsgi') - end - - it do - expect(chef_run).to enable_apache2_site('cinder-api') - end - - it do - expect(chef_run.apache2_site('cinder-api')).to notify('service[apache2]').to(:restart).immediately - end - context 'Enable SSL' do - cached(:chef_run) do - node.override['openstack']['block-storage']['ssl']['enabled'] = true - node.override['openstack']['block-storage']['ssl']['certfile'] = 'certfile' - node.override['openstack']['block-storage']['ssl']['keyfile'] = 'keyfile' - node.override['openstack']['block-storage']['ssl']['ca_certs_path'] = 'ca_certs_path' - node.override['openstack']['block-storage']['ssl']['protocol'] = 'protocol' - runner.converge(described_recipe) - end - it do - expect(chef_run).to enable_apache2_module('ssl') - end - it 'configures cinder-api.conf' do - [ - /SSLEngine On/, - /SSLCertificateFile certfile/, - /SSLCertificateKeyFile keyfile/, - /SSLCACertificatePath ca_certs_path/, - /SSLProtocol protocol/, - ].each do |line| - expect(chef_run).to render_file(file).with_content(line) - end - [ - /SSLCertificateChainFile/, - /SSLCipherSuite/, - /SSLVerifyClient/, - ].each do |line| - expect(chef_run).to_not render_file(file).with_content(line) - end - end - context 'Enable chainfile, ciphers & cert_required' do - cached(:chef_run) do - node.override['openstack']['block-storage']['ssl']['enabled'] = true - node.override['openstack']['block-storage']['ssl']['chainfile'] = 'chainfile' - node.override['openstack']['block-storage']['ssl']['ciphers'] = 'ciphers' - node.override['openstack']['block-storage']['ssl']['cert_required'] = true - runner.converge(described_recipe) - end - it 'configures cinder-api.conf' do - [ - /SSLCertificateChainFile chainfile/, - /SSLCipherSuite ciphers/, - /SSLVerifyClient require/, - ].each do |line| - expect(chef_run).to render_file(file).with_content(line) - end - end - end - end - end - - describe 'policy file' do - it 'does not manage policy file unless specified' do - expect(chef_run).not_to create_remote_file('/etc/cinder/policy.json') - end - context 'policy file specified' do - cached(:chef_run) do - node.override['openstack']['block-storage']['policyfile_url'] = 'http://server/mypolicy.json' - runner.converge(described_recipe) - end - let(:remote_policy) { chef_run.remote_file('/etc/cinder/policy.json') } - - it 'manages policy file when remote file is specified' do - expect(chef_run).to create_remote_file('/etc/cinder/policy.json').with( - user: 'cinder', - group: 'cinder', - mode: '644' - ) - end - end - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/backup-redhat_spec.rb b/cookbooks/openstack-block-storage/spec/backup-redhat_spec.rb deleted file mode 100644 index eb5bdbc2..00000000 --- a/cookbooks/openstack-block-storage/spec/backup-redhat_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::backup' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - - describe 'enable cinder backup service' do - before do - node.override['openstack']['block-storage']['backup']['enabled'] = true - end - - it 'starts cinder backup' do - expect(chef_run).to start_service 'openstack-cinder-backup' - end - - it 'starts cinder backup on boot' do - expect(chef_run).to enable_service 'openstack-cinder-backup' - end - - case p - when REDHAT_7 - it 'upgrades mysql python package' do - expect(chef_run).to upgrade_package 'MySQL-python' - end - when REDHAT_8 - it 'upgrades mysql python package' do - expect(chef_run).to upgrade_package 'python3-PyMySQL' - end - end - end - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/backup_spec.rb b/cookbooks/openstack-block-storage/spec/backup_spec.rb deleted file mode 100644 index eaeb4d71..00000000 --- a/cookbooks/openstack-block-storage/spec/backup_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::backup' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - - describe 'enable cinder backup service' do - it do - expect(chef_run).to upgrade_package %w(python3-cinder cinder-backup) - end - - it 'starts cinder backup' do - expect(chef_run).to start_service 'cinder-backup' - end - - it 'starts cinder backup on boot' do - expect(chef_run).to enable_service 'cinder-backup' - end - - it 'subscribes to the template change' do - expect(chef_run.service('cinder-backup')).to subscribe_to('template[/etc/cinder/cinder.conf]') - end - - it 'upgrades mysql python3 package' do - expect(chef_run).to upgrade_package 'python3-mysqldb' - end - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/cinder_common-redhat_spec.rb b/cookbooks/openstack-block-storage/spec/cinder_common-redhat_spec.rb deleted file mode 100644 index f7d8656c..00000000 --- a/cookbooks/openstack-block-storage/spec/cinder_common-redhat_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::cinder-common' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - - it 'upgrades the openstack-cinder package' do - expect(chef_run).to upgrade_package 'openstack-cinder' - end - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/cinder_common_spec.rb b/cookbooks/openstack-block-storage/spec/cinder_common_spec.rb deleted file mode 100644 index 2404c41e..00000000 --- a/cookbooks/openstack-block-storage/spec/cinder_common_spec.rb +++ /dev/null @@ -1,208 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::cinder-common' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - let(:test_pass) { 'test_pass' } - cached(:chef_run) do - node.override['openstack']['mq']['host'] = '127.0.0.1' - node.override['openstack']['mq']['block-storage']['rabbit']['notification_topic'] = 'rabbit_topic' - runner.converge(described_recipe) - end - - before do - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', anything) - .and_return(test_pass) - allow_any_instance_of(Chef::Recipe).to receive(:db_uri) - .and_return('sql_connection_value') - end - - include_context 'block-storage-stubs' - - it 'upgrades the cinder-common package' do - expect(chef_run).to upgrade_package 'cinder-common' - end - - describe '/etc/cinder' do - let(:dir) { chef_run.directory('/etc/cinder') } - - it 'should create the /etc/cinder directory' do - expect(chef_run).to create_directory(dir.name).with( - owner: 'cinder', - group: 'cinder', - mode: '750' - ) - end - end - - describe 'cinder.conf' do - let(:file) { chef_run.template('/etc/cinder/cinder.conf') } - - it 'should create the cinder.conf template' do - expect(chef_run).to create_template(file.name).with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - owner: 'cinder', - group: 'cinder', - mode: '640', - sensitive: true - ) - end - - describe 'keystone authtoken attributes with default values' do - it 'does not set memcached server(s)' do - expect(chef_run).not_to render_file(file.name).with_content(/^memcached_servers = $/) - end - - it 'does not set memcache security strategy' do - expect(chef_run).not_to render_file(file.name).with_content(/^memcache_security_strategy = $/) - end - - it 'does not set memcache secret key' do - expect(chef_run).not_to render_file(file.name).with_content(/^memcache_secret_key = $/) - end - - it 'does not set cafile' do - expect(chef_run).not_to render_file(file.name).with_content(/^cafile = $/) - end - end - - describe 'keystone authtoken attributes' do - it do - expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/) - end - - it 'has an admin password' do - # (fgimenez) the get_password mocking is set in spec/spec_helper.rb - expect(chef_run).to render_config_file(file.name) - .with_section_content('keystone_authtoken', /^password = cinder-pass$/) - end - end - - describe 'template contents' do - it 'has a lock_path attribute' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('oslo_concurrency', %r{^lock_path = /var/lib/cinder/tmp}) - end - - it 'does not have unique host id by default' do - expect(chef_run).not_to render_config_file(file.name).with_section_content('DEFAULT', /^host = /) - end - - it 'does not have keymgr attribute fixed_key set by default' do - expect(chef_run).not_to render_file(file.name).with_content(/^fixed_key = $/) - end - - context 'syslog use' do - cached(:chef_run) do - node.override['openstack']['block-storage']['syslog']['use'] = true - runner.converge(described_recipe) - end - it 'sets the log_config value when syslog is in use' do - expect(chef_run).to render_file(file.name).with_content(%r{^log_config = /etc/openstack/logging.conf$}) - end - end - - it 'has a db connection attribute' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('database', /^connection = sql_connection_value$/) - end - - it 'has a glance_api_servers attribute' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('DEFAULT', %r{^glance_api_servers = http://127.0.0.1:9292$}) - end - - describe 'cinder endpoint' do - it 'has osapi_volume_listen set' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('DEFAULT', /^osapi_volume_listen = 127.0.0.1$/) - end - - it 'has osapi_volume_listen_port set' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('DEFAULT', /^osapi_volume_listen_port = 8776$/) - end - end - it 'has default transport_url/AMQP options set' do - [ - %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - - describe 'rabbitmq as mq service' do - describe 'non ha attributes' do - it 'does not have a rabbit_hosts attribute' do - expect(chef_run).not_to render_config_file(file.name) - .with_section_content('oslo_messaging_rabbit', /^rabbit_hosts = /) - end - end - end - - context 'commonly named volume attributes' do - vol_attrs = %w(iscsi_ip_address iscsi_port iscsi_helper volumes_dir) - cached(:chef_run) do - vol_attrs.each do |attr| - node.override['openstack']['block-storage']['conf']['DEFAULT'][attr] = "common_volume_#{attr}_value" - end - runner.converge(described_recipe) - end - vol_attrs.each do |attr| - it "has volume related #{attr} attribute" do - expect(chef_run).to render_file(file.name).with_content(/^#{attr} = common_volume_#{attr}_value$/) - end - end - end - end - end - - describe '/var/lib/cinder/tmp' do - let(:dir) { chef_run.directory('/var/lib/cinder/tmp') } - - it 'should create the /var/lib/cinder/tmp directory' do - expect(chef_run).to create_directory(dir.name).with( - user: 'cinder', - group: 'cinder', - mode: '755' - ) - end - end - - describe 'rootwrap.conf' do - let(:file) { chef_run.template('/etc/cinder/rootwrap.conf') } - - it 'creates the /etc/cinder/rootwrap.conf file' do - expect(chef_run).to create_template(file.name).with( - user: 'root', - group: 'root', - mode: '644' - ) - end - - context 'template contents' do - it 'sets the default attributes' do - [ - %r{^filters_path = /etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$}, - %r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$}, - /^use_syslog = false$/, - /^syslog_log_facility = syslog$/, - /^syslog_log_level = ERROR$/, - ].each do |line| - expect(chef_run).to render_file(file.name).with_content(line) - end - end - end - end - - it do - expect(chef_run).to run_ruby_block("delete all attributes in node['openstack']['block-storage']['conf_secrets']") - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/identity_registration_spec.rb b/cookbooks/openstack-block-storage/spec/identity_registration_spec.rb deleted file mode 100644 index 0983cdd4..00000000 --- a/cookbooks/openstack-block-storage/spec/identity_registration_spec.rb +++ /dev/null @@ -1,110 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::identity_registration' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - - connection_params = { - openstack_auth_url: 'http://127.0.0.1:5000/v3', - openstack_username: 'admin', - openstack_api_key: 'emc_test_pass', - openstack_project_name: 'admin', - openstack_domain_name: 'default', - } - service_name = 'cinderv2' - service_type = 'volumev2' - service_user = 'cinder' - url = 'http://127.0.0.1:8776/v2/%(tenant_id)s' - url_v3 = 'http://127.0.0.1:8776/v3/%(tenant_id)s' - region = 'RegionOne' - project_name = 'service' - role_name = 'service' - password = 'cinder-pass' - domain_name = 'Default' - - it "registers #{project_name} Project" do - expect(chef_run).to create_openstack_project( - project_name - ).with( - connection_params: connection_params - ) - end - - it "registers #{service_name} service" do - expect(chef_run).to create_openstack_service( - service_name - ).with( - connection_params: connection_params, - type: service_type - ) - end - - it 'registers cinderv3 service' do - expect(chef_run).to create_openstack_service( - 'cinderv3' - ).with( - connection_params: connection_params, - type: 'volumev3' - ) - end - - context "registers #{service_name} endpoint" do - %w(internal public).each do |interface| - it "#{interface} endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - service_type - ).with( - service_name: service_name, - # interface: interface, - url: url, - region: region, - connection_params: connection_params - ) - end - - it "volumev3 #{interface} endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - 'volumev3' - ).with( - service_name: 'cinderv3', - # interface: interface, - url: url_v3, - region: region, - connection_params: connection_params - ) - end - end - - context 'with custom region override' do - cached(:chef_run) do - node.override['openstack']['block-storage']['region'] = 'volumeRegion' - runner.converge(described_recipe) - end - it do - expect(chef_run).to create_openstack_endpoint( - service_type - ).with(region: 'volumeRegion') - end - end - end - - it 'registers service user' do - expect(chef_run).to create_openstack_user( - service_user - ).with( - domain_name: domain_name, - project_name: project_name, - role_name: role_name, - password: password, - connection_params: connection_params - ) - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/scheduler-redhat_spec.rb b/cookbooks/openstack-block-storage/spec/scheduler-redhat_spec.rb deleted file mode 100644 index ff440a4b..00000000 --- a/cookbooks/openstack-block-storage/spec/scheduler-redhat_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::scheduler' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - - it 'upgrades cinder scheduler package' do - expect(chef_run).to upgrade_package 'openstack-cinder' - end - - it 'starts cinder scheduler' do - expect(chef_run).to start_service 'openstack-cinder-scheduler' - end - - it 'starts cinder scheduler on boot' do - expect(chef_run).to enable_service 'openstack-cinder-scheduler' - end - - case p - when REDHAT_7 - it 'upgrades mysql python package' do - expect(chef_run).to upgrade_package 'MySQL-python' - end - when REDHAT_8 - it 'upgrades mysql python package' do - expect(chef_run).to upgrade_package 'python3-PyMySQL' - end - end - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/scheduler_spec.rb b/cookbooks/openstack-block-storage/spec/scheduler_spec.rb deleted file mode 100644 index 54e10e9c..00000000 --- a/cookbooks/openstack-block-storage/spec/scheduler_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::scheduler' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - include_examples 'common-logging' - include_examples 'creates_cinder_conf', 'service[cinder-scheduler]', 'cinder', 'cinder' - - it do - expect(chef_run).to upgrade_package %w(python3-cinder cinder-scheduler) - end - - it 'starts cinder scheduler' do - expect(chef_run).to start_service 'cinder-scheduler' - end - - it 'starts cinder scheduler on boot' do - expect(chef_run).to enable_service 'cinder-scheduler' - end - - it 'upgrades mysql python3 package' do - expect(chef_run).to upgrade_package 'python3-mysqldb' - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/spec_helper.rb b/cookbooks/openstack-block-storage/spec/spec_helper.rb deleted file mode 100644 index 64d90540..00000000 --- a/cookbooks/openstack-block-storage/spec/spec_helper.rb +++ /dev/null @@ -1,171 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require 'chefspec' -require 'chefspec/berkshelf' -require 'chef/application' - -RSpec.configure do |config| - config.color = true - config.formatter = :documentation - config.log_level = :warn - config.file_cache_path = '/var/chef/cache' -end - -REDHAT_7 = { - platform: 'redhat', - version: '7', -}.freeze - -REDHAT_8 = { - platform: 'redhat', - version: '8', -}.freeze - -ALL_RHEL = [ - REDHAT_7, - REDHAT_8, -].freeze - -UBUNTU_OPTS = { - platform: 'ubuntu', - version: '18.04', -}.freeze - -shared_context 'block-storage-stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers) - .and_return('1.1.1.1:5672,2.2.2.2:5672') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', anything) - .and_return('') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', anything) - .and_return('') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'openstack_vmware_secret_name') - .and_return 'vmware_secret_name' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'guest') - .and_return('mq-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'netapp') - .and_return 'netapp-pass' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-block-storage') - .and_return('cinder-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return('emc_test_pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'ibmnas_admin') - .and_return('test_pass') - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('block_storage') - .and_return('rabbit://guest:mypass@127.0.0.1:5672') - stub_command('/usr/sbin/httpd -t').and_return(true) - stub_command('/usr/sbin/apache2 -t').and_return(true) - allow(Chef::Application).to receive(:fatal!) - # identity stubs - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'credential_key0') - .and_return('thisiscredentialkey0') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'credential_key1') - .and_return('thisiscredentialkey1') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'fernet_key0') - .and_return('thisisfernetkey0') - allow_any_instance_of(Chef::Recipe).to receive(:secret) - .with('secrets', 'fernet_key1') - .and_return('thisisfernetkey1') - allow_any_instance_of(Chef::Recipe).to receive(:search_for) - .with('os-identity').and_return( - [{ - 'openstack' => { - 'identity' => { - 'admin_tenant_name' => 'admin', - 'admin_user' => 'admin', - }, - }, - }] - ) - allow_any_instance_of(Chef::Recipe).to receive(:memcached_servers) - .and_return([]) - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('identity') - .and_return('rabbit://openstack:mypass@127.0.0.1:5672') - end -end - -shared_examples 'common-logging' do - context 'when syslog.use is true' do - cached(:chef_run) do - node.override['openstack']['block-storage']['syslog']['use'] = true - runner.converge(described_recipe) - end - - it 'runs logging recipe if node attributes say to' do - expect(chef_run).to include_recipe 'openstack-common::logging' - end - end - - context 'when syslog.use is false' do - cached(:chef_run) do - node.override['openstack']['block-storage']['syslog']['use'] = false - runner.converge(described_recipe) - end - - it 'runs logging recipe if node attributes say to' do - expect(chef_run).to_not include_recipe 'openstack-common::logging' - end - end -end - -def expect_runs_openstack_common_logging_recipe - it 'runs logging recipe if node attributes say to' do - expect(chef_run).to include_recipe 'openstack-common::logging' - end -end - -shared_examples 'creates_cinder_conf' do |service, user, group, action = :restart| - describe 'cinder.conf' do - let(:file) { chef_run.template('/etc/cinder/cinder.conf') } - - it 'creates the /etc/cinder/cinder.conf file' do - expect(chef_run).to create_template(file.name).with( - user: user, - group: group, - mode: '640' - ) - end - - it 'notifies service restart' do - expect(file).to notify(service).to(action) - end - - it do - [ - /^auth_type = password$/, - /^region_name = RegionOne$/, - /^username = cinder/, - /^project_name = service$/, - /^user_domain_name = Default/, - /^project_domain_name = Default/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^password = cinder-pass$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name) - .with_section_content('keystone_authtoken', line) - end - end - - it 'has oslo_messaging_notifications conf values' do - [ - /^driver = cinder.openstack.common.notifier.rpc_notifier$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_notifications', line) - end - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/volume-redhat_spec.rb b/cookbooks/openstack-block-storage/spec/volume-redhat_spec.rb deleted file mode 100644 index 18cea237..00000000 --- a/cookbooks/openstack-block-storage/spec/volume-redhat_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::volume' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - - case p - when REDHAT_7 - it do - expect(chef_run).to upgrade_package('MySQL-python') - end - - it do - expect(chef_run).to upgrade_package('qemu-img-ev') - end - - it do - expect(chef_run).to upgrade_package %w(targetcli dbus-python) - end - when REDHAT_8 - it do - expect(chef_run).to upgrade_package('python3-PyMySQL') - end - - it do - expect(chef_run).to upgrade_package('qemu-img') - end - - it do - expect(chef_run).to upgrade_package %w(targetcli python3-dbus) - end - end - - it do - expect(chef_run).to start_service('openstack-cinder-volume') - end - - it do - expect(chef_run).to enable_service('openstack-cinder-volume') - end - - context 'ISCSI' do - it do - expect(chef_run).to enable_service('iscsitarget') - end - end - end - end -end diff --git a/cookbooks/openstack-block-storage/spec/volume_spec.rb b/cookbooks/openstack-block-storage/spec/volume_spec.rb deleted file mode 100644 index 415e6087..00000000 --- a/cookbooks/openstack-block-storage/spec/volume_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -# Cookbook:: openstack-block-storage - -require_relative 'spec_helper' - -describe 'openstack-block-storage::volume' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'block-storage-stubs' - include_examples 'common-logging' - include_examples 'creates_cinder_conf', 'service[cinder-volume]', 'cinder', 'cinder' - - it do - expect(chef_run).to upgrade_package %w(python3-cinder cinder-volume qemu-utils thin-provisioning-tools) - end - - it 'starts cinder volume' do - expect(chef_run).to start_service 'cinder-volume' - end - - it 'starts cinder volume on boot' do - expect(chef_run).to enable_service 'cinder-volume' - end - - it 'starts iscsi target on boot' do - expect(chef_run).to enable_service 'iscsitarget' - end - - it 'upgrades mysql python3 packages by default' do - expect(chef_run).to upgrade_package 'python3-mysqldb' - end - - it 'upgrades cinder iscsi package' do - expect(chef_run).to upgrade_package 'targetcli-fb' - end - end -end From b9013ce2ac1805a43a544ae15bd473445ecb59ac Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 12:41:37 +0400 Subject: [PATCH 8/9] clean up on openstack orchestration cookbook --- .../.delivery/project.toml | 9 - .../openstack-orchestration/.rubocop.yml | 4 - cookbooks/openstack-orchestration/.zuul.yaml | 3 - cookbooks/openstack-orchestration/Berksfile | 24 -- .../openstack-orchestration/CONTRIBUTING.md | 36 --- cookbooks/openstack-orchestration/TESTING.md | 31 -- .../spec/api-cfn-redhat_spec.rb | 26 -- .../spec/api-cfn_spec.rb | 24 -- .../spec/api-redhat_spec.rb | 26 -- .../openstack-orchestration/spec/api_spec.rb | 24 -- .../spec/common-redhat_spec.rb | 34 --- .../spec/common_spec.rb | 60 ---- .../spec/dashboard-redhat_spec.rb | 16 - .../spec/dashboard_spec.rb | 14 - .../spec/engine-redhat_spec.rb | 26 -- .../spec/engine_spec.rb | 24 -- .../spec/identity_registration_spec.rb | 149 ---------- .../spec/spec_helper.rb | 280 ------------------ 18 files changed, 810 deletions(-) delete mode 100644 cookbooks/openstack-orchestration/.delivery/project.toml delete mode 100644 cookbooks/openstack-orchestration/.rubocop.yml delete mode 100644 cookbooks/openstack-orchestration/.zuul.yaml delete mode 100644 cookbooks/openstack-orchestration/Berksfile delete mode 100644 cookbooks/openstack-orchestration/CONTRIBUTING.md delete mode 100644 cookbooks/openstack-orchestration/TESTING.md delete mode 100644 cookbooks/openstack-orchestration/spec/api-cfn-redhat_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/api-cfn_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/api-redhat_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/api_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/common-redhat_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/common_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/dashboard-redhat_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/dashboard_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/engine-redhat_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/engine_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/identity_registration_spec.rb delete mode 100644 cookbooks/openstack-orchestration/spec/spec_helper.rb diff --git a/cookbooks/openstack-orchestration/.delivery/project.toml b/cookbooks/openstack-orchestration/.delivery/project.toml deleted file mode 100644 index 4066e559..00000000 --- a/cookbooks/openstack-orchestration/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[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/cookbooks/openstack-orchestration/.rubocop.yml b/cookbooks/openstack-orchestration/.rubocop.yml deleted file mode 100644 index 389f2700..00000000 --- a/cookbooks/openstack-orchestration/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -Chef/Modernize/FoodcriticComments: - Enabled: true -Chef/Style/CopyrightCommentFormat: - Enabled: true diff --git a/cookbooks/openstack-orchestration/.zuul.yaml b/cookbooks/openstack-orchestration/.zuul.yaml deleted file mode 100644 index f5786847..00000000 --- a/cookbooks/openstack-orchestration/.zuul.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- project: - templates: - - openstack-chef-jobs diff --git a/cookbooks/openstack-orchestration/Berksfile b/cookbooks/openstack-orchestration/Berksfile deleted file mode 100644 index f9254a81..00000000 --- a/cookbooks/openstack-orchestration/Berksfile +++ /dev/null @@ -1,24 +0,0 @@ -source 'https://supermarket.chef.io' - -solver :ruby, :required - -[ - %w(client dep), - %w(-common dep), - %w(-compute integration), - %w(-dns integration), - %w(-identity dep), - %w(-image integration), - %w(-integration-test integration), - %w(-network integration), - %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}", group: group - else - cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group - end -end - -metadata diff --git a/cookbooks/openstack-orchestration/CONTRIBUTING.md b/cookbooks/openstack-orchestration/CONTRIBUTING.md deleted file mode 100644 index e79f185a..00000000 --- a/cookbooks/openstack-orchestration/CONTRIBUTING.md +++ /dev/null @@ -1,36 +0,0 @@ -Contributing -============ - -How To Get Started ------------------- - -If you would like to contribute to the development of OpenStack Chef Cookbooks, -you must follow the steps in this page: - - https://docs.openstack.org/infra/manual/developers.html - -Gerrit Workflow ---------------- - -Once those steps have been completed, changes to OpenStack -should be submitted for review via the Gerrit tool, following -the workflow documented at: - - https://docs.openstack.org/infra/manual/developers.html#development-workflow - -Pull requests submitted through GitHub will be ignored. - -Bugs ----- - -Bugs should be filed on Launchpad, not GitHub: - - https://bugs.launchpad.net/openstack-chef - -Contacts --------- - -Mailing list: groups.google.com/group/opscode-chef-openstack -IRC: #openstack-chef is our channel on irc.oftc.net -Wiki: https://wiki.openstack.org/wiki/Chef/GettingStarted and https://docs.getchef.com/openstack.html -Twitter: @chefopenstack diff --git a/cookbooks/openstack-orchestration/TESTING.md b/cookbooks/openstack-orchestration/TESTING.md deleted file mode 100644 index 328cc4ba..00000000 --- a/cookbooks/openstack-orchestration/TESTING.md +++ /dev/null @@ -1,31 +0,0 @@ -# Testing the Cookbook # - -This cookbook uses [chefdk](https://downloads.chef.io/chef-dk/) and [berkshelf](https://berkshelf.com/) to isolate dependencies. Make sure you have chefdk and the header files for `gecode` installed before continuing. Make sure that you're using gecode version 3. More info [here](https://github.com/opscode/dep-selector-libgecode/tree/0bad63fea305ede624c58506423ced697dd2545e#using-a-system-gecode-instead). For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the [openstack-chef-repo](https://github.com/openstack/openstack-chef-repo). - -We have three test suites which you can run either, individually (there are three rake tasks): - - $ chef exec rake lint - $ chef exec rake style - $ chef exec rake unit - -or altogether: - - $ chef exec rake - -The `rake` tasks will take care of installing the needed cookbooks with `berkshelf`. - -## Rubocop ## - -[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits. - -## Foodcritic ## - -[Foodcritic](https://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules: - -* [FC003](https://acrmp.github.io/foodcritic/#FC003) These cookbooks are not intended for Chef Solo. -* [FC023](https://acrmp.github.io/foodcritic/#FC023) Prefer conditional attributes. - -## Chefspec - -[ChefSpec](https://github.com/sethvargo/chefspec) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers. - diff --git a/cookbooks/openstack-orchestration/spec/api-cfn-redhat_spec.rb b/cookbooks/openstack-orchestration/spec/api-cfn-redhat_spec.rb deleted file mode 100644 index 0eff088a..00000000 --- a/cookbooks/openstack-orchestration/spec/api-cfn-redhat_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::api-cfn' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' - - it 'installs heat cfn packages' do - expect(chef_run).to upgrade_package 'openstack-heat-api-cfn' - end - - it 'enables heat api-cfn on boot' do - expect(chef_run).to enable_service('openstack-heat-api-cfn') - end - - it 'starts heat api-cfn on boot' do - expect(chef_run).to start_service('openstack-heat-api-cfn') - end - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/api-cfn_spec.rb b/cookbooks/openstack-orchestration/spec/api-cfn_spec.rb deleted file mode 100644 index 4f5cef3b..00000000 --- a/cookbooks/openstack-orchestration/spec/api-cfn_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::api-cfn' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' - - it 'installs heat cfn packages' do - expect(chef_run).to upgrade_package 'heat-api-cfn' - end - - it 'enables heat api-cfn on boot' do - expect(chef_run).to enable_service('heat-api-cfn') - end - - it 'starts heat api-cfn on boot' do - expect(chef_run).to start_service('heat-api-cfn') - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/api-redhat_spec.rb b/cookbooks/openstack-orchestration/spec/api-redhat_spec.rb deleted file mode 100644 index aa953d29..00000000 --- a/cookbooks/openstack-orchestration/spec/api-redhat_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::api' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' - - it 'installs heat api packages' do - expect(chef_run).to upgrade_package 'openstack-heat-api' - end - - it 'enables heat api on boot' do - expect(chef_run).to enable_service('openstack-heat-api') - end - - it 'starts heat api on boot' do - expect(chef_run).to start_service('openstack-heat-api') - end - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/api_spec.rb b/cookbooks/openstack-orchestration/spec/api_spec.rb deleted file mode 100644 index 225c8bc1..00000000 --- a/cookbooks/openstack-orchestration/spec/api_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::api' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' - - it 'installs heat api packages' do - expect(chef_run).to upgrade_package 'heat-api' - end - - it 'enables heat api on boot' do - expect(chef_run).to enable_service('heat-api') - end - - it 'starts heat api on boot' do - expect(chef_run).to start_service('heat-api') - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/common-redhat_spec.rb b/cookbooks/openstack-orchestration/spec/common-redhat_spec.rb deleted file mode 100644 index 51e9aafe..00000000 --- a/cookbooks/openstack-orchestration/spec/common-redhat_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::common' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - include_examples 'logging' - include_examples 'expects to create heat directories' - include_examples 'expects to create heat conf' - include_examples 'expects to create heat default.yaml' - include_examples 'expect installs common heat package' - include_examples 'expect installs mysql package' - include_examples 'expect runs db migrations' - it do - expect(chef_run).to upgrade_package 'openstack-heat-common' - end - - case p - when REDHAT_7 - it do - expect(chef_run).to upgrade_package 'MySQL-python' - end - when REDHAT_8 - it do - expect(chef_run).to upgrade_package 'python3-PyMySQL' - end - end - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/common_spec.rb b/cookbooks/openstack-orchestration/spec/common_spec.rb deleted file mode 100644 index 6c9f1e48..00000000 --- a/cookbooks/openstack-orchestration/spec/common_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::common' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - include_examples 'logging' - include_examples 'expects to create heat directories' - include_examples 'expects to create heat conf' - include_examples 'expects to create heat default.yaml' - include_examples 'expect runs db migrations' - it do - expect(chef_run).to upgrade_package %w(heat-common python3-heat) - end - it do - expect(chef_run).to upgrade_package 'python3-mysqldb' - end - it do - expect(chef_run).to create_directory('/etc/heat').with( - owner: 'heat', - group: 'heat', - mode: '750' - ) - end - it do - expect(chef_run).to create_directory('/etc/heat/environment.d').with( - owner: 'heat', - group: 'heat', - mode: '750' - ) - end - it do - expect(chef_run).to create_template('/etc/heat/heat.conf').with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - owner: 'heat', - group: 'heat', - mode: '640', - sensitive: true - ) - end - it do - expect(chef_run).to create_template('/etc/heat/environment.d/default.yaml').with( - source: 'default.yaml.erb', - owner: 'heat', - group: 'heat', - mode: '644' - ) - end - it do - expect(chef_run).to run_execute('heat-manage db_sync').with( - user: 'heat', - group: 'heat' - ) - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/dashboard-redhat_spec.rb b/cookbooks/openstack-orchestration/spec/dashboard-redhat_spec.rb deleted file mode 100644 index 23433950..00000000 --- a/cookbooks/openstack-orchestration/spec/dashboard-redhat_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::dashboard' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - it do - expect(chef_run).to upgrade_package 'openstack-heat-ui' - end - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/dashboard_spec.rb b/cookbooks/openstack-orchestration/spec/dashboard_spec.rb deleted file mode 100644 index 9987bb29..00000000 --- a/cookbooks/openstack-orchestration/spec/dashboard_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::dashboard' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - it do - expect(chef_run).to upgrade_package 'python3-heat-dashboard' - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/engine-redhat_spec.rb b/cookbooks/openstack-orchestration/spec/engine-redhat_spec.rb deleted file mode 100644 index cfe3dea1..00000000 --- a/cookbooks/openstack-orchestration/spec/engine-redhat_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::engine' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' - - it 'installs heat engine package' do - expect(chef_run).to upgrade_package 'openstack-heat-engine' - end - - it 'enables heat engine on boot' do - expect(chef_run).to enable_service('openstack-heat-engine') - end - - it 'starts heat engine on boot' do - expect(chef_run).to start_service('openstack-heat-engine') - end - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/engine_spec.rb b/cookbooks/openstack-orchestration/spec/engine_spec.rb deleted file mode 100644 index 68c7dc3f..00000000 --- a/cookbooks/openstack-orchestration/spec/engine_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::engine' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' - - it 'installs heat engine package' do - expect(chef_run).to upgrade_package 'heat-engine' - end - - it 'enables heat engine on boot' do - expect(chef_run).to enable_service('heat_engine') - end - - it 'starts heat engine on boot' do - expect(chef_run).to start_service('heat_engine') - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/identity_registration_spec.rb b/cookbooks/openstack-orchestration/spec/identity_registration_spec.rb deleted file mode 100644 index 3c175ed6..00000000 --- a/cookbooks/openstack-orchestration/spec/identity_registration_spec.rb +++ /dev/null @@ -1,149 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-orchestration::identity_registration' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - include_context 'orchestration_stubs' - - connection_params = { - openstack_auth_url: 'http://127.0.0.1:5000/v3', - openstack_username: 'admin', - openstack_api_key: 'admin-pass', - openstack_project_name: 'admin', - openstack_domain_name: 'default', - } - service_name = 'heat' - service_type = 'orchestration' - service_user = 'heat' - stack_domain_admin = 'heat_domain_admin' - stack_domain_name = 'heat' - stack_domain_password = 'heat_domain_pass' - url = 'http://127.0.0.1:8004/v1/%(tenant_id)s' - region = 'RegionOne' - project_name = 'service' - role_name = 'service' - password = 'heat-pass' - domain_name = 'Default' - - it "registers #{project_name} Project" do - expect(chef_run).to create_openstack_project( - project_name - ).with( - connection_params: connection_params - ) - end - - it "registers #{service_name} service" do - expect(chef_run).to create_openstack_service( - service_name - ).with( - connection_params: connection_params, - type: service_type - ) - end - - context "registers #{service_name} endpoint" do - %w(internal public).each do |interface| - it "#{interface} endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - service_type - ).with( - service_name: service_name, - # interface: interface, - url: url, - region: region, - connection_params: connection_params - ) - end - end - end - - it 'registers service user' do - expect(chef_run).to create_openstack_user( - service_user - ).with( - domain_name: domain_name, - project_name: project_name, - password: password, - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_role( - 'heat_stack_owner' - ).with( - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_role( - 'heat_stack_user' - ).with( - connection_params: connection_params - ) - end - - it do - expect(chef_run).to grant_role_openstack_user( - service_user - ).with( - project_name: project_name, - role_name: role_name, - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_domain( - stack_domain_name - ).with( - connection_params: connection_params - ) - end - - it 'registers stack domain admin user' do - expect(chef_run).to create_openstack_user( - stack_domain_admin - ).with( - password: stack_domain_password, - connection_params: connection_params - ) - end - - it do - expect(chef_run).to grant_domain_openstack_user( - stack_domain_admin - ).with( - domain_name: stack_domain_name, - role_name: 'admin', - connection_params: connection_params - ) - end - it 'register heat cloudformation service' do - expect(chef_run).to create_openstack_service( - 'heat-cfn' - ).with( - connection_params: connection_params - ) - end - %w(internal public).each do |interface| - it "#{interface} cloudformation endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - 'cloudformation' - ).with( - service_name: 'heat-cfn', - url: 'http://127.0.0.1:8000/v1', - region: region, - connection_params: connection_params - ) - end - end - end - end -end diff --git a/cookbooks/openstack-orchestration/spec/spec_helper.rb b/cookbooks/openstack-orchestration/spec/spec_helper.rb deleted file mode 100644 index cd271381..00000000 --- a/cookbooks/openstack-orchestration/spec/spec_helper.rb +++ /dev/null @@ -1,280 +0,0 @@ -require 'chefspec' -require 'chefspec/berkshelf' -require 'chef/application' - -RSpec.configure do |config| - config.color = true - config.formatter = :documentation - config.log_level = :warn -end - -REDHAT_7 = { - platform: 'redhat', - version: '7', -}.freeze - -REDHAT_8 = { - platform: 'redhat', - version: '8', -}.freeze - -ALL_RHEL = [ - REDHAT_7, - REDHAT_8, -].freeze - -UBUNTU_OPTS = { - platform: 'ubuntu', - version: '18.04', -}.freeze - -shared_context 'orchestration_stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers) - .and_return '1.1.1.1:5672,2.2.2.2:5672' - allow_any_instance_of(Chef::Recipe).to receive(:address_for) - .with('lo') - .and_return '127.0.1.1' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'openstack_identity_bootstrap_token') - .and_return 'bootstrap-token' - - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'heat') - .and_return 'heat' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'guest') - .and_return 'mq-pass' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin-user') - .and_return 'admin-pass' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-orchestration') - .and_return 'heat-pass' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'heat_domain_admin') - .and_return 'heat_domain_pass' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return 'admin-pass' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'orchestration_auth_encryption_key') - .and_return 'auth_encryption_key_secret' - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('orchestration') - .and_return('rabbit://guest:mypass@127.0.0.1:5672') - allow(Chef::Application).to receive(:fatal!) - end -end - -shared_examples 'expect runs openstack orchestration common recipe' do - it 'runs orchestration common recipe' do - expect(chef_run).to include_recipe 'openstack-orchestration::common' - end -end - -shared_examples 'expect runs openstack common logging recipe' do - it 'runs logging recipe if node attributes say to' do - expect(chef_run).to include_recipe 'openstack-common::logging' - end -end - -shared_examples 'expect installs common heat package' do - it 'installs the openstack-heat common package' do - expect(chef_run).to upgrade_package 'openstack-heat-common' - end -end - -shared_examples 'expect installs mysql package' do - case p - when REDHAT_7 - it 'installs mysql python packages by default' do - expect(chef_run).to upgrade_package 'MySQL-python' - end - when REDHAT_8 - it 'installs mysql python packages by default' do - expect(chef_run).to upgrade_package 'python3-PyMySQL' - end - end -end - -shared_examples 'expect runs db migrations' do - it 'runs db migrations' do - expect(chef_run).to run_execute('heat-manage db_sync').with(user: 'heat', group: 'heat') - end -end - -shared_examples 'expects to create heat directories' do - it 'creates /etc/heat' do - expect(chef_run).to create_directory('/etc/heat').with( - owner: 'heat', - group: 'heat', - mode: '750' - ) - end - - it 'creates /etc/heat/environment.d' do - expect(chef_run).to create_directory('/etc/heat/environment.d').with( - owner: 'heat', - group: 'heat', - mode: '750' - ) - end -end - -shared_examples 'expects to create heat conf' do - describe 'heat.conf' do - let(:file) { chef_run.template('/etc/heat/heat.conf') } - - it 'creates the heat.conf file' do - expect(chef_run).to create_template(file.name).with( - owner: 'heat', - group: 'heat', - mode: '640' - ) - end - - it 'sets auth_encryption_key' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('DEFAULT', /^auth_encryption_key = auth_encryption_key_secret$/) - end - - describe 'default values' do - it 'has default conf values' do - [ - %r{^heat_metadata_server_url = http://127.0.0.1:8000$}, - %r{^heat_waitcondition_server_url = http://127.0.0.1:8000/v1/waitcondition$}, - %r{^log_dir = /var/log/heat$}, - /^region_name_for_services = RegionOne$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - - it 'has oslo_messaging_notifications conf values' do - [ - /^driver = heat.openstack.common.notifier.rpc_notifier$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name) - .with_section_content('oslo_messaging_notifications', line) - end - end - - it 'has heat_api binding' do - [ - /^bind_host = 127.0.0.1$/, - /^bind_port = 8004$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('heat_api', line) - end - end - - it 'has heat_api_cfn binding' do - [ - /^bind_host = 127.0.0.1$/, - /^bind_port = 8000$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('heat_api_cfn', line) - end - end - - it 'sets database connection value' do - expect(chef_run).to render_config_file(file.name).with_section_content( - 'database', %r{^connection = mysql\+pymysql://heat:heat@127.0.0.1:3306/heat\?charset=utf8$} - ) - end - end - - describe 'has ec2authtoken values' do - it 'has default ec2authtoken values' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('ec2authtoken', %r{^auth_uri = http://127.0.0.1:5000/v3$}) - end - end - - describe 'has clients_keystone values' do - it 'has default clients_keystone values' do - expect(chef_run).to render_config_file(file.name) - .with_section_content('clients_keystone', %r{^auth_uri = http://127.0.0.1:5000/$}) - end - end - - describe 'has oslo_messaging_rabbit values' do - it 'has default rabbit values' do - [ - %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - end - - describe 'has keystone_authtoken values' do - it 'has default keystone_authtoken values' do - [ - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^auth_type = v3password$/, - /^username = heat$/, - /^project_name = service$/, - /^user_domain_name = Default/, - /^project_domain_name = Default/, - /^password = heat-pass$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', line) - end - end - end - - describe 'has trustee values' do - it 'has default trustee values' do - [ - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^auth_type = v3password$/, - /^username = heat$/, - /^password = heat-pass$/, - /^user_domain_name = Default$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('trustee', line) - end - end - end - end -end - -shared_examples 'expects to create heat default.yaml' do - describe 'default.yaml' do - let(:file) { chef_run.template('/etc/heat/environment.d/default.yaml') } - - it 'creates the default.yaml file' do - expect(chef_run).to create_template(file.name).with( - owner: 'heat', - group: 'heat', - mode: '644' - ) - end - end -end - -shared_examples 'logging' do - context 'with logging enabled' do - cached(:chef_run) do - node.override['openstack']['orchestration']['syslog']['use'] = true - runner.converge(described_recipe) - end - - it 'runs logging recipe if node attributes say to' do - expect(chef_run).to include_recipe 'openstack-common::logging' - end - end - - context 'with logging disabled' do - cached(:chef_run) do - node.override['openstack']['orchestration']['syslog']['use'] = false - runner.converge(described_recipe) - end - - it "doesn't run logging recipe" do - expect(chef_run).not_to include_recipe 'openstack-common::logging' - end - end -end From ef34328e6a22ec5acd22b648e8198fa948c977bc Mon Sep 17 00:00:00 2001 From: nisar-binary Date: Wed, 25 Jan 2023 12:53:33 +0400 Subject: [PATCH 9/9] cleanup openstack-dns cookbook --- .../openstack-dns/.delivery/project.toml | 9 -- cookbooks/openstack-dns/.rubocop.yml | 4 - cookbooks/openstack-dns/.zuul.yaml | 3 - cookbooks/openstack-dns/Berksfile | 22 --- cookbooks/openstack-dns/TESTING.md | 31 ---- cookbooks/openstack-dns/spec/api-rhel_spec.rb | 30 ---- cookbooks/openstack-dns/spec/api_spec.rb | 28 ---- .../openstack-dns/spec/central-rhel_spec.rb | 30 ---- cookbooks/openstack-dns/spec/central_spec.rb | 28 ---- .../openstack-dns/spec/common-rhel_spec.rb | 52 ------- cookbooks/openstack-dns/spec/common_spec.rb | 142 ------------------ .../openstack-dns/spec/dashboard_spec.rb | 20 --- .../spec/identity_registration_spec.rb | 58 ------- .../openstack-dns/spec/mdns-rhel_spec.rb | 30 ---- cookbooks/openstack-dns/spec/mdns_spec.rb | 28 ---- .../openstack-dns/spec/neutron_int_spec.rb | 42 ------ .../openstack-dns/spec/producer-rhel_spec.rb | 30 ---- cookbooks/openstack-dns/spec/producer_spec.rb | 28 ---- .../openstack-dns/spec/sink-rhel_spec.rb | 30 ---- cookbooks/openstack-dns/spec/sink_spec.rb | 28 ---- cookbooks/openstack-dns/spec/spec_helper.rb | 83 ---------- .../openstack-dns/spec/worker-rhel_spec.rb | 30 ---- cookbooks/openstack-dns/spec/worker_spec.rb | 28 ---- 23 files changed, 814 deletions(-) delete mode 100644 cookbooks/openstack-dns/.delivery/project.toml delete mode 100644 cookbooks/openstack-dns/.rubocop.yml delete mode 100644 cookbooks/openstack-dns/.zuul.yaml delete mode 100644 cookbooks/openstack-dns/Berksfile delete mode 100644 cookbooks/openstack-dns/TESTING.md delete mode 100644 cookbooks/openstack-dns/spec/api-rhel_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/api_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/central-rhel_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/central_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/common-rhel_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/common_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/dashboard_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/identity_registration_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/mdns-rhel_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/mdns_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/neutron_int_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/producer-rhel_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/producer_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/sink-rhel_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/sink_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/spec_helper.rb delete mode 100644 cookbooks/openstack-dns/spec/worker-rhel_spec.rb delete mode 100644 cookbooks/openstack-dns/spec/worker_spec.rb diff --git a/cookbooks/openstack-dns/.delivery/project.toml b/cookbooks/openstack-dns/.delivery/project.toml deleted file mode 100644 index 4066e559..00000000 --- a/cookbooks/openstack-dns/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[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/cookbooks/openstack-dns/.rubocop.yml b/cookbooks/openstack-dns/.rubocop.yml deleted file mode 100644 index 389f2700..00000000 --- a/cookbooks/openstack-dns/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -Chef/Modernize/FoodcriticComments: - Enabled: true -Chef/Style/CopyrightCommentFormat: - Enabled: true diff --git a/cookbooks/openstack-dns/.zuul.yaml b/cookbooks/openstack-dns/.zuul.yaml deleted file mode 100644 index f5786847..00000000 --- a/cookbooks/openstack-dns/.zuul.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- project: - templates: - - openstack-chef-jobs diff --git a/cookbooks/openstack-dns/Berksfile b/cookbooks/openstack-dns/Berksfile deleted file mode 100644 index 593dcbd7..00000000 --- a/cookbooks/openstack-dns/Berksfile +++ /dev/null @@ -1,22 +0,0 @@ -source 'https://supermarket.chef.io' - -solver :ruby, :required - -[ - %w(client dep), - %w(-common dep), - %w(-identity dep), - %w(-image integration), - %w(-integration-test integration), - %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}", group: group - else - cookbook "openstack#{cookbook}", git: "https://opendev.org/openstack/cookbook-openstack#{cookbook}", group: group - end -end - -metadata diff --git a/cookbooks/openstack-dns/TESTING.md b/cookbooks/openstack-dns/TESTING.md deleted file mode 100644 index 328cc4ba..00000000 --- a/cookbooks/openstack-dns/TESTING.md +++ /dev/null @@ -1,31 +0,0 @@ -# Testing the Cookbook # - -This cookbook uses [chefdk](https://downloads.chef.io/chef-dk/) and [berkshelf](https://berkshelf.com/) to isolate dependencies. Make sure you have chefdk and the header files for `gecode` installed before continuing. Make sure that you're using gecode version 3. More info [here](https://github.com/opscode/dep-selector-libgecode/tree/0bad63fea305ede624c58506423ced697dd2545e#using-a-system-gecode-instead). For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the [openstack-chef-repo](https://github.com/openstack/openstack-chef-repo). - -We have three test suites which you can run either, individually (there are three rake tasks): - - $ chef exec rake lint - $ chef exec rake style - $ chef exec rake unit - -or altogether: - - $ chef exec rake - -The `rake` tasks will take care of installing the needed cookbooks with `berkshelf`. - -## Rubocop ## - -[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits. - -## Foodcritic ## - -[Foodcritic](https://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules: - -* [FC003](https://acrmp.github.io/foodcritic/#FC003) These cookbooks are not intended for Chef Solo. -* [FC023](https://acrmp.github.io/foodcritic/#FC023) Prefer conditional attributes. - -## Chefspec - -[ChefSpec](https://github.com/sethvargo/chefspec) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers. - diff --git a/cookbooks/openstack-dns/spec/api-rhel_spec.rb b/cookbooks/openstack-dns/spec/api-rhel_spec.rb deleted file mode 100644 index ab7d8804..00000000 --- a/cookbooks/openstack-dns/spec/api-rhel_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::api' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate-api').with( - service_name: 'designate-api', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate-api') - end - it do - expect(chef_run.service('designate-api')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end - end -end diff --git a/cookbooks/openstack-dns/spec/api_spec.rb b/cookbooks/openstack-dns/spec/api_spec.rb deleted file mode 100644 index e4582596..00000000 --- a/cookbooks/openstack-dns/spec/api_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::api' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate-api').with( - service_name: 'designate-api', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate-api') - end - it do - expect(chef_run.service('designate-api')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end -end diff --git a/cookbooks/openstack-dns/spec/central-rhel_spec.rb b/cookbooks/openstack-dns/spec/central-rhel_spec.rb deleted file mode 100644 index 562cb4bc..00000000 --- a/cookbooks/openstack-dns/spec/central-rhel_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::central' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_central').with( - service_name: 'designate-central', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_central') - end - it do - expect(chef_run.service('designate_central')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end - end -end diff --git a/cookbooks/openstack-dns/spec/central_spec.rb b/cookbooks/openstack-dns/spec/central_spec.rb deleted file mode 100644 index 666232ef..00000000 --- a/cookbooks/openstack-dns/spec/central_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::central' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_central').with( - service_name: 'designate-central', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_central') - end - it do - expect(chef_run.service('designate_central')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end -end diff --git a/cookbooks/openstack-dns/spec/common-rhel_spec.rb b/cookbooks/openstack-dns/spec/common-rhel_spec.rb deleted file mode 100644 index 4c00d041..00000000 --- a/cookbooks/openstack-dns/spec/common-rhel_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::common' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to_not include_recipe('openstack-common::logging') - end - it 'install designate packages' do - expect(chef_run).to upgrade_package %w(openstack-designate-api openstack-designate-central openstack-designate-mdns openstack-designate-producer openstack-designate-worker openstack-designate-sink) - end - - case p - when REDHAT_7 - it do - expect(chef_run).to upgrade_package('MySQL-python') - end - when REDHAT_8 - it do - expect(chef_run).to upgrade_package('python3-PyMySQL') - end - end - it do - expect(chef_run).to create_template('/etc/designate/pools.yaml').with( - source: 'pools.yaml.erb', - owner: 'designate', - group: 'designate', - mode: '644', - variables: { - banner: "\n# This file was autogenerated by Chef\n# Do not edit, changes will be overwritten\n", - bind_hosts: %w(127.0.0.1), - masters: %w(127.0.0.1), - ns_addresses: %w(127.0.0.1), - ns_hostnames: %w(ns1.example.org.), - rndc_key: '/etc/designate/rndc.key', - } - ) - end - end - end -end diff --git a/cookbooks/openstack-dns/spec/common_spec.rb b/cookbooks/openstack-dns/spec/common_spec.rb deleted file mode 100644 index 7ccdcc3f..00000000 --- a/cookbooks/openstack-dns/spec/common_spec.rb +++ /dev/null @@ -1,142 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::common' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to_not include_recipe('openstack-common::logging') - end - it 'install designate packages' do - expect(chef_run).to upgrade_package %w(python3-designate designate-api designate-central designate-mdns designate-producer designate-worker bind9utils designate-sink) - end - it do - expect(chef_run).to upgrade_package('python3-mysqldb') - end - it do - expect(chef_run).to create_directory('/etc/designate').with( - owner: 'designate', - group: 'designate', - mode: '750' - ) - end - describe 'designate.conf' do - let(:file) { chef_run.template('/etc/designate/designate.conf') } - it do - expect(chef_run).to create_template(file.name).with( - source: 'openstack-service.conf.erb', - cookbook: 'openstack-common', - owner: 'designate', - group: 'designate', - mode: '640', - sensitive: true - ) - end - it 'section: DEFAULT' do - [ - %r{^log_dir = /var/log/designate$}, - %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) - end - end - it 'section: service:api' do - [ - /^auth_strategy = keystone$/, - /^enable_api_v1 = True$/, - /^enabled_extensions_v1 = quotas, reports$/, - /^enable_api_v2 = True$/, - /^listen = 127.0.0.1:9001$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('service:api', line) - end - end - it 'section: service:worker' do - [ - /^enabled = True$/, - /^notify = True$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('service:worker', line) - end - end - it 'section: keystone_authtoken' do - [ - /^auth_type = password$/, - /^username = designate$/, - /^project_name = service$/, - /^project_domain_name = Default$/, - /^user_domain_name = Default$/, - /^service_token_roles_required = True$/, - %r{^www_authenticate_uri = http://127.0.0.1:5000/v3$}, - /^password = designate-pass$/, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', line) - end - end - it 'section: storage:sqlalchemy' do - [ - %r{^connection = mysql\+pymysql://designate:db-pass@127.0.0.1:3306/designate\?charset=utf8$}, - ].each do |line| - expect(chef_run).to render_config_file(file.name).with_section_content('storage:sqlalchemy', line) - end - end - end - - it do - expect(chef_run).to create_template('/etc/designate/rndc.key').with( - source: 'rndc.key.erb', - owner: 'designate', - group: 'designate', - mode: '440', - sensitive: true, - variables: { - secret: 'rndc-key', - } - ) - end - - it do - expect(chef_run).to create_template('/etc/designate/pools.yaml').with( - source: 'pools.yaml.erb', - owner: 'designate', - group: 'designate', - mode: '644', - variables: { - banner: "\n# This file was autogenerated by Chef\n# Do not edit, changes will be overwritten\n", - bind_hosts: %w(127.0.0.1), - masters: %w(127.0.0.1), - ns_addresses: %w(127.0.0.1), - ns_hostnames: %w(ns1.example.org.), - rndc_key: '/etc/designate/rndc.key', - } - ) - end - it do - expect(chef_run).to run_execute('designate-manage database sync').with( - user: 'designate', - group: 'designate', - command: 'designate-manage database sync' - ) - end - it do - expect(chef_run).to nothing_execute('designate-manage pool update').with( - user: 'designate', - group: 'designate', - command: 'designate-manage pool update' - ) - end - it do - expect(chef_run.execute('designate-manage pool update')).to \ - subscribe_to('template[/etc/designate/pools.yaml]').on(:run) - end - end -end diff --git a/cookbooks/openstack-dns/spec/dashboard_spec.rb b/cookbooks/openstack-dns/spec/dashboard_spec.rb deleted file mode 100644 index 7d4d030f..00000000 --- a/cookbooks/openstack-dns/spec/dashboard_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::dashboard' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to upgrade_package('python3-designate-dashboard') - end - end -end diff --git a/cookbooks/openstack-dns/spec/identity_registration_spec.rb b/cookbooks/openstack-dns/spec/identity_registration_spec.rb deleted file mode 100644 index 2a017deb..00000000 --- a/cookbooks/openstack-dns/spec/identity_registration_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::identity_registration' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - - connection_params = { - openstack_api_key: 'admin', - openstack_auth_url: 'http://127.0.0.1:5000/v3', - openstack_domain_name: 'default', - openstack_project_name: 'admin', - openstack_username: 'admin', - } - - it do - expect(chef_run).to create_openstack_service('designate').with( - type: 'dns', - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_endpoint('dns').with( - service_name: 'designate', - interface: 'internal', - url: 'http://127.0.0.1:9001', - region: 'RegionOne', - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_project('service').with( - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_user('designate').with( - role_name: 'service', - project_name: 'service', - domain_name: 'Default', - password: 'designate-pass', - connection_params: connection_params - ) - end - end -end diff --git a/cookbooks/openstack-dns/spec/mdns-rhel_spec.rb b/cookbooks/openstack-dns/spec/mdns-rhel_spec.rb deleted file mode 100644 index c8e4c76f..00000000 --- a/cookbooks/openstack-dns/spec/mdns-rhel_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::mdns' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_mdns').with( - service_name: 'designate-mdns', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_mdns') - end - it do - expect(chef_run.service('designate_mdns')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end - end -end diff --git a/cookbooks/openstack-dns/spec/mdns_spec.rb b/cookbooks/openstack-dns/spec/mdns_spec.rb deleted file mode 100644 index eb8ac614..00000000 --- a/cookbooks/openstack-dns/spec/mdns_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::mdns' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_mdns').with( - service_name: 'designate-mdns', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_mdns') - end - it do - expect(chef_run.service('designate_mdns')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end -end diff --git a/cookbooks/openstack-dns/spec/neutron_int_spec.rb b/cookbooks/openstack-dns/spec/neutron_int_spec.rb deleted file mode 100644 index 905bdf68..00000000 --- a/cookbooks/openstack-dns/spec/neutron_int_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::neutron_int' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe, 'openstack-network') - end - - include_context 'dns-stubs' - include_context 'neutron-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - - describe '/etc/neutron/neutron.conf' do - it 'section: DEFAULT' do - [ - /^external_dns_driver = designate$/, - ].each do |line| - expect(chef_run).to render_config_file('/etc/neutron/neutron.conf').with_section_content('DEFAULT', line) - end - end - it 'section: designate' do - [ - %r{^url = http://127.0.0.1:9001/v2$}, - /^auth_type = password$/, - %r{^auth_url = http://127.0.0.1:5000/v3$}, - /^username = designate$/, - /^project_name = service$/, - /^project_domain_name = Default$/, - /^user_domain_name = Default$/, - /^password = designate-pass$/, - ].each do |line| - expect(chef_run).to render_config_file('/etc/neutron/neutron.conf').with_section_content('designate', line) - end - end - end - end -end diff --git a/cookbooks/openstack-dns/spec/producer-rhel_spec.rb b/cookbooks/openstack-dns/spec/producer-rhel_spec.rb deleted file mode 100644 index f10079af..00000000 --- a/cookbooks/openstack-dns/spec/producer-rhel_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::producer' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_producer').with( - service_name: 'designate-producer', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_producer') - end - it do - expect(chef_run.service('designate_producer')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end - end -end diff --git a/cookbooks/openstack-dns/spec/producer_spec.rb b/cookbooks/openstack-dns/spec/producer_spec.rb deleted file mode 100644 index 3ccf9f3d..00000000 --- a/cookbooks/openstack-dns/spec/producer_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::producer' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_producer').with( - service_name: 'designate-producer', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_producer') - end - it do - expect(chef_run.service('designate_producer')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end -end diff --git a/cookbooks/openstack-dns/spec/sink-rhel_spec.rb b/cookbooks/openstack-dns/spec/sink-rhel_spec.rb deleted file mode 100644 index 8bf049bf..00000000 --- a/cookbooks/openstack-dns/spec/sink-rhel_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::sink' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_sink').with( - service_name: 'designate-sink', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_sink') - end - it do - expect(chef_run.service('designate_sink')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end - end -end diff --git a/cookbooks/openstack-dns/spec/sink_spec.rb b/cookbooks/openstack-dns/spec/sink_spec.rb deleted file mode 100644 index 564d56cc..00000000 --- a/cookbooks/openstack-dns/spec/sink_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::sink' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_sink').with( - service_name: 'designate-sink', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_sink') - end - it do - expect(chef_run.service('designate_sink')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end -end diff --git a/cookbooks/openstack-dns/spec/spec_helper.rb b/cookbooks/openstack-dns/spec/spec_helper.rb deleted file mode 100644 index 503c4153..00000000 --- a/cookbooks/openstack-dns/spec/spec_helper.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'chefspec' -require 'chefspec/berkshelf' -require 'chef/application' -require 'securerandom' - -RSpec.configure do |config| - config.color = true - config.formatter = :documentation - config.log_level = :warn - config.file_cache_path = '/var/chef/cache' -end - -REDHAT_7 = { - platform: 'redhat', - version: '7', -}.freeze - -REDHAT_8 = { - platform: 'redhat', - version: '8', -}.freeze - -ALL_RHEL = [ - REDHAT_7, - REDHAT_8, -].freeze - -UBUNTU_OPTS = { - platform: 'ubuntu', - version: '18.04', -}.freeze - -shared_context 'dns-stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('dns') - .and_return('rabbit://guest:mypass@127.0.0.1:5672') - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers) - .and_return '1.1.1.1:5672,2.2.2.2:5672' - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', 'designate') - .and_return('db-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-dns') - .and_return('designate-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'designate_rndc') - .and_return('rndc-key') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return('admin') - end -end - -shared_context 'neutron-stubs' do - before do - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'openstack_identity_bootstrap_token') - .and_return('bootstrap-token') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('token', 'neutron_metadata_secret') - .and_return('metadata-secret') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('db', anything) - .and_return('neutron') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-network') - .and_return('neutron-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'guest') - .and_return('mq-pass') - allow(Chef::Application).to receive(:fatal!) - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('service', 'openstack-compute') - .and_return('nova-pass') - allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'admin') - .and_return('admin-pass') - allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) - .with('network') - .and_return('rabbit://guest:mypass@127.0.0.1:5672') - end -end diff --git a/cookbooks/openstack-dns/spec/worker-rhel_spec.rb b/cookbooks/openstack-dns/spec/worker-rhel_spec.rb deleted file mode 100644 index a1ab1877..00000000 --- a/cookbooks/openstack-dns/spec/worker-rhel_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::worker' do - ALL_RHEL.each do |p| - context "redhat #{p[:version]}" do - let(:runner) { ChefSpec::SoloRunner.new(p) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_worker').with( - service_name: 'designate-worker', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_worker') - end - it do - expect(chef_run.service('designate_worker')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end - end -end diff --git a/cookbooks/openstack-dns/spec/worker_spec.rb b/cookbooks/openstack-dns/spec/worker_spec.rb deleted file mode 100644 index 6225c98a..00000000 --- a/cookbooks/openstack-dns/spec/worker_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'spec_helper' - -describe 'openstack-dns::worker' do - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end - - include_context 'dns-stubs' - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end - it do - expect(chef_run).to enable_service('designate_worker').with( - service_name: 'designate-worker', - supports: { restart: true, status: true } - ) - expect(chef_run).to start_service('designate_worker') - end - it do - expect(chef_run.service('designate_worker')).to \ - subscribe_to('template[/etc/designate/designate.conf]').on(:restart) - end - end -end