- Cookstyle fixes - Refactor Berksfile to use groups so we can exclude integration testing cookbooks - Update documentation - Cleanup line wraps - Enable sensitive resources for the template[/etc/neutron/neutron.conf] and template[/etc/neutron/metadata_agent.ini] to resources improve security. - Update delivery configuration to exclude integration cookbooks - Fix ChefSpec output. - Update lbaas recipe to use v2 agent driver. - Add recommended configuration settings to neutron.conf based in Stein installation docs. - Remove any resources that define the default action. - Switch package installations to send packages as arrays instead of individual package resources. This generally speeds up chef runs. - Manage /etc/neutron/neutron_lbaas.conf so we can set service_provider properly. - Add some missing ChefSpec tests. - Configure neutron_lbaas.conf on Ubuntu in a manner that allows it to properly pull in the configuration via the --config-dir option. This is due to the fact we need to set an additional [service_providers] service_provider line and we can't do that with hashes. - Remove FWaaS as it's unmaintained upstream. Depends-On: https://review.opendev.org/701027 Depends-On: https://review.opendev.org/706151 Change-Id: Id29884766440d37fa18fd62f3f93eecc22224d51
		
			
				
	
	
		
			150 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
# Encoding: utf-8
 | 
						|
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
 | 
						|
 | 
						|
      context 'lbaas enabled' do
 | 
						|
        cached(:chef_run) do
 | 
						|
          node.override['openstack']['network_lbaas']['enabled'] = true
 | 
						|
          runner.converge(described_recipe)
 | 
						|
        end
 | 
						|
        [
 | 
						|
          /^service_plugins = neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPluginv2$/,
 | 
						|
        ].each do |line|
 | 
						|
          it do
 | 
						|
            expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
 | 
						|
          end
 | 
						|
        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
 |