proctor 0.0.3 → 0.0.4
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/.rspec +1 -0
- data/TODO +28 -0
- data/bin/proctor +55 -85
- data/bin/showlog +5 -0
- data/bin/showtime +5 -0
- data/lib/proctor/command/asset_list_cmd.rb +56 -0
- data/lib/proctor/{presenter/show.rb → command/asset_show_cmd.rb} +7 -2
- data/lib/proctor/command/file_cleanup_cmd.rb +81 -0
- data/lib/proctor/command/file_export_cmd.rb +79 -0
- data/lib/proctor/command/helpers/command.rb +27 -0
- data/lib/proctor/command/render_group_cmd.rb +39 -0
- data/lib/proctor/command/render_service_cmd.rb +34 -0
- data/lib/proctor/command/start_cmd.rb +70 -0
- data/lib/proctor/config/app_file.rb +54 -0
- data/lib/proctor/config/app_files.rb +50 -0
- data/lib/proctor/config/env.rb +35 -0
- data/lib/proctor/config/template_file.rb +41 -0
- data/lib/proctor/config/template_files.rb +39 -0
- data/lib/proctor/manager.rb +36 -3
- data/lib/proctor/managers.rb +38 -0
- data/lib/proctor/node.rb +26 -0
- data/lib/proctor/nodes.rb +38 -0
- data/lib/proctor/resource/erb.rb +95 -0
- data/lib/proctor/resource/lookup.rb +82 -0
- data/lib/proctor/service.rb +28 -3
- data/lib/proctor/services.rb +38 -0
- data/lib/proctor/util/helpers.rb +13 -0
- data/lib/proctor/util/version.rb +3 -0
- data/proctor.gemspec +2 -1
- data/proctor/Proctorfile +35 -34
- data/proctor/templates/foreman_default_g.erb +3 -0
- data/proctor/templates/monit_default_s.erb +3 -6
- data/proctor/templates/monit_faye_s.erb +3 -3
- data/proctor/templates/upstart_default_g.erb +1 -0
- data/proctor/templates/upstart_default_s.erb +1 -3
- data/proctor/templates/upstart_passenger_s.erb +3 -0
- data/spec/acceptance/asset_list_spec.rb +16 -0
- data/spec/acceptance/asset_show_spec.rb +16 -0
- data/spec/acceptance/file_cleanup_spec.rb +16 -0
- data/spec/acceptance/file_export_spec.rb +16 -0
- data/spec/acceptance/render_group_spec.rb +15 -0
- data/spec/acceptance/render_service_spec.rb +16 -0
- data/spec/acceptance/start_spec.rb +16 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/unit/command/file_export_cmd_spec.rb +46 -0
- data/spec/unit/command/file_list_cmd_spec.rb +30 -0
- data/spec/unit/command/render_group_cmd_spec.rb +44 -0
- data/spec/unit/command/render_service_cmd_spec.rb +42 -0
- data/spec/unit/{app_file_spec.rb → config/app_file_spec.rb} +27 -7
- data/spec/unit/config/app_files_spec.rb +55 -0
- data/spec/unit/config/env_spec.rb +37 -0
- data/spec/unit/config/template_file_spec.rb +55 -0
- data/spec/unit/config/template_files_spec.rb +32 -0
- data/spec/unit/manager_spec.rb +30 -10
- data/spec/unit/managers_spec.rb +40 -0
- data/spec/unit/node_spec.rb +34 -0
- data/spec/unit/nodes_spec.rb +36 -0
- data/spec/unit/service_spec.rb +31 -10
- data/spec/unit/services_spec.rb +34 -0
- metadata +86 -31
- data/Proctorfile +0 -4
- data/lib/proctor/app_config.rb +0 -23
- data/lib/proctor/app_file.rb +0 -44
- data/lib/proctor/cmd_state.rb +0 -39
- data/lib/proctor/presenter/list.rb +0 -67
- data/lib/proctor/presenter/render.rb +0 -39
- data/lib/proctor/template.rb +0 -5
- data/lib/proctor/template_config.rb +0 -22
- data/lib/proctor/template_file.rb +0 -44
- data/lib/proctor/util.rb +0 -12
- data/lib/proctor/version.rb +0 -3
- data/proctor/templates/foreman_default_n.erb +0 -9
- data/proctor/templates/monit_web_s.erb +0 -0
- data/proctor/templates/upstart_default_n.erb +0 -0
- data/spec/acceptance/help_spec.rb +0 -36
- data/spec/acceptance/list_spec.rb +0 -17
- data/spec/unit/app_config_spec.rb +0 -30
- data/spec/unit/template_config_spec.rb +0 -12
- data/spec/unit/template_file_spec.rb +0 -16
- data/spec/unit/template_spec.rb +0 -8
@@ -1,6 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
check process <%= role_name %> with pidfile <%= pidfile %>
|
5
|
-
start program = "<%= start_command %>"
|
6
|
-
stop program = "<%= stop_command %>"
|
1
|
+
check process <%# role_name %> with pidfile <%# pidfile %>
|
2
|
+
start program = "<%# start_command %>"
|
3
|
+
stop program = "<%# stop_command %>"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Generated by Proctor at <%= Time.now %>
|
2
2
|
|
3
|
-
check process <%=
|
4
|
-
start program "/etc/init.d/<%=
|
5
|
-
stop program "/etc/init.d/<%=
|
3
|
+
check process <%= Dir.pwd.split('/').last %> with pidfile <%= pidfile %>
|
4
|
+
start program "/etc/init.d/<%= Dir.pwd.split('/').last %> start"
|
5
|
+
stop program "/etc/init.d/<%= Dir.pwd.split('/').last %> stop"
|
6
6
|
if failed port <%= port %> then restart
|
7
7
|
if 5 restarts within 5 cycles then timeout
|
@@ -0,0 +1 @@
|
|
1
|
+
# TBD
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'asset_list', :acceptance do
|
4
|
+
|
5
|
+
it 'returns help text' do
|
6
|
+
start_simple "help asset_list"
|
7
|
+
all_output.should include('list')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'runs' do
|
11
|
+
start_simple "asset_list"
|
12
|
+
last_exit_status.should == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'asset_show', :acceptance do
|
4
|
+
|
5
|
+
it 'runs the command' do
|
6
|
+
start_simple "asset_show", false
|
7
|
+
last_exit_status.should_not == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'runs help' do
|
11
|
+
start_simple "help asset_show"
|
12
|
+
last_exit_status.should == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'file_cleanup', :acceptance do
|
4
|
+
|
5
|
+
it 'runs the command' do
|
6
|
+
start_simple "file_cleanup", false
|
7
|
+
last_exit_status.should_not == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'runs help' do
|
11
|
+
start_simple "help file_cleanup"
|
12
|
+
last_exit_status.should == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'file_export', :acceptance do
|
4
|
+
|
5
|
+
it 'runs the command' do
|
6
|
+
start_simple "file_export", false
|
7
|
+
last_exit_status.should_not == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'runs help' do
|
11
|
+
start_simple "help file_export"
|
12
|
+
last_exit_status.should == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'render_group', :acceptance do
|
4
|
+
|
5
|
+
it 'runs the command' do
|
6
|
+
start_simple "g_group", false
|
7
|
+
last_exit_status.should_not == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'runs help' do
|
11
|
+
start_simple "help render_group"
|
12
|
+
last_exit_status.should == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'render_service', :acceptance do
|
4
|
+
|
5
|
+
it 'runs the command' do
|
6
|
+
start_simple "render_service", false
|
7
|
+
last_exit_status.should_not == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'runs help' do
|
11
|
+
start_simple "help render_service"
|
12
|
+
last_exit_status.should == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'clean', :acceptance do
|
4
|
+
|
5
|
+
it 'runs the command' do
|
6
|
+
start_simple "clean", false
|
7
|
+
last_exit_status.should_not == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'runs help' do
|
11
|
+
start_simple "help clean"
|
12
|
+
last_exit_status.should == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,7 @@ Dir['./spec/support/*.rb'].map {|f| require f}
|
|
11
11
|
RSpec.configure do |config|
|
12
12
|
|
13
13
|
config.color_enabled = true
|
14
|
+
config.fail_fast = true
|
14
15
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
15
16
|
config.run_all_when_everything_filtered = true
|
16
17
|
config.include Aruba::Api, :example_group => {
|
@@ -19,9 +20,30 @@ RSpec.configure do |config|
|
|
19
20
|
|
20
21
|
end
|
21
22
|
|
23
|
+
def lcl_file
|
24
|
+
<<-EOF
|
25
|
+
---
|
26
|
+
managers:
|
27
|
+
upstart:
|
28
|
+
export_directory: "/tmp/proctor/upstart"
|
29
|
+
monit:
|
30
|
+
export_directory: "/tmp/proctor/monit"
|
31
|
+
foreman:
|
32
|
+
export_directory: "/tmp/proctor/monit"
|
33
|
+
EOF
|
34
|
+
end
|
35
|
+
|
22
36
|
def clear_app_file(&block)
|
23
37
|
system "mv Proctorfile /tmp/Proctorfile.#{$$}" if File.exist?("Proctorfile")
|
24
38
|
yield
|
25
39
|
system "rm -f Proctorfile"
|
26
40
|
system "mv /tmp/Proctorfile.#{$$} Proctorfile" if File.exist?("/tmp/Proctorfile.#{$$}")
|
27
41
|
end
|
42
|
+
|
43
|
+
def setup_lcl_file
|
44
|
+
File.open("Proctorfile", 'w') {|f| f.puts lcl_file}
|
45
|
+
end
|
46
|
+
|
47
|
+
def clear_lcl_file
|
48
|
+
system "rm -f Proctorfile"
|
49
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative "../../../lib/proctor/command/file_export_cmd"
|
3
|
+
|
4
|
+
include Proctor::Command
|
5
|
+
|
6
|
+
describe FileExportCmd do
|
7
|
+
before(:all) do
|
8
|
+
setup_lcl_file; @options = {}
|
9
|
+
@options['env'] = Proctor::Config::Env.new([{}, {}, []])
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:all) { clear_lcl_file }
|
13
|
+
|
14
|
+
def obj(args)
|
15
|
+
FileExportCmd.new({}, @options, args.split(' '))
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "object creation" do
|
19
|
+
specify { -> {obj("")}.should raise_error }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#export - foreman" do
|
23
|
+
specify { obj("foreman backup").export.should be_nil }
|
24
|
+
specify { obj("foreman development").export.should be_nil }
|
25
|
+
specify { obj("foreman production").export.should be_nil }
|
26
|
+
specify { obj("foreman staging").export.should be_nil }
|
27
|
+
specify { obj("foreman test").export.should be_nil }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#export - upstart" do
|
31
|
+
specify { obj("upstart backup").export.should be_nil }
|
32
|
+
specify { obj("upstart development").export.should be_nil }
|
33
|
+
specify { obj("upstart production").export.should be_nil }
|
34
|
+
specify { obj("upstart staging").export.should be_nil }
|
35
|
+
specify { obj("upstart test").export.should be_nil }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#export - monit" do
|
39
|
+
specify { obj("monit backup").export.should be_nil }
|
40
|
+
specify { obj("monit development").export.should be_nil }
|
41
|
+
specify { obj("monit production").export.should be_nil }
|
42
|
+
specify { obj("monit staging").export.should be_nil }
|
43
|
+
specify { obj("monit test").export.should be_nil }
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative "../../../lib/proctor/command/asset_list_cmd"
|
3
|
+
|
4
|
+
include Proctor::Command
|
5
|
+
|
6
|
+
describe AssetListCmd do
|
7
|
+
before(:all) do
|
8
|
+
@options = {}
|
9
|
+
@options['env'] = Proctor::Config::Env.new([{}, {}, []])
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@args = ""
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:obj) { AssetListCmd.new({}, @options, @args.split(' '))}
|
17
|
+
|
18
|
+
describe "object creation" do
|
19
|
+
specify { obj.should_not be_nil }
|
20
|
+
specify { obj.should be_a(AssetListCmd) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#list" do
|
24
|
+
before(:each) { @options[:type] = "all" }
|
25
|
+
specify { obj.gen_list.should_not be_nil }
|
26
|
+
specify { obj.gen_list.should be_a(String) }
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative "../../../lib/proctor/command/render_service_cmd"
|
3
|
+
|
4
|
+
include Proctor::Command
|
5
|
+
|
6
|
+
describe RenderGroupCmd do
|
7
|
+
before(:all) do
|
8
|
+
@options = {:f => nil}
|
9
|
+
@options['env'] = Proctor::Config::Env.new([{}, {}, []])
|
10
|
+
end
|
11
|
+
|
12
|
+
def obj(args)
|
13
|
+
RenderGroupCmd.new({}, @options, args.split(' '))
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "object creation" do
|
17
|
+
context "with no args" do
|
18
|
+
specify { -> {obj("")}.should raise_error }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with valid args" do
|
22
|
+
before(:all) { @args = "foreman test" }
|
23
|
+
specify { obj(@args).should_not be_nil }
|
24
|
+
specify { obj(@args).should be_a(RenderGroupCmd) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#render - foreman" do
|
29
|
+
specify { obj("foreman backup").render_string.should be_a(String) }
|
30
|
+
specify { obj("foreman development").render_string.should be_a(String) }
|
31
|
+
specify { obj("foreman production").render_string.should be_a(String) }
|
32
|
+
specify { obj("foreman staging").render_string.should be_a(String) }
|
33
|
+
specify { obj("foreman test").render_string.should be_a(String) }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#render - upstart" do
|
37
|
+
specify { obj("upstart backup").render_string.should be_a(String) }
|
38
|
+
specify { obj("upstart development").render_string.should be_a(String) }
|
39
|
+
specify { obj("upstart production").render_string.should be_a(String) }
|
40
|
+
specify { obj("upstart staging").render_string.should be_a(String) }
|
41
|
+
specify { obj("upstart test").render_string.should be_a(String) }
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative "../../../lib/proctor/command/render_service_cmd"
|
3
|
+
|
4
|
+
include Proctor::Command
|
5
|
+
|
6
|
+
describe RenderServiceCmd do
|
7
|
+
before(:all) do
|
8
|
+
@options = {:f => nil}
|
9
|
+
@options['env'] = Proctor::Config::Env.new([{}, {}, []])
|
10
|
+
end
|
11
|
+
|
12
|
+
def obj(args)
|
13
|
+
RenderServiceCmd.new({}, @options, args.split(' '))
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "object creation" do
|
17
|
+
context "with no args" do
|
18
|
+
specify { -> {obj("")}.should raise_error }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with valid args" do
|
22
|
+
before(:all) { @args = "upstart showlog" }
|
23
|
+
specify { obj(@args).should_not be_nil }
|
24
|
+
specify { obj(@args).should be_a(RenderServiceCmd) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#render - upstart" do
|
29
|
+
specify { obj("upstart passenger").render_string.should be_a(String) }
|
30
|
+
specify { obj("upstart showlog").render_string.should be_a(String) }
|
31
|
+
specify { obj("upstart showtime").render_string.should be_a(String) }
|
32
|
+
specify { obj("upstart unicorn").render_string.should be_a(String) }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#render - monit" do
|
36
|
+
specify { obj("monit passenger").render_string.should be_a(String) }
|
37
|
+
specify { obj("monit showlog").render_string.should be_a(String) }
|
38
|
+
specify { obj("monit showtime").render_string.should be_a(String) }
|
39
|
+
specify { obj("monit unicorn").render_string.should be_a(String) }
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require_relative "
|
2
|
+
require_relative "../../../lib/proctor/config/app_file"
|
3
3
|
|
4
|
-
include Proctor
|
4
|
+
include Proctor::Config
|
5
5
|
|
6
6
|
describe AppFile do
|
7
7
|
|
8
8
|
describe "#new" do
|
9
9
|
it "reports an error if the app file is missing" do
|
10
|
-
lambda { AppFile.new("Unknown") }.should raise_error(
|
10
|
+
lambda { AppFile.new("Unknown") }.should raise_error(MissingAppFileException)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "reports an error if the app file YAML has a parser error" do
|
@@ -33,8 +33,28 @@ describe AppFile do
|
|
33
33
|
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
context "basic tests" do
|
37
|
+
|
38
|
+
before(:all) do
|
39
|
+
file = "/tmp/test.#{$$}"
|
40
|
+
system "echo '---\na:\n b: 1' > #{file}"
|
41
|
+
@obj = AppFile.new(file)
|
42
|
+
system "rm #{file}"
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#data" do
|
46
|
+
specify { @obj.should respond_to(:data) }
|
47
|
+
specify { @obj.data.should_not be_nil }
|
48
|
+
specify { @obj.data.should be_a(Hash) }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#handle" do
|
52
|
+
specify { @obj.should respond_to(:handle) }
|
53
|
+
specify { @obj.handle.should_not be_nil }
|
54
|
+
specify { @obj.handle.should be_a(String) }
|
55
|
+
specify { @obj.handle.length.should == 3 }
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
40
60
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative "../../../lib/proctor/config/app_files"
|
3
|
+
|
4
|
+
include Proctor::Config
|
5
|
+
|
6
|
+
describe AppFiles do
|
7
|
+
|
8
|
+
context "basic tests" do
|
9
|
+
|
10
|
+
before(:all) { @obj = AppFiles.new([{}, {}, []]) }
|
11
|
+
|
12
|
+
describe "#new" do
|
13
|
+
specify { @obj.should_not be_nil }
|
14
|
+
specify { @obj.should be_an(AppFiles) }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#all" do
|
18
|
+
specify { @obj.should respond_to(:all) }
|
19
|
+
specify { @obj.all.should be_an(Array) }
|
20
|
+
specify { @obj.all.length.should == 1 }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#merged_data" do
|
24
|
+
specify { @obj.should respond_to(:merged_data) }
|
25
|
+
specify { @obj.merged_data.should_not be_nil }
|
26
|
+
specify { @obj.merged_data.should be_a(Hash) }
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
#it "loads data and generates a hash" do
|
32
|
+
# result = AppConfig.load
|
33
|
+
# result.should_not be_nil
|
34
|
+
# result.should be_a(Hash)
|
35
|
+
#end
|
36
|
+
#it "has default values" do
|
37
|
+
# app_data = "---\nmanagers:\n newstart:\n export_directory: '/tmp/test'"
|
38
|
+
# clear_app_file do
|
39
|
+
# File.open("Proctorfile", 'w') {|f| f.puts "#{app_data}"}
|
40
|
+
# result = AppConfig.load
|
41
|
+
# tst_value = result["managers"]["upstart"]["export_directory"]
|
42
|
+
# tst_value.should == "/etc/init"
|
43
|
+
# end
|
44
|
+
#end
|
45
|
+
#it "overwrites default values with local values" do
|
46
|
+
# app_data = "---\nmanagers:\n upstart:\n export_directory: '/tmp/test'"
|
47
|
+
# clear_app_file do
|
48
|
+
# File.open("Proctorfile", 'w') {|f| f.puts "#{app_data}"}
|
49
|
+
# result = AppConfig.load
|
50
|
+
# tst_value = result["managers"]["upstart"]["export_directory"]
|
51
|
+
# tst_value.should == "/tmp/test"
|
52
|
+
# end
|
53
|
+
#end
|
54
|
+
|
55
|
+
end
|