mu 5.7.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/Mu_Gem.html +1591 -0
  2. data/bin/mu +11 -0
  3. data/lib/mu.rb +65 -0
  4. data/lib/mu/api/ddt.rb +233 -0
  5. data/lib/mu/api/homepage.rb +54 -0
  6. data/lib/mu/api/muapi.rb +231 -0
  7. data/lib/mu/api/netconfig.rb +233 -0
  8. data/lib/mu/api/scale.rb +199 -0
  9. data/lib/mu/api/system.rb +40 -0
  10. data/lib/mu/client.rb +31 -0
  11. data/lib/mu/command.rb +28 -0
  12. data/lib/mu/command/api.rb +95 -0
  13. data/lib/mu/command/cmd_appid.rb +486 -0
  14. data/lib/mu/command/cmd_cli.rb +151 -0
  15. data/lib/mu/command/cmd_ddt.rb +449 -0
  16. data/lib/mu/command/cmd_homepage.rb +146 -0
  17. data/lib/mu/command/cmd_muapi.rb +361 -0
  18. data/lib/mu/command/cmd_netconfig.rb +262 -0
  19. data/lib/mu/command/cmd_runscale.rb +533 -0
  20. data/lib/mu/command/cmd_runscenario.rb +258 -0
  21. data/lib/mu/command/cmd_runverify.rb +336 -0
  22. data/lib/mu/command/cmd_scale.rb +333 -0
  23. data/lib/mu/command/cmd_system.rb +127 -0
  24. data/lib/mu/command/curl.rb +246 -0
  25. data/lib/mu/command/help.rb +29 -0
  26. data/lib/mu/curl/error.rb +54 -0
  27. data/lib/mu/curl/verify.rb +137 -0
  28. data/lib/mu/helper.rb +55 -0
  29. data/lib/mu/http_helper.rb +232 -0
  30. data/rdoc/classes/Mu.html +305 -0
  31. data/rdoc/classes/Mu/Client.html +265 -0
  32. data/rdoc/classes/Mu/Command.html +208 -0
  33. data/rdoc/classes/Mu/Command/API.html +524 -0
  34. data/rdoc/classes/Mu/Command/Cmd_appid.html +934 -0
  35. data/rdoc/classes/Mu/Command/Cmd_cli.html +515 -0
  36. data/rdoc/classes/Mu/Command/Cmd_ddt.html +1169 -0
  37. data/rdoc/classes/Mu/Command/Cmd_homepage.html +489 -0
  38. data/rdoc/classes/Mu/Command/Cmd_muapi.html +968 -0
  39. data/rdoc/classes/Mu/Command/Cmd_netconfig.html +743 -0
  40. data/rdoc/classes/Mu/Command/Cmd_runscale.html +970 -0
  41. data/rdoc/classes/Mu/Command/Cmd_runscenario.html +530 -0
  42. data/rdoc/classes/Mu/Command/Cmd_runverify.html +621 -0
  43. data/rdoc/classes/Mu/Command/Cmd_scale.html +939 -0
  44. data/rdoc/classes/Mu/Command/Cmd_system.html +426 -0
  45. data/rdoc/classes/Mu/Command/Curl.html +524 -0
  46. data/rdoc/classes/Mu/Command/Help.html +166 -0
  47. data/rdoc/classes/Mu/Curl.html +116 -0
  48. data/rdoc/classes/Mu/Curl/Error.html +157 -0
  49. data/rdoc/classes/Mu/Curl/Error/Authorize.html +178 -0
  50. data/rdoc/classes/Mu/Curl/Error/Connect.html +149 -0
  51. data/rdoc/classes/Mu/Curl/Error/DNS.html +113 -0
  52. data/rdoc/classes/Mu/Curl/Error/Region.html +160 -0
  53. data/rdoc/classes/Mu/Curl/Error/Status.html +149 -0
  54. data/rdoc/classes/Mu/Curl/Error/Timeout.html +149 -0
  55. data/rdoc/classes/Mu/Curl/Verify.html +282 -0
  56. data/rdoc/classes/Mu/Curl/Verify/Request.html +227 -0
  57. data/rdoc/classes/Mu/Curl/Verify/Response.html +187 -0
  58. data/rdoc/classes/Mu/Curl/Verify/Result.html +188 -0
  59. data/rdoc/classes/Mu/Ddt.html +914 -0
  60. data/rdoc/classes/Mu/Helper.html +308 -0
  61. data/rdoc/classes/Mu/Homepage.html +377 -0
  62. data/rdoc/classes/Mu/HttpHelper.html +639 -0
  63. data/rdoc/classes/Mu/Muapi.html +816 -0
  64. data/rdoc/classes/Mu/Netconfig.html +781 -0
  65. data/rdoc/classes/Mu/Scale.html +832 -0
  66. data/rdoc/classes/Mu/System.html +281 -0
  67. data/rdoc/classes/Object.html +148 -0
  68. data/rdoc/classes/TCTestMu.html +1793 -0
  69. data/rdoc/classes/Test.html +107 -0
  70. data/rdoc/classes/Test/Unit.html +107 -0
  71. data/rdoc/classes/Test/Unit/TestCase.html +113 -0
  72. data/rdoc/created.rid +1 -0
  73. data/rdoc/files/lib/mu/api/ddt_rb.html +101 -0
  74. data/rdoc/files/lib/mu/api/homepage_rb.html +101 -0
  75. data/rdoc/files/lib/mu/api/muapi_rb.html +101 -0
  76. data/rdoc/files/lib/mu/api/netconfig_rb.html +101 -0
  77. data/rdoc/files/lib/mu/api/scale_rb.html +101 -0
  78. data/rdoc/files/lib/mu/api/system_rb.html +101 -0
  79. data/rdoc/files/lib/mu/client_rb.html +101 -0
  80. data/rdoc/files/lib/mu/command/api_rb.html +101 -0
  81. data/rdoc/files/lib/mu/command/cmd_appid_rb.html +119 -0
  82. data/rdoc/files/lib/mu/command/cmd_cli_rb.html +108 -0
  83. data/rdoc/files/lib/mu/command/cmd_ddt_rb.html +117 -0
  84. data/rdoc/files/lib/mu/command/cmd_homepage_rb.html +115 -0
  85. data/rdoc/files/lib/mu/command/cmd_muapi_rb.html +116 -0
  86. data/rdoc/files/lib/mu/command/cmd_netconfig_rb.html +116 -0
  87. data/rdoc/files/lib/mu/command/cmd_runscale_rb.html +119 -0
  88. data/rdoc/files/lib/mu/command/cmd_runscenario_rb.html +115 -0
  89. data/rdoc/files/lib/mu/command/cmd_runverify_rb.html +117 -0
  90. data/rdoc/files/lib/mu/command/cmd_scale_rb.html +115 -0
  91. data/rdoc/files/lib/mu/command/cmd_system_rb.html +116 -0
  92. data/rdoc/files/lib/mu/command/curl_rb.html +101 -0
  93. data/rdoc/files/lib/mu/command/help_rb.html +101 -0
  94. data/rdoc/files/lib/mu/command_rb.html +107 -0
  95. data/rdoc/files/lib/mu/curl/error_rb.html +101 -0
  96. data/rdoc/files/lib/mu/curl/verify_rb.html +101 -0
  97. data/rdoc/files/lib/mu/helper_rb.html +101 -0
  98. data/rdoc/files/lib/mu/http_helper_rb.html +101 -0
  99. data/rdoc/files/lib/mu_rb.html +121 -0
  100. data/rdoc/files/test/helper_rb.html +112 -0
  101. data/rdoc/files/test/tc_test_mu_rb.html +111 -0
  102. data/rdoc/fr_class_index.html +68 -0
  103. data/rdoc/fr_file_index.html +55 -0
  104. data/rdoc/fr_method_index.html +374 -0
  105. data/rdoc/index.html +24 -0
  106. data/rdoc/rdoc-style.css +208 -0
  107. data/test/data/app_id_stats.csv +1 -0
  108. data/test/data/data_cgi.msl +94 -0
  109. data/test/data/data_cgi.xml +322 -0
  110. data/test/data/default_test.csv +3 -0
  111. data/test/data/ftp_with_channel.xml +1643 -0
  112. data/test/data/irc.xml +3837 -0
  113. data/test/data/scale_configuration.json +25 -0
  114. data/test/data/test_data_cgi_error.xml +35 -0
  115. data/test/helper.rb +18 -0
  116. data/test/tc_test_mu.rb +716 -0
  117. metadata +322 -0
