Hello community, here is the log from the commit of package rubygem-sshkit for openSUSE:Factory checked in at 2017-04-11 09:33:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-sshkit (Old) and /work/SRC/openSUSE:Factory/.rubygem-sshkit.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-sshkit" Tue Apr 11 09:33:19 2017 rev:19 rq:482695 version:1.13.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-sshkit/rubygem-sshkit.changes 2016-12-29 22:46:21.639331965 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-sshkit.new/rubygem-sshkit.changes 2017-04-11 09:33:21.241172950 +0200 @@ -1,0 +2,37 @@ +Sat Mar 25 05:36:25 UTC 2017 - coolo@suse.com + +- updated to version 1.13.0 + see installed CHANGELOG.md + + ## [1.13.0][] (2017-03-24) + + ### Breaking changes + + * None + + ### New features + + * [#372](https://github.com/capistrano/sshkit/pull/372): Use cp_r in local backend with recursive option - [@okuramasafumi](https://github.com/okuramasafumi) + + ### Bug fixes + + * [#390](https://github.com/capistrano/sshkit/pull/390): Properly wrap Ruby StandardError w/ add'l context - [@mattbrictson](https://github.com/mattbrictson) + * [#392](https://github.com/capistrano/sshkit/pull/392): Fix open two connections with changed cache key - [@shirosaki](https://github.com/shirosaki) + +------------------------------------------------------------------- +Sat Feb 11 06:10:45 UTC 2017 - coolo@suse.com + +- updated to version 1.12.0 + see installed CHANGELOG.md + + ## [1.12.0][] (2017-02-10) + + ### Breaking changes + + * None + + ### New features + + * Add `SSHKit.config.default_runner_config` option that allows overriding default runner configs. + +------------------------------------------------------------------- Old: ---- sshkit-1.11.5.gem New: ---- sshkit-1.13.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-sshkit.spec ++++++ --- /var/tmp/diff_new_pack.XB95yz/_old 2017-04-11 09:33:21.841088205 +0200 +++ /var/tmp/diff_new_pack.XB95yz/_new 2017-04-11 09:33:21.845087640 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-sshkit # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-sshkit -Version: 1.11.5 +Version: 1.13.0 Release: 0 %define mod_name sshkit %define mod_full_name %{mod_name}-%{version} ++++++ sshkit-1.11.5.gem -> sshkit-1.13.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2016-12-17 02:50:45.000000000 +0100 +++ new/.travis.yml 2017-03-25 01:31:24.000000000 +0100 @@ -4,8 +4,9 @@ - 2.2.4 - 2.1.8 - 2.0.0 -include: - # Run Danger only once, on 2.3.3 - - rvm: 2.3.3 - before_script: bundle exec danger -script: "rake test:units lint" +matrix: + include: + # Run Danger only once, on 2.3.3 + - rvm: 2.3.3 + script: bundle exec danger +script: bundle exec rake test:units lint diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2016-12-17 02:50:45.000000000 +0100 +++ new/CHANGELOG.md 2017-03-25 01:31:24.000000000 +0100 @@ -7,6 +7,31 @@ * Your contribution here! +## [1.13.0][] (2017-03-24) + +### Breaking changes + + * None + +### New features + + * [#372](https://github.com/capistrano/sshkit/pull/372): Use cp_r in local backend with recursive option - [@okuramasafumi](https://github.com/okuramasafumi) + +### Bug fixes + + * [#390](https://github.com/capistrano/sshkit/pull/390): Properly wrap Ruby StandardError w/ add'l context - [@mattbrictson](https://github.com/mattbrictson) + * [#392](https://github.com/capistrano/sshkit/pull/392): Fix open two connections with changed cache key - [@shirosaki](https://github.com/shirosaki) + +## [1.12.0][] (2017-02-10) + +### Breaking changes + + * None + +### New features + + * Add `SSHKit.config.default_runner_config` option that allows overriding default runner configs. + ## [1.11.5][] (2016-12-16) ### Bug fixes @@ -662,7 +687,8 @@ First release. -[Unreleased]: https://github.com/capistrano/sshkit/compare/v1.11.5...HEAD +[Unreleased]: https://github.com/capistrano/sshkit/compare/v1.12.0...HEAD +[1.12.0]: https://github.com/capistrano/sshkit/compare/v1.11.5...v1.12.0 [1.11.5]: https://github.com/capistrano/sshkit/compare/v1.11.4...v1.11.5 [1.11.4]: https://github.com/capistrano/sshkit/compare/v1.11.3...v1.11.4 [1.11.3]: https://github.com/capistrano/sshkit/compare/v1.11.2...v1.11.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Dangerfile new/Dangerfile --- old/Dangerfile 2016-12-17 02:50:45.000000000 +0100 +++ new/Dangerfile 2017-03-25 01:31:24.000000000 +0100 @@ -1,54 +1 @@ -# Adapted from https://github.com/ruby-grape/danger/blob/master/Dangerfile -# Q: What is a Dangerfile, anyway? A: See http://danger.systems/ - -# ------------------------------------------------------------------------------ -# Additional pull request data -# ------------------------------------------------------------------------------ -project_name = github.pr_json["base"]["repo"]["name"] -pr_number = github.pr_json["number"] -pr_url = github.pr_json["_links"]["html"]["href"] - -# ------------------------------------------------------------------------------ -# What changed? -# ------------------------------------------------------------------------------ -has_lib_changes = !git.modified_files.grep(/^lib/).empty? -has_test_changes = !git.modified_files.grep(/^test/).empty? -has_changelog_changes = git.modified_files.include?("CHANGELOG.md") - -# ------------------------------------------------------------------------------ -# You've made changes to lib, but didn't write any tests? -# ------------------------------------------------------------------------------ -if has_lib_changes && !has_test_changes - warn("There are code changes, but no corresponding tests. "\ - "Please include tests if this PR introduces any modifications in "\ - "#{project_name}'s behavior.", - :sticky => false) -end - -# ------------------------------------------------------------------------------ -# Have you updated CHANGELOG.md? -# ------------------------------------------------------------------------------ -if !has_changelog_changes && has_lib_changes - markdown <<-MARKDOWN -Here's an example of a CHANGELOG.md entry (place it immediately under the `* Your contribution here!` line): - -```markdown -* [##{pr_number}](#{pr_url}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}). -``` -MARKDOWN - warn("Please update CHANGELOG.md with a description of your changes. "\ - "If this PR is not a user-facing change (e.g. just refactoring), "\ - "you can disregard this.", :sticky => false) -end - -# ------------------------------------------------------------------------------ -# Did you remove the CHANGELOG's "Your contribution here!" line? -# ------------------------------------------------------------------------------ -if has_changelog_changes - unless IO.read("CHANGELOG.md") =~ /^\* Your contribution here/i - fail( - "Please put the `* Your contribution here!` line back into CHANGELOG.md.", - :sticky => false - ) - end -end +danger.import_dangerfile(github: "capistrano/danger") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-12-17 02:50:45.000000000 +0100 +++ new/README.md 2017-03-25 01:31:24.000000000 +0100 @@ -136,6 +136,26 @@ Sequential runs were intended to be used for rolling restarts, amongst other similar use-cases. +The default runner can be set with the `SSHKit.config.default_runner` option. For +example: + ```ruby +SSHKit.config.default_runner = :parallel +SSHKit.config.default_runner = :sequence +SSHKit.config.default_runner = :groups +SSHKit.config.default_runner = MyRunner # A custom runner +``` + +If more control over the default runner is needed, the `SSHKit.config.default_runner_config` +can be set. +```ruby +# Set the runner and then the config for the runner +SSHKit.config.default_runner = :sequence +SSHKit.config.default_runner_config = { wait: 5 } + +# Or just set everything once +SSHKit.config.default_runner_config = { in: :sequence, wait: 5 } +``` + ## Synchronisation The `on()` block is the unit of synchronisation, one `on()` block will wait Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/backends/connection_pool/cache.rb new/lib/sshkit/backends/connection_pool/cache.rb --- old/lib/sshkit/backends/connection_pool/cache.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/backends/connection_pool/cache.rb 2017-03-25 01:31:24.000000000 +0100 @@ -1,7 +1,10 @@ # A Cache holds connections for a given key. Each connection is stored along # with an expiration time so that its idle duration can be measured. class SSHKit::Backend::ConnectionPool::Cache - def initialize(idle_timeout, closer) + attr_accessor :key + + def initialize(key, idle_timeout, closer) + @key = key @connections = [] @connections.extend(MonitorMixin) @idle_timeout = idle_timeout @@ -53,6 +56,10 @@ end end + def same_key?(other_key) + key == other_key + end + protected attr_reader :connections, :idle_timeout, :closer diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/backends/connection_pool/nil_cache.rb new/lib/sshkit/backends/connection_pool/nil_cache.rb --- old/lib/sshkit/backends/connection_pool/nil_cache.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/backends/connection_pool/nil_cache.rb 2017-03-25 01:31:24.000000000 +0100 @@ -8,4 +8,8 @@ def push(conn) closer.call(conn) end + + def same_key?(_key) + true + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/backends/connection_pool.rb new/lib/sshkit/backends/connection_pool.rb --- old/lib/sshkit/backends/connection_pool.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/backends/connection_pool.rb 2017-03-25 01:31:24.000000000 +0100 @@ -61,6 +61,9 @@ yield(conn) ensure cache.push(conn) unless conn.nil? + # Sometimes the args mutate as a result of opening a connection. In this + # case we need to update the cache key to match the new args. + update_key_if_args_changed(cache, args) end # Immediately remove all cached connections, without closing them. This only @@ -84,6 +87,10 @@ private + def cache_key_for_connection_args(args) + args.to_s + end + def cache_enabled? idle_timeout && idle_timeout > 0 end @@ -91,7 +98,7 @@ # Look up a Cache that matches the given connection arguments. def find_cache(args) if cache_enabled? - key = args.to_s + key = cache_key_for_connection_args(args) caches[key] || thread_safe_find_or_create_cache(key) else NilCache.new(method(:silently_close_connection)) @@ -103,11 +110,22 @@ def thread_safe_find_or_create_cache(key) caches.synchronize do caches[key] ||= begin - Cache.new(idle_timeout, method(:silently_close_connection_later)) + Cache.new(key, idle_timeout, method(:silently_close_connection_later)) end end end + # Update cache key with changed args to prevent cache miss + def update_key_if_args_changed(cache, args) + new_key = cache_key_for_connection_args(args) + return if cache.same_key?(new_key) + + caches.synchronize do + caches[new_key] = caches.delete(cache.key) + cache.key = new_key + end + end + # Loops indefinitely to close connections and to find abandoned connections # that need to be closed. def run_eviction_loop diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/backends/local.rb new/lib/sshkit/backends/local.rb --- old/lib/sshkit/backends/local.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/backends/local.rb 2017-03-25 01:31:24.000000000 +0100 @@ -10,9 +10,13 @@ super(Host.new(:local), &block) end - def upload!(local, remote, _options = {}) + def upload!(local, remote, options = {}) if local.is_a?(String) - FileUtils.cp(local, remote) + if options[:recursive] + FileUtils.cp_r(local, remote) + else + FileUtils.cp(local, remote) + end else File.open(remote, "wb") do |f| IO.copy_stream(local, f) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/backends/netssh.rb new/lib/sshkit/backends/netssh.rb --- old/lib/sshkit/backends/netssh.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/backends/netssh.rb 2017-03-25 01:31:24.000000000 +0100 @@ -36,12 +36,20 @@ if Net::SSH::VALID_OPTIONS.include?(:known_hosts) def default_options @default_options ||= {known_hosts: SSHKit::Backend::Netssh::KnownHosts.new} + assign_defaults end else def default_options @default_options ||= {} + assign_defaults end end + + # Set default options early for ConnectionPool cache key + def assign_defaults + Net::SSH.assign_defaults(@default_options) + @default_options + end end def upload!(local, remote, options = {}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/configuration.rb new/lib/sshkit/configuration.rb --- old/lib/sshkit/configuration.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/configuration.rb 2017-03-25 01:31:24.000000000 +0100 @@ -29,6 +29,16 @@ @default_runner ||= :parallel end + def default_runner_config + @default_runner_config ||= { in: default_runner } + end + + def default_runner_config=(config_hash) + config = config_hash.dup + SSHKit.config.default_runner = config.delete(:in) if config[:in] + @default_runner_config = config.merge(in: SSHKit.config.default_runner) + end + def backend @backend ||= SSHKit::Backend::Netssh end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/coordinator.rb new/lib/sshkit/coordinator.rb --- old/lib/sshkit/coordinator.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/coordinator.rb 2017-03-25 01:31:24.000000000 +0100 @@ -27,7 +27,7 @@ private def default_options - { in: SSHKit.config.default_runner } + SSHKit.config.default_runner_config end def resolve_hosts diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/runners/parallel.rb new/lib/sshkit/runners/parallel.rb --- old/lib/sshkit/runners/parallel.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/runners/parallel.rb 2017-03-25 01:31:24.000000000 +0100 @@ -10,7 +10,7 @@ Thread.new(host) do |h| begin backend(h, &block).run - rescue StandardError => e + rescue ::StandardError => e e2 = ExecuteError.new e raise e2, "Exception while executing #{host.user ? "as #{host.user}@" : "on host "}#{host}: #{e.message}" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/runners/sequential.rb new/lib/sshkit/runners/sequential.rb --- old/lib/sshkit/runners/sequential.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/runners/sequential.rb 2017-03-25 01:31:24.000000000 +0100 @@ -26,7 +26,7 @@ private def run_backend(host, &block) backend(host, &block).run - rescue StandardError => e + rescue ::StandardError => e e2 = ExecuteError.new e raise e2, "Exception while executing #{host.user ? "as #{host.user}@" : "on host "}#{host}: #{e.message}" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/sshkit/version.rb new/lib/sshkit/version.rb --- old/lib/sshkit/version.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/lib/sshkit/version.rb 2017-03-25 01:31:24.000000000 +0100 @@ -1,3 +1,3 @@ module SSHKit - VERSION = "1.11.5".freeze + VERSION = "1.13.0".freeze end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-12-17 02:50:45.000000000 +0100 +++ new/metadata 2017-03-25 01:31:24.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: sshkit version: !ruby/object:Gem::Version - version: 1.11.5 + version: 1.13.0 platform: ruby authors: - Lee Hambley @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2016-12-17 00:00:00.000000000 Z +date: 2017-03-25 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: net-ssh @@ -82,6 +82,20 @@ - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency + name: rainbow + requirement: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: 2.1.0 + type: :development + prerelease: false + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: 2.1.0 +- !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: @@ -204,6 +218,9 @@ - test/unit/formatters/test_dot.rb - test/unit/formatters/test_pretty.rb - test/unit/formatters/test_simple_text.rb +- test/unit/runners/test_group.rb +- test/unit/runners/test_parallel.rb +- test/unit/runners/test_sequential.rb - test/unit/test_color.rb - test/unit/test_command.rb - test/unit/test_command_map.rb @@ -234,7 +251,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.6.8 +rubygems_version: 2.6.11 signing_key: specification_version: 4 summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby @@ -257,6 +274,9 @@ - test/unit/formatters/test_dot.rb - test/unit/formatters/test_pretty.rb - test/unit/formatters/test_simple_text.rb +- test/unit/runners/test_group.rb +- test/unit/runners/test_parallel.rb +- test/unit/runners/test_sequential.rb - test/unit/test_color.rb - test/unit/test_command.rb - test/unit/test_command_map.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sshkit.gemspec new/sshkit.gemspec --- old/sshkit.gemspec 2016-12-17 02:50:45.000000000 +0100 +++ new/sshkit.gemspec 2017-03-25 01:31:24.000000000 +0100 @@ -23,6 +23,7 @@ gem.add_development_dependency('danger') gem.add_development_dependency('minitest', '>= 5.0.0') gem.add_development_dependency('minitest-reporters') + gem.add_development_dependency('rainbow', '~> 2.1.0') gem.add_development_dependency('rake') gem.add_development_dependency('rubocop') gem.add_development_dependency('mocha') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/functional/backends/test_local.rb new/test/functional/backends/test_local.rb --- old/test/functional/backends/test_local.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/test/functional/backends/test_local.rb 2017-03-25 01:31:24.000000000 +0100 @@ -10,6 +10,30 @@ SSHKit.config.output = SSHKit::Formatter::BlackHole.new($stdout) end + def test_upload + Dir.mktmpdir do |dir| + File.new("#{dir}/local", 'w') + Local.new do + upload!("#{dir}/local", "#{dir}/remote") + end.run + assert File.exist?("#{dir}/remote") + end + end + + def test_upload_recursive + Dir.mktmpdir do |dir| + Dir.mkdir("#{dir}/local") + File.new("#{dir}/local/file1", 'w') + File.new("#{dir}/local/file2", 'w') + Local.new do + upload!("#{dir}/local", "#{dir}/remote", recursive: true) + end.run + assert File.directory?("#{dir}/remote") + assert File.exist?("#{dir}/remote/file1") + assert File.exist?("#{dir}/remote/file2") + end + end + def test_capture captured_command_result = '' Local.new do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/functional/backends/test_netssh.rb new/test/functional/backends/test_netssh.rb --- old/test/functional/backends/test_netssh.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/test/functional/backends/test_netssh.rb 2017-03-25 01:31:24.000000000 +0100 @@ -59,7 +59,7 @@ capture(:uname) host_ssh_options = host.ssh_options end.run - assert_equal [:forward_agent, :paranoid, :known_hosts].sort, host_ssh_options.keys.sort + assert_equal [:forward_agent, :paranoid, :known_hosts, :logger, :password_prompt].sort, host_ssh_options.keys.sort assert_equal false, host_ssh_options[:forward_agent] assert_equal true, host_ssh_options[:paranoid] assert_instance_of SSHKit::Backend::Netssh::KnownHosts, host_ssh_options[:known_hosts] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/backends/test_connection_pool.rb new/test/unit/backends/test_connection_pool.rb --- old/test/unit/backends/test_connection_pool.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/test/unit/backends/test_connection_pool.rb 2017-03-25 01:31:24.000000000 +0100 @@ -50,8 +50,8 @@ end def test_connections_are_reused_if_checked_in - conn1 = pool.with(connect, "conn") {} - conn2 = pool.with(connect, "conn") {} + conn1 = pool.with(connect, "conn") { |c| c } + conn2 = pool.with(connect, "conn") { |c| c } assert_equal conn1, conn2 end @@ -134,6 +134,15 @@ pool.close_connections end end + + def test_connections_with_changed_args_is_reused + options = { known_hosts: "foo" } + connect_change_options = ->(*args) { args.last[:known_hosts] = "bar"; Object.new } + conn1 = pool.with(connect_change_options, "arg", options) { |c| c } + conn2 = pool.with(connect_change_options, "arg", options) { |c| c } + + assert_equal conn1, conn2 + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/runners/test_group.rb new/test/unit/runners/test_group.rb --- old/test/unit/runners/test_group.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/unit/runners/test_group.rb 2017-03-25 01:31:24.000000000 +0100 @@ -0,0 +1,17 @@ +require "helper" +require "sshkit" + +module SSHKit + module Runner + class TestGroup < UnitTest + def test_wraps_ruby_standard_error_in_execute_error + localhost = Host.new(:local) + runner = Group.new([localhost]) { raise "oh no!" } + error = assert_raises(SSHKit::Runner::ExecuteError) do + runner.execute + end + assert_match(/while executing.*localhost/, error.message) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/runners/test_parallel.rb new/test/unit/runners/test_parallel.rb --- old/test/unit/runners/test_parallel.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/unit/runners/test_parallel.rb 2017-03-25 01:31:24.000000000 +0100 @@ -0,0 +1,18 @@ +require "helper" +require "sshkit" + +module SSHKit + module Runner + class TestParallel < UnitTest + def test_wraps_ruby_standard_error_in_execute_error + host = Host.new("deployer@example") + runner = Parallel.new([host]) { raise "oh no!" } + error = assert_raises(SSHKit::Runner::ExecuteError) do + runner.execute + end + assert_match(/deployer@example/, error.message) + assert_match(/oh no!/, error.message) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/runners/test_sequential.rb new/test/unit/runners/test_sequential.rb --- old/test/unit/runners/test_sequential.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/unit/runners/test_sequential.rb 2017-03-25 01:31:24.000000000 +0100 @@ -0,0 +1,18 @@ +require "helper" +require "sshkit" + +module SSHKit + module Runner + class TestSequential < UnitTest + def test_wraps_ruby_standard_error_in_execute_error + host = Host.new("deployer@example") + runner = Sequential.new([host]) { raise "oh no!" } + error = assert_raises(SSHKit::Runner::ExecuteError) do + runner.execute + end + assert_match(/deployer@example/, error.message) + assert_match(/oh no!/, error.message) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/test_command.rb new/test/unit/test_command.rb --- old/test/unit/test_command.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/test/unit/test_command.rb 2017-03-25 01:31:24.000000000 +0100 @@ -218,7 +218,7 @@ def test_setting_exit_status c = Command.new(:whoami, raise_on_non_zero_exit: false) - assert_equal nil, c.exit_status + assert_nil c.exit_status assert c.exit_status = 1 assert_equal 1, c.exit_status end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/test_configuration.rb new/test/unit/test_configuration.rb --- old/test/unit/test_configuration.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/test/unit/test_configuration.rb 2017-03-25 01:31:24.000000000 +0100 @@ -57,6 +57,19 @@ assert_equal :sequence, SSHKit.config.default_runner end + def test_default_runner_config + config_hash = { wait: 5 } + config_hash_with_runner = { in: :groups, limit: 5 } + default_hash = { in: SSHKit.config.default_runner } + + assert_equal default_hash, SSHKit.config.default_runner_config + SSHKit.config.default_runner_config = config_hash + assert_equal default_hash.merge(config_hash), SSHKit.config.default_runner_config + SSHKit.config.default_runner_config = config_hash_with_runner + assert_equal config_hash_with_runner, SSHKit.config.default_runner_config + assert_equal config_hash_with_runner[:in], SSHKit.config.default_runner + end + def test_backend assert_equal SSHKit::Backend::Netssh, SSHKit.config.backend assert SSHKit.config.backend = SSHKit::Backend::Printer diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/test_coordinator.rb new/test/unit/test_coordinator.rb --- old/test/unit/test_coordinator.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/test/unit/test_coordinator.rb 2017-03-25 01:31:24.000000000 +0100 @@ -82,6 +82,32 @@ end end + def test_the_connection_manager_can_run_things_with_custom_runner_configs + begin + $original_runner = SSHKit.config.default_runner + SSHKit.config.default_runner = :groups + $original_runner_config = SSHKit.config.default_runner_config + SSHKit.config.default_runner_config = { limit: 2, wait: 5 } + + Coordinator.new( + %w{ + 1.example.com + 2.example.com + 3.example.com + 4.example.com + } + ).each(&echo_time) + assert_equal 4, actual_execution_times.length + assert_within_10_ms(actual_execution_times[0..1]) + assert_within_10_ms(actual_execution_times[2..3]) + assert_at_least_5_sec_apart(actual_execution_times[0], actual_execution_times[2]) + assert_at_least_5_sec_apart(actual_execution_times[1], actual_execution_times[3]) + ensure + SSHKit.config.default_runner = $original_runner + SSHKit.config.default_runner_config = $original_runner_config + end + end + def test_the_connection_manager_can_run_things_in_sequence_with_wait start = Time.now Coordinator.new(%w{1.example.com 2.example.com}).each in: :sequence, wait: 10, &echo_time @@ -114,6 +140,10 @@ assert_operator(last_time - first_time, :>, 1.0) end + def assert_at_least_5_sec_apart(first_time, last_time) + assert_operator(last_time - first_time, :>, 5.0) + end + def assert_within_10_ms(array) assert_in_delta(*array, 0.01) # 10 msec end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/test_host.rb new/test/unit/test_host.rb --- old/test/unit/test_host.rb 2016-12-17 02:50:45.000000000 +0100 +++ new/test/unit/test_host.rb 2017-03-25 01:31:24.000000000 +0100 @@ -75,7 +75,7 @@ def test_arbitrary_host_properties h = Host.new('example.com') - assert_equal nil, h.properties.roles + assert_nil h.properties.roles assert h.properties.roles = [:web, :app] assert_equal [:web, :app], h.properties.roles end