Add recipes for kitchen testing
This changeset adds two recipes, create_network and run_tempest. They implement parts of openstack-chef-repo's Rakefile for use in kitchen testing. Change-Id: I98706b1fc2c65a2359ca9b117a9491c0569514bd
This commit is contained in:
parent
fa8127ae6c
commit
c05b283229
52
recipes/create_network.rb
Normal file
52
recipes/create_network.rb
Normal file
@ -0,0 +1,52 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: openstack-integration-test
|
||||
# Recipe:: create_network
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Purpose: For use in kitchen tempest tests, create network/subnet identical to
|
||||
# openstack-chef-repo/Rakefile _setup_local_network
|
||||
|
||||
class Chef::Recipe
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
class Chef::Resource::RubyBlock
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
admin_user = node['openstack']['identity']['admin_user']
|
||||
admin_project = node['openstack']['identity']['admin_project']
|
||||
netname = node['openstack']['integration-test']['fixed_network']
|
||||
subnetname = 'local_subnet'
|
||||
|
||||
# NOTE: This has to be done in a ruby_block so it gets executed at execution
|
||||
# time and not compile time (when nova does not yet exist).
|
||||
ruby_block 'create_shared_network_for_testing' do
|
||||
block do
|
||||
begin
|
||||
env = openstack_command_env(admin_user, admin_project, 'Default', 'Default')
|
||||
output = openstack_command('openstack', 'network list', env)
|
||||
unless output.include? netname
|
||||
openstack_command('openstack', "network create --share #{netname}", env)
|
||||
end
|
||||
output = openstack_command('openstack', 'subnet list', env)
|
||||
unless output.include? subnetname
|
||||
openstack_command('openstack', "subnet create --network #{netname} --subnet-range 192.168.180.0/24 #{subnetname}", env)
|
||||
end
|
||||
rescue RuntimeError => e
|
||||
Chef::Log.error("Could not create network/subnet. Error was #{e.message}")
|
||||
end
|
||||
end
|
||||
end
|
31
recipes/run_tempest.rb
Normal file
31
recipes/run_tempest.rb
Normal file
@ -0,0 +1,31 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: openstack-integration-test
|
||||
# Recipe:: run_tempest
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Purpose: Run tempest like openstack-chef-repo/Rakefile (used by kitchen)
|
||||
|
||||
execute 'run_tempest' do
|
||||
# Write log file to test VM's /root directory.
|
||||
command 'cd /opt/tempest; /opt/tempest-venv/tempest.sh'
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# Run tempest after everything else.
|
||||
log 'start_tempest' do
|
||||
message 'Starting tempest at the very end.'
|
||||
level :info
|
||||
notifies :run, 'execute[run_tempest]', :delayed
|
||||
end
|
Loading…
Reference in New Issue
Block a user