sshkit 1.8.1 → 1.9.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,16 +22,16 @@ module SSHKit
22
22
  def test_execute
23
23
  printer.execute 'uname -a'
24
24
  assert_output_lines(
25
- ' INFO [aaaaaa] Running /usr/bin/env uname -a on example.com',
25
+ ' INFO [aaaaaa] Running uname -a on example.com',
26
26
  ' DEBUG [aaaaaa] Command: uname -a'
27
27
  )
28
28
  end
29
29
 
30
30
  def test_test_method
31
- printer.test '[ -d /some/file ]'
31
+ assert printer.test('[ -d /some/file ]'), 'test should return true'
32
32
 
33
33
  assert_output_lines(
34
- ' DEBUG [aaaaaa] Running /usr/bin/env [ -d /some/file ] on example.com',
34
+ ' DEBUG [aaaaaa] Running [ -d /some/file ] on example.com',
35
35
  ' DEBUG [aaaaaa] Command: [ -d /some/file ]'
36
36
  )
37
37
  end
@@ -42,7 +42,7 @@ module SSHKit
42
42
  assert_equal '', result
43
43
 
44
44
  assert_output_lines(
45
- ' DEBUG [aaaaaa] Running /usr/bin/env ls -l on example.com',
45
+ ' DEBUG [aaaaaa] Running ls -l on example.com',
46
46
  ' DEBUG [aaaaaa] Command: ls -l'
47
47
  )
48
48
  end
@@ -70,4 +70,4 @@ module SSHKit
70
70
  end
71
71
  end
72
72
  end
73
- end
73
+ end
@@ -43,6 +43,11 @@ module SSHKit
43
43
  assert_log_output 'C 1 /usr/bin/env ls'
44
44
  end
45
45
 
46
+ def test_accepts_options_hash
47
+ custom = CustomFormatter.new(output, :foo => 'value')
48
+ assert_equal('value', custom.options[:foo])
49
+ end
50
+
46
51
  private
47
52
 
48
53
  def assert_log_output(expected_output)
@@ -53,10 +58,11 @@ module SSHKit
53
58
 
54
59
  class CustomFormatter < SSHKit::Formatter::Abstract
55
60
  def write(obj)
56
- original_output << case obj
61
+ original_output << \
62
+ case obj
57
63
  when SSHKit::Command then "C #{obj.verbosity} #{obj}"
58
64
  when SSHKit::LogMessage then "LM #{obj.verbosity} #{obj}"
59
- end
65
+ end
60
66
  end
61
67
  alias :<< :write
62
68
 
@@ -56,5 +56,14 @@ module SSHKit
56
56
  assert_equal map[:rake], "/home/vagrant/.rbenv/bin/rbenv exec bundle exec rake"
57
57
  end
58
58
 
59
+ def test_prefix_initialization_is_thread_safe
60
+ map = CommandMap.new
61
+ threads = Array.new(3) do
62
+ Thread.new do
63
+ (1..1_000).each { |i| assert_equal([], map.prefix[i.to_s]) }
64
+ end
65
+ end
66
+ threads.each(&:join)
67
+ end
59
68
  end
60
69
  end
@@ -51,6 +51,12 @@ module SSHKit
51
51
  assert SSHKit.config.default_env
52
52
  end
53
53
 
54
+ def test_default_runner
55
+ assert_equal :parallel, SSHKit.config.default_runner
56
+ SSHKit.config.default_runner = :sequence
57
+ assert_equal :sequence, SSHKit.config.default_runner
58
+ end
59
+
54
60
  def test_backend
55
61
  assert_equal SSHKit::Backend::Netssh, SSHKit.config.backend
56
62
  assert SSHKit.config.backend = SSHKit::Backend::Printer
@@ -4,7 +4,6 @@ require 'helper'
4
4
  module SSHKit
5
5
 
6
6
  class TestCoordinator < UnitTest
7
-
8
7
  def setup
9
8
  super
10
9
  @output = String.new
@@ -56,6 +55,33 @@ module SSHKit
56
55
  assert_at_least_1_sec_apart(actual_execution_times.first, actual_execution_times.last)
57
56
  end
58
57
 
