switchtower 0.9.0
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/bin/switchtower +11 -0
- data/examples/sample.rb +113 -0
- data/lib/switchtower.rb +1 -0
- data/lib/switchtower/actor.rb +350 -0
- data/lib/switchtower/cli.rb +220 -0
- data/lib/switchtower/command.rb +85 -0
- data/lib/switchtower/configuration.rb +193 -0
- data/lib/switchtower/gateway.rb +106 -0
- data/lib/switchtower/generators/rails/deployment/deployment_generator.rb +25 -0
- data/lib/switchtower/generators/rails/deployment/templates/deploy.rb +116 -0
- data/lib/switchtower/generators/rails/deployment/templates/switchtower.rake +33 -0
- data/lib/switchtower/generators/rails/loader.rb +20 -0
- data/lib/switchtower/logger.rb +56 -0
- data/lib/switchtower/recipes/standard.rb +175 -0
- data/lib/switchtower/recipes/templates/maintenance.rhtml +53 -0
- data/lib/switchtower/scm/base.rb +43 -0
- data/lib/switchtower/scm/cvs.rb +73 -0
- data/lib/switchtower/scm/darcs.rb +27 -0
- data/lib/switchtower/scm/subversion.rb +104 -0
- data/lib/switchtower/ssh.rb +30 -0
- data/lib/switchtower/version.rb +9 -0
- data/test/actor_test.rb +261 -0
- data/test/command_test.rb +43 -0
- data/test/configuration_test.rb +210 -0
- data/test/fixtures/config.rb +5 -0
- data/test/scm/cvs_test.rb +164 -0
- data/test/scm/subversion_test.rb +100 -0
- data/test/ssh_test.rb +104 -0
- data/test/utils.rb +41 -0
- metadata +88 -0
data/test/ssh_test.rb
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + "/../lib"
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + "/utils"
|
|
4
|
+
require 'test/unit'
|
|
5
|
+
require 'switchtower/ssh'
|
|
6
|
+
|
|
7
|
+
class SSHTest < Test::Unit::TestCase
|
|
8
|
+
class MockSSH
|
|
9
|
+
AuthenticationFailed = Net::SSH::AuthenticationFailed
|
|
10
|
+
|
|
11
|
+
class <<self
|
|
12
|
+
attr_accessor :story
|
|
13
|
+
attr_accessor :invocations
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.start(server, opts, &block)
|
|
17
|
+
@invocations << [server, opts, block]
|
|
18
|
+
err = story.shift
|
|
19
|
+
raise err if err
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def setup
|
|
24
|
+
@config = MockConfiguration.new
|
|
25
|
+
@config[:user] = 'demo'
|
|
26
|
+
@config[:password] = 'c0c0nutfr0st1ng'
|
|
27
|
+
MockSSH.story = []
|
|
28
|
+
MockSSH.invocations = []
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_publickey_auth_succeeds_default_port_no_block
|
|
32
|
+
Net.const_during(:SSH, MockSSH) do
|
|
33
|
+
SwitchTower::SSH.connect('demo.server.i', @config)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
assert_equal 1, MockSSH.invocations.length
|
|
37
|
+
assert_equal 'demo.server.i', MockSSH.invocations.first[0]
|
|
38
|
+
assert_equal 22, MockSSH.invocations.first[1][:port]
|
|
39
|
+
assert_equal 'demo', MockSSH.invocations.first[1][:username]
|
|
40
|
+
assert_nil MockSSH.invocations.first[1][:password]
|
|
41
|
+
assert_equal %w(publickey hostbased),
|
|
42
|
+
MockSSH.invocations.first[1][:auth_methods]
|
|
43
|
+
assert_nil MockSSH.invocations.first[2]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_publickey_auth_succeeds_explicit_port_no_block
|
|
47
|
+
Net.const_during(:SSH, MockSSH) do
|
|
48
|
+
SwitchTower::SSH.connect('demo.server.i', @config, 23)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
assert_equal 1, MockSSH.invocations.length
|
|
52
|
+
assert_equal 23, MockSSH.invocations.first[1][:port]
|
|
53
|
+
assert_nil MockSSH.invocations.first[2]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_publickey_auth_succeeds_with_block
|
|
57
|
+
Net.const_during(:SSH, MockSSH) do
|
|
58
|
+
SwitchTower::SSH.connect('demo.server.i', @config) do |session|
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
assert_equal 1, MockSSH.invocations.length
|
|
63
|
+
assert_instance_of Proc, MockSSH.invocations.first[2]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_publickey_auth_fails
|
|
67
|
+
MockSSH.story << Net::SSH::AuthenticationFailed
|
|
68
|
+
|
|
69
|
+
Net.const_during(:SSH, MockSSH) do
|
|
70
|
+
SwitchTower::SSH.connect('demo.server.i', @config)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
assert_equal 2, MockSSH.invocations.length
|
|
74
|
+
|
|
75
|
+
assert_nil MockSSH.invocations.first[1][:password]
|
|
76
|
+
assert_equal %w(publickey hostbased),
|
|
77
|
+
MockSSH.invocations.first[1][:auth_methods]
|
|
78
|
+
|
|
79
|
+
assert_equal 'c0c0nutfr0st1ng', MockSSH.invocations.last[1][:password]
|
|
80
|
+
assert_equal %w(password keyboard-interactive),
|
|
81
|
+
MockSSH.invocations.last[1][:auth_methods]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_password_auth_fails
|
|
85
|
+
MockSSH.story << Net::SSH::AuthenticationFailed
|
|
86
|
+
MockSSH.story << Net::SSH::AuthenticationFailed
|
|
87
|
+
|
|
88
|
+
Net.const_during(:SSH, MockSSH) do
|
|
89
|
+
assert_raises(Net::SSH::AuthenticationFailed) do
|
|
90
|
+
SwitchTower::SSH.connect('demo.server.i', @config)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
assert_equal 2, MockSSH.invocations.length
|
|
95
|
+
|
|
96
|
+
assert_nil MockSSH.invocations.first[1][:password]
|
|
97
|
+
assert_equal %w(publickey hostbased),
|
|
98
|
+
MockSSH.invocations.first[1][:auth_methods]
|
|
99
|
+
|
|
100
|
+
assert_equal 'c0c0nutfr0st1ng', MockSSH.invocations.last[1][:password]
|
|
101
|
+
assert_equal %w(password keyboard-interactive),
|
|
102
|
+
MockSSH.invocations.last[1][:auth_methods]
|
|
103
|
+
end
|
|
104
|
+
end
|
data/test/utils.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class Module
|
|
2
|
+
def const_during(constant, value)
|
|
3
|
+
if const_defined?(constant)
|
|
4
|
+
overridden = true
|
|
5
|
+
saved = const_get(constant)
|
|
6
|
+
remove_const(constant)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
const_set(constant, value)
|
|
10
|
+
yield
|
|
11
|
+
ensure
|
|
12
|
+
if overridden
|
|
13
|
+
remove_const(constant)
|
|
14
|
+
const_set(constant, saved)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class MockLogger
|
|
20
|
+
def info(msg,pfx=nil) end
|
|
21
|
+
def debug(msg,pfx=nil) end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class MockConfiguration < Hash
|
|
25
|
+
def initialize(*args)
|
|
26
|
+
super
|
|
27
|
+
self[:release_path] = "/path/to/releases/version"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def logger
|
|
31
|
+
@logger ||= MockLogger.new
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def method_missing(sym, *args)
|
|
35
|
+
if args.length == 0
|
|
36
|
+
self[sym]
|
|
37
|
+
else
|
|
38
|
+
super
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
rubygems_version: 0.8.10
|
|
3
|
+
specification_version: 1
|
|
4
|
+
name: switchtower
|
|
5
|
+
version: !ruby/object:Gem::Version
|
|
6
|
+
version: 0.9.0
|
|
7
|
+
date: 2005-10-18
|
|
8
|
+
summary: "SwitchTower is a framework and utility for executing commands in parallel on
|
|
9
|
+
multiple remote machines, via SSH. The primary goal is to simplify and
|
|
10
|
+
automate the deployment of web applications."
|
|
11
|
+
require_paths:
|
|
12
|
+
- lib
|
|
13
|
+
email: jamis@37signals.com
|
|
14
|
+
homepage: http://www.rubyonrails.com
|
|
15
|
+
rubyforge_project:
|
|
16
|
+
description:
|
|
17
|
+
autorequire: switchtower
|
|
18
|
+
default_executable:
|
|
19
|
+
bindir: bin
|
|
20
|
+
has_rdoc: false
|
|
21
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
-
|
|
24
|
+
- ">"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.0.0
|
|
27
|
+
version:
|
|
28
|
+
platform: ruby
|
|
29
|
+
authors:
|
|
30
|
+
- Jamis Buck
|
|
31
|
+
files:
|
|
32
|
+
- bin/switchtower
|
|
33
|
+
- lib/switchtower
|
|
34
|
+
- lib/switchtower.rb
|
|
35
|
+
- lib/switchtower/actor.rb
|
|
36
|
+
- lib/switchtower/cli.rb
|
|
37
|
+
- lib/switchtower/command.rb
|
|
38
|
+
- lib/switchtower/configuration.rb
|
|
39
|
+
- lib/switchtower/gateway.rb
|
|
40
|
+
- lib/switchtower/generators
|
|
41
|
+
- lib/switchtower/logger.rb
|
|
42
|
+
- lib/switchtower/recipes
|
|
43
|
+
- lib/switchtower/scm
|
|
44
|
+
- lib/switchtower/ssh.rb
|
|
45
|
+
- lib/switchtower/version.rb
|
|
46
|
+
- lib/switchtower/generators/rails
|
|
47
|
+
- lib/switchtower/generators/rails/deployment
|
|
48
|
+
- lib/switchtower/generators/rails/loader.rb
|
|
49
|
+
- lib/switchtower/generators/rails/deployment/deployment_generator.rb
|
|
50
|
+
- lib/switchtower/generators/rails/deployment/templates
|
|
51
|
+
- lib/switchtower/generators/rails/deployment/templates/deploy.rb
|
|
52
|
+
- lib/switchtower/generators/rails/deployment/templates/switchtower.rake
|
|
53
|
+
- lib/switchtower/recipes/standard.rb
|
|
54
|
+
- lib/switchtower/recipes/templates
|
|
55
|
+
- lib/switchtower/recipes/templates/maintenance.rhtml
|
|
56
|
+
- lib/switchtower/scm/base.rb
|
|
57
|
+
- lib/switchtower/scm/cvs.rb
|
|
58
|
+
- lib/switchtower/scm/darcs.rb
|
|
59
|
+
- lib/switchtower/scm/subversion.rb
|
|
60
|
+
- examples/sample.rb
|
|
61
|
+
- test/actor_test.rb
|
|
62
|
+
- test/command_test.rb
|
|
63
|
+
- test/configuration_test.rb
|
|
64
|
+
- test/fixtures
|
|
65
|
+
- test/scm
|
|
66
|
+
- test/ssh_test.rb
|
|
67
|
+
- test/utils.rb
|
|
68
|
+
- test/fixtures/config.rb
|
|
69
|
+
- test/scm/cvs_test.rb
|
|
70
|
+
- test/scm/subversion_test.rb
|
|
71
|
+
test_files: []
|
|
72
|
+
rdoc_options: []
|
|
73
|
+
extra_rdoc_files: []
|
|
74
|
+
executables:
|
|
75
|
+
- switchtower
|
|
76
|
+
extensions: []
|
|
77
|
+
requirements: []
|
|
78
|
+
dependencies:
|
|
79
|
+
- !ruby/object:Gem::Dependency
|
|
80
|
+
name: net-ssh
|
|
81
|
+
version_requirement:
|
|
82
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
|
83
|
+
requirements:
|
|
84
|
+
-
|
|
85
|
+
- ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: 1.0.2
|
|
88
|
+
version:
|