teuton 2.7.2 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49783f5731dfc4f6344649a794f17b02e0d79e6f197068dde010414cdb6f7873
4
- data.tar.gz: 0a4c44633bc0f101e5095678edf9da2e2c22372641302647244917c573a777c2
3
+ metadata.gz: 12d43ceacd278684c8415098d95fc3803486bfa437fb2bb91c5224074b42fd2d
4
+ data.tar.gz: 610841aa8b490d72158d8641450fcf794fda245285621a454e259cfbbb5f2749
5
5
  SHA512:
6
- metadata.gz: ea56789646f536090a8afb7a28aef46e89daec281b7fe7c95bad0ff7170c27f1f1937540c899bf9d6e9b16c8126871facde4bedf97d5c7269bb8e51d49778066
7
- data.tar.gz: e1ed282d52fbbe1519bbf597669680b46b680c5b3fa7164a0edf6e1472b7b356fce9bdc7e13ab68448a9e2318139a37a1adb6eda62a667dd00a3ba0ae2b6c339
6
+ metadata.gz: 2aa8c93229422728b09aabb1f2a7c95c44af37c4a4c0a02518e8ad58a74b023d2806f299fde0005f695a66e935b03daf25ac6d75ae4fc59f2105fe4dc2fce129
7
+ data.tar.gz: 047415074d71174f1399422e2cf45b92fdecc3234f3aed94e4c99ce1298fcb9db2bcc4b0daec6abac5ab65162041acf3a519c9a30dda62ee1d10f29efea7a9b1
@@ -1,4 +1,16 @@
1
1
 
2
+ ## [2.7.3] 20230607
3
+
4
+ - [FIX] Hall of fame now use Project class instead of Application.
5
+
6
+ ## [2.7.2] 20230607
7
+
8
+ - [FIX] Fixed an issue that appeared when exporting reports without feedback after failing to connect to remote computer.
9
+
10
+ ## [2.7.1]
11
+
12
+ - [FIX] Fixed an issue that appeared when executing test and fail connection to remote computer.
13
+
2
14
  ## [2.7.0]
3
15
 
4
16
  New features:
@@ -0,0 +1,11 @@
1
+
2
+ ## [2.8.0] 20230630
3
+
4
+ expect:
5
+ - [ADD] "expect_ok" as "expect_exit 0 ".
6
+ - [ADD] "expect_fail" as "expect_exit NUMBER" where NUMBER > 0.
7
+ - [FIX] expect evaluation fail when there is no remote connection.
8
+
9
+ send:
10
+ - [UPDATE] Rename "remote_dir" send param to "dir".
11
+ - [UPDATE] send output messages
data/docs/dsl/expect.md CHANGED
@@ -29,6 +29,9 @@ expect 'obiwan' # Expect previous run command output contains obiwan text
29
29
  | expect_none | no output lines expected |
30
30
  | expect_nothing | no output lines expected |
31
31
  | expect /Obiwan\|obi-wan/ | one or more line/s with Obiwan or obi-wan. This example uses regular expresions. |
32
+ | expect_exit NUMBER | Check exit code is NUMBER |
33
+ | expect_ok | Check exit code is 0 |
34
+ | expect_fail | Check exit code is > 0 |
32
35
 
33
36
  ## Advanced
34
37
 
data/docs/dsl/export.md CHANGED
@@ -24,9 +24,11 @@ end
24
24
 
25
25
  ## Options
26
26
 
27
- 1. **format**: txt (default), html, yaml, json, colored_text (txt with colors).
28
- 2. **preserve**: false (default), true.
29
- 3. **feedback**: true (default), false
27
+ | Option | Values | Description |
28
+ | ------ | ------ | ----------- |
29
+ | format | **txt** (default), html, yaml, json, colored_text (txt with colors) |Output file format |
30
+ | preserve | **false** (default), true | Keep report old copies |
31
+ | feedback | **true** (default), false | Hide some fields from reports |
30
32
 
31
33
  ## Usage
32
34
 
@@ -40,3 +42,4 @@ end
40
42
  | 06 | `export format: 'colored_text'` or `export format: :colored_text` | Export file using colored TXT ouput format |
41
43
  | 07 | `export preserve: true` | Export default format and preserve report copies |
42
44
  | 08 | `export format: 'html', preserve: true` or `export format: :html, preserve: true` | Export 'html' format and preserve report copies |
