From 28f87738285f7056b9b9243b9bf3c2fa5ba33f39 Mon Sep 17 00:00:00 2001 From: David Vargas Date: Fri, 24 Feb 2023 13:32:00 +0000 Subject: [PATCH] F expect_nothing --- docs/changelog/v2.4.md | 6 ++++++ lib/teuton/case_manager/case/runner.rb | 9 ++++++--- lib/teuton/cli.rb | 12 ++++++------ lib/teuton/version.rb | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/docs/changelog/v2.4.md b/docs/changelog/v2.4.md index 0fa00dd5..457361d4 100644 --- a/docs/changelog/v2.4.md +++ b/docs/changelog/v2.4.md @@ -1,3 +1,9 @@ +## [2.4.5] + +-- FIX: "expect_nothing" was always TRUE when SSH/Telnet connections fails! + Now when SSH/Telnet connections fails result contains "SSH: NO CONNECTION!" + So "expect_nothing" will fail. + ## [2.4.4] -- Modify: teuton check output colors and exit codes. diff --git a/lib/teuton/case_manager/case/runner.rb b/lib/teuton/case_manager/case/runner.rb index 9706b260..a5bffd70 100644 --- a/lib/teuton/case_manager/case/runner.rb +++ b/lib/teuton/case_manager/case/runner.rb @@ -98,8 +98,10 @@ def run_cmd_remote_ssh(input_hostname) non_interactive: true ) end - if @sessions[hostname].instance_of? Net::SSH::Connection::Session - text = @sessions[hostname].exec!(@action[:command]) + text = if @sessions[hostname].instance_of? Net::SSH::Connection::Session + @sessions[hostname].exec!(@action[:command]) + else + "SSH: NO CONNECTION!" end rescue Errno::EHOSTUNREACH @sessions[hostname] = :nosession @@ -148,10 +150,11 @@ def run_cmd_remote_telnet(input_hostname) # "Prompt" => Regexp.new(username[1, 40])) # "Prompt" => /[$%#>] \z/n) h.login(username, password) - text = "" h.cmd(@action[:command]) { |i| text << i } h.close @sessions[hostname] = :ok + else + text = "TELNET: NO CONNECTION!" end rescue Net::OpenTimeout @sessions[hostname] = :nosession diff --git a/lib/teuton/cli.rb b/lib/teuton/cli.rb index 44ae9b68..878977eb 100644 --- a/lib/teuton/cli.rb +++ b/lib/teuton/cli.rb @@ -19,17 +19,17 @@ def new(projectpath) option :cname, type: :string option :cpath, type: :string desc "check [OPTIONS] DIRECTORY", "Check test and config file content" - long_desc <<-LONGDESC + long_desc <<~LONGDESC -(1) teuton check PATH/TO/DIR , Check content of start.rb and config.yaml files. + (1) teuton check PATH/TO/DIR , Check content of start.rb and config.yaml files. -(2) teuton check PATH/TO/DIR --cname=demo , Check content of start.rb and demo.yaml files: + (2) teuton check PATH/TO/DIR --cname=demo , Check content of start.rb and demo.yaml files: -(3) teuton check PATH/TO/DIR --panelconfig , Only show config file recomendations + (3) teuton check PATH/TO/DIR --panelconfig , Only show config file recomendations -(4) teuton check PATH/TO/DIR/foo.rb , Check content of foo.rb and foo.yaml files. + (4) teuton check PATH/TO/DIR/foo.rb , Check content of foo.rb and foo.yaml files. -(5) teuton check PATH/TO/DIR/foo.rb --cname=demo , Check content of foo.rb and demo.yaml files. + (5) teuton check PATH/TO/DIR/foo.rb --cname=demo , Check content of foo.rb and demo.yaml files. LONGDESC def check(projectpath) diff --git a/lib/teuton/version.rb b/lib/teuton/version.rb index 2ec314d8..49b73032 100644 --- a/lib/teuton/version.rb +++ b/lib/teuton/version.rb @@ -1,5 +1,5 @@ module Teuton - VERSION = "2.4.4" + VERSION = "2.4.5" APPNAME = "teuton" GEMNAME = "teuton" DOCKERNAME = "dvarrui/#{GEMNAME}"