bin/cucumber-chef in cucumber-chef-0.4.4 vs bin/cucumber-chef in cucumber-chef-0.5.0
- old
+ new
@@ -25,50 +25,11 @@
def self.source_root
File.dirname(__FILE__)
end
- def initialize(args = [], options = {}, config = {})
- @provisioner = ::Cucumber::Chef::Provisioner.new
- super(args, options, config)
- end
-
no_tasks do
- def tcp_test_ssh(hostname)
- tcp_socket = TCPSocket.new(hostname, 22)
- IO.select([tcp_socket], nil, nil, 5)
- rescue Errno::ETIMEDOUT
- false
- rescue Errno::EPERM
- false
- rescue Errno::ECONNREFUSED
- sleep 2
- false
- # This happens on EC2 quite often
- rescue Errno::EHOSTUNREACH
- sleep 2
- false
- ensure
- tcp_socket && tcp_socket.close
- end
-
- def get_latest_version
- installed_versions = []
- Gem::source_index.find_name('cucumber-chef').map do |g|
- version = g.version.version
- if version == ""
- version = "0"
- end
- installed_versions << version
- end
- version = installed_versions.sort { |a, b| a.to_i <=> b.to_i }.last
- if version == "0"
- version = ""
- end
- return "cucumber-chef-" + version
- end
-
def create_directory_structure(project_dir)
%w{step_definitions support}.each do |dir|
FileUtils.mkdir_p(project_dir + "features" + dir)
end
end
@@ -93,16 +54,10 @@
def error(message)
warn message
exit 255
end
-
- def find_knife_config
- @provisioner.config
- rescue ::Cucumber::Chef::ProvisionerError => err
- error(err.message)
- end
end
desc "project <project name>" , "Create a project template for testing an infrastructure"
def project(project_name)
@project = project_name
@@ -113,39 +68,57 @@
desc "setup", "Set up a cucumber-chef test lab in Amazon EC2"
method_option :test, :type => :boolean
def setup
begin
- config = find_knife_config
if options.test?
- config[:mode] = "test"
+ config = Cucumber::Chef::Config.test_config
else
- config[:mode] = "user"
+ config = Cucumber::Chef::Config.new
end
- @provisioner.verify_opscode_platform_credentials(config)
- @provisioner.verify_aws_credentials(config)
+ config.verify
$stdout.sync
- server = @provisioner.build_test_lab(config, $stdout)
+ provisioner = ::Cucumber::Chef::Provisioner.new
+ server = provisioner.build_test_lab(config, $stdout)
sleep(10)
- @provisioner.upload_cookbook(config)
- @provisioner.upload_role(config)
- @provisioner.bootstrap_node(server.dns_name, config).run
- rescue ::Cucumber::Chef::ProvisionerError => err
+ provisioner.upload_cookbook(config)
+ provisioner.upload_role(config)
+ provisioner.bootstrap_node(server.dns_name, config).run
+ rescue ::Cucumber::Chef::Error => err
error(err.message)
end
end
desc "displayconfig", "Display the current config from knife.rb"
+ method_option :test, :type => :boolean
def displayconfig
- values, missing_keys = Cucumber::Chef::Config.new.display
- puts values.join("\n")
- if missing_keys.size > 0
- error("Incomplete config file, please specify: #{missing_keys.join(", ")}")
+ if options.test?
+ config = Cucumber::Chef::Config.test_config
+ else
+ config = Cucumber::Chef::Config.new
end
- rescue ::Cucumber::Chef::ProvisionerError => err
+ puts config.list.join("\n")
+ config.verify
+ rescue ::Cucumber::Chef::Error => err
error(err.message)
end
+
+ desc "info", "Display information about the current test lab"
+ method_option :test, :type => :boolean
+ def info
+ if options.test?
+ config = Cucumber::Chef::Config.test_config
+ else
+ config = Cucumber::Chef::Config.new
+ end
+ config.verify
+ lab = Cucumber::Chef::TestLab.new(config)
+ if lab.exists?
+ puts lab.info
+ else
+ end
+ end
desc "upload", "Upload a cucumber-chef test suite to the test lab platform"
def upload
puts "Project uploaded to the test-lab."
end
@@ -154,9 +127,8 @@
def test
puts "Running test..."
puts
puts "Test results will appear here."
end
-
-
end
+
CucumberChef.start