summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2009-02-22 20:57:52 -0800
committerAdam Jacob <adam@hjksolutions.com>2009-02-22 20:57:52 -0800
commit3865a6e46f310b36217e1bcb815708a651b23c92 (patch)
tree56a046e07e2e530e78c39e50a846184637e8295d
parent12a07314216d6208f5062fad72f76de68305bee3 (diff)
downloadchef-3865a6e46f310b36217e1bcb815708a651b23c92.tar.gz
Adding rake tasks to run a dev environment, and run a dev environment specifically for cucumber features to run against
-rw-r--r--.gitignore3
-rw-r--r--Rakefile92
2 files changed, 94 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 86a1f94724..7ade6f67f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,5 +10,8 @@ chef/pkg
chef-server/pkg
chef/log
chef-server/log
+log
+couchdb.stderr
+couchdb.stdout
features/data/tmp/**
*.swp
diff --git a/Rakefile b/Rakefile
index f638e409b2..2fd474d2b3 100644
--- a/Rakefile
+++ b/Rakefile
@@ -24,7 +24,88 @@ task :spec do
end
end
-namespace :dev do
+def start_dev_environment(type="normal")
+ @couchdb_server_pid = nil
+ @chef_server_pid = nil
+ @chef_indexer_pid = nil
+ @stompserver_pid = nil
+
+ ccid = fork
+ if ccid
+ @couchdb_server_pid = ccid
+ else
+ exec("couchdb")
+ end
+
+ scid = fork
+ if scid
+ @stompserver_pid = scid
+ else
+ exec("stompserver")
+ end
+
+ mcid = fork
+ if mcid # parent
+ @chef_indexer_pid = mcid
+ else # child
+ case type
+ when "normal"
+ exec("chef-indexer -l debug")
+ when "features"
+ exec("chef-indexer -c #{File.join(File.dirname(__FILE__), "features", "data", "config", "server.rb")} -l debug")
+ end
+ end
+
+ mcid = fork
+ if mcid # parent
+ @chef_server_pid = mcid
+ else # child
+ case type
+ when "normal"
+ exec("chef-server -l debug -N -c 2")
+ when "features"
+ exec("chef-server -C #{File.join(File.dirname(__FILE__), "features", "data", "config", "server.rb")} -l debug -N -c 2")
+
+ end
+ end
+
+ puts "Running Chef at #{@chef_server_pid}"
+ puts "Running Chef Indexer at #{@chef_indexer_pid}"
+ puts "Running CouchDB at #{@couchdb_server_pid}"
+ puts "Running Stompserver at #{@stompserver_pid}"
+end
+
+def stop_dev_environment
+ puts "Stopping CouchDB"
+ Process.kill("KILL", @couchdb_server_pid)
+ puts "Stopping Stomp server"
+ Process.kill("KILL", @stompserver_pid)
+ puts "Stopping Chef Server"
+ Process.kill("INT", @chef_server_pid)
+ puts "Stopping Chef Indexer"
+ Process.kill("INT", @chef_indexer_pid)
+ puts "\nCouchDB, Stomp, Chef Server and Chef Indexer killed - have a nice day!"
+end
+
+def wait_for_ctrlc
+ puts "Hit CTRL-C to destroy development environment"
+ trap("CHLD", "IGNORE")
+ trap("INT") do
+ stop_dev_environment
+ exit 1
+ end
+ while true
+ sleep 10
+ end
+end
+
+desc "Run a Devel instance of Chef"
+task :dev => "dev:install" do
+ start_dev_environment
+ wait_for_ctrlc
+end
+
+namespace :dev do
desc "Install a Devel instance of Chef with the example-repository"
task :install do
gems.each do |dir|
@@ -32,6 +113,15 @@ namespace :dev do
end
Dir.chdir("example-repository") { sh("rake install") }
end
+
+ desc "Install a test instance of Chef for doing features against"
+ task :features do
+ gems.each do |dir|
+ Dir.chdir(dir) { sh "rake install" }
+ end
+ start_dev_environment("features")
+ wait_for_ctrlc
+ end
end
Cucumber::Rake::Task.new(:features) do |t|