teuton 2.4.3 → 2.4.5

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: 4737382a68bd95498f1fcfe7fab7dd674170ac21e56aeea7761cea9c7edb2c58
4
- data.tar.gz: 00bbd221c4251ad369a3829eb67d32fce2d05c15a9af764f76874031bc26dc0f
3
+ metadata.gz: 23e6309b8f112199998d8afd4517a06ec5b80ec4d68421ef67ef87b3c63684ef
4
+ data.tar.gz: b0c17aefadc82be10bc1c52de45fdaa65f070046bc30bad7a0416803c62c5daf
5
5
  SHA512:
6
- metadata.gz: bc557091ed6ae131bf925a0da452b34e01a64ee95ffa1cdc52f17742920614c8126ba66e5c2bd830f901dd3acbb8cc644be604ae267eddd60b3937915d3f3b83
7
- data.tar.gz: 9cd807f54792d0cf64d53a5ff82d03ca8e7e3eaf49338d511948defeaa802731ee1c8cb96ec07192d2c415c8ef113ddd180a3ed60a0bf0421ba12d314b12b601
6
+ metadata.gz: dc3e324bb363b77302758a8210e02a6258d94e99c0797806c2e2f02894a970a6ca6977984abcc7cd647982c9752b7e5799c762684ca14131d06a1260ecb49eab
7
+ data.tar.gz: b0bed729989027e9916b214b7421f88a172ef522197d1a5f589c2a5424f54688d5ea3695a3cded4410f2a68d63d5ef1687374b740b90ce91450558f03a1bcc37
data/README.md CHANGED
@@ -5,11 +5,11 @@
5
5
  ![GitHub](https://img.shields.io/github/license/dvarrui/teuton)
6
6
  ![Gem](https://img.shields.io/gem/dv/teuton/2.4.0)
7
7
 
8
- _Create Unit Test for your machines. Test your infraestructure as code._
8
+ _Create Unit Test for your machines. Test your infrastructure as code._
9
9
 
10
10
  ![logo](./docs/images/logo.png)
11
11
 
12
- Teuton is an intrastructure test tool, useful for:
12
+ Teuton is an infrastructure test tool, useful for:
13
13
  * Sysadmin teachers who want to evaluate students remote machines.
14
14
  * Sysadmin apprentices who want to evaluate their learning process as a game.
15
15
  * Professional sysadmin who want to monitor remote machines.
@@ -1,3 +1,15 @@
1
+ ## [2.4.5]
2
+
3
+ -- FIX: "expect_nothing" was always TRUE when SSH/Telnet connections fails!
4
+ Now when SSH/Telnet connections fails result contains "SSH: NO CONNECTION!"
5
+ So "expect_nothing" will fail.
6
+
7
+ ## [2.4.4]
8
+
9
+ -- Modify: teuton check output colors and exit codes.
10
+ exit code 0 = check OK
11
+ exit code 1 = check error
12
+ -- Fix teuton check docs.
1
13
 
2
14
  ## [2.4.3]
3
15
 
@@ -2,18 +2,23 @@
2
2
 
3
3
  # Check Teuton Test
4
4
 
5
- Objective: Revise Teuton test located into `example\01-target`.
5
+ | Param | Description | Default value |
6
+ | ---------------- | ---------------------- | ------------- |
7
+ | --no-panelconfig | Show check information | Enabled |
8
+ | --panelconfig | Only show config file recomended content | Disabled |
9
+ | --cpath | Specify path to config file | TEST-FOLDER/config.yaml |
10
+ | --cname | Specify name to config file | config.yaml |
6
11
 
7
12
  Usage:
8
13
 
9
14
  ```
10
- teuton check examples/01-target
15
+ teuton check PATH-TO-TEST-FOLDER
11
16
  ```
12
17
 
13
18
  Example:
14
19
 
15
20
  ```bash
16
- ❯ teuton check examples/01-target
21
+ ❯ teuton check examples/02-target
17
22
 
18
23
  +----------------------------+
19
24
  | GROUP: Learn about targets |
@@ -28,7 +33,7 @@ Example:
28
33
  +--------------+-------+
29
34
  | Groups | 1 |
30
35
  | Targets | 1 |
31
- | Goto | 1 |
36
+ | Runs | 1 |
32
37
  | * localhost | 1 |
33
38
  | Uniques | 0 |
34
39
  | Logs | 0 |
@@ -39,12 +44,18 @@ Example:
39
44
  +----------------------+
40
45
  | Revising CONFIG file |
41
46
  +----------------------+
42
- [WARN] File .../examples/01-target/config.yaml not found!
47
+ [WARN] Configfile not found
48
+ /home/david/proy/repos/teuton.d/teuton/examples/02-target/config.yaml
43
49
  [INFO] Recomended content:
44
50
  ---
45
51
  :global:
46
52
  :cases:
47
53
  - :tt_members: VALUE
54
+
55
+ Check OK!
48
56
  ```
49
57
 
50
- > The check process notifies that this Test Unit hasn't config file, and Teuton recommends content for config file. But it isn't necessary for this example.
58
+ The check process notifies that
59
+ * This test hasn't config file
60
+ * and recommends content for our config file. But it isn't necessary for this example.
61
+ * Syntax is OK!
data/docs/dsl/expect.md CHANGED
@@ -25,7 +25,9 @@ expect 'obiwan' # Expect previous run command output contains obiwan text
25
25
  | expect_one "rogue" | only one line with "rogue" |
26
26
  | expect_one ["obiwan","kenobi"] | only one line with "obiwan" and "kenobi" |
27
27
  | expect_none "vader"| no line with "vader" |
28
- | expect_none ["darth", "vader"] | no line with "darth" and "vader" |
28
+ | expect_none ["darth", "vader"] | no line with "darth" or "vader" |
29
+ | expect_none | no output lines expected |
30
+ | expect_nothing | no output lines expected |
29
31
  | expect /Obiwan\|obi-wan/ | one or more line/s with Obiwan or obi-wan. This example uses regular expresions. |
30
32
 
31
33
  ## Advanced
@@ -98,8 +98,10 @@ class Case
98
98
  non_interactive: true
99
99
  )
100
100
  end
101
- if @sessions[hostname].instance_of? Net::SSH::Connection::Session
102
- text = @sessions[hostname].exec!(@action[:command])
101
+ text = if @sessions[hostname].instance_of? Net::SSH::Connection::Session
102
+ @sessions[hostname].exec!(@action[:command])
103
+ else
104
+ "SSH: NO CONNECTION!"
103
105
  end
104
106
  rescue Errno::EHOSTUNREACH
105
107
  @sessions[hostname] = :nosession
@@ -148,10 +150,11 @@ class Case
148
150
  # "Prompt" => Regexp.new(username[1, 40]))
149
151
  # "Prompt" => /[$%#>] \z/n)
150
152
  h.login(username, password)
151
- text = ""
152
153
  h.cmd(@action[:command]) { |i| text << i }
153
154
  h.close
154
155
  @sessions[hostname] = :ok
156
+ else
157
+ text = "TELNET: NO CONNECTION!"
155
158
  end
156
159
  rescue Net::OpenTimeout
157
160
  @sessions[hostname] = :nosession
@@ -69,15 +69,14 @@ class Laboratory
69
69
  end
70
70
 
71
71
  def recomended_config_content
72
- verbose Rainbow("[WARN] File ").yellow
73
- verbose Rainbow(@path[:config]).yellow.bright
74
- verboseln Rainbow(" not found!").yellow
75
- verboseln "[INFO] Recomended content:"
72
+ verboseln Rainbow("[WARN] Configfile not found").bright.yellow
73
+ verboseln Rainbow(" #{@path[:config]}").white
74
+ verboseln Rainbow("[INFO] Recomended content:").bright.yellow
76
75
  output = {global: nil, cases: []}
77
76
  output[:cases][0] = {}
78
77
  script_vars = find_script_vars
79
78
  script_vars.each { |i| output[:cases][0][i] = "VALUE" }
80
- verboseln YAML.dump(output)
79
+ verboseln Rainbow(YAML.dump(output)).white
81
80
  end
82
81
 
83
82
  def recomended_panelconfig_content
data/lib/teuton/cli.rb CHANGED
@@ -19,19 +19,17 @@ class CLI < Thor
19
19
  option :cname, type: :string
20
20
  option :cpath, type: :string
21
21
  desc "check [OPTIONS] DIRECTORY", "Check test and config file content"
22
- long_desc <<-LONGDESC
22
+ long_desc <<~LONGDESC
23
+
24
+ (1) teuton check PATH/TO/DIR , Check content of start.rb and config.yaml files.
23
25
 
24
- (1) teuton check path/to/dir/foo
25
- , Check content of start.rb and config.yaml files.
26
+ (2) teuton check PATH/TO/DIR --cname=demo , Check content of start.rb and demo.yaml files:
26
27
 
27
- (2) teuton check path/to/dir/foo --cname=demo
28
- , Check content of start.rb and demo.yaml files.
28
+ (3) teuton check PATH/TO/DIR --panelconfig , Only show config file recomendations
29
29
 
30
- (3) teuton check path/to/file/foo.rb
31
- , Check content of foo.rb and foo.yaml files.
30
+ (4) teuton check PATH/TO/DIR/foo.rb , Check content of foo.rb and foo.yaml files.
32
31
 
33
- (4) teuton check path/to/file/foo.rb --cname=demo
34
- , Check content of foo.rb and demo.yaml files.
32
+ (5) teuton check PATH/TO/DIR/foo.rb --cname=demo , Check content of foo.rb and demo.yaml files.
35
33
 
36
34
  LONGDESC
37
35
  def check(projectpath)
@@ -31,11 +31,11 @@ module ConfigFileReader
31
31
  begin
32
32
  data = YAML.load(File.open(filepath))
33
33
  rescue => e
34
- puts "\n" + ("=" * 80)
35
- puts "[ERROR] ConfigFileReader#read <#{filepath}>"
36
- puts " I suggest to revise file format!"
37
- puts " #{e.message}\n" + ("=" * 80)
38
- raise "[ERROR] ConfigFileReader <#{e}>"
34
+ $stderr.puts "\n" + ("=" * 80)
35
+ $stderr.puts "[ERROR] ConfigFileReader#read <#{filepath}>"
36
+ $stderr.puts " I suggest to revise file format!"
37
+ $stderr.puts " #{e.message}\n" + ("=" * 80)
38
+ exit 1
39
39
  end
40
40
  data = convert_string_keys_to_symbol(data)
41
41
  data[:global] = data[:global] || {}
@@ -27,9 +27,7 @@ module NameFileFinder
27
27
  # COMPLEX MODE: We use start.rb as main RB file
28
28
  script_path = File.join(folder_path, "start.rb")
29
29
  unless File.exist? script_path
30
- print Rainbow("[ERROR] File ").red
31
- print Rainbow(script_path).bright.red
32
- puts Rainbow(" not found!").red
30
+ warn Rainbow("[ERROR] File not found: #{script_path}").bright.red
33
31
  exit 1
34
32
  end
35
33
 
@@ -68,9 +66,8 @@ module NameFileFinder
68
66
  # SIMPLE MODE: We use script_path as main RB file
69
67
  # This must be fullpath to DSL script file
70
68
  if File.extname(script_path) != ".rb"
71
- print Rainbow("[ERROR] Script ").red
72
- print Rainbow(script_path).bright.red
73
- puts Rainbow(" must have rb extension").red
69
+ warn Rainbow("[ERROR] .rb extension required!").bright.red
70
+ warn Rainbow(" #{script_path}").white
74
71
  exit 1
75
72
  end
76
73
 
@@ -1,5 +1,5 @@
1
1
  module Teuton
2
- VERSION = "2.4.3"
2
+ VERSION = "2.4.5"
3
3
  APPNAME = "teuton"
4
4
  GEMNAME = "teuton"
5
5
  DOCKERNAME = "dvarrui/#{GEMNAME}"
data/lib/teuton.rb CHANGED
@@ -27,8 +27,13 @@ module Teuton
27
27
 
28
28
  app = Application.instance
29
29
  lab = Laboratory.new(app.script_path, app.config_path)
30
- lab.show unless options[:panelconfig]
31
- lab.show_panelconfig if options[:panelconfig]
30
+ if options[:panelconfig]
31
+ lab.show_panelconfig
32
+ else
33
+ lab.show
34
+ end
35
+ puts Rainbow("Check OK!").green
36
+ exit 0
32
37
  end
33
38
 
34
39
  private_class_method def self.require_dsl_and_script(dslpath)
@@ -36,10 +41,11 @@ module Teuton
36
41
  require_relative dslpath
37
42
  begin
38
43
  require_relative app.script_path
39
- rescue SyntaxError => e
40
- puts e.to_s
41
- puts Rainbow.new("[FAIL ] Reading file #{app.script_path}").red
42
- puts Rainbow.new("[ERROR] Syntax Error!").red
44
+ rescue
45
+ warn e.to_s
46
+ warn Rainbow.new("[FAIL ] Reading file #{app.script_path}").red
47
+ warn Rainbow.new("[ERROR] Syntax Error!").red
48
+ exit 1
43
49
  end
44
50
  end
45
51
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 2.4.5
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-02-17 00:00:00.000000000 Z
11
+ date: 2023-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: colorize
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.8.1
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.8.1
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rainbow
29
15
  requirement: !ruby/object:Gem::Requirement