teuton 2.1.7 → 2.1.8dev1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/learn/example-02-configfile.md +7 -8
- data/docs/learn/example-03-remote-hosts.md +9 -3
- data/docs/learn/example-04-use.md +4 -0
- data/docs/learn/example-05-debug.md +17 -13
- data/lib/teuton/application.rb +1 -1
- data/lib/teuton/case_manager/case/case.rb +2 -2
- data/lib/teuton/case_manager/case/dsl/log.rb +2 -4
- data/lib/teuton/case_manager/case_manager.rb +1 -3
- data/lib/teuton/case_manager/export_manager.rb +7 -1
- data/lib/teuton/case_manager/report.rb +1 -1
- data/lib/teuton/report/formatter/moodle_csv_formatter.rb +13 -3
- data/lib/teuton/report/formatter/resume_txt_formatter.rb +28 -25
- data/lib/teuton/report/report.rb +2 -4
- data/lib/teuton/report/show.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9adfc25439c6c4041e3ebe2c3defd49f2377fd5bc9283da0849e5e2ad220581
|
4
|
+
data.tar.gz: ddfb9194f6ce7d070fd53aa796094ffa25faa19f7d7142bb044ce9d92ed6725a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca261f8258065c3684c82dae7ea8929c1d77bfeeb64baea71dd60c2aa52d99f1767af1bd2467a1747881a4e37ba4078df1dc9541895bcee6f0695b73874e8cc8
|
7
|
+
data.tar.gz: 001aa6f198e560ec39cac6a1cca65ed67d7ef887751e7f9e13759309c7bf42cf772c8c8fb32fc8e0f8ec1ddc92477ef2a8bfbdae7c74851cad4afb7123eadeff
|
@@ -8,6 +8,7 @@
|
|
8
8
|
|
9
9
|
> This example is on GitHub repository at `examples/learn-02-config`.
|
10
10
|
|
11
|
+
---
|
11
12
|
## Config file
|
12
13
|
|
13
14
|
By default, `config.yaml` is our config file. Let's an example:
|
@@ -47,10 +48,8 @@ In this section we define targets using keywords: target, run, expect and get.
|
|
47
48
|
```ruby
|
48
49
|
play do
|
49
50
|
show
|
50
|
-
|
51
|
-
export :format => :colored_text
|
51
|
+
export
|
52
52
|
end
|
53
|
-
|
54
53
|
```
|
55
54
|
|
56
55
|
Runing this example and see `show` keyword output:
|
@@ -100,7 +99,7 @@ HALL OF FAME
|
|
100
99
|
|
101
100
|
## Results
|
102
101
|
|
103
|
-
Output reports are saved into `var/learn-02-config/` directory.
|
102
|
+
Output reports are saved into `var/learn-02-config/` directory. Detail output report is created for every case.
|
104
103
|
|
105
104
|
```
|
106
105
|
var/learn-02-config
|
@@ -109,7 +108,7 @@ var/learn-02-config
|
|
109
108
|
└── resume.txt
|
110
109
|
```
|
111
110
|
|
112
|
-
Let's see `export` keyword output.
|
111
|
+
Let's see `export` keyword output for case 01.
|
113
112
|
|
114
113
|
```
|
115
114
|
$ more var/learn-02-config/case-01.txt
|
@@ -156,18 +155,18 @@ By default, when you run `teuton run foo`, this will search for:
|
|
156
155
|
* `foo/config.yaml` config file.
|
157
156
|
|
158
157
|
**Using cname param:**
|
159
|
-
But it's posible run `teuton run --cname=rock foo`, and
|
158
|
+
But it's posible run `teuton run --cname=rock foo`, and choose diferent config file into projet folder:
|
160
159
|
* `foo/start.rb` test file and
|
161
160
|
* `foo/rock.yaml` config file.
|
162
161
|
|
163
162
|
`cname` param searchs YAML config file into the same project folder.
|
164
163
|
|
165
164
|
**Using cpath param:**
|
166
|
-
An also, it's posible run `teuton run --cpath=/home/david/startwars.yaml foo`, and
|
165
|
+
An also, it's posible run `teuton run --cpath=/home/david/startwars.yaml foo`, and choose config file using its absolute path:
|
167
166
|
* `foo/start.rb` test file and
|
168
167
|
* `/home/david/starwars.yaml` config file.
|
169
168
|
|
170
|
-
`cpath` param
|
169
|
+
`cpath` param selects YAML config file, from the specified path.
|
171
170
|
|
172
171
|
**Using diferent main rb name:**
|
173
172
|
When you run `teuton run foo/mazingerz.rb`, this will search for:
|
@@ -1,4 +1,8 @@
|
|
1
1
|
|
2
|
+
[<< back](README.md)
|
3
|
+
|
4
|
+
# Example: learn-03-remote-hosts
|
5
|
+
|
2
6
|
Learn how to:
|
3
7
|
* Check a group of remote hosts.
|
4
8
|
* Export reports using other output formats.
|
@@ -6,7 +10,9 @@ Learn how to:
|
|
6
10
|
|
7
11
|
> This example is on GitHub repository at `examples/learn-03-remote-hosts`.
|
8
12
|
|
9
|
-
## Config file
|
13
|
+
## Config file
|
14
|
+
|
15
|
+
`config.yaml` file:
|
10
16
|
|
11
17
|
```yaml
|
12
18
|
---
|
@@ -30,7 +36,7 @@ Learn how to:
|
|
30
36
|
|
31
37
|
## Definitions (group section)
|
32
38
|
|
33
|
-
|
39
|
+
Define 3 targets (items to be checked):
|
34
40
|
|
35
41
|
```ruby
|
36
42
|
group "learn 03 remote hosts" do
|
@@ -87,4 +93,4 @@ var
|
|
87
93
|
* `case-01`, report with details about case 01 (maul)
|
88
94
|
* `case-02`, report with details about case 02 (r2d2)
|
89
95
|
* `case-03`, report with details about case 03 (obiwan)
|
90
|
-
* `
|
96
|
+
* `resume`, report with global resumed information about all cases.
|
@@ -1,4 +1,8 @@
|
|
1
1
|
|
2
|
+
[<< back](README.md)
|
3
|
+
|
4
|
+
# Example: learn-05-debug
|
5
|
+
|
2
6
|
Learn how to:
|
3
7
|
* Check test syntax.
|
4
8
|
* Debug your tests.
|
@@ -35,23 +39,23 @@ end
|
|
35
39
|
|
36
40
|
## Debugging: Testing rb files
|
37
41
|
|
38
|
-
Tests grows and becames huge, with a lot of targets (That isn't a problem). Then, we organize them spliting into several files and invoke `use` keywork from our main rb file (That's good)
|
42
|
+
Tests grows and becames huge, with a lot of targets (That isn't a problem). Then, we organize them spliting into several files and invoke `use` keywork from our main rb file to load other files (That's good idea) .
|
39
43
|
|
40
|
-
When this happend, sometimes we need to verify or check rb file consistency and syntax, and we will do it with `teuton
|
44
|
+
When this happend, sometimes we need to verify or check rb file consistency and syntax, and we will do it with `teuton check PATH/TO/PROJECT/FOLDER`. Let's see an example:
|
41
45
|
|
42
46
|
```bash
|
43
|
-
|
44
|
-
[INFO] ScriptPath =>
|
45
|
-
[INFO] ConfigPath => ...
|
47
|
+
teuton check examples/learn-01-target
|
48
|
+
[INFO] ScriptPath => .../teuton.d/teuton/examples/learn-01-target/start.rb
|
49
|
+
[INFO] ConfigPath => ...uton.d/teuton/examples/learn-01-target/config.yaml
|
46
50
|
[INFO] TestName => learn-01-target
|
47
51
|
|
48
52
|
+------------------------+
|
49
53
|
| GROUP: learn-01-target |
|
50
54
|
+------------------------+
|
51
55
|
(001) target Create user <david>
|
52
|
-
|
53
|
-
|
54
|
-
|
56
|
+
weight 1.0
|
57
|
+
goto localhost and {:exec=>"id david"}
|
58
|
+
expect david (String)
|
55
59
|
|
56
60
|
+--------------+-------+
|
57
61
|
| DSL Stats | Count |
|
@@ -69,7 +73,7 @@ $ teuton test learn/learn-01-target
|
|
69
73
|
+----------------------+
|
70
74
|
| Revising CONFIG file |
|
71
75
|
+----------------------+
|
72
|
-
[WARN] File /
|
76
|
+
[WARN] File ./examples/learn-01-target/config.yaml not found!
|
73
77
|
[INFO] Recomended content:
|
74
78
|
---
|
75
79
|
:global:
|
@@ -77,13 +81,13 @@ $ teuton test learn/learn-01-target
|
|
77
81
|
- :tt_members: VALUE
|
78
82
|
```
|
79
83
|
|
80
|
-
In this case, Teuton detects that there isn't config file and propose us content for `config.yaml`.
|
84
|
+
In this case, Teuton detects that there isn't exist config file, and propose us content for `config.yaml`.
|
81
85
|
|
82
86
|
## Debugging: Result content
|
83
87
|
|
84
|
-
Every time we invoke `goto` or `run` keywork,
|
88
|
+
Every time we invoke `goto` or `run` keywork, an OS command is executed and the output showed on screen is captured by Teuton and saved into `result` internal object.
|
85
89
|
|
86
|
-
We
|
90
|
+
We could debug it invoking `result.debug` into our rb file. Let's see an example from `external.rb.rb` file:
|
87
91
|
|
88
92
|
```ruby
|
89
93
|
group "Windows: external configuration" do
|
@@ -101,4 +105,4 @@ group "Windows: external configuration" do
|
|
101
105
|
end
|
102
106
|
```
|
103
107
|
|
104
|
-
`result.debug` it's usefull when you are verifying
|
108
|
+
`result.debug` it's usefull when you are verifying command output captured by Teuton.
|
data/lib/teuton/application.rb
CHANGED
@@ -26,7 +26,7 @@ class Case
|
|
26
26
|
attr_accessor :result
|
27
27
|
attr_accessor :action # TODO: why not reader only???
|
28
28
|
attr_reader :id, :config, :uniques, :conn_status
|
29
|
-
@@id =
|
29
|
+
@@id = '01'
|
30
30
|
|
31
31
|
def initialize(config)
|
32
32
|
app = Application.instance
|
@@ -34,7 +34,7 @@ class Case
|
|
34
34
|
@groups = app.groups
|
35
35
|
|
36
36
|
@id = @@id
|
37
|
-
@@id
|
37
|
+
@@id = @@id.next
|
38
38
|
|
39
39
|
# Define Case Report
|
40
40
|
@report = Report.new(@id)
|
@@ -7,16 +7,14 @@ module DSL
|
|
7
7
|
# Record log message
|
8
8
|
# @param text (String)
|
9
9
|
# @param type (Symbol) Values :info, :warn or :error
|
10
|
-
# rubocop:disable Style/FormatStringToken
|
11
10
|
def log(text = '', type = :info)
|
12
11
|
s = ''
|
13
12
|
s = Rainbow('WARN!').color(:yellow) if type == :warn
|
14
13
|
s = Rainbow('ERROR').bg(:red) if type == :error
|
15
14
|
t = Time.now
|
16
|
-
|
17
|
-
|
15
|
+
f = format('%<hour>02d:%<min>02d:%<sec>02d',
|
16
|
+
{ hour: t.hour, min: t.min, sec: t.sec })
|
18
17
|
@report.lines << "[#{f}] #{s}: #{text}"
|
19
18
|
end
|
20
|
-
# rubocop:enable Style/FormatStringToken
|
21
19
|
alias msg log
|
22
20
|
end
|
@@ -61,9 +61,7 @@ class CaseManager
|
|
61
61
|
srcdir = File.join(app.output_basedir, app.global[:tt_testname])
|
62
62
|
puts "[INFO] Preserving files => #{logdir}"
|
63
63
|
FileUtils.mkdir(logdir)
|
64
|
-
Dir.glob('
|
65
|
-
FileUtils.cp(file, logdir)
|
66
|
-
end
|
64
|
+
Dir.glob(srcdir, '**.*').each { |file| FileUtils.cp(file, logdir) }
|
67
65
|
end
|
68
66
|
|
69
67
|
def send(args = {})
|
@@ -2,8 +2,14 @@
|
|
2
2
|
|
3
3
|
require_relative '../application'
|
4
4
|
|
5
|
-
|
5
|
+
##
|
6
|
+
# ExportManager is used by CaseManager to export output reports)
|
6
7
|
module ExportManager
|
8
|
+
##
|
9
|
+
# Run export function
|
10
|
+
# @param main_report (Report)
|
11
|
+
# @param cases (Array)
|
12
|
+
# @param args (Hash) Selected export options
|
7
13
|
def self.run(main_report, cases, args)
|
8
14
|
# default :mode=>:all, :format=>:txt
|
9
15
|
format = args[:format] || Application.instance.default[:format]
|
@@ -38,7 +38,7 @@ class CaseManager
|
|
38
38
|
moodle_id: '', moodle_feedback: '' }
|
39
39
|
else
|
40
40
|
line[:skip] = false
|
41
|
-
line[:id] = format('
|
41
|
+
line[:id] = format('%<id>02d', { id: c.id.to_i })
|
42
42
|
line[:letter] = app.letter[:error] if c.grade < 50.0
|
43
43
|
line[:grade] = c.grade.to_f #format(' %3d', c.grade.to_f)
|
44
44
|
line[:members] = c.members
|
@@ -2,13 +2,19 @@
|
|
2
2
|
|
3
3
|
require_relative 'resume_array_formatter'
|
4
4
|
|
5
|
-
|
5
|
+
##
|
6
|
+
# Format data to Moodle CSV
|
6
7
|
class MoodleCSVFormatter < ResumeArrayFormatter
|
8
|
+
##
|
9
|
+
# initialize instance
|
10
|
+
# @param report (Report)
|
7
11
|
def initialize(report)
|
8
12
|
super(report)
|
9
13
|
@data = {}
|
10
14
|
end
|
11
15
|
|
16
|
+
##
|
17
|
+
# Process internal data and generates data with format
|
12
18
|
def process
|
13
19
|
build_data
|
14
20
|
process_cases
|
@@ -21,8 +27,12 @@ class MoodleCSVFormatter < ResumeArrayFormatter
|
|
21
27
|
# MoodleID, Grade, Feedback
|
22
28
|
w "MoodleID, TeutonGrade, TeutonFeedback\n"
|
23
29
|
@data[:cases].each do |line|
|
24
|
-
|
25
|
-
|
30
|
+
moodle_id = line[:moodle_id]
|
31
|
+
moodle_id = line[:moodle_id].split(',') if moodle_id.class == String
|
32
|
+
moodle_id.each do |id|
|
33
|
+
w "#{id.strip},#{line[:grade]}," \
|
34
|
+
"#{line[:moodle_feedback]}\n" unless line[:skip]
|
35
|
+
end
|
26
36
|
end
|
27
37
|
end
|
28
38
|
end
|
@@ -6,7 +6,7 @@ require_relative 'resume_array_formatter'
|
|
6
6
|
|
7
7
|
# TXTFormatter class
|
8
8
|
class ResumeTXTFormatter < ResumeArrayFormatter
|
9
|
-
def initialize(report, color=false)
|
9
|
+
def initialize(report, color = false)
|
10
10
|
@color = color
|
11
11
|
super(report)
|
12
12
|
@data = {}
|
@@ -30,60 +30,61 @@ class ResumeTXTFormatter < ResumeArrayFormatter
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def process_config
|
33
|
-
w "#{Rainbow(
|
33
|
+
w "#{Rainbow('CONFIGURATION').bg(:blue)}\n"
|
34
34
|
my_screen_table = Terminal::Table.new do |st|
|
35
|
-
@data[:config].each do |key,value|
|
36
|
-
st.add_row [
|
35
|
+
@data[:config].each do |key, value|
|
36
|
+
st.add_row [key.to_s, trim(value)]
|
37
37
|
end
|
38
38
|
end
|
39
|
-
w my_screen_table
|
39
|
+
w "#{my_screen_table}\n\n"
|
40
40
|
end
|
41
41
|
|
42
|
+
# rubocop:disable Metrics/MethodLength
|
42
43
|
def process_cases
|
43
44
|
w "#{Rainbow('CASES').bg(:blue)}\n"
|
44
|
-
|
45
45
|
my_screen_table = Terminal::Table.new do |st|
|
46
|
-
st.add_row [
|
46
|
+
st.add_row %w[CASE MEMBERS GRADE STATE]
|
47
47
|
@data[:cases].each do |line|
|
48
|
-
st.add_row [
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
st.add_row [line[:id],
|
49
|
+
line[:members],
|
50
|
+
format(' %<grade>3d', { grade: line[:grade] }),
|
51
|
+
line[:letter]]
|
52
52
|
end
|
53
53
|
end
|
54
|
-
w my_screen_table
|
54
|
+
w "#{my_screen_table}\n\n"
|
55
55
|
end
|
56
|
+
# rubocop:enable Metrics/MethodLength
|
56
57
|
|
57
58
|
def process_conn_errors
|
58
|
-
w "#{Rainbow('CONN ERRORS').bg(:red)}\n"
|
59
|
-
|
60
59
|
my_screen_table = Terminal::Table.new do |st|
|
61
|
-
st.add_row [
|
60
|
+
st.add_row %w[CASE MEMBERS HOST ERROR]
|
62
61
|
@data[:cases].each do |line|
|
63
62
|
line[:conn_status].each_pair do |h, e|
|
64
|
-
st.add_row [
|
65
|
-
line[:members],
|
66
|
-
h, e ]
|
63
|
+
st.add_row [line[:id], line[:members], h, e]
|
67
64
|
end
|
68
65
|
end
|
69
66
|
end
|
70
|
-
|
67
|
+
return unless my_screen_table.rows.size > 1
|
68
|
+
w "#{Rainbow('CONN ERRORS').bg(:red)}\n"
|
69
|
+
w "#{my_screen_table}\n"
|
71
70
|
end
|
72
71
|
|
73
72
|
def process_results
|
74
|
-
w "\n#{Rainbow(
|
73
|
+
w "\n#{Rainbow('RESULTS').bg(:blue)}\n"
|
75
74
|
my_screen_table = Terminal::Table.new do |st|
|
76
|
-
@data[:results].each do |key,value|
|
77
|
-
st.add_row [
|
75
|
+
@data[:results].each do |key, value|
|
76
|
+
st.add_row [key.to_s, value.to_s]
|
78
77
|
end
|
79
78
|
end
|
80
|
-
w my_screen_table
|
79
|
+
w "#{my_screen_table}\n"
|
81
80
|
end
|
82
81
|
|
82
|
+
# rubocop:disable Metrics/MethodLength
|
83
|
+
# rubocop:disable Metrics/AbcSize
|
83
84
|
def process_hof
|
84
85
|
return if @data[:hall_of_fame].size < 3
|
85
86
|
|
86
|
-
w "\n#{Rainbow(
|
87
|
+
w "\n#{Rainbow('HALL OF FAME').bg(:blue)}\n"
|
87
88
|
my_screen_table = Terminal::Table.new do |st|
|
88
89
|
@data[:hall_of_fame].each do |line|
|
89
90
|
mycolor = :green
|
@@ -97,6 +98,8 @@ class ResumeTXTFormatter < ResumeArrayFormatter
|
|
97
98
|
st.add_row [text1, text2]
|
98
99
|
end
|
99
100
|
end
|
100
|
-
w my_screen_table
|
101
|
+
w "#{my_screen_table}\n"
|
101
102
|
end
|
103
|
+
# rubocop:enable Metrics/MethodLength
|
104
|
+
# rubocop:enable Metrics/AbcSize
|
102
105
|
end
|
data/lib/teuton/report/report.rb
CHANGED
@@ -28,11 +28,9 @@ class Report
|
|
28
28
|
attr_reader :history
|
29
29
|
##
|
30
30
|
# Class constructor
|
31
|
-
def initialize(id =
|
31
|
+
def initialize(id = '00')
|
32
32
|
@id = id
|
33
|
-
|
34
|
-
number = @id.to_s if @id > 9
|
35
|
-
@filename = "case-#{number}"
|
33
|
+
@filename = "case-#{@id}"
|
36
34
|
@output_dir = Application.instance.output_basedir
|
37
35
|
@head = {}
|
38
36
|
@lines = []
|
data/lib/teuton/report/show.rb
CHANGED
@@ -35,7 +35,7 @@ class Report
|
|
35
35
|
def show_case_list
|
36
36
|
puts 'CASE RESULTS'
|
37
37
|
my_screen_table = Terminal::Table.new do |st|
|
38
|
-
st.add_row ['CASE
|
38
|
+
st.add_row ['CASE', 'MEMBERS', 'GRADE', 'STATE' ]
|
39
39
|
@lines.each do |line|
|
40
40
|
st.add_row [line[:id], line[:members], line[:grade], line[:letter]]
|
41
41
|
end
|
@@ -50,7 +50,7 @@ class Report
|
|
50
50
|
|
51
51
|
puts 'CONN ERRORS'
|
52
52
|
my_screen_table = Terminal::Table.new do |st|
|
53
|
-
st.add_row ['CASE
|
53
|
+
st.add_row ['CASE', 'MEMBERS', 'HOST', 'ERROR']
|
54
54
|
@lines.each do |line|
|
55
55
|
line[:conn_status].each_pair do |h,e|
|
56
56
|
st.add_row [line[:id], line[:members], h, e]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teuton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.8dev1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Vargas Ruiz
|
@@ -336,9 +336,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
336
336
|
version: 2.5.0
|
337
337
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
338
338
|
requirements:
|
339
|
-
- - "
|
339
|
+
- - ">"
|
340
340
|
- !ruby/object:Gem::Version
|
341
|
-
version:
|
341
|
+
version: 1.3.1
|
342
342
|
requirements: []
|
343
343
|
rubygems_version: 3.1.2
|
344
344
|
signing_key:
|