45
+ | 09 | `export feedback: false` | With "feedback: false" some fields are hidden: command, alterations, expected and result |
data/docs/dsl/send.md CHANGED
@@ -12,33 +12,18 @@ end
12
12
  ```
13
13
 
14
14
  * `send` instruction must be execute after `export`. Reports must be generated before send them, of course.
15
- * `host1`, it' the label that identified remote host. This information must be configured into config file.
15
+ * `host1`, label that identify remote host. This information must be configured into config file.
16
16
  * `send copy_to: :host1`, copy every case resport file into temp directory on remote host `host1`.
17
17
 
18
- ## Example
18
+ ## Options
19
19
 
20
- Example 1: send `case-01-txt` file to remote Windows host.
20
+ | Option | Action | Description |
21
+ | ------: | ------ | ----------- |
22
+ | copy_to | send copy_to: :host1 | Copy report into default directory of remote machine `host1`. |
23
+ | prefix | send copy_to: :host1, prefix: "example_" | Case report will be save into default directory on every host `host1`, named as `example_case-XX.txt`. |
24
+ | dir | send copy_to: :host1, dir: "/home/obiwan" | Reports will be saved into "/home/obiwan" directory in remote machine `host1`. |
21
25
 
22
- ![](images/send-remote-dir-dot1.jpg)
23
-
24
- ![](images/send-remote-dir-dot2.jpg)
25
-
26
- Example 2: send report file to remote "./Desktop" folder.
27
-
28
- ![](images/send-remote-dir-desktop1.jpg)
29
-
30
- ## Parameters
31
-
32
- | Action | Description |
33
- | ------ | ----------- |
34
- | `send copy_to: :host1, remote_dir: "/home/david"` | Reports will be saved into "/home/david" directory in remote machine `host1`. |
35
- | `send copy_to: :host1, prefix: "samba_"` | Case report will be save into temp directory on every host `host1`, named as `samba_case-XX.txt`. |
36
-
37
- > Teuton version 2.0.x
38
- > * By default, `send` only works when remote OS type is UNIX base, like GNU/Linux, MACOS, BSD, etc.
39
- > * For Windows OS we must specified `:remote_dir`. Example: `send :copy_to => :host1, :remote_dir => "C:\\"`. This example will copy files on directory c:\ of host1 machine.
40
-
41
- ## Send several reports
26
+ ## Example: Send several reports with diferent formats
42
27
 
43
28
  If you export several files using differents output formats, you will use several `export` orders. Then when invoke `send` order, this will send the last exported file.
44
29
 
@@ -64,3 +49,29 @@ start do
64
49
  send copy_to: :host1
65
50
  end
66
51
  ```
52
+
53
+ ## Example: Using "dir" options
54
+
55
+ Example 1: send `case-01-txt` file to default folder of remote remote host.
56
+
57
+ ```ruby
58
+ play do
59
+ show
60
+ export
61
+ send copy_to: :host1
62
+ end
63
+ ```
64
+
65
+ Result:
66
+
67
+ ![](images/send-remote-dir-dot2.jpg)
68
+
69
+ Example 2: send report file to "./Desktop" folder of remote host.
70
+
71
+ ```ruby
72
+ play do
73
+ show
74
+ export
75
+ send copy_to: :host1, dir: "./Desktop"
76
+ end
77
+ ```
@@ -20,17 +20,16 @@ end
20
20
 
21
21
  Every time teuton is run, all cases are evaluated and when exporting the results, by default, all the information collected during the evaluation process is logged.
22
22
 
23
- Each "target" contains the following fields:
23
+ Each `target` contains following fields:
24
24
 
25
- * Identification: id, description
26
- * Evaluation result: check(true/false)
27
- * Punctuation: score, weight
28
- * Check process: conn_type, command, duration, alterations, expected, result
25
+ * Identification: `id`, `description`
26
+ * Evaluation result: `check`(true/false)
27
+ * Punctuation: `score`, `weight`
28
+ * Check process: `conn_type`, `command`, `duration`, `alterations`, `expected` and `result`
29
29
 
30
- Some of these fields should always be visible, such as: id, description, check, score, and weight. And others, more related to the process that perform teuton for verification can be hidden using the "feedback: false" parameter.
31
-
32
- With "feedback: false" the fields are hidden: command, alterations, expected and result.
30
+ Some of these fields should always be visible, such as: id, description, check, score, and weight. And others, more related to the process that perform teuton for verification can be hidden using the `feedback: false` parameter.
33
31
 
32
+ With `feedback: false` the fields are hidden: command, alterations, expected and result.
34
33
 
35
34
  ## Results
36
35
 
@@ -40,7 +39,7 @@ Executing `teuton run examples/13-feedback`, we get this output:
40
39
  GROUPS
41
40
  - Preserve output reports
42
41
  01 (1.0/1.0)
43
- Description : Exits user david
42
+ Description : Exits user Obiwan
44
43
  Command : ********
45
44
  Duration : 0.002 (local)
46
45
  Alterations : *******************
@@ -11,7 +11,6 @@ require_relative "play"
11
11
  require_relative "builtin/main"
12
12
 
