baton 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ log/*
19
19
  .DS_Store
20
20
  coverage
21
21
  *.swp
22
+ *.rdb
data/.rspec CHANGED
@@ -1 +1,2 @@
1
- --color
1
+ --color
2
+ --order rand
data/.travis.yml CHANGED
@@ -2,5 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
5
6
  bundler_args: --without=darwin
6
7
  script: bundle exec rspec
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source 'http://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :darwin do
6
- gem "guard-rspec", "~> 0.5.8"
7
6
  gem 'rb-fsevent', "~> 0.9.1"
8
7
  gem 'growl_notify', "~> 0.0.3"
9
8
  end
File without changes
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Baton - Server Orchestration Tool
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/baton.png)](http://badge.fury.io/rb/baton)
3
4
  [![Build Status](https://secure.travis-ci.org/digital-science/baton.png?branch=master)](http://travis-ci.org/digital-science/baton)
5
+ [![Code Climate](https://codeclimate.com/github/digital-science/baton.png)](https://codeclimate.com/github/digital-science/baton)
4
6
 
5
7
  ## Description
6
8
 
@@ -89,3 +91,7 @@ If you would like to create your own extension, simply install baton (`gem insta
89
91
  batonize gem GEMNAME -b
90
92
 
91
93
  This will create a basic gem structure with the necessary files to create a minimum viable baton extension.
94
+
95
+ # Copyright
96
+
97
+ Copyright (c) Digital Science. See [LICENSE](https://github.com/digital-science/baton/blob/master/LICENSE) for details.
data/Rakefile CHANGED
@@ -1,12 +1,18 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
3
  require "rspec/core/rake_task"
4
+ require "bueller"
4
5
 
5
6
  task :default => [:test]
6
7
 
8
+ Bueller::Tasks.new
9
+
7
10
  RSpec::Core::RakeTask.new(:test)
11
+
12
+ desc "Run RSpec tests"
8
13
  task :test => :spec
9
14
 
15
+ desc "Run a console with baton lib loaded"
10
16
  task :console do
11
17
  sh "irb -rubygems -I lib -r baton.rb"
12
18
  end
data/baton.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |gem|
24
24
  gem.add_runtime_dependency "chef", ">= 11.0"
25
25
  gem.add_runtime_dependency "thor"
26
26
 
27
+ gem.add_development_dependency "bueller", "~> 0.0.9"
27
28
  gem.add_development_dependency "rspec", "~> 2.7"
28
29
  gem.add_development_dependency "moqueue", "~> 0.1.4"
29
30
  gem.add_development_dependency "fakefs", "~> 0.4.0"
@@ -32,4 +33,5 @@ Gem::Specification.new do |gem|
32
33
  gem.add_development_dependency "minitar", "0.5.3"
33
34
  gem.add_development_dependency "simplecov", "0.6.4"
34
35
  gem.add_development_dependency "pry"
36
+ gem.add_development_dependency "guard-rspec", "~> 3.0.0"
35
37
  end
data/lib/baton/channel.rb CHANGED
@@ -31,6 +31,7 @@ module Baton
31
31
 
32
32
  # Attach callbacks for error handling
33
33
  @connection.on_tcp_connection_loss(&method(:handle_tcp_failure))
34
+ @connection.on_skipped_heartbeats(&method(:handle_tcp_failure))
34
35
  @channel.on_error(&method(:handle_channel_exception))
35
36
  end
36
37
 
data/lib/baton/server.rb CHANGED
@@ -5,12 +5,10 @@ module Baton
5
5
 
6
6
  attr_accessor :environment, :fqdn, :app_names
7
7
 
8
- # Public: Initialize a Server. ALso, configures the server by reading Baton's configuration
9
- # file.
8
+ # Public: Initializes a server. Loads Ohai plugins and sets up basic
9
+ # server info, such as environment, fqdn and app names.
10
10
  def initialize
11
- Ohai::Config[:plugin_path] << ohai_plugin_path
12
- @ohai = Ohai::System.new
13
- @ohai.all_plugins
11
+ setup_ohai
14
12
  configure
15
13
  end
16
14
 
@@ -55,5 +53,12 @@ module Baton
55
53
  "/etc/chef/ohai_plugins"
56
54
  end
57
55
 
56
+ # Load Ohai plugins from the server
57
+ def setup_ohai
58
+ Ohai::Config[:plugin_path] << ohai_plugin_path
59
+ @ohai = Ohai::System.new
60
+ @ohai.all_plugins
61
+ end
62
+
58
63
  end
59
64
  end
data/lib/baton/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Baton
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
data/lib/baton.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require "baton/configuration"
2
2
  require "baton/version"
3
3
  require "baton/logging"
4
+ require "baton/consumer_manager"
5
+ require "baton/server"
6
+ require "baton/consumer"
7
+ require "json"
4
8
 
5
9
  module Baton
6
10
  def self.configuration
@@ -1,5 +1,4 @@
1
1
  require "spec_helper"
2
- require "baton"
3
2
 
4
3
  describe Baton do
5
4
  describe ".configure" do
@@ -10,4 +9,4 @@ describe Baton do
10
9
  Baton.configuration.pusher_key.should eq("foo")
11
10
  end
12
11
  end
13
- end
12
+ end
@@ -1,9 +1,9 @@
1
1
  require "spec_helper"
2
- require "baton/configuration"
3
2
 
4
3
  describe Baton::Configuration do
5
4
  describe "#config_path=" do
6
5
  context "given config file available" do
6
+
7
7
  before(:each) do
8
8
  subject.config_path = "#{File.dirname(__FILE__)}/../fixtures/config.cfg"
9
9
  end
@@ -45,12 +45,12 @@ describe Baton::Configuration do
45
45
  context "give a config file" do
46
46
  it "will return a config hash" do
47
47
  subject.connection_opts.should eq({
48
- :host=>"fromconfig.com",
49
- :vhost=>"fromconfig",
50
- :user=>"fromconfiguser",
51
- :password=>"fromconfigpass",
52
- :pass=>"fromconfigpass",
53
- :heartbeat=>666
48
+ host: "fromconfig.com",
49
+ vhost: "fromconfig",
50
+ user: "fromconfiguser",
51
+ password: "fromconfigpass",
52
+ pass: "fromconfigpass",
53
+ heartbeat: 666
54
54
  })
55
55
  end
56
56
  end
@@ -59,11 +59,11 @@ describe Baton::Configuration do
59
59
  it "will not be returned in the config hash" do
60
60
  subject.vhost = nil
61
61
  subject.connection_opts.should eq({
62
- :host=>"fromconfig.com",
63
- :user=>"fromconfiguser",
64
- :password=>"fromconfigpass",
65
- :pass=>"fromconfigpass",
66
- :heartbeat=>666
62
+ host: "fromconfig.com",
63
+ user: "fromconfiguser",
64
+ password: "fromconfigpass",
65
+ pass: "fromconfigpass",
66
+ heartbeat: 666
67
67
  })
68
68
  end
69
69
  end
@@ -1,41 +1,30 @@
1
1
  require "spec_helper"
2
- require "baton"
3
- require "baton/consumer"
4
- require "baton/consumer_manager"
5
- require "baton/server"
6
- require "ostruct"
2
+ require "moqueue"
7
3
 
8
4
  describe Baton::ConsumerManager do
9
5
 
10
- before :each do
6
+ subject { Baton::ConsumerManager.new(consumer, nil,
7
+ mock_exchange({:direct => true}),
8
+ mock_exchange({:direct => true})) }
9
+ let(:server) {
11
10
  Baton::Server.any_instance.stub(:facts).and_return({
12
11
  "fqdn" => "camac.dsci.it",
13
12
  "chef_environment" => "production"
14
13
  })
15
- server = Baton::Server.new
16
- @consumer = Baton::Consumer.new("camac", server)
17
- end
18
-
19
- subject {
20
- Baton::ConsumerManager.new(@consumer, nil, mock_exchange({:direct => true}), mock_exchange({:direct => true}))
14
+ Baton::Server.any_instance.stub(:setup_ohai)
15
+ Baton::Server.new
21
16
  }
22
-
23
- let(:metadata) do
24
- obj = OpenStruct.new
25
- obj.content_type = "application/json"
26
- obj
27
- end
28
-
29
- let(:payload) do
30
- JSON({"type" => "message type" })
31
- end
17
+ let(:consumer) { Baton::Consumer.new("camac", server) }
18
+ let(:metadata) { o = OpenStruct.new ; o.content_type = "application/json"; o }
19
+ let(:payload) { JSON({"type" => "message type" }) }
32
20
 
33
21
  describe "#start" do
34
22
  it "will subscribe to a queue using the correct routing key" do
35
23
  subject.exchange_in.stub(:name)
36
24
  allow_message_expectations_on_nil
37
25
  queue = mock("queue")
38
- queue.should_receive(:bind).with(subject.exchange_in, routing_key: "camac.production")
26
+ queue.should_receive(:bind).with(subject.exchange_in,
27
+ routing_key: "camac.production")
39
28
  queue.should_receive(:subscribe)
40
29
  subject.channel.stub(:queue).and_return(queue)
41
30
  subject.start
@@ -61,8 +50,8 @@ describe Baton::ConsumerManager do
61
50
  describe "#update" do
62
51
  context "given a message is sent to the consumer and the consumer notifies" do
63
52
  it "should trigger update with a message" do
64
- @consumer.stub(:process_message) do |message|
65
- @consumer.notify("message from consumer")
53
+ consumer.stub(:process_message) do |message|
54
+ consumer.notify("message from consumer")
66
55
  end
67
56
  subject.should_receive(:update)
68
57
  subject.handle_message(metadata, payload)
@@ -1,26 +1,17 @@
1
1
  require "spec_helper"
2
- require "baton"
3
- require "baton/consumer"
4
- require "baton/server"
5
- require 'ostruct'
6
2
 
7
3
  describe Baton::Consumer do
8
4
 
9
- before :each do
5
+ let(:server) {
10
6
  Baton::Server.any_instance.stub(:facts).and_return({
11
7
  "fqdn" => "camac.dsci.it",
12
8
  "chef_environment" => "production"
13
9
  })
14
- @server = Baton::Server.new
15
- end
16
-
17
- let(:payload) do
18
- JSON({"type" => "message type" })
19
- end
20
-
21
- subject {
22
- Baton::Consumer.new("deploy-consumer", @server)
10
+ Baton::Server.any_instance.stub(:setup_ohai)
11
+ Baton::Server.new
23
12
  }
13
+ let(:payload) { JSON({"type" => "message type" }) }
14
+ let(:subject) { Baton::Consumer.new("deploy-consumer", server) }
24
15
 
25
16
  describe "#routing_key" do
26
17
  context "given an instance of Baton::Consumer" do
@@ -1,5 +1,4 @@
1
1
  require "spec_helper"
2
- require "baton/observer"
3
2
 
4
3
  describe "Baton::Observer module" do
5
4
 
@@ -1,15 +1,16 @@
1
1
  require "spec_helper"
2
- require "baton/server"
3
2
 
4
3
  describe Baton::Server do
4
+
5
5
  context "stubbed ohai" do
6
+
6
7
  before(:each) do
7
- Ohai::System.any_instance.stub(:all_plugins).and_return(true)
8
- Ohai::System.any_instance.stub(:data).and_return({
8
+ Baton::Server.any_instance.stub(:facts).and_return({
9
9
  "chef_environment" => "production",
10
10
  "fqdn" => "build-prod-i-722b0004.dsci.it",
11
11
  "trebuchet" => ["octobutler"]
12
12
  })
13
+ Baton::Server.any_instance.stub(:setup_ohai)
13
14
  end
14
15
 
15
16
  describe "#configure" do
@@ -31,6 +32,7 @@ describe Baton::Server do
31
32
  context "given the required facts are not available" do
32
33
  before(:each) do
33
34
  Baton::Server.any_instance.stub(:facts).and_return({})
35
+ Baton::Server.any_instance.stub(:setup_ohai)
34
36
  subject.configure
35
37
  end
36
38
 
@@ -68,7 +70,7 @@ describe Baton::Server do
68
70
  describe "#environment" do
69
71
  context "production" do
70
72
  it "should have the correct environment set" do
71
- subject.environment.should eq('production')
73
+ Baton::Server.new.environment.should eq('production')
72
74
  end
73
75
  end
74
76
  end
data/spec/spec_helper.rb CHANGED
@@ -2,16 +2,16 @@ require 'simplecov'
2
2
  SimpleCov.start do
3
3
  add_filter "/spec"
4
4
  end
5
+
5
6
  require 'rubygems'
6
- require 'bundler'
7
- Bundler.setup
7
+ require 'bundler/setup'
8
+
9
+ dir = File.dirname(File.expand_path(__FILE__))
10
+ $LOAD_PATH.unshift dir + '/../lib'
11
+ require 'baton'
12
+
8
13
  require 'fakefs/spec_helpers'
9
- require "moqueue"
10
- require "rspec/expectations"
11
14
  require 'webmock/rspec'
12
- require "baton/logging"
13
- require 'json'
14
- require 'pry'
15
15
 
16
16
  WebMock.disable_net_connect!
17
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-05 00:00:00.000000000 Z
13
+ date: 2013-07-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: amqp
@@ -140,6 +140,22 @@ dependencies:
140
140
  - - ! '>='
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: bueller
145
+ requirement: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ~>
149
+ - !ruby/object:Gem::Version
150
+ version: 0.0.9
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ~>
157
+ - !ruby/object:Gem::Version
158
+ version: 0.0.9
143
159
  - !ruby/object:Gem::Dependency
144
160
  name: rspec
145
161
  requirement: !ruby/object:Gem::Requirement
@@ -268,6 +284,22 @@ dependencies:
268
284
  - - ! '>='
269
285
  - !ruby/object:Gem::Version
270
286
  version: '0'
287
+ - !ruby/object:Gem::Dependency
288
+ name: guard-rspec
289
+ requirement: !ruby/object:Gem::Requirement
290
+ none: false
291
+ requirements:
292
+ - - ~>
293
+ - !ruby/object:Gem::Version
294
+ version: 3.0.0
295
+ type: :development
296
+ prerelease: false
297
+ version_requirements: !ruby/object:Gem::Requirement
298
+ none: false
299
+ requirements:
300
+ - - ~>
301
+ - !ruby/object:Gem::Version
302
+ version: 3.0.0
271
303
  description: Baton
272
304
  email:
273
305
  - johnog@gmail.com
@@ -281,14 +313,13 @@ files:
281
313
  - .rspec
282
314
  - .travis.yml
283
315
  - CHANGELOG.md
284
- - COPYING
285
316
  - Gemfile
286
317
  - Guardfile
318
+ - LICENSE
287
319
  - README.md
288
320
  - Rakefile
289
321
  - baton.gemspec
290
322
  - bin/batonize
291
- - dump.rdb
292
323
  - lib/baton.rb
293
324
  - lib/baton/api.rb
294
325
  - lib/baton/channel.rb
@@ -369,4 +400,3 @@ test_files:
369
400
  - spec/fixtures/invalid_file.sum
370
401
  - spec/fixtures/ohai_plugins/chef_environment.rb
371
402
  - spec/spec_helper.rb
372
- has_rdoc:
data/dump.rdb DELETED
Binary file