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