13
13
  class Case
14
- # Case: export, filename, grade, members,skip
15
14
  include DSL
16
15
  include Verbose
17
16
 
@@ -18,9 +18,13 @@ module DSL
18
18
  def expect2(cond, args = {})
19
19
  @action_counter += 1
20
20
  @action[:id] = @action_counter
21
- @action[:check] = cond
22
-
23
- @action[:result] = (args[:value] || @result.value)
21
+ if @result.exitcode < 0
22
+ @action[:check] = false
23
+ @action[:result] = @action[:output]
24
+ else
25
+ @action[:check] = cond
26
+ @action[:result] = (args[:value] || @result.value)
27
+ end
24
28
 
25
29
  @action[:alterations] = @result.alterations
26
30
  @action[:expected] = (args[:expected] || @result.expected)
@@ -57,6 +61,14 @@ module DSL
57
61
  expect2 cond, value: real_value, expected: expect_value
58
62
  end
59
63
 
64
+ def expect_fail
65
+ @result.alterations = "Read exit code"
66
+ real_value = result.exitcode
67
+ expect_value = "Greater than 0"
68
+ cond = (real_value > 0)
69
+ expect2 cond, value: real_value, expected: expect_value
70
+ end
71
+
60
72
  def expect_first(input, args = {})
61
73
  @result.first
62
74
  output = input
@@ -95,6 +107,10 @@ module DSL
95
107
  expect2 result.count.eq(1), args
96
108
  end
97
109
 
110
+ def expect_ok
111
+ expect_exit 0
112
+ end
113
+
98
114
  def weight(value = nil)
99
115
  # Set weight value for the action
100
116
  if value.nil?
@@ -2,7 +2,6 @@
2
2
 
3
3
  require_relative "../../utils/project"
4
4
 
5
- # DSL module methods: assert, missing_method
6
5
  module DSL
7
6
  ##
8
7
  # Invoke macro
@@ -21,8 +21,8 @@ module DSL
21
21
  localfilepath = File.join(@report.output_dir, filename)
22
22
  filename = args[:prefix].to_s + filename if args[:prefix]
23
23
 
24
- remotefilepath = if args[:remote_dir]
25
- File.join(args[:remote_dir], filename)
24
+ remotefilepath = if args[:dir]
25
+ File.join(args[:dir], filename)
26
26
  else
27
27
  File.join(".", filename)
28
28
  end
@@ -32,7 +32,7 @@ module DSL
32
32
  Net::SFTP.start(ip, username, password: password, port: port) do |sftp|
33
33
  sftp.upload!(localfilepath, remotefilepath)
34
34
  end
35
- msg = Rainbow("==> File '#{remotefilepath}' of '#{get(:tt_members)}' has been copied").green
35
+ msg = Rainbow("==> Case #{get(:tt_members)}: report (#{remotefilepath}) copy to (#{ip})").green
36
36
  verboseln(msg)
37
37
  rescue
38
38
  msg = Rainbow("==> [FAIL] #{get(:tt_members)}: 'scp #{localfilepath}' to #{remotefilepath}").red
@@ -35,7 +35,7 @@ class ExecuteSSH < ExecuteBase
35
35
  end
36
36
  end
37
37
 
38
- text = ""
38
+ text = "TEUTON_NODATA"
39
39
  exitcode = 0
40
40
  begin
41
41
  if sessions[hostname].nil?
@@ -49,25 +49,29 @@ class ExecuteSSH < ExecuteBase
49
49
  non_interactive: true
50
50
  )
51
51
  end
52
- text = if sessions[hostname].instance_of? Net::SSH::Connection::Session
53
- sessions[hostname].exec!(action[:command])
52
+ if sessions[hostname].instance_of? Net::SSH::Connection::Session
53
+ text = sessions[hostname].exec!(action[:command])
54
+ exitcode = text.exitstatus
54
55
  else
55
- "SSH: NO CONNECTION!"
56
+ text = "TEUTON_ERROR_SSH_NO_CONNECTION"
57
+ exitcode = -1
56
58
  end
57
- exitcode = text.exitstatus
58
59
  rescue Errno::EHOSTUNREACH
59
60
  sessions[hostname] = :nosession
60
61
  conn_status[hostname] = :host_unreachable
62
+ text = "TEUTON_ERROR_SSH_HOST_UNREACHABLE"
61
63
  exitcode = -1
62
64
  log("Host #{ip} unreachable!", :error)
63
65
  rescue Net::SSH::AuthenticationFailed
64
66
  sessions[hostname] = :nosession
65
67
  conn_status[hostname] = :error_authentication_failed
68
+ text = "TEUTON_ERROR_SSH_AUTH_FAILED"
66
69
  exitcode = -1
67
70
  log("SSH::AuthenticationFailed!", :error)
