Integration Tests for Knife cloud plugins using Rspec and FactoryGirl
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:
-
Valid knife.rb
-
Valid Cloud Plugin Parameters
-
Valid Cloud Credentials
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.
Each cloud plugin should implement factories that generate the valid parameters. Example: github.com/opscode/knife-bluelock/tree/master/spec/integration/bluelock_factories.rb
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.
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.
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.
- 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.