Skip to content

(wip) CLI Acceptance tests #61

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

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8f7df35
Beating my head against the wall
May 29, 2016
1e09ca6
ey-core accounts feature
May 30, 2016
7e46226
Stubbed CLI features
May 30, 2016
4f1feb9
Described behavior for `ey-core status`
May 31, 2016
6f23a7e
Better core client mock for cukes
May 31, 2016
3c6cdf1
Added cuke for applications command
May 31, 2016
51f9fa8
Simplified language in the applications cuke
May 31, 2016
9e2725e
Added step definitions for applications
May 31, 2016
c899809
Changed -c to -a in applications command
May 31, 2016
4420421
Added coverage-features to gitignore
May 31, 2016
a72b346
Cuke for current_user
May 31, 2016
3e1f082
Aded cuke and steps for environments
May 31, 2016
27321c7
Changed environments account flag to -a
May 31, 2016
889bc23
Added cuke and steps for servers command
Jun 1, 2016
42ca69f
Made servers command match specified behavior
Jun 1, 2016
3b0e0ce
copied current_user cuke to whoami cuke
Jun 1, 2016
3a6c486
Ensure that `servers` lists all applicable servers
Jun 1, 2016
d7bfa1a
Cuked out the two deprecated commands
Jun 1, 2016
88313ca
Merge branch 'master' into acceptance-test-boilerplate
Jun 1, 2016
5e4f53b
Simplified servers command
Jun 1, 2016
8aac2dc
Critic tweaks for server command
Jun 1, 2016
f893d6a
filter attributes must be IDs
Jun 1, 2016
bc8d534
Simplified the status command
Jun 1, 2016
0606786
Added cuke for recipes apply
Jun 6, 2016
304323e
Cleaned up recipe apply cuke and added steps
Jun 6, 2016
34df3c8
Chef run output more specific
Jun 6, 2016
f285c25
Modified `recipes apply` behavior to match cuke
Jun 6, 2016
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Gemfile.lock
InstalledFiles
_yardoc
coverage
coverage-features
doc/
lib/bundler/man
pkg
Expand Down
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'cucumber/rake/task'

namespace :spec do
task :mocked do
Expand All @@ -12,4 +13,6 @@ end

task :spec => ["spec:mocked", "spec:unmocked"]

task default: "spec:mocked"
Cucumber::Rake::Task.new

task default: ["spec:mocked", :cucumber]
3 changes: 3 additions & 0 deletions ey-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "rspec", "~> 3.0"
gem.add_development_dependency "ffaker"
gem.add_development_dependency "rake"
gem.add_development_dependency "aruba", "~> 0.11"
gem.add_development_dependency "cucumber", "~> 2.1"
gem.add_development_dependency "factis", "~> 1.0"
end
13 changes: 13 additions & 0 deletions features/accounts.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: Accounts
In order to know what Engine Yard accounts I can access
As a User
I want to be able to list the accounts with which I'm associated

Background:
Given I'm an Engine Yard user
And ey-core is configured with my cloud token
And I'm associated with several accounts

Scenario: Listing my accounts
When I run `ey-core accounts`
Then I see the name and ID of each of my accounts
29 changes: 29 additions & 0 deletions features/applications.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Feature: Applications
In order to determine what I can work with
As a User
I want to be able to list the applications that live in my accounts

Background:
Given I'm an Engine Yard user
And ey-core is configured with my cloud token
And I have the following accounts:
| Account Name |
| one |
| two |
| three |
And each of my accounts has several applications

Scenario: Listing all of my applications
When I run `ey-core applications`
Then I see the name and ID for all of my applications

Scenario Outline: Listing applications for a specific account
When I run `ey-core applications <Account Flag> one`
Then I see the applications in the one account
But I do not see applications from other accounts

Examples:
| Account Flag |
| -a |
| --account |

14 changes: 14 additions & 0 deletions features/current_user.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Current User
In order to ensure that I'm logged into the right account
As a User
I want to be able to see my user information

Background:
Given I'm an Engine Yard user
And ey-core is configured with my cloud token

