Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (37 sloc) 2.961 kB

Knife Cloud Plugin Tests

Integration Tests for Knife cloud plugins using Rspec and FactoryGirl

Description

This package provides a framework to develop long running integration tests for the various knife cloud plugins. It uses Rspec for test case development while FactoryGirl to manage fixtures. The main goal of this framework is to simplify development of integration tests which perform real API calls (and hence incur cost) to the Cloud services. The framework executes the knife command with all the parameters set as per the individual cloud providers' requirements.

The main requirements for the successful execution of a knife command are:

  1. Valid knife.rb

  2. Valid Cloud Plugin Parameters

  3. Valid Cloud Credentials

Generating a Valid knife.rb

The knife.rb is generated from a knife_factory. The sample knife factory is show in lib/knife_cloud_tests/knife_factory_sample.rb Create the knife_factory.rb (in lib/knife_cloud_tests) with valid values using the knife_factory_sample.rb.

Generating Valid Cloud Plugin Parameters

Each cloud plugin should implement factories that generate the valid parameters. Example: github.com/opscode/knife-bluelock/tree/master/spec/integration/bluelock_factories.rb

Generating Valid Cloud Credentials

Each cloud plugin should typically read such credentials from a properties file(YAML, XML etc) typically located in the spec/integration/properties folder. Also one should ensure that the properties folder is also added the .gitignore file to prevent committing secret data.

Understanding the Framework

The framework (similar to chef-pedant) extends the ActiveSupport::Concern allowing the rspec tests to simply define the commands to be executed and match the results received as stdout, stderr and status code. The helper provide several utilities including generating the knife command, comparing expected results with those actually returned etc.

Usage

Steps:

1.Create the knife_factory.rb (in lib/knife_cloud_tests) with valid values using the knife_factory_sample.rb.

2.Build and Install the knife_cloud_tests gem.

3.Develop integration tests leveraging the framework. Example: github.com/opscode/knife-bluelock/blob/master/spec/integration/bluelock_spec.rb

4.Execute the test using rspec.

LICENSE:

Author

Chirag Jog (<chirag@clogeny.com>)

Copyright

Copyright © 2012-2013 Opscode, Inc.

License

Apache License, Version 2.0

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.

Jump to Line
Something went wrong with that request. Please try again.