sshkit 1.11.5 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -5
- data/CHANGELOG.md +12 -1
- data/Dangerfile +1 -1
- data/README.md +20 -0
- data/lib/sshkit/configuration.rb +10 -0
- data/lib/sshkit/coordinator.rb +1 -1
- data/lib/sshkit/version.rb +1 -1
- data/sshkit.gemspec +1 -0
- data/test/unit/backends/test_connection_pool.rb +2 -2
- data/test/unit/test_command.rb +1 -1
- data/test/unit/test_configuration.rb +13 -0
- data/test/unit/test_coordinator.rb +30 -0
- data/test/unit/test_host.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2075a49a2e5d52e26409761fffbb3da8dd6bc46d
|
4
|
+
data.tar.gz: d9579584daf0ac0f3d2170fa4dc0c2bc57d3ac55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a84ef1bf0b996cf4a3ecb0d855f8d7b872c1d0bc31f46804908b3f51f31cb1f2af0ff7d39e7bc498f8a7aecf05576116bff008b8955b853b6e39c3fcb6f71bf
|
7
|
+
data.tar.gz: b2e42bf3216b4fdfbdd531329a09e9534775b71eb15dd2853319dca4ac358623b494474f179f136034beee435fd424f03b13d64fe6eb64dd283da39fcd6ae3f8
|
data/.travis.yml
CHANGED
@@ -4,8 +4,9 @@ rvm:
|
|
4
4
|
- 2.2.4
|
5
5
|
- 2.1.8
|
6
6
|
- 2.0.0
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
script:
|
7
|
+
matrix:
|
8
|
+
include:
|
9
|
+
# Run Danger only once, on 2.3.3
|
10
|
+
- rvm: 2.3.3
|
11
|
+
script: bundle exec danger
|
12
|
+
script: bundle exec rake test:units lint
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,16 @@ appear at the top.
|
|
7
7
|
|
8
8
|
* Your contribution here!
|
9
9
|
|
10
|
+
## [1.12.0][] (2017-02-10)
|
11
|
+
|
12
|
+
### Breaking changes
|
13
|
+
|
14
|
+
* None
|
15
|
+
|
16
|
+
### New features
|
17
|
+
|
18
|
+
* Add `SSHKit.config.default_runner_config` option that allows overriding default runner configs.
|
19
|
+
|
10
20
|
## [1.11.5][] (2016-12-16)
|
11
21
|
|
12
22
|
### Bug fixes
|
@@ -662,7 +672,8 @@ version `0.0.5`.
|
|
662
672
|
|
663
673
|
First release.
|
664
674
|
|
665
|
-
[Unreleased]: https://github.com/capistrano/sshkit/compare/v1.
|
675
|
+
[Unreleased]: https://github.com/capistrano/sshkit/compare/v1.12.0...HEAD
|
676
|
+
[1.12.0]: https://github.com/capistrano/sshkit/compare/v1.11.5...v1.12.0
|
666
677
|
[1.11.5]: https://github.com/capistrano/sshkit/compare/v1.11.4...v1.11.5
|
667
678
|
[1.11.4]: https://github.com/capistrano/sshkit/compare/v1.11.3...v1.11.4
|
668
679
|
[1.11.3]: https://github.com/capistrano/sshkit/compare/v1.11.2...v1.11.3
|
data/Dangerfile
CHANGED
@@ -45,7 +45,7 @@ end
|
|
45
45
|
# Did you remove the CHANGELOG's "Your contribution here!" line?
|
46
46
|
# ------------------------------------------------------------------------------
|
47
47
|
if has_changelog_changes
|
48
|
-
unless IO.read("CHANGELOG.md") =~
|
48
|
+
unless IO.read("CHANGELOG.md") =~ /^\s*\* Your contribution here/i
|
49
49
|
fail(
|
50
50
|
"Please put the `* Your contribution here!` line back into CHANGELOG.md.",
|
51
51
|
:sticky => false
|
data/README.md
CHANGED
@@ -136,6 +136,26 @@ it too hard.
|
|
136
136
|
Sequential runs were intended to be used for rolling restarts, amongst other
|
137
137
|
similar use-cases.
|
138
138
|
|
139
|
+
The default runner can be set with the `SSHKit.config.default_runner` option. For
|
140
|
+
example:
|
141
|
+
```ruby
|
142
|
+
SSHKit.config.default_runner = :parallel
|
143
|
+
SSHKit.config.default_runner = :sequence
|
144
|
+
SSHKit.config.default_runner = :groups
|
145
|
+
SSHKit.config.default_runner = MyRunner # A custom runner
|
146
|
+
```
|
147
|
+
|
148
|
+
If more control over the default runner is needed, the `SSHKit.config.default_runner_config`
|
149
|
+
can be set.
|
150
|
+
```ruby
|
151
|
+
# Set the runner and then the config for the runner
|
152
|
+
SSHKit.config.default_runner = :sequence
|
153
|
+
SSHKit.config.default_runner_config = { wait: 5 }
|
154
|
+
|
155
|
+
# Or just set everything once
|
156
|
+
SSHKit.config.default_runner_config = { in: :sequence, wait: 5 }
|
157
|
+
```
|
158
|
+
|
139
159
|
## Synchronisation
|
140
160
|
|
141
161
|
The `on()` block is the unit of synchronisation, one `on()` block will wait
|
data/lib/sshkit/configuration.rb
CHANGED
@@ -29,6 +29,16 @@ module SSHKit
|
|
29
29
|
@default_runner ||= :parallel
|
30
30
|
end
|
31
31
|
|
32
|
+
def default_runner_config
|
33
|
+
@default_runner_config ||= { in: default_runner }
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_runner_config=(config_hash)
|
37
|
+
config = config_hash.dup
|
38
|
+
SSHKit.config.default_runner = config.delete(:in) if config[:in]
|
39
|
+
@default_runner_config = config.merge(in: SSHKit.config.default_runner)
|
40
|
+
end
|
41
|
+
|
32
42
|
def backend
|
33
43
|
@backend ||= SSHKit::Backend::Netssh
|
34
44
|
end
|
data/lib/sshkit/coordinator.rb
CHANGED
data/lib/sshkit/version.rb
CHANGED
data/sshkit.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_development_dependency('danger')
|
24
24
|
gem.add_development_dependency('minitest', '>= 5.0.0')
|
25
25
|
gem.add_development_dependency('minitest-reporters')
|
26
|
+
gem.add_development_dependency('rainbow', '~> 2.1.0')
|
26
27
|
gem.add_development_dependency('rake')
|
27
28
|
gem.add_development_dependency('rubocop')
|
28
29
|
gem.add_development_dependency('mocha')
|
@@ -50,8 +50,8 @@ module SSHKit
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_connections_are_reused_if_checked_in
|
53
|
-
conn1 = pool.with(connect, "conn") {}
|
54
|
-
conn2 = pool.with(connect, "conn") {}
|
53
|
+
conn1 = pool.with(connect, "conn") { |c| c }
|
54
|
+
conn2 = pool.with(connect, "conn") { |c| c }
|
55
55
|
|
56
56
|
assert_equal conn1, conn2
|
57
57
|
end
|
data/test/unit/test_command.rb
CHANGED
@@ -57,6 +57,19 @@ module SSHKit
|
|
57
57
|
assert_equal :sequence, SSHKit.config.default_runner
|
58
58
|
end
|
59
59
|
|
60
|
+
def test_default_runner_config
|
61
|
+
config_hash = { wait: 5 }
|
62
|
+
config_hash_with_runner = { in: :groups, limit: 5 }
|
63
|
+
default_hash = { in: SSHKit.config.default_runner }
|
64
|
+
|
65
|
+
assert_equal default_hash, SSHKit.config.default_runner_config
|
66
|
+
SSHKit.config.default_runner_config = config_hash
|
67
|
+
assert_equal default_hash.merge(config_hash), SSHKit.config.default_runner_config
|
68
|
+
SSHKit.config.default_runner_config = config_hash_with_runner
|
69
|
+
assert_equal config_hash_with_runner, SSHKit.config.default_runner_config
|
70
|
+
assert_equal config_hash_with_runner[:in], SSHKit.config.default_runner
|
71
|
+
end
|
72
|
+
|
60
73
|
def test_backend
|
61
74
|
assert_equal SSHKit::Backend::Netssh, SSHKit.config.backend
|
62
75
|
assert SSHKit.config.backend = SSHKit::Backend::Printer
|
@@ -82,6 +82,32 @@ module SSHKit
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
def test_the_connection_manager_can_run_things_with_custom_runner_configs
|
86
|
+
begin
|
87
|
+
$original_runner = SSHKit.config.default_runner
|
88
|
+
SSHKit.config.default_runner = :groups
|
89
|
+
$original_runner_config = SSHKit.config.default_runner_config
|
90
|
+
SSHKit.config.default_runner_config = { limit: 2, wait: 5 }
|
91
|
+
|
92
|
+
Coordinator.new(
|
93
|
+
%w{
|
94
|
+
1.example.com
|
95
|
+
2.example.com
|
96
|
+
3.example.com
|
97
|
+
4.example.com
|
98
|
+
}
|
99
|
+
).each(&echo_time)
|
100
|
+
assert_equal 4, actual_execution_times.length
|
101
|
+
assert_within_10_ms(actual_execution_times[0..1])
|
102
|
+
assert_within_10_ms(actual_execution_times[2..3])
|
103
|
+
assert_at_least_5_sec_apart(actual_execution_times[0], actual_execution_times[2])
|
104
|
+
assert_at_least_5_sec_apart(actual_execution_times[1], actual_execution_times[3])
|
105
|
+
ensure
|
106
|
+
SSHKit.config.default_runner = $original_runner
|
107
|
+
SSHKit.config.default_runner_config = $original_runner_config
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
85
111
|
def test_the_connection_manager_can_run_things_in_sequence_with_wait
|
86
112
|
start = Time.now
|
87
113
|
Coordinator.new(%w{1.example.com 2.example.com}).each in: :sequence, wait: 10, &echo_time
|
@@ -114,6 +140,10 @@ module SSHKit
|
|
114
140
|
assert_operator(last_time - first_time, :>, 1.0)
|
115
141
|
end
|
116
142
|
|
143
|
+
def assert_at_least_5_sec_apart(first_time, last_time)
|
144
|
+
assert_operator(last_time - first_time, :>, 5.0)
|
145
|
+
end
|
146
|
+
|
117
147
|
def assert_within_10_ms(array)
|
118
148
|
assert_in_delta(*array, 0.01) # 10 msec
|
119
149
|
end
|
data/test/unit/test_host.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sshkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Hambley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rainbow
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 2.1.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.1.0
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: rake
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
248
|
version: '0'
|
235
249
|
requirements: []
|
236
250
|
rubyforge_project:
|
237
|
-
rubygems_version: 2.6.
|
251
|
+
rubygems_version: 2.6.10
|
238
252
|
signing_key:
|
239
253
|
specification_version: 4
|
240
254
|
summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
|