@@ -0,0 +1,25 @@
1
+ {
2
+ "musl": "scenario(name: \"data_cgi\") {\n hosts {\n # a2/192.168.40.217|\n &host_0 = host(type: v4)\n # 192.168.40.9|\n &host_1 = host(type: v4)\n }\n\n options {\n # data_length|data length\n $data_length = \"3\"\n # data|data\n $data = \"123\"\n # data_type|data type\n $data_type = \"numbers\"\n # url|url\n $url = \"/whats_my_data.cgi?data\"\n # http_port|http_port\n $http_port = \"80\"\n }\n\n steps {\n HTTP_80 = tcp(timeout: 10000, src: &host_0, dst: &host_1, dst_port: $http_port)\n\n # GET /whats_my_data.cgi?data=123 HTTP/1.1\n HTTP_GET_Client_Send = HTTP_80.client_send {\n # get|GET /whats_my_data.cgi?data=123 HTTP/1.1\\r\\n\n line [\n dsv(delimiter: \" \") [\n # request_method|Request Method: GET\n \"GET\"\n dsv(delimiter: \"=\") [\n $url\n $data\n ]\n \"HTTP/1.1\"\n ]\n ]\n # host|Host: dell-9\\r\\n\n \"Host: dell-9\\r\\n\"\n # user_agent|User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3\\r\\n\n \"User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3\\r\\n\"\n # accept|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\\r\\n\n \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\\r\\n\"\n # accept_language|Accept-Language: en-us,en;q=0.5\\r\\n\n \"Accept-Language: en-us,en;q=0.5\\r\\n\"\n # accept_encoding|Accept-Encoding: gzip,deflate\\r\\n\n \"Accept-Encoding: gzip,deflate\\r\\n\"\n # accept_charset|Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\\r\\n\n \"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\\r\\n\"\n # keep_alive|Keep-Alive: 300\\r\\n\n \"Keep-Alive: 300\\r\\n\"\n # connection|Connection: keep-alive\\r\\n\n \"Connection: keep-alive\\r\\n\"\n # cache_control|Cache-Control: max-age=0\\r\\n\n \"Cache-Control: max-age=0\\r\\n\"\n # |\\r\\n\n \"\\r\\n\"\n }\n\n # GET /whats_my_data.cgi?data=123 HTTP/1.1\n HTTP_GET_Server_Receive = HTTP_GET_Client_Send.server_receive\n\n # HTTP/1.1 200 OK (text/html)\n HTTP_Server_Send = HTTP_80.server_send {\n # http|HTTP/1.1 200 OK\\r\\n\n \"HTTP/1.1 200 OK\\r\\n\"\n # date|Date: Wed, 16 Sep 2009 00:09:17 GMT\\r\\n\n \"Date: Wed, 16 Sep 2009 00:09:17 GMT\\r\\n\"\n # server|Server: Apache/2.0.52 (CentOS)\\r\\n\n \"Server: Apache/2.0.52 (CentOS)\\r\\n\"\n # content_length_header|Content-Length: 243\\r\\n\n \"Content-Length: 243\\r\\n\"\n # connection|Connection: close\\r\\n\n \"Connection: close\\r\\n\"\n # content_type|Content-Type: text/html; charset=UTF-8\\r\\n\n \"Content-Type: text/html; charset=UTF-8\\r\\n\"\n # |\\r\\n\n \"\\r\\n\"\n \"<\"\n \"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 4.01//EN\\\" \\\"http://www.w3.org/TR/html4/strict.dtd\\\"><HTML><HEAD><TITLE>What\\'s My Data?</TITLE></HEAD><BODY><H1>Data has been analyzed</H1><P>Input: 123</P><P>Length: 3</P><P>Type: numbers</P></BODY></HTML>\"\n }\n\n # HTTP/1.1 200 OK (text/html)\n HTTP_Client_Receive = HTTP_Server_Send.client_receive {\n assertions {\n # data type check\n string(/Type: (.+?)</:1) == $data_type\n # data length check\n string(/Length: (.+?)</:1) >= $data_length\n }\n }\n }\n}",
3
+ "holdConcurrency": true,
4
+ "vectorAddressPairing": false,
5
+ "delay": 0,
6
+ "timeout": 5000,
7
+ "limitConcurrency": false,
8
+ "hosts": {
9
+ "host_0": "b1/*,10000,1",
10
+ "host_1": "b2/*"
11
+ },
12
+ "pattern": {
13
+ "iterations": 1,
14
+ "intervals": [
15
+ {
16
+ "duration": 10,
17
+ "iterations": 1,
18
+ "end": 100,
19
+ "start": 1
20
+ }
21
+ ]
22
+ },
23
+ "csv": "",
24
+ "volume": 1
25
+ }
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <mu_config version="5.0">
3
+ <templates>
4
+ <ddt_set name="test_data_cgi_error" uuid="49cd406e-a8ca-4360-a115-e7ac33e8034f">
5
+ <io_delay>0</io_delay>
6
+ <commands>
7
+ <defaults_command>
8
+ <options>
9
+ <option>
10
+ <name>scenario_user_options.data</name>
11
+ <value>123</value>
12
+ </option>
13
+ <option>
14
+ <name>scenario_user_options.data_length</name>
15
+ <value>3</value>
16
+ </option>
17
+ <option>
18
+ <name>scenario_user_options.data_type</name>
19
+ <value>numbers</value>
20
+ </option>
21
+ </options>
22
+ </defaults_command>
23
+ <test_command>
24
+ <options>
25
+ <option>
26
+ <name>scenario_user_options.data_type</name>
27
+ <value>words</value>
28
+ </option>
29
+ </options>
30
+ <name>error</name>
31
+ </test_command>
32
+ </commands>
33
+ </ddt_set>
34
+ </templates>
35
+ </mu_config>
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'mu'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,716 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'lib/mu'
4
+ require 'json'
5
+
6
+ class Object
7
+ def deep_clone
8
+ Marshal::load(Marshal.dump(self))
9
+ end
10
+ end
11
+
12
+ class TCTestMu < Test::Unit::TestCase
13
+
14
+ $dir = Dir.pwd
15
+
16
+
17
+
18
+ def setup
19
+ $log.level = Logger::INFO
20
+ @mu_ip = ENV['MU_IP']
21
+ @mu_admin_user = ENV['MU_ADMIN_USER']
22
+ @mu_admin_pass = ENV['MU_ADMIN_PASS']
23
+ Dir.chdir($dir)
24
+ $cookie = nil # reset for htto_helper
25
+ # puts "pwd = #{Dir.pwd}"
26
+ end
27
+
28
+ def teardown
29
+
30
+ end
31
+
32
+ # -------------- cmd_appid ----------------
33
+
34
+ # use ip range setting and a brief pattern
35
+ def test_cmd_appid_run_file
36
+ File.delete("app_id_status.json") if File.exists?("app_id_status.json")
37
+ app = Mu::Command::Cmd_appid.new
38
+ args = Array.new
39
+ args << "-s"
40
+ args << "#{Dir.pwd}/test/data/data_cgi.msl"
41
+ args << "-i"
42
+ args << "b1-10000,b2"
43
+ args << "-p"
44
+ args << "1-100:10"
45
+ app.cmd_run_file args
46
+ assert(File.exists?("app_id_status.json"), "app_id_status.json file was not created")
47
+ j = JSON File.read("app_id_status.json")
48
+ status = j["status"]
49
+ assert(status["statistics"]["summary"]["duration"].to_f >= 10.0, "expected summary duration > 10, but got #{status["statistics"]["summary"]["duration"]}")
50
+ assert(status["statistics"]["summary"]["instances"]["executed"].to_i > 10, "expected instances executed > 0, but got #{status["statistics"]["summary"]["instances"]["executed"]}")
51
+ end
52
+
53
+ # use ip range setting and a brief pattern
54
+ def test_cmd_appid_run_dir
55
+ File.delete("app_id_status.json") if File.exists?("app_id_status.json")
56
+ app = Mu::Command::Cmd_appid.new
57
+ args = Array.new
58
+ args << "-d"
59
+ args << "#{Dir.pwd}/test/data"
60
+ args << "-i"
61
+ args << "b1-10000,b2"
62
+ args << "-p"
63
+ args << "1-100:10"
64
+ app.cmd_run_dir args
65
+ sleep 2
66
+ assert(File.exists?("app_id_status.json"), "app_id_status.json file was not created")
67
+ j = JSON File.read("app_id_status.json")
68
+ status = j["status"]
69
+ assert(status["statistics"]["summary"]["duration"].to_f >= 10.0, "expected summary duration > 10, but got #{status["statistics"]["summary"]["duration"]}")
70
+ assert(status["statistics"]["summary"]["instances"]["executed"].to_i > 10, "expected instances executed > 0, but got #{status["statistics"]["summary"]["instances"]["executed"]}")
71
+ end
72
+
73
+
74
+ # -------------- cmd_cli ----------------
75
+
76
+ def test_cli_history
77
+ api = Mu::Command::Cmd_cli.new
78
+ result = api.cmd_history []
79
+ puts result
80
+ assert result==true, "expected 'true'"
81
+ end
82
+
83
+ def test_cli_question
84
+ api = Mu::Command::Cmd_cli.new
85
+ result = api.cmd_question []
86
+ puts result
87
+ assert result==true, "expected 'true'"
88
+ end
89
+
90
+ # -------------- cmd_ddt --------------
91
+
92
+ def test_cmd_ddt_get_all_sessions
93
+ api = Mu::Command::Cmd_ddt.new
94
+ api.cmd_close_all_sessions []
95
+ api.cmd_new_session []
96
+ api.cmd_new_session []
97
+ sessions = Nokogiri::XML(api.cmd_get_all_sessions [])
98
+ sess = sessions.xpath("//session")
99
+ assert(sess.length == 2, "expected 2 sessions, got #{sess.length}")
100
+ ensure
101
+ api.cmd_close_all_sessions []
102
+ end
103
+
104
+ def test_cmd_ddt_csv_import_export
105
+ api = Mu::Command::Cmd_ddt.new
106
+ api.cmd_close_all_sessions []
107
+ api.cmd_new_session []
108
+ response = Nokogiri::XML(api.cmd_csv_import [ "-t", "#{Dir.pwd}/test/data/default_test.csv"])
109
+ status = response.xpath("//status")[0].content
110
+ assert(status == "true", "expected status=true, got #{status}")
111
+ uuid = response.xpath("//message")[0].content
112
+ response = Nokogiri::XML(api.cmd_csv_export ["-u", uuid ])
113
+ status = response.xpath("//status")[0].content
114
+ assert(status == "true", "expected status=true, got #{status}")
115
+ ensure
116
+ api.cmd_close_all_sessions []
117
+ end
118
+
119
+ def test_cmd_ddt_get_set_options
120
+ scenario_uuid = "ef6fe3eb-4e9f-44b5-a99e-c431d82e4eeb"
121
+ #test_set_uuid = "49cd406e-a8ca-4360-a115-e7ac33e8034f"
122
+ api = Mu::Command::Cmd_ddt.new
123
+ api.cmd_close_all_sessions []
124
+ api.cmd_new_session []
125
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
126
+ http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/data_cgi.xml"))
127
+ # http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/test_data_cgi_error.xml"))
128
+ api.cmd_load_scenario [ "-u", scenario_uuid ]
129
+ api.cmd_setup_test []
130
+ response = api.cmd_get_options []
131
+ doc = Nokogiri::XML(response)
132
+ options = doc.xpath("//option/name")
133
+ assert options.length==8, "expected 8 scenario options, found #{options.length}"
134
+ response = api.cmd_set_options [ "-n", "scenario_user_options.url", "-p", "hullo" ]
135
+ response.each do | resp |
136
+ doc = Nokogiri::XML(resp)
137
+ message = doc.xpath("//message").text
138
+ assert message.include?("Option set") , "expected 'Option set' but got #{message}"
139
+ end
140
+ ensure
141
+ api.cmd_close_all_sessions []
142
+ end
143
+
144
+ def test_cmd_ddt_get_set_hosts
145
+ scenario_uuid = "ef6fe3eb-4e9f-44b5-a99e-c431d82e4eeb"
146
+ api = Mu::Command::Cmd_ddt.new
147
+ api.cmd_close_all_sessions [ "-v" ]
148
+ api.cmd_new_session []
149
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
150
+ http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/data_cgi.xml"))
151
+ api.cmd_load_scenario [ "-u", scenario_uuid ]
152
+ api.cmd_setup_test []
153
+ response = api.cmd_get_hosts []
154
+ doc = Nokogiri::XML(response)
155
+ hosts = doc.xpath("//host")
156
+ role = doc.xpath("//host/role")[0].text
157
+ assert hosts.length==2, "expected 2 scenario hosts, found #{hosts.length}"
158
+ response = api.cmd_set_hosts [ "-r", role, "-n", "a3" ]
159
+ response.each do | resp |
160
+ doc = Nokogiri::XML(resp)
161
+ message = doc.xpath("//message").text
162
+ assert message.include?("Bind host successfully") , "expected 'Bind host successfully' but got #{message}"
163
+ end
164
+ ensure
165
+ api.cmd_close_all_sessions []
166
+ end
167
+
168
+ def test_cmd_ddt_get_set_channels
169
+ add_localhost_with_channel
170
+ scenario_uuid = "379a4cf8-8fe7-4d2d-8f6b-b8c6b71557b4" # ftp_with_channel
171
+ api = Mu::Command::Cmd_ddt.new
172
+ api.cmd_close_all_sessions [ "-v" ]
173
+ api.cmd_new_session []
174
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
175
+ http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/ftp_with_channel.xml"))
176
+ api.cmd_load_scenario [ "-u", scenario_uuid ]
177
+ api.cmd_setup_test []
178
+ response = api.cmd_get_channels []
179
+ doc = Nokogiri::XML(response)
180
+ channels = doc.xpath("//channel")
181
+ assert channels.length==1, "expected 1 scenario channel, found #{channels.length}"
182
+ response = api.cmd_set_channels [ "-r", "channel", "-n", "localhost" ]
183
+ response.each do | resp |
184
+ doc = Nokogiri::XML(resp)
185
+ message = doc.xpath("//message").text
186
+ assert message.include?("Bind channel successfully") , "expected 'Bind host successfully' but got #{message}"
187
+ end
188
+ ensure
189
+ api.cmd_close_all_sessions []
190
+ end
191
+
192
+ # -------------- ddt ------------------
193
+
194
+ def test_ddt_new
195
+ api = Mu::Ddt.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
196
+ assert(api.host == @mu_ip, "failed to set mu_ip")
197
+ assert(api.docroot == "/api/v5/ddt/", "failed to set docroot")
198
+ end
199
+
200
+ def test_ddt_get_all_sessions
201
+ api = Mu::Ddt.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
202
+ api.new_session
203
+ api.new_session
204
+ sessions = Nokogiri::XML(api.get_all_sessions)
205
+ sess = sessions.xpath("//session")
206
+ assert(sess.length == 2, "expected 2 sessions, got #{sess.length}")
207
+ ensure
208
+ api.close_all_sessions
209
+ end
210
+
211
+ def test_ddt_close_all_sessions
212
+ api = Mu::Ddt.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
213
+ api.new_session
214
+ api.new_session
215
+ api.new_session
216
+ api.close_all_sessions
217
+ sessions = Nokogiri::XML(api.get_all_sessions)
218
+ sess = sessions.xpath("//session")
219
+ assert(sess.length == 0, "expected 0 sessions, got #{sess.length}")
220
+ end
221
+
222
+ def test_ddt_set_hosts
223
+ $log.level = Logger::DEBUG
224
+ data_cgi_uuid = "ef6fe3eb-4e9f-44b5-a99e-c431d82e4eeb"
225
+ api = Mu::Ddt.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
226
+ api.new_session
227
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
228
+ http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/data_cgi.xml"))
229
+ api.load_scenario(data_cgi_uuid)
230
+ api.setup_test
231
+ response = api.set_hosts( ["192.168.40.217","192.168.40.9"], ["a1", "a2"] )
232
+ response.each do | resp |
233
+ doc = Nokogiri::XML(resp)
234
+ message = doc.xpath("//message").text
235
+ assert message.include?("Bind host successfully") , "expected 'Bind host successfully' but got #{message}"
236
+ end
237
+ ensure
238
+ api.close_all_sessions
239
+ end
240
+
241
+ # -------------- cmd_homepage -------------
242
+
243
+ def test_homepage_status
244
+ api = Mu::Command::Cmd_homepage.new
245
+ result = JSON api.cmd_status []
246
+ assert result[0]["title"] == "Licenses", "expected 'Licenses'"
247
+ end
248
+
249
+ def test_homepage_recent
250
+ api = Mu::Command::Cmd_homepage.new
251
+ result = JSON api.cmd_recent []
252
+ assert !result[0]["summary"].nil?, "expected to find a summary field but didn't"
253
+ end
254
+
255
+ def test_homepage_all
256
+ api = Mu::Command::Cmd_homepage.new
257
+ result = JSON api.cmd_all []
258
+ assert !result["status"].nil?, "expected to find a status field but didn't"
259
+ end
260
+
261
+ def test_homepage_latest_test
262
+ api = Mu::Command::Cmd_homepage.new
263
+ result = JSON api.cmd_latest_test []
264
+ assert !result.nil?, "expected to get something back but didn't"
265
+ end
266
+
267
+ # -------------- homepage -------------
268
+
269
+ def test_homepage_new
270
+ api = Mu::Homepage.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
271
+ assert(api.host == @mu_ip, "failed to set mu_ip")
272
+ assert(api.docroot == "/api/v5/homepage/", "failed to set docroot")
273
+ end
274
+
275
+ # -------------- cmd_muapi ------------
276
+
277
+ def test_cmd_muapi_types
278
+ api = Mu::Command::Cmd_muapi.new
279
+ response = api.cmd_types []
280
+ assert(response.include?("scenario"), "expected scenario got #{response}")
281
+ end
282
+
283
+ def test_cmd_muapi_export_by_uuid
284
+ api = Mu::Command::Cmd_muapi.new
285
+ scenario_uuid = "379a4cf8-8fe7-4d2d-8f6b-b8c6b71557b4" # ftp_with_channel
286
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
287
+ http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/ftp_with_channel.xml"))
288
+ response = api.cmd_export_by_uuid(["-u", scenario_uuid]).to_s
289
+ assert response.include?(scenario_uuid), "expected #{scenario_uuid} but did not find it"
290
+ end
291
+
292
+ def test_cmd_muapi_export_by_type_and_name
293
+ api = Mu::Command::Cmd_muapi.new
294
+ scenario_uuid = "379a4cf8-8fe7-4d2d-8f6b-b8c6b71557b4" # ftp_with_channel
295
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
296
+ http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/ftp_with_channel.xml"))
297
+ response = api.cmd_export_by_type_and_name(["-n", "ftp_with_channel", "-t", "scenario"]).to_s
298
+ assert response.include?(scenario_uuid), "expected #{scenario_uuid} but did not find it"
299
+ end
300
+
301
+ def test_cmd_muapi_capture
302
+ api = Mu::Command::Cmd_muapi.new
303
+ run_args = Array.new
304
+ run_args << "-c"
305
+ run_args << "run"
306
+ run_args << "-p"
307
+ run_args << "a1"
308
+ job_id = api.cmd_capture run_args
309
+ sleep 2
310
+ status_args = Array.new
311
+ status_args << "-c"
312
+ status_args << "status"
313
+ status_args << "-p"
314
+ status_args << "a1"
315
+ status_args << "-u"
316
+ status_args << job_id
317
+ status = api.cmd_capture status_args
318
+ sleep 2
319
+ get_args = Array.new
320
+ get_args << "-c"
321
+ get_args << "get"
322
+ get_args << "-p"
323
+ get_args << "a1"
324
+ get_args << "-u"
325
+ get_args << job_id
326
+ api.cmd_capture get_args
327
+ sleep 2
328
+ assert( File.exists?("#{job_id}.pcap"), "expected to find #{job_id}.pcap but didn't")
329
+ end
330
+
331
+ def test_cmd_muapi_analysis
332
+ # $log.level = Logger::DEBUG
333
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
334
+ response = http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/irc.xml"))
335
+ uuid = response.xpath("//uuid")[0].content
336
+ api = Mu::Command::Cmd_muapi.new
337
+
338
+ run_uuid = api.cmd_run make_uuid_args(uuid) # use the run_uuid for subsequent calls
339
+ sleep 2
340
+ status = api.cmd_status make_uuid_args(run_uuid)
341
+ assert(status == "RUNNING", "after RUN, expected status=RUNNING, got #{status}")
342
+ api.cmd_pause make_uuid_args(run_uuid)
343
+ while true
344
+ sleep 2
345
+ status = api.cmd_status make_uuid_args(run_uuid)
346
+ break if status == "SUSPENDED"
347
+ end
348
+ api.cmd_resume make_uuid_args(run_uuid)
349
+ while true
350
+ sleep 2
351
+ status = api.cmd_status make_uuid_args(run_uuid)
352
+ break if status == "RUNNING"
353
+ end
354
+ list = api.cmd_list_by_status ["-s", "running"]
355
+ assert(list.to_s.include?(run_uuid), "expected run_uuid #{run_uuid}in the list_by_status for running, but got #{list}")
356
+ api.cmd_stop make_uuid_args(run_uuid)
357
+ sleep 2
358
+ status = api.cmd_status make_uuid_args(run_uuid)
359
+ assert(status == "ABORTED", "after STOP, expected status=ABORTED, got #{status}")
360
+ name = api.cmd_get_name make_uuid_args(run_uuid) # returns a Nokogiri::XML::Attr
361
+ assert(name.value.include?("irc_scenario_mugem"), "expected name = irc_scenario_mugem but got #{name.value}")
362
+ ensure
363
+ begin
364
+ api.cmd_stop make_uuid_args(run_uuid)
365
+ rescue
366
+ # do nothing. probably already stopped
367
+ end
368
+ end
369
+
370
+ def make_uuid_args(uuid)
371
+ args = Array.new
372
+ args << "-u"
373
+ args << uuid
374
+ args << "-v"
375
+ return args
376
+ end
377
+
378
+ def test_cmd_muapi_archive
379
+ # $log.level = Logger::DEBUG
380
+ # load it
381
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
382
+ response = http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/irc.xml"))
383
+ uuid = response.xpath("//uuid")[0].content
384
+ api = Mu::Command::Cmd_muapi.new
385
+
386
+ # run it
387
+ run_uuid = api.cmd_run make_uuid_args(uuid) # use the run_uuid for subsequent calls
388
+ sleep 2
389
+ status = api.cmd_status make_uuid_args(run_uuid)
390
+ assert(status == "RUNNING", "after RUN, expected status=RUNNING, got #{status}")
391
+ while status == "RUNNING"
392
+ sleep 5
393
+ status = api.cmd_status make_uuid_args(run_uuid)
394
+ end
395
+
396
+ # archive it
397
+ response = api.cmd_archive ["-c", "run", "-u", run_uuid ]
398
+ sleep 5
399
+ status = api.cmd_archive ["-s", "status", "-u", run_uuid ]
400
+
401
+ while true
402
+ status = api.cmd_archive ["-s", "status", "-u", run_uuid ]
403
+ break if status == false
404
+ sleep 5
405
+ end
406
+
407
+ # now get it
408
+ api.cmd_archive ["-c", "get", "-u", run_uuid ]
409
+ file_name = run_uuid.to_s + ".zip"
410
+ assert(File.exists?(file_name), "did not find the expected file #{file_name}")
411
+ end
412
+
413
+ def test_cmd_muapi_delete
414
+ # $log.level = Logger::DEBUG"
415
+ # load it
416
+ http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
417
+ response = http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/irc.xml"))
418
+ uuid = response.xpath("//uuid")[0].content
419
+ api = Mu::Command::Cmd_muapi.new
420
+
421
+ # run it
422
+ run_uuid = api.cmd_run make_uuid_args(uuid) # use the run_uuid for subsequent calls
423
+ sleep 2
424
+ status = api.cmd_status make_uuid_args(run_uuid)
425
+ assert(status == "RUNNING", "after RUN, expected status=RUNNING, got #{status}")
426
+ while status == "RUNNING"
427
+ sleep 5
428
+ status = api.cmd_status make_uuid_args(run_uuid)
429
+ end
430
+
431
+ # now delete it
432
+ status = api.cmd_delete [ "-u", run_uuid ]
433
+ puts status
434
+
435
+ status = api.cmd_status make_uuid_args(run_uuid)
436
+ assert(status.nil?, "expected status=nil, got #{status}")
437
+ end
438
+
439
+ # -------------- muapi ----------------
440
+
441
+ def test_muapi_new
442
+ api = Mu::Muapi.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
443
+ assert(api.host == @mu_ip, "failed to set mu_ip")
444
+ assert(api.docroot == "/api/v3/", "failed to set docroot")
445
+ end
446
+
447
+ def test_muapi_list_by_status
448
+ api = Mu::Muapi.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
449
+ response = api.list_by_status("finished")
450
+ assert(!response.empty?, "got empty response")
451
+ end
452
+
453
+ def test_muapi_types
454
+ api = Mu::Muapi.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
455
+ response = api.types
456
+ assert(response.include?("scenario"), "expected scenario, got\n#{response}")
457
+ end
458
+
459
+ # -------------- cmd_netfconfig -------
460
+
461
+ def test_cmd_netconfig_get_interfaces_a1
462
+ api = Mu::Command::Cmd_netconfig.new
463
+ response = api.cmd_get ["-e", "interfaces/a1"]
464
+ assert(response["display_name"] == "A1", "expected A1 got #{response["display_name"]}")
465
+ end
466
+
467
+ def test_cmd_netconfig_modify_interfaces_a1
468
+ # $log.level = Logger::DEBUG
469
+ api = Mu::Command::Cmd_netconfig.new
470
+ saved = api.cmd_get ["-e", "interfaces/a1"]
471
+ assert(saved["display_name"] == "A1", "expected A1 got #{saved["display_name"]}")
472
+ api.cmd_modify ["-e", "interfaces/a1", "-j", '{"v4_dhcp"=>false}']
473
+ sleep 2
474
+ modified = api.cmd_get ["-e", "interfaces/a1"]
475
+ assert(modified["v4_dhcp"] == false, "expected dhcp false but it wasn't")
476
+ ensure
477
+ api.cmd_modify ["-e", "interfaces/a1", "-j", '{"v4_dhcp"=>true}']
478
+ end
479
+
480
+ def test_cmd_netconfig_vlans
481
+ # $log.level = Logger::DEBUG
482
+ api = Mu::Command::Cmd_netconfig.new
483
+ begin
484
+ api.cmd_delete ["-e", "interfaces/b1.222"]
485
+ rescue
486
+ # ignore. the vlan probably did not exist
487
+ end
488
+ vlan_222 = {"v4_addrs"=>["2.2.2.2"],"v4_mask"=>"26","v6_addrs"=>["2222:0:0:0:0:0:0:2"],"v6_mask"=>"64"}
489
+ api.cmd_create ["-j", '{"name"=>"b1","vlan"=>"222"}', "-e", "interfaces" ]
490
+ sleep 3
491
+ api.cmd_modify [ "-j", vlan_222, "-e", "interfaces/b1.222"]
492
+ b1 = api.cmd_get ["-e", "interfaces/b1.222"]
493
+ assert(b1["v4_addrs"]["begin"] == "2.2.2.2","vlan v4_addrs incorrect: #{b1["v4_addrs"]["begin"]}")
494
+ response = api.cmd_delete ["-e", "interfaces/b1.222"]
495
+ assert(response.include?("deleted"), "Failed to delete host:" + response)
496
+ end
497
+
498
+ def test_cmd_netconfig_create_delete_host
499
+ # $log.level = Logger::DEBUG
500
+ api = Mu::Command::Cmd_netconfig.new
501
+ response = api.cmd_create ["-j", '{"name"=>"deleteme","v4_addr"=>"192.168.30.9"}', "-e", "hosts"]
502
+ assert(response.include?("created"), "Failed to create host:" + response.to_s)
503
+ response = api.cmd_delete ["-e", "hosts/deleteme"]
504
+ assert(response.include?("deleted"), "Failed to delete host:" + response.to_s)
505
+ end
506
+
507
+ def test_cmd_netconfig_add_modify_delete_route
508
+ puts "assumes a1 on 192.168.30.x subnet and a router at 192.168.30.247"
509
+ # $log.level = Logger::DEBUG
510
+ api = Mu::Command::Cmd_netconfig.new
511
+ system = api.cmd_get ["-e", "system"]
512
+ # delete route if if already existsname"] ==
513
+ begin
514
+ response = api.cmd_delete ["-e", "routes/192.168.100.0-192.168.30.247-a1"]
515
+ rescue
516
+ # do nothing. route may not exists
517
+ end
518
+ # turn dhcp on
519
+ dhcp = {"name"=>"a1","v4_dhcp"=>"Enabled"}
520
+ response = api.cmd_modify ["-j", dhcp, "-e", "interfaces/a1"]
521
+ sleep 3
522
+ g = api.cmd_get ["-e", "interfaces/a1"]
523
+ assert(g["v4_addrs"]["begin"].include?("192.168.30"),"A1 DHCP failed")
524
+ new_route = {"interface"=>"a1", "dst"=>"192.168.100.0", "gateway"=>"192.168.30.247", "dst_pfx_len"=>24}
525
+ response = api.cmd_create ["-j", new_route, "-e", "routes"]
526
+ assert(response.include?("192.168.100.0-192.168.30.247-a1 created."), response) # not sure what this will be
527
+ update_mask = {"dst_pfx_len"=>24}
528
+ response = api.cmd_modify ["-j", update_mask, "-e", "routes/192.168.100.0-192.168.30.247-a1"]
529
+ ensure
530
+ response = api.cmd_delete ["-e", "routes/192.168.100.0-192.168.30.247-a1"]
531
+ assert(response.include?("deleted"),response)
532
+ end
533
+
534
+ def test_cmd_netconfig_resolve_hosts
535
+ # $log.level = Logger::DEBUG
536
+ api = Mu::Command::Cmd_netconfig.new
537
+ add_localhost_with_channel
538
+ response = api.cmd_resolve_hosts ["-n", "localhost"]
539
+ response = api.cmd_get ["-e", "hosts/localhost"]
540
+ assert response["name"] == "localhost", "expected to find localhost but found #{response["name"]}"
541
+ end
542
+
543
+ def test_cmd_netconfig_save
544
+ # $log.level = Logger::DEBUG
545
+ api = Mu::Command::Cmd_netconfig.new
546
+ File.delete("save.json") if File.exists?("save.json")
547
+ response = api.cmd_save ["-f", "save.json"]
548
+ assert(File.exists?("save.json"), "wxpected for find file 'save.json but did not")
549
+ ensure
550
+ File.delete("save.json") if File.exists?("save.json")
551
+ end
552
+
553
+ # -------------- netconfig -----------
554
+
555
+ def test_netconfig_new
556
+ api = Mu::Netconfig.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
557
+ assert(api.host == @mu_ip, "failed to set mu_ip")
558
+ assert(api.docroot == "/restlet/netconfig/", "failed to set docroot")
559
+ end
560
+
561
+ # -------------- cmd_runscale -------------
562
+
563
+ # use ip range setting and a brief pattern
564
+ def test_cmd_runscale_run_file
565
+ File.delete("app_id_status.json") if File.exists?("app_id_status.json")
566
+ app = Mu::Command::Cmd_runscale.new
567
+ args = Array.new
568
+ args << "-s"
569
+ args << "#{Dir.pwd}/test/data/data_cgi.msl"
570
+ args << "-i"
571
+ args << "b1-10000,b2"
572
+ args << "-p"
573
+ args << "1-100:10"
574
+ app.cmd_run_file args
575
+ assert(File.exists?("app_id_status.json"), "app_id_status.json file was not created")
576
+ j = JSON File.read("app_id_status.json")
577
+ status = j["status"]
578
+ assert(status["statistics"]["summary"]["duration"].to_f >= 10.0, "expected summary duration > 10, but got #{status["statistics"]["summary"]["duration"]}")
579
+ assert(status["statistics"]["summary"]["instances"]["executed"].to_i > 10, "expected instances executed > 0, but got #{status["statistics"]["summary"]["instances"]["executed"]}")
580
+ end
581
+
582
+ # use ip range setting and a brief pattern
583
+ def test_cmd_runscale_run_dir
584
+ File.delete("app_id_status.json") if File.exists?("app_id_status.json")
585
+ app = Mu::Command::Cmd_runscale.new
586
+ args = Array.new
587
+ args << "-d"
588
+ args << "#{Dir.pwd}/test/data"
589
+ args << "-i"
590
+ args << "b1-10000,b2"
591
+ args << "-p"
592
+ args << "1-100:10"
593
+ app.cmd_run_dir args
594
+ assert(File.exists?("app_id_status.json"), "app_id_status.json file was not created")
595
+ j = JSON File.read("app_id_status.json")
596
+ status = j["status"]
597
+ assert(status["statistics"]["summary"]["duration"].to_f >= 10.0, "expected summary duration > 10, but got #{status["statistics"]["summary"]["duration"]}")
598
+ assert(status["statistics"]["summary"]["instances"]["executed"].to_i > 10, "expected instances executed > 0, but got #{status["statistics"]["summary"]["instances"]["executed"]}")
599
+ end
600
+
601
+
602
+ # -------------- cmd_runscenario ----------
603
+
604
+ def test_cmd_runscenario
605
+ app = Mu::Command::Cmd_runscenario.new
606
+ args = Array.new
607
+ args << "-s"
608
+ args << "#{Dir.pwd}/test/data/data_cgi.xml"
609
+ args << "-i"
610
+ args << "b1,b2"
611
+ args << "-v"
612
+ app.cmd_run args
613
+ assert(app.errors.size == 0, "expected 0 errors but got #{app.errors}")
614
+ end
615
+
616
+
617
+ # -------------- cmd_runverify ------------
618
+
619
+ def test_cmd_runverify
620
+ app = Mu::Command::Cmd_runverify.new
621
+ args = Array.new
622
+ args << "-s"
623
+ args << "#{Dir.pwd}/test/data/data_cgi.xml"
624
+ args << "-t"
625
+ args << "#{Dir.pwd}/test/data/default_test.csv"
626
+ args << "-i"
627
+ args << "b1,b2"
628
+ args << "-v"
629
+ app.cmd_run args
630
+ assert(app.errors.size > 0, "expected errors but got none")
631
+ end
632
+
633
+
634
+ # -------------- scale ----------------
635
+
636
+ def test_scale_new
637
+ api = Mu::Scale.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
638
+ assert(api.host == @mu_ip, "failed to set mu_ip")
639
+ assert(api.docroot == "/api/v5/scale/", "failed to set docroot")
640
+ assert(!api.uuid.nil?, "uuid is nil")
641
+ end
642
+
643
+ def test_scale_about
644
+ api = Mu::Scale.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
645
+ about = api.about
646
+ # puts JSON.pretty_generate about
647
+ assert(about[0]["group"] == "active", "expected 'active' group, got #{about[0]["group"]}")
648
+ assert(about[0]["type"] == "bot", "expected 'bot' type, got #{about[0]["type"]}")
649
+ assert(!api.uuid.nil?, "uuid is nil")
650
+ end
651
+
652
+ def test_scale_list
653
+ api = Mu::Scale.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
654
+ list = api.list
655
+ assert(list.length == 1 , "expected list of length 1, got #{list.length}")
656
+ assert(!api.uuid.nil?, "uuid is nil")
657
+ end
658
+
659
+ def test_scale_session
660
+ api = Mu::Scale.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
661
+ api.session
662
+ assert(!api.uuid.nil?, "uuid is nil")
663
+ end
664
+
665
+ # -------------- system ---------------
666
+
667
+ # do NOT write a test for system:restart please!
668
+
669
+ def test_system_new
670
+ api = Mu::System.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
671
+ assert(api.host == @mu_ip, "failed to set mu_ip")
672
+ assert(api.docroot == "/api/v5/system/", "failed to set docroot")
673
+ end
674
+
675
+ # -------------- cmd_system ----------------
676
+
677
+ # do NOT write a test for cmd_system:restart please!
678
+
679
+ def test_cmd_system_status
680
+ api = Mu::Command::Cmd_system.new
681
+ result = api.cmd_status []
682
+ doc = Nokogiri::XML(result)
683
+ ports = doc.xpath("//ports")
684
+ assert(ports.length >= 5, "expected to find at least 5 ports, but got #{ports.length}")
685
+ end
686
+
687
+ def test_cmd_system_status2
688
+ api = Mu::Command::Cmd_system.new
689
+ result = api.cmd_status2 []
690
+ assert(result.to_s.include?("raid"), "expected to find 'raid' in results, but got #{result}")
691
+ end
692
+
693
+ #---------------------- utility methods -----------------------
694
+
695
+ def add_localhost_with_channel
696
+ local_host = {
697
+ "name"=> "localhost",
698
+ "ssh_channel"=> {
699
+ "username"=> "root",
700
+ "prompt"=> "]#",
701
+ "commands"=> [
702
+
703
+ ],
704
+ "tcp_port"=> 22,
705
+ "password"=> "bogus"
706
+ },
707
+ "v4_addr"=> @mu_ip
708
+ }
709
+ # $log.level = Logger::DEBUG
710
+ api = Mu::Command::Cmd_netconfig.new
711
+ api.cmd_delete ["-e", "hosts/localhost"] # may not exist
712
+ response = api.cmd_create ["-j", JSON(local_host), "-e", "hosts"]
713
+ assert(response.include?("created"), "Failed to create host:" + response.to_s)
714
+ end
715
+
716
+ end