58
+ class MyRunner < SSHKit::Runner::Parallel
59
+ def execute
60
+ threads = hosts.map do |host|
61
+ Thread.new(host) do |h|
62
+ b = backend(h, &block)
63
+ b.run
64
+ b.warn "custom runner out"
65
+ end
66
+ end
67
+ threads.each(&:join)
68
+ end
69
+ end
70
+
71
+ def test_the_connection_manager_can_run_things_in_custom_runner
72
+ begin
73
+ $original_runner = SSHKit.config.default_runner
74
+ SSHKit.config.default_runner = MyRunner
75
+
76
+ Coordinator.new(%w{1.example.com 2.example.com}).each(&echo_time)
77
+ assert_equal 2, actual_execution_times.length
78
+ assert_within_10_ms(actual_execution_times)
79
+ assert_match(/custom runner out/, @output)
80
+ ensure
81
+ SSHKit.config.default_runner = $original_runner
82
+ end
83
+ end
84
+
59
85
  def test_the_connection_manager_can_run_things_in_sequence_with_wait
60
86
  start = Time.now
61
87
  Coordinator.new(%w{1.example.com 2.example.com}).each in: :sequence, wait: 10, &echo_time
@@ -0,0 +1,26 @@
1
+ require 'helper'
2
+
3
+ module SSHKit
4
+
5
+ class TestDSL < UnitTest
6
+ include SSHKit::DSL
7
+
8
+ def test_dsl_on
9
+ coordinator = mock
10
+ Coordinator.stubs(:new).returns coordinator
11
+ coordinator.expects(:each).at_least_once
12
+
13
+ on('1.2.3.4')
14
+ end
15
+
16
+ def test_dsl_run_locally
17
+ local_backend = mock
18
+ Backend::Local.stubs(:new).returns local_backend
19
+ local_backend.expects(:run).at_least_once
20
+
21
+ run_locally
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -65,8 +65,12 @@ module SSHKit
65
65
  end
66
66
 
67
67
  def test_assert_hosts_compare_equal
68
- assert Host.new('example.com').eql? Host.new('example.com')
69
- assert Host.new('example.com').equal? Host.new('example.com')
68
+ h1 = Host.new('example.com')
69
+ h2 = Host.new('example.com')
70
+
71
+ assert h1 == h2
72
+ assert h1.eql? h2
73
+ assert h1.equal? h2
70
74
  end
71
75
 
72
76
  def test_arbitrary_host_properties
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.8.1
4
+ version: 1.9.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Hambley
@@ -9,110 +9,118 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-04 00:00:00.000000000 Z
12
+ date: 2016-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 2.8.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 2.8.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: net-scp
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: 1.1.2
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: 1.1.2
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: minitest
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 2.11.3
49
- - - <
50
- - !ruby/object:Gem::Version
51
- version: 2.12.0
48
+ version: 5.0.0
52
49
  type: :development
53
50
  prerelease: false
54
51
  version_requirements: !ruby/object:Gem::Requirement
55
52
  requirements:
56
- - - '>='
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 5.0.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest-reporters
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
57
61
  - !ruby/object:Gem::Version
58
- version: 2.11.3
59
- - - <
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
60
68
  - !ruby/object:Gem::Version
61
- version: 2.12.0
69
+ version: '0'
62
70
  - !ruby/object:Gem::Dependency
63
71
  name: rake
64
72
  requirement: !ruby/object:Gem::Requirement
65
73
  requirements:
66
- - - '>='
74
+ - - ">="
67
75
  - !ruby/object:Gem::Version
68
76
  version: '0'
69
77
  type: :development
70
78
  prerelease: false
71
79
  version_requirements: !ruby/object:Gem::Requirement
72
80
  requirements:
73
- - - '>='
81
+ - - ">="
74
82
  - !ruby/object:Gem::Version
75
83
  version: '0'
76
84
  - !ruby/object:Gem::Dependency
77
- name: turn
85
+ name: rubocop
78
86
  requirement: !ruby/object:Gem::Requirement
79
87
  requirements:
80
- - - '>='
88
+ - - ">="
81
89
  - !ruby/object:Gem::Version
82
90
  version: '0'
