Class: Mu::Command::Cmd_appid

Inherits:
Mu::Command show all
Defined in:
lib/mu/command/cmd_appid.rb

Constant Summary

Constants inherited from Mu::Command

Api

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#ask, #error, #format_float, #get_file_as_string_array, #msg, #shift, #to_boolean

Instance Attribute Details

#addr_indexesObject

Returns the value of attribute addr_indexes.



10
11
12
# File 'lib/mu/command/cmd_appid.rb', line 10

def addr_indexes
  @addr_indexes
end

#apiObject

Returns the value of attribute api.



10
11
12
# File 'lib/mu/command/cmd_appid.rb', line 10

def api
  @api
end

#hashObject

Returns the value of attribute hash.



10
11
12
# File 'lib/mu/command/cmd_appid.rb', line 10

def hash
  @hash
end

#hostsObject

Returns the value of attribute hosts.



10
11
12
# File 'lib/mu/command/cmd_appid.rb', line 10

def hosts
  @hosts
end

#paramsObject

Returns the value of attribute params.



10
11
12
# File 'lib/mu/command/cmd_appid.rb', line 10

def params
  @params
end

Instance Method Details

#cmd_help(argv) ⇒ Object

displays command-line help



13
14
15
# File 'lib/mu/command/cmd_appid.rb', line 13

def cmd_help argv
    help
end

#cmd_run_dir(argv) ⇒ Object

runs through a directory of msl files and executes a Studio Scale test for each one

* argv = command-line arguments, require a directory (-d) argument
 * optional -r argument for recursive directory search (default is a flat directory)


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/mu/command/cmd_appid.rb', line 68

def cmd_run_dir argv
    puts "\n***WARNING***\nThe following commands will be deprecated in a future release:"
    puts "cmd_runscale:run_file, cmd_runscale:run_dir, cmd_appid\n"
    puts "Please use 'cmd_runscale:run_files'"
    setup argv

    if not @hash['dir']
        raise "*** Error: directory required, using -d option"
    else
        dir = @hash['dir']
    end

    File.delete("app_id_status.json") if File.exists?("app_id_status.json")
    File.delete("app_id_stats.csv") if File.exists?("app_id_stats.csv")

    @api = Scale.new(@@mu_ip, @@mu_admin_user, @@mu_admin_pass)
    @api.configure("pattern", @cmd_line_pattern)
    @params = {}
    @params["dir"] = dir
    @params["hosts"] = @cmd_line_hosts
    Dir.chdir(@params["dir"])
    File.delete("app_id_status.json") if File.exists?("app_id_status.json")
    if @hash['recursive'].nil?
        files = Dir.glob("*.msl")
    else
        files = Dir.glob("**/*.msl")
    end
    if !files.empty?
        files.sort.each do | f |
            run(f)
            output_csv(f)
            sleep 2
        end
    else
        msg "no msl files found in #{dir}"
    end
    @api.release
end

#cmd_run_file(argv) ⇒ Object

runs a single Studio Scale test

* argv = command-line arguments, requires a scenario (-s) argument


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
# File 'lib/mu/command/cmd_appid.rb', line 37

def cmd_run_file argv
    puts "\n***WARNING***\nThe following commands will be deprecated in a future release:"
    puts "cmd_runscale:run_file, cmd_runscale:run_dir, cmd_appid\n"
    puts "Please use 'cmd_runscale:run_files'"
    setup argv

    if not @hash['scenario']
        raise "*** Error: scenario required, using -s option"
    else
        scenario = @hash['scenario']
    end

    if !File.exists?(scenario)
        raise "*** Error: Scenario file #{scenario} was not found"
    end

    File.delete("app_id_status.json") if File.exists?("app_id_status.json")
    File.delete("app_id_stats.csv") if File.exists?("app_id_stats.csv")

    @api = Scale.new(@@mu_ip, @@mu_admin_user, @@mu_admin_pass)
    @api.configure("pattern", @cmd_line_pattern)
    @params = {}
    @params["msl"] = scenario
    @params["hosts"] = @cmd_line_hosts
    run(scenario)
    @api.release
end

#cmd_running?(argv) ⇒ Boolean

returns a boolean indicating whether the scale test is running or not

* argv = command-line arguments

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mu/command/cmd_appid.rb', line 19

def cmd_running? argv
    if @api.nil?
        msg "false"
        return
    end

    status = @api.status
    if !status.nil?
        if !status["status"].nil?
            msg status["status"]["running"]
        end
    else
        msg "false"
    end
end