From 72ad95ea4d00d9d7655ece0504641affaad65fd0 Mon Sep 17 00:00:00 2001 From: Samuel Cassiba Date: Thu, 8 Feb 2018 22:16:32 -0800 Subject: [PATCH] Revert from packaged tempest to git, update image refs - due to inconsistencies in RDO versus UCA packaging, Tempest performs more consistently from upstream git - update cirros references to 0.4.0 Change-Id: I374497db1b602683f1f9c62489f523b18c50266c Implements: blueprint modern-chef --- attributes/default.rb | 14 ++++--- attributes/tempest_conf.rb | 3 ++ recipes/run_tempest.rb | 2 +- recipes/setup.rb | 65 +++++++++++++++++++++----------- spec/setup-redhat_spec.rb | 7 ++-- spec/setup_spec.rb | 28 ++++++-------- spec/spec_helper.rb | 6 +++ templates/default/tempest.sh.erb | 3 +- 8 files changed, 80 insertions(+), 48 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index a7c7d33..addbeaf 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -44,13 +44,13 @@ default['openstack']['integration-test'] = { 'name' => 'cirros-test1', 'id' => '1ac790f6-903a-4833-979f-a38f1819e3b1', 'flavor' => 99, - 'source' => 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img', + 'source' => 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img', }, 'image2' => { 'name' => 'cirros-test2', 'id' => 'f7c2ac6d-0011-499f-a9ec-ca71348bf2e4', 'flavor' => 99, - 'source' => 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img', + 'source' => 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img', }, } @@ -58,18 +58,20 @@ default['openstack']['integration-test'] = { case node['platform_family'] when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this default['openstack']['integration-test']['platform'] = { - tempest_packages: %w(git libxslt-devel + tempest_packages: %w(git curl libxslt-devel libxml2-devel python-testrepository libffi-devel python-devel python-setuptools - openstack-tempest), + python-gabbi python-testscenarios + python-ddt), package_overrides: '', } when 'debian' default['openstack']['integration-test']['platform'] = { - 'tempest_packages' => %w(git libssl-dev libffi-dev python-dev libxml2-dev + 'tempest_packages' => %w(git curl libssl-dev libffi-dev python-dev libxml2-dev libxslt1-dev libpq-dev libxml2-dev libxslt-dev testrepository python-dev libffi-dev - python-gabbi tempest), + python-gabbi python-testscenarios + python-ddt), 'package_overrides' => '', } end diff --git a/attributes/tempest_conf.rb b/attributes/tempest_conf.rb index f25adc4..f8255ef 100644 --- a/attributes/tempest_conf.rb +++ b/attributes/tempest_conf.rb @@ -1,5 +1,7 @@ default['openstack']['integration-test']['conf_secrets'] = {} default['openstack']['integration-test']['conf'].tap do |conf| + conf['DEFAULT']['log_dir'] = '/opt/tempest/logs' + conf['DEFAULT']['log_file'] = 'tempest.log' conf['auth']['use_dynamic_credentials'] = node['openstack']['integration-test']['use_dynamic_credentials'] conf['auth']['default_credentials_domain_name'] = 'Default' conf['auth']['admin_domain_name'] = 'Default' @@ -91,4 +93,5 @@ default['openstack']['integration-test']['conf'].tap do |conf| conf['service_available']['glance'] = true conf['service_available']['cinder'] = false conf['service_available']['nova'] = true + conf['oslo_concurrency']['lock_path'] = '/opt/tempest/tempest_lock' end diff --git a/recipes/run_tempest.rb b/recipes/run_tempest.rb index 05a0bd9..d6f8f70 100644 --- a/recipes/run_tempest.rb +++ b/recipes/run_tempest.rb @@ -19,7 +19,7 @@ execute 'run_tempest' do # Write log file to test VM's /root directory. - command 'tempest run --smoke --serial --config-file /etc/tempest/tempest.conf' + command 'cd /opt/tempest; /opt/tempest-venv/tempest.sh' action :nothing end diff --git a/recipes/setup.rb b/recipes/setup.rb index ba9ca59..e7d9fe0 100644 --- a/recipes/setup.rb +++ b/recipes/setup.rb @@ -27,7 +27,8 @@ end platform_options = node['openstack']['integration-test']['platform'] -python_runtime '2' do +python_runtime 'tempest' do + version '2' provider :system end @@ -39,8 +40,6 @@ platform_options['tempest_packages'].each do |pkg| end end -package 'curl' - identity_admin_endpoint = admin_endpoint 'identity' identity_public_endpoint = public_endpoint 'identity' auth_url = ::URI.decode identity_admin_endpoint.to_s @@ -70,35 +69,52 @@ connection_params = { connection_params connection_params end - openstack_role service_role do - connection_params connection_params - end - openstack_user service_user do + role_name service_role project_name service_project domain_name service_domain password service_pass connection_params connection_params - end - - openstack_user service_user do - role_name service_role - project_name service_project - connection_params connection_params - action :grant_role + action [:create, :grant_role, :grant_domain] end heat_stack_user_role = node['openstack']['integration-test']['heat_stack_user_role'] openstack_role heat_stack_user_role do connection_params connection_params end +end - openstack_user service_user do - domain_name service_domain - user_name service_user - connection_params connection_params - action :grant_domain - end +tempest_path = '/opt/tempest' +venv_path = '/opt/tempest-venv' + +python_virtualenv venv_path do + python 'tempest' + system_site_packages true +end + +python_execute 'install tempest' do + action :nothing + command '-m pip install .' + cwd tempest_path + virtualenv venv_path +end + +git tempest_path do + repository 'https://github.com/openstack/tempest' + reference 'master' + depth 1 + action :sync + notifies :run, 'python_execute[install tempest]', :immediately +end + +template "#{venv_path}/tempest.sh" do + source 'tempest.sh.erb' + user 'root' + group 'root' + mode 0o755 + variables( + venv_path: venv_path + ) end %w(image1 image2).each do |img| @@ -150,7 +166,7 @@ end integration_test_conf_options = merge_config_options 'integration-test' # create the keystone.conf from attributes -template '/etc/tempest/tempest.conf' do +template '/opt/tempest/etc/tempest.conf' do source 'openstack-service.conf.erb' cookbook 'openstack-common' owner 'root' @@ -161,6 +177,13 @@ template '/etc/tempest/tempest.conf' do ) end +directory '/opt/tempest/logs' do + owner 'root' + group 'root' + mode 0755 + action :create +end + # delete all secrets saved in the attribute # node['openstack']['identity']['conf_secrets'] after creating the keystone.conf ruby_block "delete all attributes in node['openstack']['integration-test']['conf_secrets']" do diff --git a/spec/setup-redhat_spec.rb b/spec/setup-redhat_spec.rb index afb25da..6960b48 100644 --- a/spec/setup-redhat_spec.rb +++ b/spec/setup-redhat_spec.rb @@ -11,11 +11,12 @@ describe 'openstack-integration-test::setup' do include_context 'tempest-stubs' - it 'installs tempest from package' do - %w(git libxslt-devel + it 'installs tempest dependencies' do + %w(git curl libxslt-devel libxml2-devel python-testrepository libffi-devel python-devel python-setuptools - openstack-tempest).each do |pkg| + python-gabbi python-testscenarios + python-ddt).each do |pkg| expect(chef_run).to upgrade_package(pkg) end end diff --git a/spec/setup_spec.rb b/spec/setup_spec.rb index 1187676..b41b250 100644 --- a/spec/setup_spec.rb +++ b/spec/setup_spec.rb @@ -41,20 +41,13 @@ describe 'openstack-integration-test::setup' do 'tempest_user1' ).with( domain_name: 'Default', + role_name: 'Member', project_name: 'tempest_project1', password: 'tempest_user1_pass', connection_params: connection_params ) end - it 'create service role' do - expect(chef_run).to create_openstack_role( - 'Member' - ).with( - connection_params: connection_params - ) - end - it do expect(chef_run).to grant_role_openstack_user( 'tempest_user1' @@ -79,6 +72,7 @@ describe 'openstack-integration-test::setup' do 'tempest_user2' ).with( domain_name: 'Default', + role_name: 'Member', project_name: 'tempest_project2', password: 'tempest_user2_pass', connection_params: connection_params @@ -96,11 +90,13 @@ describe 'openstack-integration-test::setup' do ) end - it 'create service role' do - expect(chef_run).to create_openstack_role( - 'heat_stack_owner' + it 'syncs /opt/tempest from github' do + expect(chef_run).to sync_git( + '/opt/tempest' ).with( - connection_params: connection_params + repository: 'https://github.com/openstack/tempest', + reference: 'master', + depth: 1 ) end @@ -114,7 +110,7 @@ describe 'openstack-integration-test::setup' do identity_project_domain_name: 'default', image_name: 'cirros-test1', image_id: '1ac790f6-903a-4833-979f-a38f1819e3b1', - image_url: 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img' + image_url: 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img' ) end @@ -128,12 +124,12 @@ describe 'openstack-integration-test::setup' do identity_project_domain_name: 'default', image_name: 'cirros-test2', image_id: 'f7c2ac6d-0011-499f-a9ec-ca71348bf2e4', - image_url: 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img' + image_url: 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img' ) end describe 'tempest.conf default' do - let(:file) { chef_run.template('/etc/tempest/tempest.conf') } + let(:file) { chef_run.template('/opt/tempest/etc/tempest.conf') } it 'creates tempest.conf' do expect(chef_run).to create_template(file.name).with( @@ -174,7 +170,7 @@ describe 'openstack-integration-test::setup' do runner.node.normal['openstack']['endpoints']['public']['identity']['scheme'] = 'https' runner.converge(described_recipe) end - let(:file) { chef_run.template('/etc/tempest/tempest.conf') } + let(:file) { chef_run.template('/opt/tempest/etc/tempest.conf') } it 'has a v2 auth URI with the secure scheme' do expect(chef_run).to render_file(file.name).with_content( diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 46b7185..a2e289e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -37,6 +37,12 @@ shared_context 'tempest-stubs' do 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('openstack_user', 'tempest_user1') + .and_return('tempest_user1_pass') + allow_any_instance_of(Chef::Recipe).to receive(:get_password) + .with('openstack_user', 'tempest_user2') + .and_return('tempest_user2_pass') allow_any_instance_of(Chef::Resource::RubyBlock).to receive(:openstack_command_env) .with('admin', 'admin', 'Default', 'Default') .and_return(env) diff --git a/templates/default/tempest.sh.erb b/templates/default/tempest.sh.erb index 49ff0a4..3603a37 100644 --- a/templates/default/tempest.sh.erb +++ b/templates/default/tempest.sh.erb @@ -1,2 +1,3 @@ #!/bin/bash -tempest run --smoke --serial --config-file /etc/tempest/tempest.conf +source <%= @venv_path -%>/bin/activate +tempest run --smoke --serial --config-file /opt/tempest/etc/tempest.conf