Class: Case
- Inherits:
-
Object
- Object
- Case
- Defined in:
- lib/teuton/case_manager/case/case.rb,
lib/teuton/case_manager/case/play.rb,
lib/teuton/case_manager/case/close.rb,
lib/teuton/case_manager/case/config.rb,
lib/teuton/case_manager/case/runner.rb,
lib/teuton/case_manager/case/builtin/main.rb
Overview
Class Case::Config
-
get
-
set
-
unset
-
missing_method
Defined Under Namespace
Classes: Config
Constant Summary collapse
- @@id =
First case ID value
"01"
Instance Attribute Summary collapse
-
#action ⇒ Object
TODO: why not reader only???.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#conn_status ⇒ Object
readonly
Returns the value of attribute conn_status.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#result ⇒ Object
Returns the value of attribute result.
-
#skip ⇒ Object
(also: #skip?)
readonly
Returns the value of attribute skip.
-
#uniques ⇒ Object
readonly
Returns the value of attribute uniques.
Instance Method Summary collapse
- #close(uniques) ⇒ Object
- #close_opened_sessions ⇒ Object
-
#export(format) ⇒ Object
Export Case with specific output format.
-
#filename ⇒ Object
Return case report filename.
-
#grade ⇒ Object
Return case grade.
- #host(host = "localhost") ⇒ Object
-
#initialize(config) ⇒ Case
constructor
Initialize case from specified config.
-
#members ⇒ Object
Return case members.
-
#play ⇒ Object
(also: #start)
Execute “play” order on this case.
-
#show ⇒ Object
Show case report data on screen.
Methods included from Utils
#encode_and_split, #ensure_dir, #my_execute, #verbose, #verboseln
Methods included from DSL
#expect, #expect2, #expect_any, #expect_first, #expect_last, #expect_none, #expect_one, #get, #gett, #goto, #log, #macro, #method_missing, #readme, #remote_tempdir, #remote_tempfile, #respond_to_missing?, #run, #send, #set, #target, #tempdir, #tempfile, #unique, #unset, #weight
Constructor Details
#initialize(config) ⇒ Case
Initialize case from specified config
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/teuton/case_manager/case/case.rb', line 35 def initialize(config) app = Application.instance @config = Case::Config.new(local: config, global: app.global) @groups = app.groups @id = @@id @@id = @@id.next # Define Case Report @report = Report.new(@id) @report.output_dir = File.join("var", @config.global[:tt_testname]) ensure_dir @report.output_dir # Default configuration @skip = false @skip = get(:tt_skip) unless get(:tt_skip) == "NODATA" unless app.["case"].nil? @skip = true @skip = false if app.["case"].include? @id.to_i end @conn_status = {} @tmpdir = File.join("var", @config.get(:tt_testname), "tmp", @id.to_s) # ensure_dir @tmpdir # REVISE: When we will need this? Samba? @remote_tmpdir = File.join("/", "tmp") @unique_values = {} @result = Result.new @debug = Application.instance.debug @verbose = Application.instance.verbose @action_counter = 0 @action = { id: 0, weight: 1.0, description: "No description!", groupname: nil } @uniques = [] @sessions = {} # Store opened sessions for this case tempfile :default end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DSL
Instance Attribute Details
#action ⇒ Object
TODO: why not reader only???
27 28 29 |
# File 'lib/teuton/case_manager/case/case.rb', line 27 def action @action end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
28 29 30 |
# File 'lib/teuton/case_manager/case/case.rb', line 28 def config @config end |
#conn_status ⇒ Object (readonly)
Returns the value of attribute conn_status.
28 29 30 |
# File 'lib/teuton/case_manager/case/case.rb', line 28 def conn_status @conn_status end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28 29 30 |
# File 'lib/teuton/case_manager/case/case.rb', line 28 def id @id end |
#result ⇒ Object
Returns the value of attribute result.
26 27 28 |
# File 'lib/teuton/case_manager/case/case.rb', line 26 def result @result end |
#skip ⇒ Object (readonly) Also known as: skip?
Returns the value of attribute skip.
29 30 31 |
# File 'lib/teuton/case_manager/case/case.rb', line 29 def skip @skip end |
#uniques ⇒ Object (readonly)
Returns the value of attribute uniques.
28 29 30 |
# File 'lib/teuton/case_manager/case/case.rb', line 28 def uniques @uniques end |
Instance Method Details
#close(uniques) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/teuton/case_manager/case/close.rb', line 5 def close(uniques) fails = 0 @uniques.each do |key| next unless uniques[key].include?(id) && uniques[key].count > 1 fails += 1 (key, uniques[key]) end @report.tail[:unique_fault] = fails @report.close end |
#close_opened_sessions ⇒ Object
29 30 31 32 33 |
# File 'lib/teuton/case_manager/case/play.rb', line 29 def close_opened_sessions @sessions.each_value do |s| s.close if s.instance_of? Net::SSH::Connection::Session end end |
#export(format) ⇒ Object
Export Case with specific output format
82 83 84 85 86 |
# File 'lib/teuton/case_manager/case/case.rb', line 82 def export(format) return if skip? @report.export format end |
#filename ⇒ Object
Return case report filename
91 92 93 |
# File 'lib/teuton/case_manager/case/case.rb', line 91 def filename @report.filename end |
#grade ⇒ Object
Return case grade
98 99 100 101 102 |
# File 'lib/teuton/case_manager/case/case.rb', line 98 def grade return 0.0 if skip @report.tail[:grade] end |
#host(host = "localhost") ⇒ Object
4 5 6 |
# File 'lib/teuton/case_manager/case/builtin/main.rb', line 4 def host(host = "localhost") TeutonHost.new(self, host) end |
#members ⇒ Object
Return case members
106 107 108 109 110 |
# File 'lib/teuton/case_manager/case/case.rb', line 106 def members return "-" if skip @report.head[:tt_members] || "noname" end |
#play ⇒ Object Also known as: start
Execute “play” order on this case
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/teuton/case_manager/case/play.rb', line 12 def play if skip? verbose "Skipping case <#{@config.get(:tt_members)}>\n" return false end # TODO: Delete old reports??? start_time = Time.now if get(:tt_sequence) == true play_in_sequence else play_in_parallel end fill_report(start_time, Time.now) close_opened_sessions end |
#show ⇒ Object
Show case report data on screen
119 120 121 |
# File 'lib/teuton/case_manager/case/case.rb', line 119 def show @report.show end |