Scenario: Getting the current user information
When I run `ey-core current_user`
Then I should see my user ID
And I should see my email address
And I should see my name
Empty file added features/deploy.feature
Empty file.
30 changes: 30 additions & 0 deletions features/environments.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Feature: Environments
In order to know what Engine Yard environments I can access
As a User
I want to be able to list the environments with which I'm associated

Background:
Given I'm an Engine Yard user
And ey-core is configured with my cloud token
And I have the following accounts:
| Account Name |
| one |
| two |
| three |
And each of my accounts has several applications
And each of my applications has an environment

Scenario: Listing all of my environments
When I run `ey-core environments`
Then I see the name and ID for all of my environments

Scenario Outline: Listing environments for a specific account
When I run `ey-core environments <Account Flag> one`
Then I see the environments in the one account
But I do not see environments from other accounts

Examples:
| Account Flag |
| -a |
| --account |

6 changes: 6 additions & 0 deletions features/init.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Init
This command is deprecated

Scenario: Running init
When I run `ey-core init`
Then I am advised that this command has been deprecated
6 changes: 6 additions & 0 deletions features/login.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Login
In order to interact with Engine Yard Cloud
As a User
I want to be able to log into the Cloud API


Empty file added features/logout.feature
Empty file.
Empty file added features/logs.feature
Empty file.
98 changes: 98 additions & 0 deletions features/recipes/apply.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Feature: Recipes Apply
In order to keep my server configs up to date
As a User
I want to be able to apply config changes

Background:
Given I'm an Engine Yard user
And ey-core is configured with my cloud token
And I have an account named ACME Inc
And ACME Inc has the following environments:
| Environment |
| coyote |
| roadrunner |

Scenario: Applying changes to an environment (default behavior)
When I run `ey-core recipes apply coyote`
Then main recipes are applied to the coyote environment
But no changes are made to the roadrunner environment

Scenario Outline: Applying main recipes
When I run `ey-core recipes apply <Main Flag> coyote`
Then main recipes are applied to the coyote environment
But no changes are made to the roadrunner environment

Examples:
| Main Flag |
| -m |
| --main |

Scenario Outline: Applying custom recipes
When I run `ey-core recipes apply <Custom Flag> coyote`
Then custom recipes are applied to the coyote environment
But no changes are made to the roadrunner environment

Examples:
| Custom Flag |
| -c |
| --custom |

Scenario Outline: Performing a quick chef run
When I run `ey-core recipes apply <Quick Flag> coyote`
Then a quick run is applied to the coyote environment
But no changes are made to the roadrunner environment

Examples:
| Quick Flag |
| -q |
| --quick |

Scenario Outline: Performing a full chef run
When I run `ey-core recipes apply <Full Flag> coyote`
Then main recipes are applied to the coyote environment
And custom recipes are applied to the coyote environment
But no changes are made to the roadrunner environment

Examples:
| Full Flag |
| -f |
| --full |

Scenario Outline: Attempting to use more than one run type flag
When I run `ey-core recipes apply <Run Type Flags> coyote`
Then I'm advised that only one run type flag may be used
And no changes are made to any environment

Examples:
| Run Type Flags |
| -m -c -q -f |
| -m -c -q |
| -m -c -f |
| -m -q -f |
| -c -q -f |
| -m -c |
| -m -q |
| -m -f |
| -c -q |
| -c -f |
| -q -f |

Scenario Outline: Applying changes to an environment on a specific account
Given I have an account named Wile E Enterprises
And Wile E Enterprises has the following environments:
| Environment |
| coyote |
| roadrunner |

When I run `ey-core recipes apply coyote`
Then I am advised that my criteria matched several environments
And no changes are made to any environment

When I run `ey-core recipes apply <Account Flag> 'ACME Inc' coyote`
Then the main recipes are applied to the coyote environment for ACME Inc
But no changes are made to any other environment

Examples:
| Account Flag |
| -a |
| --account |
Empty file.
70 changes: 70 additions & 0 deletions features/recipes/step_definitions/apply_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Given %r(^I have an account named (.+)$) do |account_name|
known_accounts.push(
create_account(
client: client,
owner: current_user,
account: {
name: account_name
}
)
)
end

Given %r(^(.+) has an application called (.+)$) do |account_name, app_name|
known_apps.push(
create_application(
account: account_named(account_name),
name: app_name
)
)
end

