Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for barclamp_keystone #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions features/barclamp_keystone.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@keystone
Feature: Tests Openstack Keystone barclamp
As an actor
I want to perform various validations
In order to verify the feature functionality

Background:
Given the chef role "keystone-server" exists on admin node
And the "keystone" cookbook exists on the admin node

Scenario: Keystone deployment and functioning
Given the barclamp proposal is using the keystone identity service
When the node with keystone-server role has been detected successfully
And the "python-keystone" is installed in the controller node
And the "python-openstackclient" is installed in the controller node
Then I can create a new project "cucumber_test" on the cloud
And I can create a new user "cucumber_user" for the "cucumber_test" project
And I can see the list of all available hosts on the cloud
And I can delete the project "cucumber_test" and user "cucumber_user"


44 changes: 44 additions & 0 deletions features/step_definitions/barclamp_keystone/keystone_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Given(/^the barclamp proposal is using the keystone identity service$/) do
json_response = JSON.parse(admin_node.exec!("crowbar keystone show default").output)
@node_fqdn = json_response["deployment"]["keystone"]["elements"]["keystone-server"][0]
expect(@node_fqdn).not_to be_empty
end

When(/^the node with keystone-server role has been detected successfully$/) do
user_list = control_node.openstack.user.list
expect(user_list).not_to be_empty
end

And(/^the "([^"]*)" is installed in the controller node$/) do |test_package|
control_node.rpm_q(test_package)
end

And(/^the "([^"]*)" is installed on the controller node$/) do |client_package|
control_node.rpm_q(client_package)
end

Then(/^I can create a new project "([^"]*)" on the cloud$/) do |project_name|
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all (or most of) the OpenStack CLI code is already available upstream. See i.e. https://github.com/openstack/python-openstackclient/blob/master/functional/tests/identity/v2/test_project.py . Why are not using that code (and extend it if needed)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add checks for SSL,PKI and Tokens instead of using openstack client tests here ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client uses SSL and PKI tokens if that's what was deployed. AFAIR we agreed to not check things like "Feature A was enabled, now check if Feature A is really enabled". That will be done with crowbar_batch. Or am I missunderstanding your question?

response = control_node.openstack.project.create(project_name)
puts "Project #{response.name} created with ID: #{response.id}"
expect(response.name).to eq(project_name)
end

And(/^I can create a new user "([^"]*)" for the "([^"]*)" project$/) do |user_name, project_name|
response = control_node.openstack.user.create(user_name,
project: project_name)
puts "Created user #{response.name} on Project : #{response.project_id}"
expect(response.name).to eq(user_name)
end

And(/^I can see the list of all available hosts on the cloud$/) do
host_list = control_node.openstack.host.list
puts "List of hosts available"
host_list.each do |host|
puts "Name: #{host.name} Service: #{host.service} Zone: #{host.zone}"
end
end

And(/^I can delete the project "([^"]*)" and user "([^"]*)"$/) do |project_name, user_name|
control_node.openstack.user.delete(user_name)
control_node.openstack.project.delete(project_name)
end
3 changes: 3 additions & 0 deletions lib/cct/commands/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Client
attr_reader :project
attr_reader :network
attr_reader :role
attr_reader :host

# @param [Cct::Node] as the receiver for the openstack client
def initialize node
Expand All @@ -30,6 +31,7 @@ def initialize node
@project = Openstack::Project.new(node)
@network = Openstack::Network.new(node)
@role = Openstack::Role.new(node)
@host = Openstack::Host.new(node)
end

def actions
Expand Down Expand Up @@ -222,4 +224,5 @@ def filter_params type
require 'cct/commands/openstack/project'
require 'cct/commands/openstack/network'
require 'cct/commands/openstack/role'
require 'cct/commands/openstack/host'

13 changes: 13 additions & 0 deletions lib/cct/commands/openstack/host.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Cct
module Commands
module Openstack
class Host < Command
self.command = "host"

def list *options
super(*(options << {row: Struct.new(:name, :service, :zone)}))
end
end
end
end
end
1 change: 1 addition & 0 deletions tasks/features.rake
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ namespace :features do
desc "Run barclamp tests"
task :barclamps do
invoke_task "feature:barclamp:rabbitmq"
invoke_task "feature:barclamp:keystone"
end
end
11 changes: 11 additions & 0 deletions tasks/features/barclamp_keystone.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace :feature do
feature_name "Tests Openstack Keystone barclamp"

namespace :barclamp do
desc "Barclamp Keystone feature"
feature_task :keystone, tags: :@keystone

desc "Verification of 'Tests Openstack Keystone barclamp' feature"
feature_task :all
end
end