68
71
  rescue Net::SSH::HostKeyMismatch
69
72
  sessions[hostname] = :nosession
70
73
  conn_status[hostname] = :host_key_mismatch
74
+ text = "TEUTON_ERROR_SSH_HOST_KEY"
71
75
  exitcode = -1
72
76
  log("SSH::HostKeyMismatch!", :error)
73
77
  log("* The destination server's fingerprint is not matching " \
@@ -78,13 +82,13 @@ class ExecuteSSH < ExecuteBase
78
82
  rescue => e
79
83
  sessions[hostname] = :nosession
80
84
  conn_status[hostname] = :error
85
+ text = "TEUTON_ERROR_SSH"
81
86
  exitcode = -1
82
87
  log("[#{e.class}] SSH on <#{username}@#{ip}>" \
83
88
  " exec: #{action[:command]}", :error)
84
89
  end
85
- output = encode_and_split(action[:encoding], text)
86
90
  result.exitcode = exitcode
87
- result.content = output
91
+ result.content = encode_and_split(action[:encoding], text)
88
92
  result.content.compact!
89
93
  end
90
94
  end
@@ -1,5 +1,6 @@
1
1
  require "rainbow"
2
2
  require "terminal-table"
3
+ # require_relative "../utils/application"
3
4
  require_relative "../utils/project"
4
5
 
5
6
  # | Verbosity level | Description |
@@ -121,11 +122,12 @@ class ShowReport
121
122
  end
122
123
 
123
124
  def show_hall_of_fame
124
- return if Project.value[:hall_of_fame].size < 3
125
+ hall_of_fame = Project.value[:hall_of_fame]
126
+ return if hall_of_fame.size < 3
125
127
 
126
128
  puts Rainbow("HALL OF FAME").bright
127
129
  my_screen_table = Terminal::Table.new do |st|
128
- app.hall_of_fame.each do |line|
130
+ hall_of_fame.each do |line|
129
131
  st.add_row [line[0], line[1]]
130
132
  end
131
133
  end
@@ -94,8 +94,8 @@ class TXTFormatter < ArrayFormatter
94
94
  w "#{tab * 4}Output : #{i[:output]}\n"
95
95
  w "#{tab * 4}Duration : #{i[:duration]} (#{i[:conn_type]})\n"
96
96
  w "#{tab * 4}Alterations : #{i[:alterations]}\n"
97
- w "#{tab * 4}Expected : #{i[:expected]} (#{i[:expected].class})\n"
98
- w "#{tab * 4}Result : #{i[:result]} (#{i[:result].class})\n"
97
+ w "#{tab * 4}Expected : #{i[:expected]}\n"
98
+ w "#{tab * 4}Result : #{i[:result]}\n"
99
99
  end
100
100
  end
101
101
  end
@@ -11,10 +11,7 @@ class Application
11
11
  attr_accessor :verbose
12
12
  attr_accessor :global # Global configuration params
13
13
  attr_accessor :ialias # Internal alias
14
- attr_accessor :macros # Array of macros
15
- attr_accessor :groups # Array of groups
16
14
  attr_accessor :uses # Array of uses
17
- attr_accessor :hall_of_fame
18
15
  attr_accessor :project_path, :script_path, :config_path, :test_name
19
16
 
20
17
  def initialize
@@ -42,10 +39,7 @@ class Application
42
39
 
43
40
  @global = {}
44
41
  @ialias = {}
45
- @macros = {}
46
- @groups = []
47
42
  @uses = [] # TODO
48
- @hall_of_fame = []
49
43
  end
50
44
 
51
45
  def debug
@@ -1,5 +1,5 @@
1
1
  module Teuton
2
- VERSION = "2.7.2"
2
+ VERSION = "2.8.0"
3
3
  APPNAME = "teuton"
4
4
  GEMNAME = "teuton"
5
5
  DOCKERNAME = "dvarrui/#{GEMNAME}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-07 00:00:00.000000000 Z
11
+ date: 2023-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -134,6 +134,7 @@ extra_rdoc_files:
134
134
  - docs/changelog/v2.5.md
135
135
  - docs/changelog/v2.6.md
136
136
  - docs/changelog/v2.7.md
137
+ - docs/changelog/v2.8.md
137
138
  - docs/changelog/version2.1.md
138
139
  - docs/commands/README.md
139
140
  - docs/commands/example_check.md
@@ -204,6 +205,7 @@ files:
204
205
  - docs/changelog/v2.5.md
205
206
  - docs/changelog/v2.6.md
206
207
  - docs/changelog/v2.7.md
208
+ - docs/changelog/v2.8.md
207
209
  - docs/changelog/version2.1.md
208
210
  - docs/commands/README.md
209
211
  - docs/commands/example_check.md