Given %r(^(.+) has the following environments:$) do |account_name, environment_names|

account = account_named(account_name)
app = account.applications.first
environment_names.hashes.each do |environment_hash|
known_environments.push(
create_environment(
account: account,
application: app,
environment: {
name: environment_hash['Environment']
}
)
)
end
end

Then %r(^(.+) recipes are applied to the coyote environment$) do |run_type|
expect(output_text).to match(/.*Started #{Regexp.escape(run_type)} chef run.*environment: coyote\).*/)
end

Then %(no changes are made to the roadrunner environment) do
expect(output_text).not_to match(/.*chef run.*environment: roadrunner\).*/)
end

Then %(a quick run is applied to the coyote environment) do
step %{quick recipes are applied to the coyote environment}
end

Then %(I'm advised that only one run type flag may be used) do
expect(output_text).to match("Only one of --main, --custom, --quick, and --full may be specified.")
end

Then %(no changes are made to any environment) do
expect(output_text).not_to match(/Started .* chef run.*\(account: .*/)
end

Then %(I am advised that my criteria matched several environments) do
expect(output_text).to match(%{The criteria you've provided matches multiple environments. Please refine further with an account.})
end

Then %(the main recipes are applied to the coyote environment for ACME Inc) do
expect(output_text).to match(/Started main chef run.*\(account: ACME Inc, environment: coyote\)/)
end

Then %(no changes are made to any other environment) do
runs = output_text.split("\n").select {|line| line =~ /Started .* chef run.*\(/}
expect(runs.count).to eql(1)
end
Empty file added features/recipes/upload.feature
Empty file.
6 changes: 6 additions & 0 deletions features/scp.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Scp
This command is deprecated

Scenario: Running init
When I run `ey-core init`
Then I am advised that this command has been deprecated
56 changes: 56 additions & 0 deletions features/servers.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Feature: Servers
In order to determine what servers I can access
As a User
I want to see a list of servers with which I'm associated

Background:
Given I'm an Engine Yard user
And ey-core is configured with my cloud token
And I have the following accounts:
| Account Name |
| one |
| two |
| three |
And each of my accounts has several applications
And each of my applications has an environment
And each of my environments has a server

Scenario: Listing all of my servers
When I run `ey-core servers`
Then I see the name, role, and provisioned ID for all of my servers

Scenario Outline: Listing servers for a specific account
When I run `ey-core servers <Account Flag> one`
Then I see the servers in the one account
But I do not see servers from other accounts

Examples:
| Account Flag |
| -a |
| --account |

Scenario Outline: Listing severs for a specific environment
When I run `ey-core servers <Environment Flag> one_1_env`
Then I see the servers in the one_1_env environment
But I do not see servers from other environments

Examples:
| Environment Flag |
| -e |
| --environment |

Scenario: Ambiguous environments
Given the two account has an environment named one_1_env with a server
When I run `ey-core servers -e one_1_env`
Then I do not see any servers
But I am advised that my filters yielded ambiguous results

Scenario: Listing servers for a specific account and environment
When I run `ey-core servers -a one -e one_1_env`
Then I see the servers from the one_1_env environment in the one account
But I do not see any other servers

Scenario: Account and environment filters down to no results
When I run `ey-core servers -a one -e two_1_env`
Then I do not see any servers
But I am advised that my filters matched no servers
Empty file added features/ssh.feature
Empty file.
25 changes: 25 additions & 0 deletions features/status.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: Status
In order to know if my app is healthy
As a User
I want to see the details of the app deployments

Background:
Given I'm an Engine Yard user
And ey-core is configured with my cloud token
And I have an account
And my account has an application named super_app
And my application is associated with an environment named super_env

Scenario: Getting the status with no deployments
When I run `ey-core status super_env super_app`
Then I see a message regarding my lack of deployments

Scenario: Getting the status with one deployment
Given I've deployed the app
When I run `ey-core status super_env super_app`
Then I see the details for the deployment

Scenario: Getting the status with more than one deployment
Given I've deployed the app twice
When I run `ey-core status super_env super_app`
Then I see the details for the most recent deployment
Loading