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
-
run_local_cmd
-
run_remote_cmd
-
run_remote_cmd_ssh
-
run_remote_cmd_telnet
Defined Under Namespace
Classes: Config
Constant Summary collapse
- @@id =
1
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.
-
#uniques ⇒ Object
readonly
Returns the value of attribute uniques.
Instance Method Summary collapse
- #close(uniques) ⇒ Object
- #close_opened_sessions ⇒ Object
- #export(format) ⇒ Object
- #filename ⇒ Object
- #grade ⇒ Object
-
#initialize(config) ⇒ Case
constructor
A new instance of Case.
- #members ⇒ Object
- #package(param) ⇒ Object
- #play ⇒ Object (also: #start)
- #service(param) ⇒ Object
- #show ⇒ Object
- #skip ⇒ Object (also: #skip?)
- #user(param) ⇒ Object
Methods included from Utils
#encode_and_split, #ensure_dir, #my_execute, #verbose, #verboseln
Methods included from DSL
#check, #command, #expect, #expect2, #expect_any, #expect_none, #expect_one, #get, #gett, #goto, #log, #method_missing, #readme, #remote_tempdir, #remote_tempfile, #request, #run, #send, #set, #target, #tempdir, #tempfile, #unique, #unset, #weight
Constructor Details
#initialize(config) ⇒ Case
Returns a new instance of Case.
31 32 33 34 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 |
# File 'lib/teuton/case_manager/case/case.rb', line 31 def initialize(config) app = Application.instance @config = Case::Config.new(local: config, global: app.global) @groups = app.groups @id = @@id @@id += 1 # 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 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 |
#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
24 25 26 27 28 |
# File 'lib/teuton/case_manager/case/play.rb', line 24 def close_opened_sessions @sessions.each_value do |s| s.close if s.class == Net::SSH::Connection::Session end end |
#export(format) ⇒ Object
73 74 75 76 |
# File 'lib/teuton/case_manager/case/case.rb', line 73 def export(format) return if skip? @report.export format end |
#filename ⇒ Object
78 79 80 |
# File 'lib/teuton/case_manager/case/case.rb', line 78 def filename @report.filename #+ '.' + @report.format.to_s end |
#grade ⇒ Object
82 83 84 85 |
# File 'lib/teuton/case_manager/case/case.rb', line 82 def grade return 0.0 if skip @report.tail[:grade] end |
#members ⇒ Object
87 88 89 90 |
# File 'lib/teuton/case_manager/case/case.rb', line 87 def members return '-' if skip @report.head[:tt_members] || 'noname' end |
#package(param) ⇒ Object
7 8 9 10 11 |
# File 'lib/teuton/case_manager/case/builtin/main.rb', line 7 def package(param) @package = @package || Package.new(self) @package.param = param @package end |
#play ⇒ Object Also known as: start
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/teuton/case_manager/case/play.rb', line 10 def play if skip? verbose "Skipping case <#{@config.get(:tt_members)}>\n" return false end # TODO: Delete old reports??? start_time = Time.now play_in_sequence if get(:tt_sequence) == true # Play in sequence play_in_parallel if get(:tt_sequence) != true # Play in parallel fill_report(start_time, Time.now) close_opened_sessions end |
#service(param) ⇒ Object
13 14 15 16 17 |
# File 'lib/teuton/case_manager/case/builtin/main.rb', line 13 def service(param) @service = @service || Service.new(self) @service.param = param @service end |
#show ⇒ Object
97 98 99 |
# File 'lib/teuton/case_manager/case/case.rb', line 97 def show @report.show end |
#skip ⇒ Object Also known as: skip?
92 93 94 |
# File 'lib/teuton/case_manager/case/case.rb', line 92 def skip @skip end |