83
91
  type: :development
84
92
  prerelease: false
85
93
  version_requirements: !ruby/object:Gem::Requirement
86
94
  requirements:
87
- - - '>='
95
+ - - ">="
88
96
  - !ruby/object:Gem::Version
89
97
  version: '0'
90
98
  - !ruby/object:Gem::Dependency
91
99
  name: unindent
92
100
  requirement: !ruby/object:Gem::Requirement
93
101
  requirements:
94
- - - '>='
102
+ - - ">="
95
103
  - !ruby/object:Gem::Version
96
104
  version: '0'
97
105
  type: :development
98
106
  prerelease: false
99
107
  version_requirements: !ruby/object:Gem::Requirement
100
108
  requirements:
101
- - - '>='
109
+ - - ">="
102
110
  - !ruby/object:Gem::Version
103
111
  version: '0'
104
112
  - !ruby/object:Gem::Dependency
105
113
  name: mocha
106
114
  requirement: !ruby/object:Gem::Requirement
107
115
  requirements:
108
- - - '>='
116
+ - - ">="
109
117
  - !ruby/object:Gem::Version
110
118
  version: '0'
111
119
  type: :development
112
120
  prerelease: false
113
121
  version_requirements: !ruby/object:Gem::Requirement
114
122
  requirements:
115
- - - '>='
123
+ - - ">="
116
124
  - !ruby/object:Gem::Version
117
125
  version: '0'
118
126
  description: A comprehensive toolkit for remotely running commands in a structured
@@ -124,9 +132,9 @@ executables: []
124
132
  extensions: []
125
133
  extra_rdoc_files: []
126
134
  files:
127
- - .gitignore
128
- - .travis.yml
129
- - .yardopts
135
+ - ".gitignore"
136
+ - ".travis.yml"
137
+ - ".yardopts"
130
138
  - BREAKING_API_WISHLIST.md
131
139
  - CHANGELOG.md
132
140
  - CONTRIBUTING.md
@@ -146,6 +154,8 @@ files:
146
154
  - lib/sshkit/all.rb
147
155
  - lib/sshkit/backends/abstract.rb
148
156
  - lib/sshkit/backends/connection_pool.rb
157
+ - lib/sshkit/backends/connection_pool/cache.rb
158
+ - lib/sshkit/backends/connection_pool/nil_cache.rb
149
159
  - lib/sshkit/backends/local.rb
150
160
  - lib/sshkit/backends/netssh.rb
151
161
  - lib/sshkit/backends/printer.rb
@@ -196,6 +206,7 @@ files:
196
206
  - test/unit/test_configuration.rb
197
207
  - test/unit/test_coordinator.rb
198
208
  - test/unit/test_deprecation_logger.rb
209
+ - test/unit/test_dsl.rb
199
210
  - test/unit/test_host.rb
200
211
  - test/unit/test_logger.rb
201
212
  - test/unit/test_mapping_interaction_handler.rb
@@ -209,17 +220,17 @@ require_paths:
209
220
  - lib
210
221
  required_ruby_version: !ruby/object:Gem::Requirement
211
222
  requirements:
212
- - - '>='
223
+ - - ">="
213
224
  - !ruby/object:Gem::Version
214
225
  version: '0'
215
226
  required_rubygems_version: !ruby/object:Gem::Requirement
216
227
  requirements:
217
- - - '>='
228
+ - - ">"
218
229
  - !ruby/object:Gem::Version
219
- version: '0'
230
+ version: 1.3.1
220
231
  requirements: []
221
232
  rubyforge_project:
222
- rubygems_version: 2.0.14
233
+ rubygems_version: 2.5.1
223
234
  signing_key:
224
235
  specification_version: 4
225
236
  summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
@@ -246,6 +257,7 @@ test_files:
246
257
  - test/unit/test_configuration.rb
247
258
  - test/unit/test_coordinator.rb
248
259
  - test/unit/test_deprecation_logger.rb
260
+ - test/unit/test_dsl.rb
249
261
  - test/unit/test_host.rb
250
262
  - test/unit/test_logger.rb
251
263
  - test/unit/test_mapping_interaction_handler.rb