Skip to content
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
17 changes: 17 additions & 0 deletions features/barclamp_database.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: Test the database server resource
As an administrator
I want to make sure the database service is deployed successfully
In order to be available for other services later

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

@postgresql
Scenario: Database barclamp is deployed using PostgreSQL as backend
Given the "postgresql" cookbook exists on the admin node
And the barclamp proposal is using "postgresql" as sql engine
When the node with database role has been detected successfully
Then I can establish connection to "postgresql" database server
And I can create a database called "cucumber_test"
And I can drop the database "cucumber_test" successfully
50 changes: 50 additions & 0 deletions features/step_definitions/barclamps/database_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Given(/^the barclamp proposal is using "([^"]*)" as sql engine$/) do |sql_engine_name|
@db_proposal = proposal("database")
expect(@db_proposal["attributes"]["database"]["sql_engine"]).to eq(sql_engine_name)
end

When(/^the node with database role has been detected successfully$/) do
@db_nodes = nodes.find(barclamp: "database", element: "database-server")
expect(@db_nodes).not_to be_empty
end

Then(/^I can establish connection to "([^"]*)" database server$/) do |db_name|
@db_name = db_name
@password = @db_proposal["attributes"]["database"]["db_maker_password"]
results = @db_nodes.map do |node|
case db_name
when "postgresql"
node.exec!(
"PGPASSWORD=#{@password} psql -U db_maker -h #{node.fqdn} postgres -c 'SELECT 1'",
capture_error: true
)
end
end
expect(results).to succeed_at_least_once
end

Then(/^I can create a database called "([^"]*)"$/) do |db|
results = @db_nodes.map do |node|
case @db_name
when "postgresql"
node.exec!(
"PGPASSWORD=#{@password} psql -U db_maker -h #{node.fqdn} postgres -c 'CREATE DATABASE #{db}'",
capture_error: true
)
end
end
expect(results).to succeed_at_least_once
end

Then(/^I can drop the database "([^"]*)" successfully$/) do |db|
results = @db_nodes.map do |node|
case @db_name
when "postgresql"
node.exec!(
"PGPASSWORD=#{@password} psql -U db_maker -h #{node.fqdn} postgres -c 'DROP DATABASE #{db}'",
capture_error: true
)
end
end
expect(results).to succeed_at_least_once
end
13 changes: 13 additions & 0 deletions tasks/features/barclamp_database.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace :feature do
feature_name "Test the database server resource"

namespace :barclamp do
namespace :database do
feature_task :postgres, tags: :@postgresql

end

desc "Verify the database resource"
task :database => :"database:postgres"
end
end