summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2011-02-03 23:47:41 -0800
committerDaniel DeLeo <dan@opscode.com>2011-02-03 23:47:41 -0800
commit514c51cf35ccddb6accf8f5a60174649187b521c (patch)
treec9753462c815fe616d277e27f19a0f09006fa03e
parent5b59c478edda1491362d2de560758c3c95bd79eb (diff)
downloadchef-514c51cf35ccddb6accf8f5a60174649187b521c.tar.gz
update features infrastructure for chef-expander
-rw-r--r--Rakefile17
-rw-r--r--chef-server-api/app/controllers/nodes.rb2
-rw-r--r--chef-server-api/app/controllers/search.rb2
-rw-r--r--features/data/config/server.rb2
-rwxr-xr-xscripts/mac-dev-start107
5 files changed, 74 insertions, 56 deletions
diff --git a/Rakefile b/Rakefile
index 8b83123cce..720783f92b 100644
--- a/Rakefile
+++ b/Rakefile
@@ -102,17 +102,14 @@ def start_chef_solr(type="normal")
end
end
-def start_chef_solr_indexer(type="normal")
+def start_chef_expander(type="normal")
@chef_solr_indexer = nil
- cid = fork
- if cid
- @chef_solr_indexer_pid = cid
- else
+ @chef_solr_indexer_pid = fork do
case type
when "normal"
- exec("./chef-solr/bin/chef-solr-indexer -l debug")
+ exec("./chef-expander/bin/chef-expander -n 1 -i 1 -l debug")
when "features"
- exec("./chef-solr/bin/chef-solr-indexer -c #{File.join(File.dirname(__FILE__), "features", "data", "config", "server.rb")} -l debug")
+ exec("./chef-expander/bin/chef-expander -c #{File.join(File.dirname(__FILE__), "features", "data", "config", "server.rb")} -l debug -n 1 -i 1")
end
end
end
@@ -245,8 +242,8 @@ namespace :dev do
end
desc "Start Chef Solr Indexer for testing"
- task :chef_solr_indexer do
- start_chef_solr_indexer("features")
+ task :chef_expander do
+ start_chef_expander("features")
wait_for_ctrlc
end
@@ -287,7 +284,7 @@ namespace :dev do
desc "Start Chef Solr Indexer"
task :chef_solr_indexer do
- start_chef_solr_indexer
+ start_chef_expander
wait_for_ctrlc
end
diff --git a/chef-server-api/app/controllers/nodes.rb b/chef-server-api/app/controllers/nodes.rb
index b825c93562..79cb6b9c0c 100644
--- a/chef-server-api/app/controllers/nodes.rb
+++ b/chef-server-api/app/controllers/nodes.rb
@@ -109,7 +109,7 @@ class Nodes < Application
# expand returns a RunListExpansion which contains recipes, default and override attrs [cb]
# TODO: check for this on the client side before we make the http request [stephen 9/1/10]
begin
- recipes = @node.run_list.expand('couchdb', @node.chef_environment).recipes.with_versions
+ recipes = @node.run_list.expand('couchdb', :environment => @node.chef_environment).recipes.with_versions
rescue Chef::Exceptions::RecipeVersionConflict => e
raise PreconditionFailed, "#Conflict: #{e.message}"
end
diff --git a/chef-server-api/app/controllers/search.rb b/chef-server-api/app/controllers/search.rb
index ad54dbb422..77a639945e 100644
--- a/chef-server-api/app/controllers/search.rb
+++ b/chef-server-api/app/controllers/search.rb
@@ -40,7 +40,7 @@ class Search < Application
raise NotFound, "I don't know how to search for #{params[:id]} data objects."
end
- query = Chef::SolrQuery.new(Chef::Config[:solr_url])
+ query = Chef::SolrQuery.new
params[:type] = params[:id]
objects, start, total = query.search(params)
diff --git a/features/data/config/server.rb b/features/data/config/server.rb
index 08b5873093..8ba01ae2ab 100644
--- a/features/data/config/server.rb
+++ b/features/data/config/server.rb
@@ -1,3 +1,5 @@
+require 'tmpdir'
+
supportdir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
tmpdir = File.expand_path(File.join(File.dirname(__FILE__), "..", "tmp"))
diff --git a/scripts/mac-dev-start b/scripts/mac-dev-start
index 78faf962d6..b2b029335a 100755
--- a/scripts/mac-dev-start
+++ b/scripts/mac-dev-start
@@ -1,59 +1,78 @@
#!/usr/bin/env ruby
require 'rubygems'
+require 'pp'
require 'appscript'
+require 'mixlib/cli'
-include Appscript
-
-SRCDIR = File.expand_path(File.join(File.dirname(__FILE__), ".."))
-DELAY = 1
-BASE_CMD = case ARGV[0]
- when "features"
- "cd #{SRCDIR} && rake dev:features:start:"
- when "dev"
- "cd #{SRCDIR} && rake dev:start:"
- else
- "cd #{SRCDIR} && rake dev:start:"
- end
-SERVICES = ["couchdb","rabbitmq","chef_solr","chef_solr_indexer","chef_server","chef_webui"]
-
-def auth_up
- #system("sudo echo")
-end
+class MacDevStart
+ include Mixlib::CLI
+ include Appscript
-def create_tab
- app("System Events").application_processes["Terminal.app"].keystroke("t", :using=>:command_down)
-end
+ SERVICES = %w{couchdb rabbitmq chef_solr chef_expander chef_server chef_webui}
-def activate_terminal
- app("/Applications/Utilities/Terminal.app").windows.first.activate
- app("System Events").application_processes["Terminal.app"].keystroke("n", :using=>:command_down)
- app('Terminal')
-end
+ option :environment,
+ :short => '-e ENV',
+ :long => '--environment ENV',
+ :default => 'test',
+ :description => 'Set the environment (test|dev), defaults to test'
-def start_service_in_last_tab(window,service)
- # use xterm escape codes to set the tab title to the service running in the tab.
- cmd =
- "unset PROMPT_COMMAND; echo -e \"\\033]0;#{service}\\007\"; " +
- BASE_CMD +
- service
+ def run
+ @srcdir = File.expand_path(File.dirname(__FILE__))
- app('Terminal').do_script(cmd, :in => window.tabs.last.get)
- sleep DELAY
-end
+ @base_cmd = case config[:environment]
+ when 'test'
+ "cd #{@srcdir} && rake dev:features:start:"
+ when 'dev'
+ "cd #{@srcdir} && rake dev:start:"
+ else
+ puts "--environment must be set to either 'test' or 'dev'"
+ puts @opt_parser
+ exit 1
+ end
+
+ STDOUT.puts "Starting services:"
+ pp SERVICES
+ start_services(SERVICES)
+ end
+
+ def create_tab
+ @window.activate
+ app("System Events").application_processes["Terminal.app"].keystroke("t", :using=>:command_down)
+ end
+
+ def terminal_app
+ @terminal_app ||= app("Terminal")
+ end
+
+ def create_term_window
+ terminal_app.windows.first.activate
+ app("System Events").application_processes["Terminal.app"].keystroke("n", :using=>:command_down)
+ @window = terminal_app.windows.first.get
+ end
-def start_services
- auth_up
- term = activate_terminal
- window = term.windows.first.get
-
- SERVICES.each do |service|
- create_tab
- start_service_in_last_tab(window,service)
+ def start_service_in_tab(service, tab)
+ # use xterm escape codes to set the tab title to the service running in the tab.
+ cmd = "unset PROMPT_COMMAND; echo -e \"\\033]0;#{service}\\007\"; #{@base_cmd}#{service}"
+ app('Terminal').do_script(cmd, :in => @window.tabs[tab].get)
+ end
+
+ def start_services(services)
+ create_term_window
+
+ tab_index = 1 # applescript indexes from 1 instead of 0
+
+ (services.size - 1).times { create_tab }
+
+ services.each do |service|
+ start_service_in_tab(service, tab_index)
+ tab_index += 1
+ end
end
end
if __FILE__ == $0
- start_services
+ os = MacDevStart.new
+ os.parse_options
+ os.run
end
-