summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rakefile23
-rw-r--r--chef-server-api/lib/chef-server-api.rb68
-rw-r--r--chef-solr/lib/chef/solr/application/indexer.rb67
-rw-r--r--chef-solr/lib/chef/solr/application/rebuild.rb4
-rw-r--r--chef-solr/lib/chef/solr/index_queue_consumer.rb (renamed from chef-solr/lib/chef/solr/index_actor.rb)10
-rw-r--r--chef/lib/chef/api_client.rb3
-rw-r--r--chef/lib/chef/couchdb.rb60
-rw-r--r--chef/lib/chef/data_bag.rb2
-rw-r--r--chef/lib/chef/data_bag_item.rb2
-rw-r--r--chef/lib/chef/index_queue/amqp_client.rb6
-rw-r--r--chef/lib/chef/index_queue/consumer.rb23
-rw-r--r--chef/lib/chef/nanite.rb100
-rw-r--r--chef/lib/chef/node.rb2
-rw-r--r--chef/lib/chef/openid_registration.rb2
-rw-r--r--chef/lib/chef/role.rb2
-rw-r--r--chef/lib/chef/webui_user.rb2
-rw-r--r--chef/spec/unit/couchdb_spec.rb29
-rw-r--r--chef/spec/unit/node_spec.rb1
-rw-r--r--features/support/env.rb10
19 files changed, 146 insertions, 270 deletions
diff --git a/Rakefile b/Rakefile
index fcfa40b221..fc9e664537 100644
--- a/Rakefile
+++ b/Rakefile
@@ -57,23 +57,17 @@ def configure_rabbitmq(type="normal")
# hack. wait for rabbit to come up.
sleep 2
- puts `rabbitmqctl add_vhost /nanite`
+ puts `rabbitmqctl add_vhost /chef`
- # create 'mapper' and 'nanite' users, give them each the password 'testing'
- %w[mapper nanite].each do |agent|
- puts `rabbitmqctl add_user #{agent} testing`
- end
-
- # grant the mapper user the ability to do anything with the /nanite vhost
- # the three regex's map to config, write, read permissions respectively
- puts `rabbitmqctl set_permissions -p /nanite mapper ".*" ".*" ".*"`
+ # create 'chef' user, give it the password 'testing'
+ puts `rabbitmqctl add_user chef testing`
- # grant the nanite user more limited permissions on the /nanite vhost
- puts `rabbitmqctl set_permissions -p /nanite nanite ".*" ".*" ".*"`
+ # the three regexes map to config, write, read permissions respectively
+ puts `rabbitmqctl set_permissions -p /chef chef ".*" ".*" ".*"`
puts `rabbitmqctl list_users`
puts `rabbitmqctl list_vhosts`
- puts `rabbitmqctl list_permissions -p /nanite`
+ puts `rabbitmqctl list_permissions -p /chef`
end
@@ -108,6 +102,7 @@ def start_chef_solr_indexer(type="normal")
end
def start_chef_server(type="normal")
+ puts "Staring #{type} chef development server"
@chef_server_pid = nil
mcid = fork
if mcid # parent
@@ -115,8 +110,10 @@ def start_chef_server(type="normal")
else # child
case type
when "normal"
+ puts "Starting chef server for development with './chef-server/bin/chef-server -a thin -l debug -N'"
exec("./chef-server/bin/chef-server -a thin -l debug -N")
when "features"
+ puts "Starting chef server for features with #{["./chef-server/bin/chef-server -a thin -C #{File.join(File.dirname(__FILE__), "features", "data", "config", "server.rb")} -l debug -N"].join(' ')}"
exec("./chef-server/bin/chef-server -a thin -C #{File.join(File.dirname(__FILE__), "features", "data", "config", "server.rb")} -l debug -N")
end
end
@@ -184,7 +181,7 @@ namespace :dev do
start_dev_environment("features")
wait_for_ctrlc
end
-
+
namespace :features do
namespace :start do
diff --git a/chef-server-api/lib/chef-server-api.rb b/chef-server-api/lib/chef-server-api.rb
index 20dd832d45..95e69f2452 100644
--- a/chef-server-api/lib/chef-server-api.rb
+++ b/chef-server-api/lib/chef-server-api.rb
@@ -5,7 +5,7 @@ if defined?(Merb::Plugins)
dependency 'merb-slices', :immediate => true
dependency 'chef', :immediate=>true unless defined?(Chef)
- dependency 'nanite', :immediate=>true
+ dependency 'bunny', :immediate=>true
dependency 'uuidtools', :immediate=>true
require 'chef/role'
@@ -13,7 +13,6 @@ if defined?(Merb::Plugins)
require 'chef/data_bag_item'
require 'chef/api_client'
require 'chef/webui_user'
- require 'chef/nanite'
require 'chef/certificate'
require 'mixlib/authentication'
@@ -21,7 +20,6 @@ if defined?(Merb::Plugins)
require 'chef/data_bag'
require 'chef/data_bag_item'
require 'ohai'
- require 'chef/nanite'
require 'openssl'
Merb::Plugins.add_rakefiles "chef-server-api/merbtasks", "chef-server-api/slicetasks", "chef-server-api/spectasks"
@@ -59,41 +57,39 @@ if defined?(Merb::Plugins)
# Activation hook - runs after AfterAppLoads BootLoader
def self.activate
- Mixlib::Authentication::Log.logger = Nanite::Log.logger = Ohai::Log.logger = Chef::Log.logger
-
- Thread.new do
- Chef::Log.level = :debug
- # Okay, we're here because if you run this with the thin adaptor, you
- # need to wait for EM to heat all the way up - and it won't, until
- # after activate is finished.
- sleep 1
- Chef::Nanite.in_event { Chef::Log.info("Nanite is ready") }
-
- # This is because nanite needs to broadcast, and we don't know how long
- # that will take.
- 20.downto(0) do |sleep_time|
- Chef::Log.info("Waiting for Nanite to heat up.. #{sleep_time} seconds left")
- sleep 1
+ Mixlib::Authentication::Log.logger = Ohai::Log.logger = Chef::Log.logger
+
+ unless Merb::Config.environment == "test"
+ # create the couch design docs for nodes, roles, and databags
+ Chef::CouchDB.new.create_id_map
+ Chef::Node.create_design_document
+ Chef::Role.create_design_document
+ Chef::DataBag.create_design_document
+ Chef::ApiClient.create_design_document
+ Chef::WebUIUser.create_design_document
+
+ Chef::Log.info('Loading roles')
+ Chef::Role.sync_from_disk_to_couchdb
+
+ # Create the default WebUI admin user "admin" if not already exists
+ begin
+ user = Chef::WebUIUser.load(Chef::Config[:web_ui_admin_user_name])
+ rescue Chef::Exceptions::CouchDBNotFound => e
+ user = Chef::WebUIUser.new
+ user.name = Chef::Config[:web_ui_admin_user_name]
+ user.set_password(Chef::Config[:web_ui_admin_default_password])
+ user.admin = true
+ user.save
end
- unless Merb::Config.environment == "test"
- # create the couch design docs for nodes, roles, and databags
- Chef::CouchDB.new.create_id_map
- Chef::Node.create_design_document
- Chef::Role.create_design_document
- Chef::DataBag.create_design_document
- Chef::ApiClient.create_design_document
- Chef::WebUIUser.create_design_document
-
- # Create the signing key and certificate
- Chef::Certificate.generate_signing_ca
-
- # Generate the validation key
- Chef::Certificate.gen_validation_key
-
- # Generate the Web UI Key
- Chef::Certificate.gen_validation_key(Chef::Config[:web_ui_client_name], Chef::Config[:web_ui_key])
- end
+ # Create the signing key and certificate
+ Chef::Certificate.generate_signing_ca
+
+ # Generate the validation key
+ Chef::Certificate.gen_validation_key
+
+ # Generate the Web UI Key
+ Chef::Certificate.gen_validation_key(Chef::Config[:web_ui_client_name], Chef::Config[:web_ui_key])
end
end
diff --git a/chef-solr/lib/chef/solr/application/indexer.rb b/chef-solr/lib/chef/solr/application/indexer.rb
index 4804352d66..7a58907fbd 100644
--- a/chef-solr/lib/chef/solr/application/indexer.rb
+++ b/chef-solr/lib/chef/solr/application/indexer.rb
@@ -21,12 +21,9 @@ require 'chef/config'
require 'chef/application'
require 'chef/solr'
require 'chef/solr/index'
-require 'chef/solr/index_actor'
+require 'chef/solr/index_queue_consumer'
require 'chef/daemon'
-require 'chef/nanite'
require 'chef/webui_user'
-require 'nanite'
-require 'eventmachine'
class Chef
class Solr
@@ -78,49 +75,39 @@ class Chef
:description => "Daemonize the process",
:proc => lambda { |p| true }
- option :nanite_identity,
- :long => "--nanite-identity ID",
- :description => "The nanite identity"
+ option :amqp_host,
+ :long => "--amqp-host HOST",
+ :description => "The amqp host"
- option :nanite_host,
- :long => "--nanite-host HOST",
- :description => "The nanite host"
+ option :amqp_port,
+ :long => "--amqp-port PORT",
+ :description => "The amqp port"
- option :nanite_port,
- :long => "--nanite-port PORT",
- :description => "The nanite port"
+ option :amqp_user,
+ :long => "--amqp-user USER",
+ :description => "The amqp user"
- option :nanite_user,
- :long => "--nanite-user USER",
- :description => "The nanite user"
-
- option :nanite_pass,
- :long => "--nanite-pass PASS",
- :description => "The nanite password"
-
- option :nanite_vhost,
- :long => "--nanite-vhost VHOST",
- :description => "The nanite vhost"
+ option :amqp_pass,
+ :long => "--amqp-pass PASS",
+ :description => "The amqp password"
+ option :amqp_vhost,
+ :long => "--amqp-vhost VHOST",
+ :description => "The amqp vhost"
+
+ Signal.trap("INT") do
+ fatal!("SIGINT received, stopping", 2)
+ end
+
def initialize
super
@index = Chef::Solr::Index.new
- ::Nanite::Log.logger = Chef::Log.logger
+ @consumer = Chef::Solr::IndexQueueConsumer.new
end
def setup_application
Chef::Daemon.change_privilege
- identity = Chef::Config[:nanite_identity] ? Chef::Config[:nanite_identity] : Chef::Nanite.get_identity("solr-indexer")
- @nanite_config = {
- :host => Chef::Config[:nanite_host],
- :port => 5672,
- :user => Chef::Config[:nanite_user],
- :pass => Chef::Config[:nanite_pass],
- :vhost => Chef::Config[:nanite_vhost],
- :identity => identity,
- :format => :json
- }
Chef::Log.level = Chef::Config[:log_level]
end
@@ -128,12 +115,10 @@ class Chef
if Chef::Config[:daemonize]
Chef::Daemon.daemonize("chef-solr-indexer")
end
-
- EM.run do
- agent = ::Nanite::Agent.start(@nanite_config)
- agent.register(Chef::Solr::IndexActor.new, 'index')
- agent.send :advertise_services
- end
+
+ @consumer.set_signal_traps
+ @consumer.start
+
end
end
end
diff --git a/chef-solr/lib/chef/solr/application/rebuild.rb b/chef-solr/lib/chef/solr/application/rebuild.rb
index b1673c9b12..50cc14fc2a 100644
--- a/chef-solr/lib/chef/solr/application/rebuild.rb
+++ b/chef-solr/lib/chef/solr/application/rebuild.rb
@@ -21,8 +21,6 @@ require 'chef/config'
require 'chef/application'
require 'chef/solr'
require 'chef/solr/index'
-require 'nanite'
-require 'eventmachine'
class Chef
class Solr
@@ -94,7 +92,6 @@ class Chef
super
@index = Chef::Solr::Index.new
- ::Nanite::Log.logger = Chef::Log.logger
end
def setup_application
@@ -102,7 +99,6 @@ class Chef
Chef::Log.warn("This operation is destructive!")
Chef::Log.warn("I'm going to count to 20, and then delete your Solr index and rebuild it.")
Chef::Log.warn("CTRL-C will, of course, stop this disaster.")
- Chef::Nanite.in_event { }
0.upto(20) do |num|
Chef::Log.warn("... #{num}")
sleep 1
diff --git a/chef-solr/lib/chef/solr/index_actor.rb b/chef-solr/lib/chef/solr/index_queue_consumer.rb
index 9157150ed4..8d55b01d12 100644
--- a/chef-solr/lib/chef/solr/index_actor.rb
+++ b/chef-solr/lib/chef/solr/index_queue_consumer.rb
@@ -28,15 +28,15 @@ require 'chef/data_bag'
require 'chef/data_bag_item'
require 'chef/api_client'
require 'chef/couchdb'
-require 'nanite/actor'
+require 'chef/index_queue'
class Chef
class Solr
- class IndexActor
- include ::Nanite::Actor
-
- expose :add, :delete, :commit, :optimize
+ class IndexQueueConsumer
+ include Chef::IndexQueue::Consumer
+ #expose :add, :delete, :commit, :optimize
+
def add(payload)
index = Chef::Solr::Index.new
diff --git a/chef/lib/chef/api_client.rb b/chef/lib/chef/api_client.rb
index 918c4acd89..f3933b3c15 100644
--- a/chef/lib/chef/api_client.rb
+++ b/chef/lib/chef/api_client.rb
@@ -21,6 +21,7 @@ require 'chef/config'
require 'chef/mixin/params_validate'
require 'chef/couchdb'
require 'chef/certificate'
+require 'chef/index_queue'
require 'extlib'
require 'json'
@@ -29,6 +30,8 @@ class Chef
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
+ include IndexQueue::Indexable
+
DESIGN_DOCUMENT = {
"version" => 1,
diff --git a/chef/lib/chef/couchdb.rb b/chef/lib/chef/couchdb.rb
index 5959feaf2b..b2e41f7554 100644
--- a/chef/lib/chef/couchdb.rb
+++ b/chef/lib/chef/couchdb.rb
@@ -21,7 +21,6 @@ require 'chef/rest'
require 'chef/log'
require 'digest/sha2'
require 'json'
-require 'chef/nanite'
# We want to fail on create if uuidtools isn't installed
begin
@@ -112,27 +111,16 @@ class Chef
:object => { :respond_to => :to_json },
}
)
- r = get_view("id_map", "name_to_id", :key => [ obj_type, name ])
- uuid = nil
- if r["rows"].length == 1
- uuid = r["rows"][0]["id"]
- else
- uuid = UUIDTools::UUID.random_create.to_s
- end
-
- r = @rest.put_rest("#{couchdb_database}/#{uuid}", object)
- Chef::Log.info("Sending #{uuid} to Nanite for indexing..")
- n = Chef::Nanite.push(
- "/index/add",
- {
- :id => uuid,
- :database => couchdb_database,
- :type => obj_type,
- :item => object
- },
- :persistent => true
- )
- r
+ response = get_view("id_map", "name_to_id", :key => [ obj_type, name ])
+ uuid = response["rows"].empty? ? nil : response["rows"].first.fetch("id")
+ uuid ||= UUIDTools::UUID.random_create.to_s
+
+ db_put_response = @rest.put_rest("#{couchdb_database}/#{uuid}", object)
+
+ Chef::Log.info("Sending #{obj_type}(#{uuid}) to the index queue for addition.")
+ object.add_to_index(:database => couchdb_database, :id => uuid, :type => obj_type)
+
+ db_put_response
end
def load(obj_type, name)
@@ -163,27 +151,21 @@ class Chef
}
)
del_id = nil
- last_obj, obj_id = find_by_name(obj_type, name, true)
+ object, uuid = find_by_name(obj_type, name, true)
unless rev
- if last_obj.respond_to?(:couchdb_rev)
- rev = last_obj.couchdb_rev
+ if object.respond_to?(:couchdb_rev)
+ rev = object.couchdb_rev
else
- rev = last_obj['_rev']
+ rev = object['_rev']
end
end
- r = @rest.delete_rest("#{couchdb_database}/#{obj_id}?rev=#{rev}")
- r.couchdb = self if r.respond_to?(:couchdb)
- Chef::Log.info("Sending #{obj_id} to Nanite for deletion..")
- n = Chef::Nanite.push(
- "/index/delete",
- {
- :id => obj_id,
- :database => couchdb_database,
- :type => obj_type
- },
- :persistent => true
- )
- r
+ response = @rest.delete_rest("#{couchdb_database}/#{uuid}?rev=#{rev}")
+ response.couchdb = self if response.respond_to?(:couchdb=)
+ Chef::Log.info("Sending #{obj_type}(#{uuid}) to the index queue for deletion..")
+
+ object.delete_from_index(:database => couchdb_database, :id => uuid, :type => obj_type)
+
+ response
end
def list(view, inflate=false)
diff --git a/chef/lib/chef/data_bag.rb b/chef/lib/chef/data_bag.rb
index 96b58f4809..70c5d44a1e 100644
--- a/chef/lib/chef/data_bag.rb
+++ b/chef/lib/chef/data_bag.rb
@@ -22,6 +22,7 @@ require 'chef/mixin/params_validate'
require 'chef/mixin/from_file'
require 'chef/couchdb'
require 'chef/data_bag_item'
+require 'chef/index_queue'
require 'extlib'
require 'json'
@@ -30,6 +31,7 @@ class Chef
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
+ include IndexQueue::Indexable
DESIGN_DOCUMENT = {
"version" => 2,
diff --git a/chef/lib/chef/data_bag_item.rb b/chef/lib/chef/data_bag_item.rb
index 2cfd342b29..5dbbf5dfc7 100644
--- a/chef/lib/chef/data_bag_item.rb
+++ b/chef/lib/chef/data_bag_item.rb
@@ -21,6 +21,7 @@ require 'chef/config'
require 'chef/mixin/params_validate'
require 'chef/mixin/from_file'
require 'chef/couchdb'
+require 'chef/data_bag_item'
require 'extlib'
require 'json'
@@ -29,6 +30,7 @@ class Chef
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
+ include IndexQueue::Indexable
DESIGN_DOCUMENT = {
"version" => 1,
diff --git a/chef/lib/chef/index_queue/amqp_client.rb b/chef/lib/chef/index_queue/amqp_client.rb
index d8b7a473eb..586264a1ea 100644
--- a/chef/lib/chef/index_queue/amqp_client.rb
+++ b/chef/lib/chef/index_queue/amqp_client.rb
@@ -41,18 +41,18 @@ class Chef
unless @amqp_client
@amqp_client = Bunny.new(amqp_opts)
@amqp_client.start
- @amqp_client.qos(:prefetch => 1)
+ @amqp_client.qos(:prefetch_count => 1)
end
@amqp_client
end
def exchange
- @exchange ||= amqp_client.exchange("chef-indexer")
+ @exchange ||= amqp_client.exchange("chef-indexer", :durable => true, :type => :fanout)
end
def queue
unless @queue
- @queue = amqp_client.queue("chef-indexer-" + UUIDTools::UUID.random_create.to_s)
+ @queue = amqp_client.queue("chef-index-consumer-" + UUIDTools::UUID.random_create.to_s)
@queue.bind(exchange)
end
@queue
diff --git a/chef/lib/chef/index_queue/consumer.rb b/chef/lib/chef/index_queue/consumer.rb
index de5770c99f..2c894eb3b3 100644
--- a/chef/lib/chef/index_queue/consumer.rb
+++ b/chef/lib/chef/index_queue/consumer.rb
@@ -21,11 +21,14 @@ class Chef
module Consumer
def run
- AmqpClient.instance.queue.subscribe(:ack => true) do |message|
+ Chef::Log.debug("Starting Index Queue Consumer")
+ queue = AmqpClient.instance.queue
+ queue.subscribe(:ack => true, :timeout => false) do |message|
call_action_for_message(message)
- AmqpClient.instance.queue.ack
+ #queue.ack
end
end
+ alias :start :run
def call_action_for_message(message)
amqp_payload = JSON.parse(message[:payload])
@@ -35,8 +38,20 @@ class Chef
end
def set_signal_traps
- Kernel.trap("INT") { AmqpClient.stop }
- Kernel.trap("TERM") { AmqpClient.stop }
+ Kernel.trap("INT") do
+ begin
+ AmqpClient.instance.stop
+ rescue Bunny::ProtocolError
+ rescue Bunny::ConnectionError
+ end
+ end
+ Kernel.trap("TERM") do
+ begin
+ AmqpClient.instance.stop
+ rescue Bunny::ProtocolError
+ rescue Bunny::ConnectionError
+ end
+ end
end
end
diff --git a/chef/lib/chef/nanite.rb b/chef/lib/chef/nanite.rb
deleted file mode 100644
index b7bb070a03..0000000000
--- a/chef/lib/chef/nanite.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 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.
-#
-
-require 'chef'
-require 'chef/config'
-require 'chef/mixin/params_validate'
-require 'json'
-
-# The client doesn't use this class, so we are cool without having it
-begin
- require 'nanite'
- require 'uuidtools'
-rescue LoadError
-end
-
-class Chef
- class Nanite
-
- class << self
-
- def start_mapper(config={})
- Chef::Log.info("Running the Nanite Mapper")
- ::Nanite::Log.logger = Chef::Log.logger
- identity = get_identity
- ::Nanite.start_mapper(
- :host => Chef::Config[:nanite_host],
- :user => Chef::Config[:nanite_user],
- :pass => Chef::Config[:nanite_pass],
- :vhost => Chef::Config[:nanite_vhost],
- :identity => identity,
- :format => :json,
- :log_level => Chef::Config[:log_level]
- )
- end
-
- def get_identity(type="mapper")
- id = nil
- if Chef::Config[:nanite_persistent_mapper]
- if Chef::FileCache.has_key?("nanite-#{type}-identity")
- id = Chef::FileCache.load("nanite-#{type}-identity")
- else
- id = UUIDTools::UUID.random_create.to_s
- Chef::FileCache.store("nanite-#{type}-identity", id)
- end
- else
- id = Chef::Config[:nanite_identity] ? "#{Chef::Config[:nanite_identity]}-#{UUIDTools::UUID.random_create.to_s}" : UUIDTools::UUID.random_create.to_s
- end
- id
- end
-
- def request(*args)
- in_event do
- ::Nanite.request(*args)
- end
- end
-
- def push(*args)
- in_event do
- ::Nanite.push(*args)
- end
- end
-
- def in_event(&block)
- if EM.reactor_running?
- begin
- ::Nanite.ensure_mapper
- rescue ::Nanite::MapperNotRunning
- start_mapper
- end
- block.call
- else
- Chef::Log.warn("Starting Event Machine Loop")
- Thread.new do
- EM.run do
- start_mapper
- block.call
- end
- end
- end
- end
-
- end
-
- end
-end
diff --git a/chef/lib/chef/node.rb b/chef/lib/chef/node.rb
index b449a2c337..a255d883ef 100644
--- a/chef/lib/chef/node.rb
+++ b/chef/lib/chef/node.rb
@@ -25,6 +25,7 @@ require 'chef/couchdb'
require 'chef/rest'
require 'chef/run_list'
require 'chef/node/attribute'
+require 'chef/index_queue'
require 'extlib'
require 'json'
@@ -37,6 +38,7 @@ class Chef
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
include Chef::Mixin::LanguageIncludeAttribute
+ include IndexQueue::Indexable
DESIGN_DOCUMENT = {
"version" => 9,
diff --git a/chef/lib/chef/openid_registration.rb b/chef/lib/chef/openid_registration.rb
index e6f51e0975..81ffb3aaa6 100644
--- a/chef/lib/chef/openid_registration.rb
+++ b/chef/lib/chef/openid_registration.rb
@@ -19,6 +19,7 @@
require 'chef/config'
require 'chef/mixin/params_validate'
require 'chef/couchdb'
+require 'chef/index_queue'
require 'digest/sha1'
require 'rubygems'
require 'json'
@@ -29,6 +30,7 @@ class Chef
attr_accessor :name, :salt, :validated, :password, :couchdb_rev, :admin
include Chef::Mixin::ParamsValidate
+ include IndexQueue::Indexable
DESIGN_DOCUMENT = {
"version" => 3,
diff --git a/chef/lib/chef/role.rb b/chef/lib/chef/role.rb
index ee650239da..4c34dde375 100644
--- a/chef/lib/chef/role.rb
+++ b/chef/lib/chef/role.rb
@@ -22,6 +22,7 @@ require 'chef/mixin/params_validate'
require 'chef/mixin/from_file'
require 'chef/couchdb'
require 'chef/run_list'
+require 'chef/index_queue'
require 'extlib'
require 'json'
@@ -30,6 +31,7 @@ class Chef
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
+ include IndexQueue::Indexable
DESIGN_DOCUMENT = {
"version" => 6,
diff --git a/chef/lib/chef/webui_user.rb b/chef/lib/chef/webui_user.rb
index 672cca8c48..ea131c10dc 100644
--- a/chef/lib/chef/webui_user.rb
+++ b/chef/lib/chef/webui_user.rb
@@ -20,6 +20,7 @@
require 'chef/config'
require 'chef/mixin/params_validate'
require 'chef/couchdb'
+require 'chef/index_queue'
require 'digest/sha1'
require 'rubygems'
require 'json'
@@ -30,6 +31,7 @@ class Chef
attr_accessor :name, :salt, :validated, :password, :couchdb_rev, :admin, :openid
include Chef::Mixin::ParamsValidate
+ include IndexQueue::Indexable
DESIGN_DOCUMENT = {
"version" => 3,
diff --git a/chef/spec/unit/couchdb_spec.rb b/chef/spec/unit/couchdb_spec.rb
index e35f2a9374..698d36b250 100644
--- a/chef/spec/unit/couchdb_spec.rb
+++ b/chef/spec/unit/couchdb_spec.rb
@@ -25,9 +25,6 @@ describe Chef::CouchDB do
@mock_rest.stub!(:url).and_return("http://localhost:5984")
Chef::REST.stub!(:new).and_return(@mock_rest)
@couchdb = Chef::CouchDB.new
- Chef::Nanite.stub!(:push).and_return(true)
- Chef::Nanite.stub!(:in_event).and_return(true)
- Chef::Nanite.stub!(:start_mapper).and_return(true)
end
describe "new" do
@@ -142,22 +139,22 @@ describe Chef::CouchDB do
end
it "should put the object into couchdb with a pre-existing GUID" do
- @mock_rest.should_receive(:put_rest).with("chef/#{@mock_results["rows"][0]["id"]}", {}).and_return(true)
- @couchdb.store("node", "bob", {})
+ item_to_store = {}
+ item_to_store.should_receive(:add_to_index)
+ @mock_rest.should_receive(:put_rest).with("chef/#{@mock_results["rows"][0]["id"]}", item_to_store).and_return(true)
+ @couchdb.store("node", "bob", item_to_store)
end
it "should put the object into couchdb with a new GUID" do
@mock_results = { "rows" => [] }
+ item_to_store = {}
+ item_to_store.should_receive(:add_to_index).with(:database => "chef", :id => "aaaaaaaa-xxxx-xxxx-xxxx-xxxxxxxxxxx", :type => "node")
@couchdb.stub!(:get_view).with("id_map", "name_to_id", :key => [ "node", "bob" ]).and_return(@mock_results)
UUIDTools::UUID.stub!(:random_create).and_return("aaaaaaaa-xxxx-xxxx-xxxx-xxxxxxxxxxx")
- @mock_rest.should_receive(:put_rest).with("chef/aaaaaaaa-xxxx-xxxx-xxxx-xxxxxxxxxxx", {}).and_return(true)
- @couchdb.store("node", "bob", {})
+ @mock_rest.should_receive(:put_rest).with("chef/aaaaaaaa-xxxx-xxxx-xxxx-xxxxxxxxxxx", item_to_store).and_return(true)
+ @couchdb.store("node", "bob", item_to_store)
end
- it "should send the object to nanite for indexing" do
- Chef::Nanite.should_receive(:push)
- @couchdb.store("node", "bob", {})
- end
end
describe "load" do
@@ -180,10 +177,10 @@ describe Chef::CouchDB do
}
@mock_rest.stub!(:get_rest).and_return(@mock_current)
@mock_rest.stub!(:delete_rest).and_return(true)
- @mock_node = Chef::Node.new()
- @mock_node.name("bob")
- @mock_node.couchdb_rev = 15
- @couchdb.stub!(:find_by_name).with("node", "bob", true).and_return([ @mock_node, "ax" ])
+ @node = Chef::Node.new()
+ @node.name("bob")
+ @node.couchdb_rev = 15
+ @couchdb.stub!(:find_by_name).with("node", "bob", true).and_return([ @node, "ax" ])
end
def do_delete(rev=nil)
@@ -191,11 +188,13 @@ describe Chef::CouchDB do
end
it "should remove the object from couchdb with a specific revision" do
+ @node.should_receive(:delete_from_index)
@mock_rest.should_receive(:delete_rest).with("chef/ax?rev=1")
do_delete(1)
end
it "should remove the object from couchdb based on the couchdb_rev of the current obj" do
+ @node.should_receive(:delete_from_index)
@mock_rest.should_receive(:delete_rest).with("chef/ax?rev=15")
do_delete
end
diff --git a/chef/spec/unit/node_spec.rb b/chef/spec/unit/node_spec.rb
index 5aa75dc059..505cc28f71 100644
--- a/chef/spec/unit/node_spec.rb
+++ b/chef/spec/unit/node_spec.rb
@@ -21,7 +21,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
describe Chef::Node do
before(:each) do
Chef::Config.node_path(File.join(File.dirname(__FILE__), "..", "data", "nodes"))
- Nanite.stub!(:request).and_return(true)
@node = Chef::Node.new()
end
diff --git a/features/support/env.rb b/features/support/env.rb
index 0633492247..1a3088f022 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -52,14 +52,7 @@ def setup_logging
Chef::Log.level = ENV['LOG_LEVEL'].to_sym
Merb.logger.set_log(STDOUT, ENV['LOG_LEVEL'].to_sym)
end
- Nanite::Log.logger = Ohai::Log.logger = Chef::Log.logger
-end
-
-def setup_nanite
- Chef::Config[:nanite_identity] = "chef-integration-test"
- Chef::Nanite.in_event { Chef::Log.debug("Nanite is up!") }
- Chef::Log.debug("Waiting for Nanites to register with us as a mapper")
- sleep 10
+ Ohai::Log.logger = Chef::Log.logger
end
def delete_databases
@@ -117,7 +110,6 @@ Merb.start_environment(
# Pre-testing setup
###
setup_logging
-setup_nanite
cleanup
delete_databases
create_databases