puppet-keystone/spec/spec_helper_acceptance.rb
Sofer Athlan-Guyot 74799f9e34 Add composite namevar for tenant, user, user_role.
There are two sides on this patch, the user facing one, and the
developer's one.

It gives more flexibility for the interface used by the user for the
Keystone_tenant, Keystone_user and Keystone_user_roles resources.  For
instance to specify a user and give the admin role, currently you have
to:

  keystone_user { 'new_admin::admin_domain':
    ensure      => present,
    enabled     => true,
    tenant      => 'openstackv3::admin_domain',
    email       => 'test@example.tld',
    password    => 'a_big_secret',
  }
  keystone_user_role { 'new_admin::admin_domain@openstackv3::admin_domain':
    ensure         => present,
    roles          => ['admin'],
  }

Now you can specify it like this:

  keystone_user { 'new_admin':
    ensure      => present,
    enabled     => true,
    domain      => 'admin_domain',
    tenant      => 'openstackv3::admin_domain',
    email       => 'test@example.tld',
    password    => 'a_big_secret',
  }
  keystone_user_role { 'new_admin@openstackv3':
    ensure         => present,
    user_domain    => 'admin_domain',
    project_domain => 'admin_domain',
    roles          => ['admin'],
  }

For the developer this simplify the code.  Puppet is using composite
namevar to make all the resources unique.  So guessing what pattern is
used in the title is no longer required.  For instance this :

  keystone_tenant { 'project_one': ensure => present }
  keystone_tenant { 'meaningless': name => 'project_one', domain => 'Default', ensure => present }

is detected as the same tenant by puppet.

The same is true for dependencies. This is working correctly:

  keystone_tenant { 'meaningless': name => 'project_one', domain => 'domain_one', ensure => present }
  file {'/tmp/needed': ensure => present, require => Keystone_tenant['project_one::domain_one'] }

In autorequire term in type definition, you just have to pass the fully
qualified name (with the domain suffix for user and tenant) of the
resource and puppet will do the matching, whatever the original title
is.  See the examples in user and tenant in keystone_user_role type.

Change-Id: I4deb27dc6f71fb7a7ec6a9c72bd0e1412c2e9a30
2015-11-03 18:25:35 +01:00

59 lines
1.9 KiB
Ruby

require 'beaker-rspec'
require 'beaker/puppet_install_helper'
run_puppet_install_helper
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
hosts.each do |host|
# install git
install_package host, 'git'
zuul_ref = ENV['ZUUL_REF']
zuul_branch = ENV['ZUUL_BRANCH']
zuul_url = ENV['ZUUL_URL']
repo = 'openstack/puppet-openstack-integration'
# Start out with clean moduledir, don't trust r10k to purge it
on host, "rm -rf /etc/puppet/modules/*"
# Install dependent modules via git or zuul
r = on host, "test -e /usr/zuul-env/bin/zuul-cloner", { :acceptable_exit_codes => [0,1] }
if r.exit_code == 0
zuul_clone_cmd = '/usr/zuul-env/bin/zuul-cloner '
zuul_clone_cmd += '--cache-dir /opt/git '
zuul_clone_cmd += "--zuul-ref #{zuul_ref} "
zuul_clone_cmd += "--zuul-branch #{zuul_branch} "
zuul_clone_cmd += "--zuul-url #{zuul_url} "
zuul_clone_cmd += "git://git.openstack.org #{repo}"
on host, zuul_clone_cmd
else
on host, "git clone https://git.openstack.org/#{repo} #{repo}"
end
on host, "ZUUL_REF=#{zuul_ref} ZUUL_BRANCH=#{zuul_branch} ZUUL_URL=#{zuul_url} bash #{repo}/install_modules.sh"
# Install the module being tested
on host, "rm -fr /etc/puppet/modules/#{modname}"
puppet_module_install(:source => proj_root, :module_name => modname)
on host, "rm -fr #{repo}"
# List modules installed to help with debugging
on host, puppet('module','list'), { :acceptable_exit_codes => 0 }
end
end
end
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }