spectools 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +1 -0
- data/Manifest.txt +80 -0
- data/README.txt +33 -0
- data/README.vnmsh.txt +39 -0
- data/Rakefile +42 -0
- data/TODO +5 -0
- data/lib/spectools.rb +588 -0
- data/lib/spectools/version.rb +9 -0
- data/lib/vnmsh.rb +1930 -0
- data/test/data/connect.success +8 -0
- data/test/data/create.alarm +2 -0
- data/test/data/create.association +1 -0
- data/test/data/create.model +1 -0
- data/test/data/create.model.ip +1 -0
- data/test/data/destroy.alarm +1 -0
- data/test/data/destroy.association +1 -0
- data/test/data/destroy.model +9 -0
- data/test/data/seek +2 -0
- data/test/data/seek.-s +17 -0
- data/test/data/show.alarms +10 -0
- data/test/data/show.alarms-a +11 -0
- data/test/data/show.alarms-a-x +22 -0
- data/test/data/show.alarms-x +20 -0
- data/test/data/show.alarms.mh +1 -0
- data/test/data/show.associations +160 -0
- data/test/data/show.attributes +909 -0
- data/test/data/show.attributes.attr +2 -0
- data/test/data/show.attributes.attriid +2 -0
- data/test/data/show.attributes.attrname +6 -0
- data/test/data/show.attributes.attrr +14 -0
- data/test/data/show.attributes.enum +2 -0
- data/test/data/show.attributes.flags +16 -0
- data/test/data/show.attributes.mth +242 -0
- data/test/data/show.attributes.mth.attrr +12 -0
- data/test/data/show.children +47 -0
- data/test/data/show.children.rel +14 -0
- data/test/data/show.devices +21 -0
- data/test/data/show.enumerations +142383 -0
- data/test/data/show.enumerations.attr +4 -0
- data/test/data/show.enumerations.mth +149 -0
- data/test/data/show.events +2001 -0
- data/test/data/show.events-a +10001 -0
- data/test/data/show.events-n5 +6 -0
- data/test/data/show.events-x-n5 +21 -0
- data/test/data/show.inheritance +12 -0
- data/test/data/show.landscapes +3 -0
- data/test/data/show.models +2252 -0
- data/test/data/show.models.mhr +18 -0
- data/test/data/show.models.mname +4 -0
- data/test/data/show.models.mth +4 -0
- data/test/data/show.parents +6 -0
- data/test/data/show.relations +151 -0
- data/test/data/show.rules +5838 -0
- data/test/data/show.types +4210 -0
- data/test/data/show.types.flags +3137 -0
- data/test/data/show.types.mthr +55 -0
- data/test/data/show.types.mtname +2 -0
- data/test/data/show.watch +9 -0
- data/test/data/test.reconnect +1 -0
- data/test/data/update.alarm +1 -0
- data/test/data/update.model +3 -0
- data/test/test_helper.rb +2 -0
- data/test/test_spectools.rb +403 -0
- data/test/test_vnmsh.rb +1537 -0
- data/test/testcmds/ack +1 -0
- data/test/testcmds/connect +32 -0
- data/test/testcmds/create +34 -0
- data/test/testcmds/destroy +36 -0
- data/test/testcmds/disconnect +7 -0
- data/test/testcmds/seek +18 -0
- data/test/testcmds/show +243 -0
- data/test/testcmds/update +12 -0
- data/test/vnmsh/ack +1 -0
- data/test/vnmsh/connect +5 -0
- data/test/vnmsh/create +1 -0
- data/test/vnmsh/destroy +1 -0
- data/test/vnmsh/disconnect +1 -0
- data/test/vnmsh/seek +3 -0
- data/test/vnmsh/show +1 -0
- data/test/vnmsh/update +1 -0
- metadata +134 -0
data/test/test_vnmsh.rb
ADDED
@@ -0,0 +1,1537 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'tmpdir.rb'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'vnmsh'
|
5
|
+
|
6
|
+
module VNMSHTestHelpers
|
7
|
+
|
8
|
+
def tmp_specroot
|
9
|
+
return Dir.tmpdir + '/test_spectools'
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_temp_vnmsh(filelist)
|
13
|
+
Dir.mkdir(tmp_specroot) unless File.exists?(tmp_specroot)
|
14
|
+
Dir.mkdir(tmp_specroot + '/vnmsh') unless File.exists?(tmp_specroot + '/vnmsh')
|
15
|
+
copy_command(filelist[:showcmd], 'show')
|
16
|
+
copy_command(filelist[:ackcmd], 'ack')
|
17
|
+
copy_command(filelist[:connectcmd], 'connect')
|
18
|
+
copy_command(filelist[:createcmd], 'create')
|
19
|
+
copy_command(filelist[:destroycmd], 'destroy')
|
20
|
+
copy_command(filelist[:disconnectcmd], 'disconnect')
|
21
|
+
copy_command(filelist[:seekcmd], 'seek')
|
22
|
+
copy_command(filelist[:updatecmd], 'update')
|
23
|
+
end
|
24
|
+
def destroy_temp_vnmsh
|
25
|
+
Dir.glob(tmp_specroot + '/vnmsh/*').each { |file| File.delete(file) }
|
26
|
+
Dir.delete(tmp_specroot + '/vnmsh/')
|
27
|
+
end
|
28
|
+
|
29
|
+
def copy_command(src, dest)
|
30
|
+
FileUtils.copy(FileUtils.pwd + '/test/testcmds/' + src, tmp_specroot + '/vnmsh/' + dest) unless src == 'bogus'
|
31
|
+
end
|
32
|
+
|
33
|
+
def basecmds
|
34
|
+
return { :showcmd => 'show',
|
35
|
+
:ackcmd => 'ack',
|
36
|
+
:connectcmd => 'connect',
|
37
|
+
:createcmd => 'create',
|
38
|
+
:destroycmd => 'destroy',
|
39
|
+
:seekcmd => 'seek',
|
40
|
+
:updatecmd => 'update',
|
41
|
+
:disconnectcmd => 'disconnect'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
class BasicVNMSHTests < Test::Unit::TestCase
|
48
|
+
include VNMSHTestHelpers
|
49
|
+
|
50
|
+
def setup
|
51
|
+
|
52
|
+
|
53
|
+
@specroot = Dir.pwd + '/test'
|
54
|
+
ENV['TESTDATA'] = Dir.pwd + '/test/data/'
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
def test_init_vnmsh
|
64
|
+
create_temp_vnmsh(basecmds)
|
65
|
+
ENV['SPECROOT'] = tmp_specroot
|
66
|
+
session = VNMSH.new
|
67
|
+
assert_not_nil session.session_id
|
68
|
+
destroy_temp_vnmsh
|
69
|
+
assert_equal 3, session.reconnect_retries
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_init_vnmsh_args
|
73
|
+
session = VNMSH.new(@specroot)
|
74
|
+
assert_not_nil session.session_id
|
75
|
+
session.reconnect_retries = 50
|
76
|
+
assert_equal 50, session.reconnect_retries
|
77
|
+
assert_raise VNMSH::EnvironmentError do
|
78
|
+
VNMSH.new("bogus")
|
79
|
+
end
|
80
|
+
basecmds.keys.each do |cmd|
|
81
|
+
cmdlist = basecmds.clone
|
82
|
+
cmdlist[cmd] = 'bogus'
|
83
|
+
create_temp_vnmsh(cmdlist)
|
84
|
+
assert_raise VNMSH::EnvironmentError do
|
85
|
+
VNMSH.new(tmp_specroot)
|
86
|
+
end
|
87
|
+
destroy_temp_vnmsh
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_vnmsh_default_session
|
92
|
+
create_temp_vnmsh(basecmds)
|
93
|
+
session = VNMSH.new(tmp_specroot)
|
94
|
+
assert_nil VNMSH.default_session
|
95
|
+
VNMSH.default_session = session
|
96
|
+
assert_same session, VNMSH.default_session
|
97
|
+
destroy_temp_vnmsh
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class VNMSHConnectionTests < Test::Unit::TestCase
|
102
|
+
|
103
|
+
include VNMSHTestHelpers
|
104
|
+
|
105
|
+
def setup
|
106
|
+
create_temp_vnmsh(basecmds)
|
107
|
+
@session = VNMSH.new(tmp_specroot)
|
108
|
+
end
|
109
|
+
|
110
|
+
def teardown
|
111
|
+
destroy_temp_vnmsh
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_vnmsh_connect
|
115
|
+
landscape = @session.connect
|
116
|
+
assert_instance_of SpecTools::Landscape, landscape
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_vnmsh_connect_args
|
120
|
+
landscape = @session.connect("testhost")
|
121
|
+
assert_instance_of SpecTools::Landscape, landscape
|
122
|
+
assert_equal 'testhost', landscape.ss
|
123
|
+
assert_equal '0x400000', landscape.handle
|
124
|
+
assert_same landscape, @session.current_landscape
|
125
|
+
landscape = @session.connect("connected")
|
126
|
+
assert_instance_of SpecTools::Landscape, landscape
|
127
|
+
assert_equal 'testhost', landscape.ss
|
128
|
+
assert_equal '0x400000', landscape.handle
|
129
|
+
|
130
|
+
(0..7).each do |i|
|
131
|
+
assert_raise VNMSH::ConnectError do
|
132
|
+
@session.connect("error" + i.to_s)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_vnmsh_disconnect
|
138
|
+
assert_equal false, @session.connected?
|
139
|
+
@session.connect
|
140
|
+
assert_equal true, @session.connected?
|
141
|
+
assert_nothing_raised do
|
142
|
+
@session.disconnect
|
143
|
+
end
|
144
|
+
assert_equal false, @session.connected?
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_vnmsh_exec_cmd
|
148
|
+
assert_raise VNMSH::NotConnectedError do
|
149
|
+
@session.exec_cmd('show test')
|
150
|
+
end
|
151
|
+
@session.connect
|
152
|
+
assert_nothing_raised do
|
153
|
+
output = @session.exec_cmd('show test')
|
154
|
+
assert_equal 'Test Succeeded', output.readline.chomp
|
155
|
+
end
|
156
|
+
assert_nothing_raised do
|
157
|
+
output = @session.exec_cmd('show reconnect')
|
158
|
+
assert_equal 'Test Succeeded', output.readline.chomp
|
159
|
+
end
|
160
|
+
assert_raise VNMSH::NotConnectedError do
|
161
|
+
output = @session.exec_cmd('show noreconnect')
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
class VNMSHCommandTests < Test::Unit::TestCase
|
167
|
+
|
168
|
+
include VNMSHTestHelpers
|
169
|
+
|
170
|
+
|
171
|
+
def setup
|
172
|
+
SpecTools::Config.default_access_method = :cli
|
173
|
+
@orig_default_access_method = SpecTools::Config.default_access_method
|
174
|
+
create_temp_vnmsh(basecmds)
|
175
|
+
@session = VNMSH.new(tmp_specroot)
|
176
|
+
@session.connect
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_vnmsh_show_alarms
|
180
|
+
assert_nothing_raised do
|
181
|
+
assert_not_nil alarms = @session.show_alarms(:standard)
|
182
|
+
end
|
183
|
+
assert_nothing_raised do
|
184
|
+
maintalarms = 0
|
185
|
+
assert_instance_of StringIO, alarms = @session.show_alarms(:all)
|
186
|
+
alarms.each do |alarm|
|
187
|
+
if alarm =~ /MAINT/
|
188
|
+
maintalarms = maintalarms + 1
|
189
|
+
end
|
190
|
+
end
|
191
|
+
#assert(maintalarms > 0)
|
192
|
+
end
|
193
|
+
assert_nothing_raised do
|
194
|
+
noresponses = 0
|
195
|
+
assert_not_nil alarms = @session.show_alarms(:standard,nil,:probcause)
|
196
|
+
alarms.each do |alarm|
|
197
|
+
if alarm =~ /RESPONDING TO/
|
198
|
+
noresponses = noresponses + 1
|
199
|
+
end
|
200
|
+
end
|
201
|
+
assert(noresponses > 0)
|
202
|
+
end
|
203
|
+
assert_nothing_raised do
|
204
|
+
assert_not_nil alarms = @session.show_alarms(:model,'0x400005c7')
|
205
|
+
#assert_match( /0x400005c7/, alarms.readline )
|
206
|
+
end
|
207
|
+
|
208
|
+
assert_nothing_raised do
|
209
|
+
assert_not_nil alarms = @session.show_alarms(:landscape,'0x400000')
|
210
|
+
assert_not_nil alarms.readline
|
211
|
+
end
|
212
|
+
|
213
|
+
assert_raise ArgumentError do
|
214
|
+
@session.show_alarms(:model,'bogus')
|
215
|
+
end
|
216
|
+
|
217
|
+
assert_raise ArgumentError do
|
218
|
+
@session.show_alarms(:landscape,'bogus')
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_vnmsh_show_models
|
224
|
+
assert_nothing_raised do
|
225
|
+
assert_not_nil @session.show_models
|
226
|
+
end
|
227
|
+
assert_nothing_raised do
|
228
|
+
assert_not_nil models = @session.show_models({:landscape,'0x400000'})
|
229
|
+
assert_match(/0x40000025/, models.readline)
|
230
|
+
end
|
231
|
+
assert_nothing_raised do
|
232
|
+
assert_not_nil models = @session.show_models({:type,'0x13d0018'})
|
233
|
+
assert_match(/0x13d0018/,models.readline)
|
234
|
+
end
|
235
|
+
|
236
|
+
assert_nothing_raised do
|
237
|
+
assert_not_nil models = @session.show_models({:name,'DTM'})
|
238
|
+
assert_match(/0x40000178/, models.readline)
|
239
|
+
end
|
240
|
+
|
241
|
+
assert_nothing_raised do
|
242
|
+
assert_not_nil models = @session.show_models({:range,'0x40000000-0x40000010'})
|
243
|
+
assert_match(/0x40000003/,models.readline)
|
244
|
+
assert_match(/0x4000000d/,models.readline)
|
245
|
+
end
|
246
|
+
|
247
|
+
assert_nothing_raised do
|
248
|
+
assert_not_nil models = @session.show_models({:range,['0x40000000','0x40000010']})
|
249
|
+
assert_match(/0x40000003/,models.readline)
|
250
|
+
assert_match(/0x4000000d/,models.readline)
|
251
|
+
end
|
252
|
+
|
253
|
+
assert_raise ArgumentError do
|
254
|
+
@session.show_models({:mtype,'bogus'})
|
255
|
+
end
|
256
|
+
|
257
|
+
assert_raise ArgumentError do
|
258
|
+
@session.show_models({:landscape,'bogus'})
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_vnmsh_seek
|
264
|
+
assert_nothing_raised do
|
265
|
+
assert_not_nil models = @session.seek('0x1006e','intspeclab01')
|
266
|
+
assert_match(/0x408cac/,models.readline)
|
267
|
+
end
|
268
|
+
|
269
|
+
specattr = SpecTools::Attr.new
|
270
|
+
specattr.id = '0x1006e'
|
271
|
+
specattr.value = 'intspeclab01'
|
272
|
+
assert_nothing_raised do
|
273
|
+
assert_not_nil models = @session.seek(specattr,nil,true)
|
274
|
+
assert_match(/0x408cb8/,models.readline)
|
275
|
+
end
|
276
|
+
|
277
|
+
assert_nothing_raised do
|
278
|
+
assert_not_nil models = @session.seek(specattr,nil,true,true)
|
279
|
+
assert_match(/0x408cb8/,models.readline)
|
280
|
+
end
|
281
|
+
|
282
|
+
assert_raise ArgumentError do
|
283
|
+
@session.seek('bogus')
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
|
289
|
+
def test_vnmsh_show_devices
|
290
|
+
|
291
|
+
assert_nothing_raised do
|
292
|
+
assert_not_nil @session.show_devices
|
293
|
+
end
|
294
|
+
|
295
|
+
assert_nothing_raised do
|
296
|
+
assert_not_nil @session.show_devices('0x400000')
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
assert_raise ArgumentError do
|
301
|
+
@session.show_devices('bogus')
|
302
|
+
end
|
303
|
+
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_vnmsh_show_types
|
307
|
+
|
308
|
+
assert_nothing_raised do
|
309
|
+
assert_not_nil @session.show_types
|
310
|
+
end
|
311
|
+
assert_nothing_raised do
|
312
|
+
assert_not_nil @session.show_types({:landscape, '0x400000'})
|
313
|
+
end
|
314
|
+
assert_nothing_raised do
|
315
|
+
assert_not_nil @session.show_types({:flag,'D'})
|
316
|
+
end
|
317
|
+
assert_nothing_raised do
|
318
|
+
assert_not_nil types = @session.show_types({:range,'0x13d0000-0x13d00ff'})
|
319
|
+
assert_match(/0x13d0005/, types.readline)
|
320
|
+
assert_match(/0x13d0008/, types.readline)
|
321
|
+
end
|
322
|
+
|
323
|
+
assert_nothing_raised do
|
324
|
+
assert_not_nil types = @session.show_types({:range,['0x13d0000','0x13d00ff']})
|
325
|
+
assert_match(/0x13d0005/, types.readline)
|
326
|
+
assert_match(/0x13d0008/, types.readline)
|
327
|
+
end
|
328
|
+
|
329
|
+
|
330
|
+
assert_nothing_raised do
|
331
|
+
assert_not_nil types = @session.show_types({:name,'IcsLicenseMgr'})
|
332
|
+
assert_match(/0x1ad0002/, types.readline)
|
333
|
+
end
|
334
|
+
|
335
|
+
assert_raise ArgumentError do
|
336
|
+
@session.show_types({:landscape,'bogus'})
|
337
|
+
end
|
338
|
+
|
339
|
+
assert_raise ArgumentError do
|
340
|
+
@session.show_types({:bogus,'bogus'})
|
341
|
+
end
|
342
|
+
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_vnmsh_show_relations
|
346
|
+
|
347
|
+
assert_nothing_raised do
|
348
|
+
assert_not_nil @session.show_relations
|
349
|
+
end
|
350
|
+
|
351
|
+
assert_nothing_raised do
|
352
|
+
assert_not_nil @session.show_relations('0x400000')
|
353
|
+
end
|
354
|
+
|
355
|
+
assert_raise ArgumentError do
|
356
|
+
@session.show_relations('bogus')
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|
360
|
+
|
361
|
+
def test_vnmsh_show_associations
|
362
|
+
|
363
|
+
assert_nothing_raised do
|
364
|
+
assert_not_nil associations = @session.show_associations('mh=0x400005c7')
|
365
|
+
assert_match(/^0x400005c7/, associations.readline)
|
366
|
+
assert_match(/^0x400005c7/,associations.readline)
|
367
|
+
end
|
368
|
+
assert_raise ArgumentError do
|
369
|
+
@session.show_associations
|
370
|
+
end
|
371
|
+
assert_raise VNMSH::CommandError do
|
372
|
+
@session.show_associations("mh=bogus")
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
def test_vnmsh_show_parents
|
377
|
+
|
378
|
+
assert_nothing_raised do
|
379
|
+
assert_not_nil parents = @session.show_parents('0x4000004b')
|
380
|
+
assert_match(/0x40000042/, parents.readline)
|
381
|
+
end
|
382
|
+
|
383
|
+
assert_nothing_raised do
|
384
|
+
assert_not_nil parents = @session.show_parents('0x4000004b','Collects')
|
385
|
+
assert_match(/0x40000042/, parents.readline)
|
386
|
+
|
387
|
+
end
|
388
|
+
|
389
|
+
assert_raise VNMSH::CommandError do
|
390
|
+
@session.show_parents('0x400007','bogus')
|
391
|
+
end
|
392
|
+
|
393
|
+
assert_raise ArgumentError do
|
394
|
+
@session.show_parents('bogus')
|
395
|
+
end
|
396
|
+
|
397
|
+
end
|
398
|
+
|
399
|
+
def test_vnmsh_show_children
|
400
|
+
|
401
|
+
assert_nothing_raised do
|
402
|
+
assert_not_nil children = @session.show_children('0x400005cb')
|
403
|
+
assert_match(/0x40000cc0/, children.readline)
|
404
|
+
end
|
405
|
+
|
406
|
+
assert_nothing_raised do
|
407
|
+
assert_not_nil children = @session.show_children('0x400005cb','PossPrimApp')
|
408
|
+
assert_match(/0x400005d8/, children.readline)
|
409
|
+
end
|
410
|
+
|
411
|
+
assert_raise VNMSH::CommandError do
|
412
|
+
@session.show_children('0x400000','bogus')
|
413
|
+
end
|
414
|
+
|
415
|
+
assert_raise ArgumentError do
|
416
|
+
@session.show_children('bogus')
|
417
|
+
end
|
418
|
+
|
419
|
+
end
|
420
|
+
|
421
|
+
def test_vnmsh_show_events
|
422
|
+
|
423
|
+
assert_nothing_raised do
|
424
|
+
assert_not_nil events = @session.show_events
|
425
|
+
end
|
426
|
+
|
427
|
+
assert_nothing_raised do
|
428
|
+
assert_not_nil events = @session.show_events(:model,'0x400000')
|
429
|
+
assert_match(/09\/21\/2007/, events.readline)
|
430
|
+
end
|
431
|
+
|
432
|
+
assert_nothing_raised do
|
433
|
+
eventcount = 0
|
434
|
+
assert_not_nil events = @session.show_events(:landscape,'0x400000')
|
435
|
+
events.each do
|
436
|
+
eventcount = eventcount + 1
|
437
|
+
end
|
438
|
+
assert_equal 2000, eventcount
|
439
|
+
end
|
440
|
+
|
441
|
+
assert_nothing_raised do
|
442
|
+
eventcount = 0
|
443
|
+
assert_not_nil events = @session.show_events(:model,'0x400000',:all)
|
444
|
+
events.each do
|
445
|
+
eventcount = eventcount + 1
|
446
|
+
end
|
447
|
+
assert_equal 10000, eventcount
|
448
|
+
end
|
449
|
+
|
450
|
+
assert_nothing_raised do
|
451
|
+
noresponses = 0
|
452
|
+
assert_not_nil events = @session.show_events(:model,'0x400000',nil,true)
|
453
|
+
events.each do |event|
|
454
|
+
if event =~ /SpectroSERVER has disconnected/
|
455
|
+
noresponses = noresponses + 1
|
456
|
+
end
|
457
|
+
end
|
458
|
+
assert(noresponses > 0)
|
459
|
+
end
|
460
|
+
|
461
|
+
assert_nothing_raised do
|
462
|
+
eventcount = 0
|
463
|
+
assert_not_nil events = @session.show_events(:model,'0x400000',5)
|
464
|
+
events.each do
|
465
|
+
eventcount = eventcount + 1
|
466
|
+
end
|
467
|
+
assert_equal 5, eventcount
|
468
|
+
end
|
469
|
+
|
470
|
+
assert_raise ArgumentError do
|
471
|
+
@session.show_events(:model,'bogus')
|
472
|
+
end
|
473
|
+
|
474
|
+
assert_raise ArgumentError do
|
475
|
+
@session.show_events(:landscape,'bogus')
|
476
|
+
end
|
477
|
+
|
478
|
+
end
|
479
|
+
|
480
|
+
def test_vnmsh_show_inheritence
|
481
|
+
|
482
|
+
assert_nothing_raised do
|
483
|
+
assert_not_nil types = @session.show_inheritance('0x13d000d')
|
484
|
+
assert_match(/0x102dd/, types.readline)
|
485
|
+
end
|
486
|
+
|
487
|
+
assert_nothing_raised do
|
488
|
+
assert_not_nil types = @session.show_inheritance('0x13d000d', '0x400000')
|
489
|
+
assert_match(/0x102dd/, types.readline)
|
490
|
+
end
|
491
|
+
|
492
|
+
assert_raise ArgumentError do
|
493
|
+
@session.show_inheritance
|
494
|
+
end
|
495
|
+
|
496
|
+
assert_raise ArgumentError do
|
497
|
+
@session.show_inheritance('bogus')
|
498
|
+
end
|
499
|
+
|
500
|
+
assert_raise ArgumentError do
|
501
|
+
@session.show_inheritance('0x13d000d', 'bogus')
|
502
|
+
end
|
503
|
+
|
504
|
+
end
|
505
|
+
|
506
|
+
def test_vnmsh_show_rules
|
507
|
+
|
508
|
+
assert_nothing_raised do
|
509
|
+
assert_not_nil rules = @session.show_rules('Collects')
|
510
|
+
assert_match(/0x3f50001/, rules.readline)
|
511
|
+
end
|
512
|
+
|
513
|
+
assert_nothing_raised do
|
514
|
+
assert_not_nil rules = @session.show_rules('Collects', '0x400000')
|
515
|
+
assert_match(/0x3f50001/, rules.readline)
|
516
|
+
end
|
517
|
+
|
518
|
+
assert_raise ArgumentError do
|
519
|
+
@session.show_rules
|
520
|
+
end
|
521
|
+
|
522
|
+
assert_raise VNMSH::CommandError do
|
523
|
+
@session.show_rules('bogus')
|
524
|
+
end
|
525
|
+
|
526
|
+
assert_raise ArgumentError do
|
527
|
+
@session.show_rules('Collects','bogus')
|
528
|
+
end
|
529
|
+
|
530
|
+
end
|
531
|
+
|
532
|
+
def test_vnmsh_show_enumerations
|
533
|
+
|
534
|
+
assert_nothing_raised do
|
535
|
+
assert_not_nil enumerations = @session.show_enumerations
|
536
|
+
assert_match(/0x10004/, enumerations.readline)
|
537
|
+
end
|
538
|
+
|
539
|
+
assert_nothing_raised do
|
540
|
+
assert_not_nil enumerations = @session.show_enumerations(:landscape,'0x400000')
|
541
|
+
assert_match(/0x10004/, enumerations.readline)
|
542
|
+
end
|
543
|
+
|
544
|
+
assert_nothing_raised do
|
545
|
+
assert_not_nil enumerations = @session.show_enumerations(:attr,'0x13d031e')
|
546
|
+
assert_match(/0x13d031e/, enumerations.readline)
|
547
|
+
end
|
548
|
+
|
549
|
+
assert_nothing_raised do
|
550
|
+
assert_not_nil enumerations = @session.show_enumerations(:mtype,'0x13d0018')
|
551
|
+
assert_match(/0x10004/, enumerations.readline)
|
552
|
+
end
|
553
|
+
|
554
|
+
assert_raise ArgumentError do
|
555
|
+
@session.show_enumerations(:mtype,'bogus')
|
556
|
+
end
|
557
|
+
|
558
|
+
assert_raise ArgumentError do
|
559
|
+
@session.show_enumerations(:mtype,'bogus')
|
560
|
+
end
|
561
|
+
|
562
|
+
assert_raise ArgumentError do
|
563
|
+
@session.show_enumerations(:landscape,'bogus')
|
564
|
+
end
|
565
|
+
|
566
|
+
end
|
567
|
+
|
568
|
+
def test_vnmsh_show_watch
|
569
|
+
|
570
|
+
assert_nothing_raised do
|
571
|
+
assert_not_nil watches = @session.show_watch('0x4000004b')
|
572
|
+
assert_match(/0x13d0190/, watches.readline)
|
573
|
+
end
|
574
|
+
|
575
|
+
assert_raise ArgumentError do
|
576
|
+
@session.show_watch('bogus')
|
577
|
+
end
|
578
|
+
|
579
|
+
end
|
580
|
+
|
581
|
+
def test_vnmsh_show_landscapes
|
582
|
+
|
583
|
+
assert_nothing_raised do
|
584
|
+
assert_not_nil landscapes = @session.show_landscapes
|
585
|
+
assert_match(/0x50000000/, landscapes.readline)
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
def test_vnmsh_show_attributes
|
592
|
+
|
593
|
+
assert_nothing_raised do
|
594
|
+
assert_not_nil attrs = @session.show_attributes(:model,'0x400005c7')
|
595
|
+
assert_match(/0x10000/, attrs.readline)
|
596
|
+
end
|
597
|
+
|
598
|
+
assert_nothing_raised do
|
599
|
+
assert_not_nil attrs = @session.show_attributes(:model,'0x400005c7',{:id,'0x10030'})
|
600
|
+
assert_match(/0x10030/, attrs.readline)
|
601
|
+
end
|
602
|
+
|
603
|
+
assert_nothing_raised do
|
604
|
+
assert_not_nil attrs = @session.show_attributes(:model,'0x400005c7',{:instance,['0x12a53','192.2.20.2']})
|
605
|
+
assert_match(/0x12a53/, attrs.readline)
|
606
|
+
end
|
607
|
+
|
608
|
+
specattr = Attr.new('0x12a53',nil,'192.2.20.2')
|
609
|
+
assert_nothing_raised do
|
610
|
+
assert_not_nil attrs = @session.show_attributes(:model,'0x400005c7',{:instance,[specattr,'192.2.20.2']})
|
611
|
+
assert_match(/0x12a53/, attrs.readline)
|
612
|
+
end
|
613
|
+
|
614
|
+
|
615
|
+
#assert_nothing_raised do
|
616
|
+
# assert_not_nil attrs = @session.show_attributes('mth=0x13d0018','attrname=MAC_Address')
|
617
|
+
# assert_match(/0x110df/, attrs.readline)
|
618
|
+
#end
|
619
|
+
|
620
|
+
assert_nothing_raised do
|
621
|
+
assert_not_nil attrs = @session.show_attributes(:model,'0x400005c7',{:name,'Condition'})
|
622
|
+
assert_match(/0x1000a/, attrs.readline)
|
623
|
+
end
|
624
|
+
|
625
|
+
assert_nothing_raised do
|
626
|
+
assert_not_nil attrs = @session.show_attributes(:model,'0x400005c7',{:range,'0x10000-0x10010'})
|
627
|
+
assert_match(/Modeltype_Name/, attrs.readline)
|
628
|
+
end
|
629
|
+
|
630
|
+
assert_nothing_raised do
|
631
|
+
assert_not_nil attrs = @session.show_attributes(:model,'0x400005c7',{:range,['0x10000','0x10010']})
|
632
|
+
assert_match(/Modeltype_Name/, attrs.readline)
|
633
|
+
end
|
634
|
+
|
635
|
+
assert_nothing_raised do
|
636
|
+
assert_not_nil attrs = @session.show_attributes(:model,'0x4000017b',{:id,'0x13d0315'},true)
|
637
|
+
assert_match(/0x13d0315/, attrs.readline)
|
638
|
+
end
|
639
|
+
|
640
|
+
assert_nothing_raised do
|
641
|
+
assert_not_nil attrs = @session.show_attributes(:mtype,'0x13d0018',{:flag,'O'})
|
642
|
+
assert_match(/0x10009/, attrs.readline)
|
643
|
+
end
|
644
|
+
|
645
|
+
assert_nothing_raised do
|
646
|
+
assert_not_nil attrs = @session.show_attributes(:mtype,'0x13d0018')
|
647
|
+
assert_match(/0x10000/, attrs.readline)
|
648
|
+
end
|
649
|
+
|
650
|
+
assert_raise ArgumentError do
|
651
|
+
@session.show_attributes(:model,'bogus')
|
652
|
+
end
|
653
|
+
|
654
|
+
assert_raise ArgumentError do
|
655
|
+
@session.show_attributes(:mtype,'bogus')
|
656
|
+
end
|
657
|
+
|
658
|
+
assert_raise ArgumentError do
|
659
|
+
@session.show_attributes(:model,'0x400005c7',{:id,'bogus'})
|
660
|
+
end
|
661
|
+
|
662
|
+
assert_raise VNMSH::CommandError do
|
663
|
+
@session.show_attributes(:model,'0x400005c7',{:instance,['0x1000a','12345']})
|
664
|
+
end
|
665
|
+
|
666
|
+
assert_raise ArgumentError do
|
667
|
+
@session.show_attributes(:model,'0x400005c7',{:instance,['0x12bfa','bogus']})
|
668
|
+
end
|
669
|
+
|
670
|
+
assert_raise ArgumentError do
|
671
|
+
@session.show_attributes(:mtype,'0x13d0018',{:landscape,'bogus'})
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
675
|
+
def test_vnmsh_destroy_model
|
676
|
+
assert_nothing_raised do
|
677
|
+
assert @session.destroy_model('0x40b42b')
|
678
|
+
end
|
679
|
+
|
680
|
+
assert_raise ArgumentError do
|
681
|
+
@session.destroy_model('bogus')
|
682
|
+
end
|
683
|
+
end
|
684
|
+
|
685
|
+
def test_vnmsh_destroy_association
|
686
|
+
assert_nothing_raised do
|
687
|
+
assert @session.destroy_association('Connects_to','0x4065e8','0x40b63e')
|
688
|
+
end
|
689
|
+
|
690
|
+
assert_raise VNMSH::CommandError do
|
691
|
+
@session.destroy_association('bogus','0x4065e8','0x40b63e')
|
692
|
+
end
|
693
|
+
end
|
694
|
+
|
695
|
+
def test_vnmsh_destroy_alarm
|
696
|
+
assert_nothing_raised do
|
697
|
+
assert @session.destroy_alarm('7888881','0x4000000')
|
698
|
+
end
|
699
|
+
|
700
|
+
assert_raise ArgumentError do
|
701
|
+
@session.destroy_alarm('bogus')
|
702
|
+
end
|
703
|
+
end
|
704
|
+
|
705
|
+
def test_vnmsh_discover_device
|
706
|
+
assert_nothing_raised do
|
707
|
+
assert model = @session.discover_device('192.168.1.1','public')
|
708
|
+
assert_equal '0x40b8cf', model.handle
|
709
|
+
end
|
710
|
+
end
|
711
|
+
|
712
|
+
def test_model_discover
|
713
|
+
VNMSH.default_session = @session
|
714
|
+
assert_nothing_raised do
|
715
|
+
assert model = Model.discover('192.168.1.1','public')
|
716
|
+
assert_equal '0x40b8cf', model.handle
|
717
|
+
end
|
718
|
+
end
|
719
|
+
|
720
|
+
def test_vnmsh_create_model
|
721
|
+
mtype = MType.new('0x3dc0001')
|
722
|
+
newattrs = []
|
723
|
+
newattrs.push Attr.new('0xfffff','test1','','testval1')
|
724
|
+
newattrs.push Attr.new('0x4ffff','test2','','testval2')
|
725
|
+
|
726
|
+
assert_raise ArgumentError do
|
727
|
+
model = @session.create_model('bogus',Attr.new('test','testval'))
|
728
|
+
end
|
729
|
+
|
730
|
+
assert_raise ArgumentError do
|
731
|
+
model = @session.create_model('0x3dc0001','bogus')
|
732
|
+
end
|
733
|
+
|
734
|
+
assert_nothing_raised do
|
735
|
+
assert model = @session.create_model('0x3dc0001',newattrs)
|
736
|
+
assert_equal '0x40b95a', model.handle
|
737
|
+
assert_equal newattrs, model.attrs
|
738
|
+
assert_equal '0x3dc0001', model.type.handle
|
739
|
+
end
|
740
|
+
|
741
|
+
assert_nothing_raised do
|
742
|
+
assert model = @session.create_model(mtype,newattrs)
|
743
|
+
assert_equal '0x40b95a', model.handle
|
744
|
+
assert_equal newattrs, model.attrs
|
745
|
+
assert_equal '0x3dc0001', model.type.handle
|
746
|
+
end
|
747
|
+
end
|
748
|
+
|
749
|
+
def test_create_model
|
750
|
+
VNMSH.default_session = @session
|
751
|
+
newattrs = []
|
752
|
+
newattrs.push Attr.new('0xfffff','test1','','testval1')
|
753
|
+
newattrs.push Attr.new('0x4ffff','test2','','testval2')
|
754
|
+
mtype = MType.new('0x3dc0001')
|
755
|
+
assert_nothing_raised do
|
756
|
+
assert model = Model.create('0x3dc0001',newattrs)
|
757
|
+
assert_equal '0x40b95a', model.handle
|
758
|
+
assert_equal newattrs, model.attrs
|
759
|
+
end
|
760
|
+
assert_nothing_raised do
|
761
|
+
assert model = Model.create(mtype,newattrs)
|
762
|
+
assert_equal '0x40b95a', model.handle
|
763
|
+
assert_equal newattrs, model.attrs
|
764
|
+
assert_equal '0x3dc0001', model.type.handle
|
765
|
+
end
|
766
|
+
assert_nothing_raised do
|
767
|
+
assert model = mtype.create_model(newattrs)
|
768
|
+
assert_equal '0x40b95a', model.handle
|
769
|
+
assert_equal newattrs, model.attrs
|
770
|
+
assert_equal '0x3dc0001', model.type.handle
|
771
|
+
end
|
772
|
+
|
773
|
+
end
|
774
|
+
|
775
|
+
|
776
|
+
|
777
|
+
def test_vnmsh_update_model
|
778
|
+
newattrs = []
|
779
|
+
newattrs.push Attr.new('0x12c06','SshPortNum','222')
|
780
|
+
newattrs.push Attr.new('0x1006e','Model_Name','NewModel')
|
781
|
+
|
782
|
+
assert_raise ArgumentError do
|
783
|
+
@session.update_model('bogus',Attr.new('test','testname'))
|
784
|
+
end
|
785
|
+
|
786
|
+
assert_raise ArgumentError do
|
787
|
+
@session.update_model('0x40b737','bogus')
|
788
|
+
end
|
789
|
+
|
790
|
+
assert_nothing_raised do
|
791
|
+
assert attrs = @session.update_model('0x40b737',newattrs)
|
792
|
+
end
|
793
|
+
|
794
|
+
assert_nothing_raised do
|
795
|
+
assert attrs = @session.update_model(Model.new('0x40b737'),newattrs)
|
796
|
+
end
|
797
|
+
end
|
798
|
+
|
799
|
+
def test_model_save_attrs
|
800
|
+
newattrs = []
|
801
|
+
newattrs.push Attr.new('0x12c06','SshPortNum','222')
|
802
|
+
newattrs.push Attr.new('0x1006e','Model_Name','NewModel')
|
803
|
+
model = Model.new('0x40b737')
|
804
|
+
assert_nothing_raised do
|
805
|
+
assert model.update_attrs(newattrs)
|
806
|
+
end
|
807
|
+
assert_nothing_raised do
|
808
|
+
assert model.update_attrs(newattrs,true)
|
809
|
+
newattrs.each do |specattr|
|
810
|
+
assert_equal specattr, model.attrs[specattr.id]
|
811
|
+
end
|
812
|
+
end
|
813
|
+
end
|
814
|
+
|
815
|
+
|
816
|
+
|
817
|
+
def test_vnmsh_update_alarm
|
818
|
+
alarminfo = Hash.new
|
819
|
+
alarminfo[:ticket] = '12345'
|
820
|
+
alarminfo[:assign] = 'dpantke'
|
821
|
+
alarminfo[:status] = 'Test'
|
822
|
+
alarminfo[:ack] = true
|
823
|
+
alarminfo[:url] = 'http://www.appriss.com'
|
824
|
+
assert_nothing_raised do
|
825
|
+
assert @session.update_alarm('3699400',alarminfo)
|
826
|
+
end
|
827
|
+
assert_nothing_raised do
|
828
|
+
assert @session.update_alarm(Alarm.new('3699400'),:status,'Test2',true)
|
829
|
+
end
|
830
|
+
assert_raise ArgumentError do
|
831
|
+
@session.update_alarm('3699400',:bogus,'test')
|
832
|
+
end
|
833
|
+
assert_raise ArgumentError do
|
834
|
+
@session.update_alarm('3699400',:status)
|
835
|
+
end
|
836
|
+
alarminfo[:bogus] = 'bogus'
|
837
|
+
assert_raise ArgumentError do
|
838
|
+
@session.update_alarm('3699400',alarminfo)
|
839
|
+
end
|
840
|
+
end
|
841
|
+
|
842
|
+
def test_save_alarm
|
843
|
+
VNMSH.default_session = @session
|
844
|
+
alarm = Alarm.new('3699400')
|
845
|
+
alarm.assignment = 'dpantke'
|
846
|
+
alarm.status = 'Test'
|
847
|
+
alarm.ack = true
|
848
|
+
alarm.url = "http://www.test.com"
|
849
|
+
alarm.ticket = 'ticket12345'
|
850
|
+
assert_nothing_raised do
|
851
|
+
assert alarm.save
|
852
|
+
end
|
853
|
+
|
854
|
+
end
|
855
|
+
|
856
|
+
def test_vnmsh_create_association
|
857
|
+
assert_nothing_raised do
|
858
|
+
assert assoc = @session.create_association('Collects','0x40b736','0x40b7d3')
|
859
|
+
assert_instance_of SpecTools::Association, assoc
|
860
|
+
end
|
861
|
+
|
862
|
+
left_model = Model.new
|
863
|
+
right_model = Model.new
|
864
|
+
left_model.handle = '0x40b736'
|
865
|
+
right_model.handle = '0x40b7d3'
|
866
|
+
rel = Relation.new('Collects')
|
867
|
+
assert_nothing_raised do
|
868
|
+
assert assoc = @session.create_association(rel,left_model,right_model)
|
869
|
+
assert_instance_of SpecTools::Association, assoc
|
870
|
+
end
|
871
|
+
end
|
872
|
+
|
873
|
+
def test_associate
|
874
|
+
VNMSH.default_session = @session
|
875
|
+
left_model = Model.new('0x40b736')
|
876
|
+
right_model = Model.new('0x40b7d3')
|
877
|
+
rel = Relation.new('Collects')
|
878
|
+
assert_nothing_raised do
|
879
|
+
assert assoc = left_model.associate(:left,right_model,rel)
|
880
|
+
assert_instance_of SpecTools::Association, assoc
|
881
|
+
assoc = nil
|
882
|
+
assert assoc = right_model.associate(:right,left_model,rel)
|
883
|
+
assert_instance_of SpecTools::Association, assoc
|
884
|
+
assoc = nil
|
885
|
+
assert assoc = Association.create(rel,left_model,right_model)
|
886
|
+
assert_instance_of SpecTools::Association, assoc
|
887
|
+
assoc = nil
|
888
|
+
assert assoc = rel.associate(left_model,right_model)
|
889
|
+
assert_instance_of SpecTools::Association, assoc
|
890
|
+
end
|
891
|
+
assert_raise ArgumentError do
|
892
|
+
left_model = Model.new('0x40b736')
|
893
|
+
right_model = Model.new('0x40b7d3')
|
894
|
+
rel = Relation.new('Collects')
|
895
|
+
left_model.associate(:bogus,right_model,rel)
|
896
|
+
end
|
897
|
+
|
898
|
+
end
|
899
|
+
|
900
|
+
|
901
|
+
|
902
|
+
|
903
|
+
def test_vnmsh_create_alarm
|
904
|
+
assert_nothing_raised do
|
905
|
+
assert alarm = @session.create_alarm('CRITICAL','0x48fffc5','0x40b7d3')
|
906
|
+
assert_instance_of SpecTools::Alarm, alarm
|
907
|
+
end
|
908
|
+
|
909
|
+
srcalarm = Alarm.new
|
910
|
+
srcalarm.causeid = '0x48fffc5'
|
911
|
+
model = Model.new('0x40b7d3')
|
912
|
+
|
913
|
+
assert_nothing_raised do
|
914
|
+
assert alarm = @session.create_alarm('CRITICAL',srcalarm,model,true)
|
915
|
+
assert_instance_of SpecTools::Alarm, alarm
|
916
|
+
end
|
917
|
+
|
918
|
+
assert_raise ArgumentError do
|
919
|
+
@session.create_alarm('bogus',srcalarm,model)
|
920
|
+
end
|
921
|
+
end
|
922
|
+
|
923
|
+
def test_vnmsh_create_event
|
924
|
+
assert_nothing_raised do
|
925
|
+
assert @session.create_event('0x40b737','0x04f0fff7','Test Event')
|
926
|
+
end
|
927
|
+
|
928
|
+
assert_nothing_raised do
|
929
|
+
assert @session.create_event(Model.new('0x40b737'),Event.new(nil,'0x04f0fff7',Model.new,'Test Event'))
|
930
|
+
end
|
931
|
+
end
|
932
|
+
|
933
|
+
|
934
|
+
def test_mtype_parse
|
935
|
+
types_output = @session.show_types
|
936
|
+
mtype = SpecTools::MType.parse(types_output.readline)
|
937
|
+
assert_instance_of SpecTools::MType, mtype
|
938
|
+
assert_equal '0x10000', mtype.handle
|
939
|
+
assert_equal 'Root', mtype.name
|
940
|
+
assert_equal true, mtype.visible
|
941
|
+
assert_equal true, mtype.derivable
|
942
|
+
end
|
943
|
+
|
944
|
+
def test_association_parse
|
945
|
+
assoc_output = @session.show_associations('mh=0x400005c7')
|
946
|
+
association = SpecTools::Association.parse(assoc_output.readline)
|
947
|
+
assert_instance_of SpecTools::Association, association
|
948
|
+
assert_equal '0x400005c7', association.left_model.handle
|
949
|
+
assert_equal 'Ped20-BD6808i', association.left_model.name
|
950
|
+
assert_equal 'Contains', association.relation.name
|
951
|
+
assert_equal '0x40000c68', association.right_model.handle
|
952
|
+
assert_equal 'ExtrMod', association.right_model.name
|
953
|
+
end
|
954
|
+
|
955
|
+
def test_association_parse_child
|
956
|
+
|
957
|
+
assoc_output = @session.show_children('0x400005cb')
|
958
|
+
association = SpecTools::Association.parse_child(assoc_output.readline)
|
959
|
+
assert_equal '0x40000cc0', association.right_model.handle
|
960
|
+
assert_equal '0.20.E0-66.93.87', association.right_model.name
|
961
|
+
assert_equal '0x102c8', association.right_model.type.handle
|
962
|
+
assert_equal 'Physical_Addr', association.right_model.type.name
|
963
|
+
assert_equal 'Collects', association.relation.name
|
964
|
+
|
965
|
+
end
|
966
|
+
|
967
|
+
def test_attribute_parse_mh
|
968
|
+
|
969
|
+
attr_output = @session.show_attributes(:model,'0x400005c7',{:instance,['0x12a53','192.2.20.2']})
|
970
|
+
specattr = SpecTools::Attr.parse_mh(attr_output.readline)
|
971
|
+
assert_instance_of SpecTools::Attr, specattr
|
972
|
+
assert_equal '0x12a53', specattr.id
|
973
|
+
assert_equal 'deviceIPAddressList', specattr.name
|
974
|
+
assert_equal specattr.value_table['192.2.20.2'], '20030'
|
975
|
+
|
976
|
+
attr_output = @session.show_attributes(:model,'0x400005c7')
|
977
|
+
specattr = SpecTools::Attr.parse_mh(attr_output.readline)
|
978
|
+
assert_instance_of SpecTools::Attr, specattr
|
979
|
+
assert_equal '0x10000', specattr.id
|
980
|
+
assert_equal 'Modeltype_Name', specattr.name
|
981
|
+
assert_equal 'ExtrDevice', specattr.value
|
982
|
+
|
983
|
+
end
|
984
|
+
|
985
|
+
def test_attribute_parse_mth
|
986
|
+
|
987
|
+
attr_output = @session.show_attributes(:mtype,'0x13d0018')
|
988
|
+
specattr = SpecTools::Attr.parse_mth(attr_output.readline)
|
989
|
+
assert_instance_of SpecTools::Attr, specattr
|
990
|
+
assert_equal '0x10000', specattr.id
|
991
|
+
assert_equal 'Modeltype_Name', specattr.name
|
992
|
+
assert_equal 'Text String', specattr.type
|
993
|
+
assert_equal true, specattr.readable
|
994
|
+
assert_equal true, specattr.shared
|
995
|
+
assert_equal true, specattr.memory
|
996
|
+
|
997
|
+
end
|
998
|
+
|
999
|
+
def test_event_parse
|
1000
|
+
|
1001
|
+
event_output = @session.show_events
|
1002
|
+
event = SpecTools::Event.parse(event_output.readline)
|
1003
|
+
assert_instance_of SpecTools::Event, event
|
1004
|
+
assert_equal Time.local(2007,9,21,11,15,43), event.time
|
1005
|
+
assert_equal '0x10105', event.type
|
1006
|
+
assert_equal '0x40000030', event.model.handle
|
1007
|
+
assert_equal 'kloeber', event.model.name
|
1008
|
+
assert_equal 'User', event.model.type.name
|
1009
|
+
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
def test_mtype_parse_inheritance
|
1013
|
+
|
1014
|
+
mtype_output = @session.show_inheritance('0x13d000d')
|
1015
|
+
mtype = SpecTools::MType.parse_inheritance(mtype_output.readline)
|
1016
|
+
assert_instance_of SpecTools::MType, mtype
|
1017
|
+
assert_equal '0x102dd', mtype.handle
|
1018
|
+
assert_equal 'ModelFragment', mtype.name
|
1019
|
+
assert_equal true, mtype.visible
|
1020
|
+
assert_equal true, mtype.derivable
|
1021
|
+
assert_equal 'Base', mtype.inheritance
|
1022
|
+
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
def test_landscape_parse
|
1026
|
+
|
1027
|
+
lscape_output = @session.show_landscapes
|
1028
|
+
landscape = SpecTools::Landscape.parse(lscape_output.readline)
|
1029
|
+
assert_instance_of SpecTools::Landscape, landscape
|
1030
|
+
assert_equal 'S81-2', landscape.ss
|
1031
|
+
assert_equal '10', landscape.precedence
|
1032
|
+
assert_equal '0xbeef', landscape.port
|
1033
|
+
assert_equal '0x10101', landscape.service
|
1034
|
+
assert_equal '0x50000000', landscape.handle
|
1035
|
+
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
def test_model_parse
|
1039
|
+
|
1040
|
+
model_output = @session.show_models
|
1041
|
+
model = SpecTools::Model.parse(model_output.readline)
|
1042
|
+
assert_instance_of SpecTools::Model, model
|
1043
|
+
assert_equal '0x40000025', model.handle
|
1044
|
+
assert_equal 'MgmtInventory', model.name
|
1045
|
+
assert_equal '0x25e0000', model.type.handle
|
1046
|
+
assert_equal 'MgmtInventory', model.type.name
|
1047
|
+
|
1048
|
+
end
|
1049
|
+
|
1050
|
+
def test_association_parse_parent
|
1051
|
+
|
1052
|
+
assoc_output = @session.show_parents('0x4000004b')
|
1053
|
+
assoc = SpecTools::Association.parse_parent(assoc_output.readline)
|
1054
|
+
assert_instance_of SpecTools::Association, assoc
|
1055
|
+
assert_equal '0x40000042', assoc.left_model.handle
|
1056
|
+
assert_equal 'TopService', assoc.left_model.name
|
1057
|
+
assert_equal '0x13d0019', assoc.left_model.type.handle
|
1058
|
+
assert_equal 'Top_Service', assoc.left_model.type.name
|
1059
|
+
assert_equal 'Requires', assoc.relation.name
|
1060
|
+
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
def test_relation_parse
|
1064
|
+
|
1065
|
+
rel_output = @session.show_relations
|
1066
|
+
rel = SpecTools::Relation.parse(rel_output.readline)
|
1067
|
+
assert_instance_of SpecTools::Relation, rel
|
1068
|
+
assert_equal 'Contains', rel.name
|
1069
|
+
assert_equal 'ONE_TO_MANY', rel.type
|
1070
|
+
|
1071
|
+
end
|
1072
|
+
|
1073
|
+
def test_rule_parse
|
1074
|
+
|
1075
|
+
rules_output = @session.show_rules('Collects')
|
1076
|
+
rule = SpecTools::Rule.parse(rules_output.readline)
|
1077
|
+
assert_instance_of SpecTools::Rule, rule
|
1078
|
+
assert_equal '0x3f50001', rule.left_mtype.handle
|
1079
|
+
assert_equal 'BbSrvContainer', rule.left_mtype.name
|
1080
|
+
assert_equal '0x3f50001', rule.right_mtype.handle
|
1081
|
+
assert_equal 'BbSrvContainer', rule.right_mtype.name
|
1082
|
+
|
1083
|
+
end
|
1084
|
+
|
1085
|
+
def test_watch_parse
|
1086
|
+
|
1087
|
+
watch_output = @session.show_watch('0x4000004b')
|
1088
|
+
watch = SpecTools::Watch.parse(watch_output.readline)
|
1089
|
+
assert_instance_of SpecTools::Watch, watch
|
1090
|
+
assert_equal '0x13d0190', watch.id
|
1091
|
+
assert_equal 'TotalRedTime', watch.name
|
1092
|
+
assert_equal 'PollLog/Calc', watch.type
|
1093
|
+
assert_equal 'ACTIVE', watch.status
|
1094
|
+
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
def test_alarm_parse
|
1098
|
+
|
1099
|
+
alarm_output = @session.show_alarms
|
1100
|
+
alarm = SpecTools::Alarm.parse(alarm_output.readline)
|
1101
|
+
assert_instance_of SpecTools::Alarm, alarm
|
1102
|
+
assert_equal '98', alarm.id
|
1103
|
+
assert_equal Time.local(2007,9,20,17,19,13), alarm.time
|
1104
|
+
assert_equal '0x13df00c', alarm.causeid
|
1105
|
+
assert_equal '0x40000175', alarm.model.handle
|
1106
|
+
assert_equal 'Gold SLA', alarm.model.name
|
1107
|
+
assert_equal 'SLA', alarm.model.type.name
|
1108
|
+
assert_equal 'CRITICAL', alarm.severity
|
1109
|
+
assert_equal false, alarm.ack
|
1110
|
+
assert_equal false, alarm.stale
|
1111
|
+
|
1112
|
+
end
|
1113
|
+
|
1114
|
+
def test_model_cli_find_all
|
1115
|
+
VNMSH.default_session = @session
|
1116
|
+
|
1117
|
+
models = SpecTools::Model.cli_find
|
1118
|
+
assert_equal 2251, models.size
|
1119
|
+
assert_equal '0x40000028', models[1].handle
|
1120
|
+
assert_equal 'Modeling Gateway', models[1].name
|
1121
|
+
assert_equal '0x4040000', models[1].type.handle
|
1122
|
+
assert_equal 'ModelingGatewy', models[1].type.name
|
1123
|
+
|
1124
|
+
assert_equal '0x40001240', models.last.handle
|
1125
|
+
assert_equal '802.3_Segment', models.last.name
|
1126
|
+
assert_equal '0x100ae', models.last.type.handle
|
1127
|
+
assert_equal 'Fanout', models.last.type.name
|
1128
|
+
|
1129
|
+
VNMSH.default_session = nil
|
1130
|
+
models = nil
|
1131
|
+
assert_raise ArgumentError do
|
1132
|
+
SpecTools::Model.cli_find
|
1133
|
+
end
|
1134
|
+
models = SpecTools::Model.cli_find(nil,nil,@session)
|
1135
|
+
assert_equal 2251, models.size
|
1136
|
+
|
1137
|
+
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
def test_type_cli_find_all
|
1141
|
+
VNMSH.default_session = @session
|
1142
|
+
|
1143
|
+
mtypes = SpecTools::MType.cli_find
|
1144
|
+
assert_equal 4209, mtypes.size
|
1145
|
+
assert_equal '0x10001', mtypes[1].handle
|
1146
|
+
assert_equal 'CabletronFrags', mtypes[1].name
|
1147
|
+
assert_equal true, mtypes[1].visible
|
1148
|
+
assert_equal true, mtypes[1].derivable
|
1149
|
+
|
1150
|
+
assert_equal '0xfff00001', mtypes.last.handle
|
1151
|
+
assert_equal 'IBUS-MIB', mtypes.last.name
|
1152
|
+
assert_equal true, mtypes.last.visible
|
1153
|
+
assert_equal true, mtypes.last.derivable
|
1154
|
+
|
1155
|
+
VNMSH.default_session = nil
|
1156
|
+
mtypes = nil
|
1157
|
+
assert_raise ArgumentError do
|
1158
|
+
SpecTools::MType.cli_find
|
1159
|
+
end
|
1160
|
+
mtypes = SpecTools::MType.cli_find(nil,@session)
|
1161
|
+
assert_equal 4209, mtypes.size
|
1162
|
+
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
def test_alarm_cli_find
|
1166
|
+
VNMSH.default_session = @session
|
1167
|
+
|
1168
|
+
alarms = SpecTools::Alarm.cli_find
|
1169
|
+
assert_equal 9, alarms.size
|
1170
|
+
assert_equal '89', alarms[1].id
|
1171
|
+
assert_equal Time.local(2007,9,20,17,19,13), alarms[1].time
|
1172
|
+
assert_equal '0x13df00d', alarms[1].causeid
|
1173
|
+
assert_equal '0x40000175', alarms[1].model.handle
|
1174
|
+
assert_equal 'Gold SLA', alarms[1].model.name
|
1175
|
+
assert_equal 'SLA', alarms[1].model.type.name
|
1176
|
+
assert_equal 'CRITICAL', alarms[1].severity
|
1177
|
+
|
1178
|
+
assert_equal '3784', alarms.last.id
|
1179
|
+
assert_equal Time.local(2007,9,20,18,30,37), alarms.last.time
|
1180
|
+
assert_equal '0x10519', alarms.last.causeid
|
1181
|
+
assert_equal '0x400005ca', alarms.last.model.handle
|
1182
|
+
assert_equal 'ped90-a3804', alarms.last.model.name
|
1183
|
+
assert_equal 'ExtrDevice', alarms.last.model.type.name
|
1184
|
+
assert_equal 'MINOR', alarms.last.severity
|
1185
|
+
|
1186
|
+
VNMSH.default_session = nil
|
1187
|
+
alarms = nil
|
1188
|
+
assert_raise ArgumentError do
|
1189
|
+
SpecTools::Alarm.cli_find(:all)
|
1190
|
+
end
|
1191
|
+
assert_equal 10, SpecTools::Alarm.cli_find(:all,nil,nil,@session).size
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
def test_event_cli_find_all
|
1195
|
+
VNMSH.default_session = @session
|
1196
|
+
|
1197
|
+
events = SpecTools::Event.cli_find
|
1198
|
+
assert_equal 2000, events.size
|
1199
|
+
assert_equal Time.local(2007,9,21,11,15,41), events[1].time
|
1200
|
+
assert_equal '0x10103', events[1].type
|
1201
|
+
assert_equal '0x40000030', events[1].model.handle
|
1202
|
+
assert_equal 'kloeber', events[1].model.name
|
1203
|
+
assert_equal 'User', events[1].model.type.name
|
1204
|
+
|
1205
|
+
assert_equal Time.local(2007,9,20,18,51,20), events.last.time
|
1206
|
+
|
1207
|
+
VNMSH.default_session = nil
|
1208
|
+
events = nil
|
1209
|
+
assert_raise ArgumentError do
|
1210
|
+
SpecTools::Event.cli_find(:all)
|
1211
|
+
end
|
1212
|
+
events = SpecTools::Event.cli_find(:all,nil,nil,nil,@session)
|
1213
|
+
assert_equal 2000,events.size
|
1214
|
+
|
1215
|
+
end
|
1216
|
+
|
1217
|
+
def test_landscape_cli_find_all
|
1218
|
+
VNMSH.default_session = @session
|
1219
|
+
|
1220
|
+
landscapes = SpecTools::Landscape.get_landscapes
|
1221
|
+
assert_equal 2, landscapes.size
|
1222
|
+
assert_equal 'S81-2', landscapes.first.ss
|
1223
|
+
assert_equal '10', landscapes.first.precedence
|
1224
|
+
assert_equal '0xbeef', landscapes.first.port
|
1225
|
+
assert_equal '0x10101', landscapes.first.service
|
1226
|
+
assert_equal '0x50000000', landscapes.first.handle
|
1227
|
+
|
1228
|
+
VNMSH.default_session = nil
|
1229
|
+
landscapes = nil
|
1230
|
+
assert_raise ArgumentError do
|
1231
|
+
SpecTools::Landscape.get_landscapes
|
1232
|
+
|
1233
|
+
end
|
1234
|
+
landscapes = SpecTools::Landscape.get_landscapes(@session)
|
1235
|
+
assert_equal 2, landscapes.size
|
1236
|
+
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
def test_relation_cli_find_all
|
1240
|
+
VNMSH.default_session = @session
|
1241
|
+
|
1242
|
+
relations = SpecTools::Relation.cli_find
|
1243
|
+
assert_equal 150, relations.size
|
1244
|
+
assert_equal 'Collects', relations[1].name
|
1245
|
+
assert_equal 'ONE_TO_MANY', relations[1].type
|
1246
|
+
|
1247
|
+
assert_equal 'QosUsesApp', relations.last.name
|
1248
|
+
assert_equal 'MANY_TO_MANY', relations.last.type
|
1249
|
+
|
1250
|
+
VNMSH.default_session = nil
|
1251
|
+
assert_raise ArgumentError do
|
1252
|
+
relations = SpecTools::Relation.cli_find(:all)
|
1253
|
+
end
|
1254
|
+
|
1255
|
+
relations = nil
|
1256
|
+
relations = SpecTools::Relation.cli_find(nil,@session)
|
1257
|
+
assert_equal 150, relations.size
|
1258
|
+
|
1259
|
+
end
|
1260
|
+
|
1261
|
+
def test_model_find
|
1262
|
+
|
1263
|
+
assert_equal 2251, SpecTools::Model.find(nil,nil,@session).size
|
1264
|
+
|
1265
|
+
assert_equal 20, SpecTools::Model.find(nil,true,@session).size
|
1266
|
+
|
1267
|
+
assert_equal 17, SpecTools::Model.find({:range,['0x40000000','0x40000010']},nil,@session).size
|
1268
|
+
assert_raise ArgumentError do
|
1269
|
+
SpecTools::Model.find({:range,['bogus','0x400020']},nil,@session)
|
1270
|
+
end
|
1271
|
+
|
1272
|
+
assert_raise ArgumentError do
|
1273
|
+
SpecTools::Model.find({:range,['0x400000','bogus']},nil,@session)
|
1274
|
+
end
|
1275
|
+
|
1276
|
+
assert_equal '0x40000178', SpecTools::Model.find({:name,'DTM'},false,@session).first.handle
|
1277
|
+
|
1278
|
+
assert_equal 'S3', SpecTools::Model.find({:type,'0x13d0018'},nil,@session).first.name
|
1279
|
+
assert_equal 'S3', SpecTools::Model.find({:type,MType.new('0x13d0018')},nil,@session).first.name
|
1280
|
+
|
1281
|
+
assert_raise ArgumentError do
|
1282
|
+
SpecTools::Model.find({:mtype,'bogus'})
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
assert_equal 1, SpecTools::Model.find_by_attr('0x1006e','intspeclab01',false,false,@session).size
|
1286
|
+
assert_equal 1, SpecTools::Model.find_by_attr(Attr.new('0x1006e',nil,'intspeclab01'),false,false,@session).size
|
1287
|
+
|
1288
|
+
assert_equal 16,SpecTools::Model.find_by_attr('0x1006e','intspeclab01',true,false,@session).size
|
1289
|
+
assert_raise ArgumentError do
|
1290
|
+
SpecTools::Model.find_by_attr(Attr.new,false,false,@session)
|
1291
|
+
end
|
1292
|
+
assert_raise ArgumentError do
|
1293
|
+
SpecTools::Model.find_by_attr('bogus',nil,false,false,@session)
|
1294
|
+
end
|
1295
|
+
|
1296
|
+
end
|
1297
|
+
|
1298
|
+
def test_mtype_find
|
1299
|
+
assert_equal 4209, SpecTools::MType.find(nil,@session).size
|
1300
|
+
assert_equal 3136, SpecTools::MType.find({:flag,:derivable},@session).size
|
1301
|
+
assert_equal 54, SpecTools::MType.find({:range,['0x13d0000','0x13d00ff']},@session).size
|
1302
|
+
assert_raise ArgumentError do
|
1303
|
+
SpecTools::MType.find({:range,['bogus','0x3ccffff']},@session)
|
1304
|
+
end
|
1305
|
+
assert_raise ArgumentError do
|
1306
|
+
SpecTools::MType.find({:range,['0x3cc0000','bogus']},@session)
|
1307
|
+
end
|
1308
|
+
assert_equal 1, SpecTools::MType.find({:name,'IcsLicenseMgr'},@session).size
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
def test_alarm_find
|
1312
|
+
assert_equal 9, SpecTools::Alarm.find(:standard,nil,nil,@session).size
|
1313
|
+
#assert_equal '', SpecTools::Alarm.find('0x40313f',@session).first.model.name
|
1314
|
+
assert_match(/service has been unavailable/,SpecTools::Alarm.find(:standard,nil,true,@session)[1].message)
|
1315
|
+
end
|
1316
|
+
|
1317
|
+
def test_event_find
|
1318
|
+
assert_equal 2000, SpecTools::Event.find(:all,nil,nil,nil,@session).size
|
1319
|
+
assert_equal 10000, SpecTools::Event.find(:all,nil,:all,nil,@session).size
|
1320
|
+
assert_equal 5, SpecTools::Event.find(:all,nil,5,nil,@session).size
|
1321
|
+
assert_equal 2000, SpecTools::Event.find(:model,'0x400000',nil,nil,@session).size
|
1322
|
+
assert_match(/SpectroSERVER has disconnected/,SpecTools::Event.find(:all,nil,nil,true,@session).first.message)
|
1323
|
+
assert_equal 2000, SpecTools::Event.find(:model,'0x400000',nil,nil,@session).size
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
def test_landscape_get
|
1327
|
+
assert_equal 2, SpecTools::Landscape.get_landscapes(@session).size
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
def test_relation_find_all
|
1331
|
+
assert_equal 150, SpecTools::Relation.find(nil,@session).size
|
1332
|
+
end
|
1333
|
+
|
1334
|
+
def test_cli_attr_get
|
1335
|
+
VNMSH.default_session = @session
|
1336
|
+
model = SpecTools::Model.new('0x400005c7')
|
1337
|
+
attrs = model.cli_get_attrs
|
1338
|
+
model.cli_get_attrs!
|
1339
|
+
assert_equal attrs.size, model.attrs.size
|
1340
|
+
|
1341
|
+
attrs = model.cli_get_attrs({:id,'0x10030'})
|
1342
|
+
assert_equal 1, attrs.size
|
1343
|
+
|
1344
|
+
enummodel = Model.new('0x4000017b')
|
1345
|
+
sattrs = enummodel.cli_get_attrs({:id,'0x13d0315'},true)
|
1346
|
+
assert_equal 'Record/s', sattrs['0x13d0315'].value
|
1347
|
+
|
1348
|
+
sattrs = model.cli_get_attrs({:instance,['0x12a53','192.2.20.2']})
|
1349
|
+
assert_equal '20030', sattrs['0x12a53'].value
|
1350
|
+
assert_equal '20030', sattrs['0x12a53'].value_table['192.2.20.2']
|
1351
|
+
|
1352
|
+
attrs = model.get_attrs({:id,'0x10030'})
|
1353
|
+
assert_equal 1, attrs.size
|
1354
|
+
|
1355
|
+
|
1356
|
+
model.get_attrs!({:id,'0x10030'})
|
1357
|
+
assert_instance_of Hash,model.attrs
|
1358
|
+
assert_equal 1, model.attrs.size
|
1359
|
+
|
1360
|
+
attrs = model.cli_get_attrs({:range, ['0x10000', '0x10010']})
|
1361
|
+
assert_equal 11, attrs.size
|
1362
|
+
|
1363
|
+
assert_equal 11, model.cli_get_attrs({:range, '0x10000-0x10010'}).size
|
1364
|
+
|
1365
|
+
model = SpecTools::Model.new('0x400005c7')
|
1366
|
+
model.get_attrs!
|
1367
|
+
assert_equal '0x36c001a', model.attrs['0x11fb4'].value_table['129']
|
1368
|
+
assert_equal 53, model.attrs['0x11fb4'].value_table.size
|
1369
|
+
assert_equal 780, model.attrs.size
|
1370
|
+
|
1371
|
+
assert_raise ArgumentError do
|
1372
|
+
model.cli_get_attrs({:range,['bogus','0x1007c']})
|
1373
|
+
end
|
1374
|
+
|
1375
|
+
assert_raise ArgumentError do
|
1376
|
+
model.cli_get_attrs({:range,['0x10010','bogus']})
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
attrs = model.cli_get_attrs({:name, 'Condition'})
|
1380
|
+
assert_equal '0', attrs[attrs.keys.first].value
|
1381
|
+
|
1382
|
+
model.handle = 'bogus'
|
1383
|
+
assert_raise ArgumentError do
|
1384
|
+
model.cli_get_attrs
|
1385
|
+
end
|
1386
|
+
|
1387
|
+
end
|
1388
|
+
|
1389
|
+
def test_cli_attr_mtype_get
|
1390
|
+
VNMSH.default_session = @session
|
1391
|
+
mtype = SpecTools::MType.new('0x13d0018')
|
1392
|
+
attrs = mtype.cli_get_attrs
|
1393
|
+
mtype.cli_get_attrs!
|
1394
|
+
|
1395
|
+
assert_equal attrs.size, mtype.attrs.size
|
1396
|
+
|
1397
|
+
assert_equal 11, mtype.cli_get_attrs({:range,['0x10000','0x10010']}).size
|
1398
|
+
|
1399
|
+
#assert_equal '', mtype.cli_get_attr(:name,'Condition').first.type
|
1400
|
+
|
1401
|
+
attrs = mtype.cli_get_attrs({:flag, :global})
|
1402
|
+
assert_equal 'Security_String', attrs['0x10009'].name
|
1403
|
+
|
1404
|
+
assert_raise ArgumentError do
|
1405
|
+
mtype.cli_get_attrs({:range,['bogus','0x1007c']})
|
1406
|
+
end
|
1407
|
+
|
1408
|
+
assert_raise ArgumentError do
|
1409
|
+
mtype.cli_get_attrs({:range,['0x10010','bogus']})
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
assert_equal 241, mtype.get_attrs.size
|
1413
|
+
|
1414
|
+
mtype.attrs = Hash.new
|
1415
|
+
mtype.get_attrs!
|
1416
|
+
assert_equal 241, mtype.attrs.size
|
1417
|
+
|
1418
|
+
|
1419
|
+
|
1420
|
+
mtype.handle = 'bogus'
|
1421
|
+
|
1422
|
+
assert_raise ArgumentError do
|
1423
|
+
mtype.cli_get_attrs
|
1424
|
+
end
|
1425
|
+
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
def test_cli_model_children
|
1429
|
+
VNMSH.default_session = @session
|
1430
|
+
model = SpecTools::Model.new('0x400005cb')
|
1431
|
+
|
1432
|
+
assert_equal 46, model.cli_get_children.size
|
1433
|
+
|
1434
|
+
assert_equal 46, model.get_children.size
|
1435
|
+
|
1436
|
+
assert_equal 13, model.get_children('PossPrimApp').size
|
1437
|
+
|
1438
|
+
rel = SpecTools::Relation.new('PossPrimApp')
|
1439
|
+
assert_equal 13, model.get_children(rel).size
|
1440
|
+
|
1441
|
+
model.handle = 'bogus'
|
1442
|
+
|
1443
|
+
assert_raise ArgumentError do
|
1444
|
+
model.cli_get_children
|
1445
|
+
end
|
1446
|
+
end
|
1447
|
+
|
1448
|
+
def test_cli_model_parents
|
1449
|
+
VNMSH.default_session = @session
|
1450
|
+
model = SpecTools::Model.new('0x4000004b')
|
1451
|
+
|
1452
|
+
assert_equal '0x40000042', model.cli_get_parents.first.handle
|
1453
|
+
|
1454
|
+
assert_equal '0x40000042', model.get_parents.first.handle
|
1455
|
+
|
1456
|
+
assert_equal '0x40000042', model.get_parents('Collects').first.handle
|
1457
|
+
|
1458
|
+
rel = SpecTools::Relation.new('Collects')
|
1459
|
+
assert_equal '0x40000042', model.get_parents(rel).first.handle
|
1460
|
+
|
1461
|
+
model.handle = 'bogus'
|
1462
|
+
assert_raise ArgumentError do
|
1463
|
+
model.cli_get_parents
|
1464
|
+
end
|
1465
|
+
end
|
1466
|
+
|
1467
|
+
def test_cli_attr_enums
|
1468
|
+
VNMSH.default_session = @session
|
1469
|
+
|
1470
|
+
sattr = SpecTools::Attr.new('0x13d031e')
|
1471
|
+
|
1472
|
+
assert_equal 3, sattr.cli_get_enums.size
|
1473
|
+
|
1474
|
+
assert_equal 3, sattr.get_enums.size
|
1475
|
+
sattr.value = '0'
|
1476
|
+
assert_equal 'Resource Faced', sattr.enumerate
|
1477
|
+
sattr.enumerate!
|
1478
|
+
assert_equal 'Resource Faced', sattr.value
|
1479
|
+
sattr.get_enums!
|
1480
|
+
assert_equal 3, sattr.enums.size
|
1481
|
+
|
1482
|
+
end
|
1483
|
+
|
1484
|
+
def test_cli_rules_find
|
1485
|
+
relation = SpecTools::Relation.new('Collects')
|
1486
|
+
assert_equal 5837, relation.cli_get_rules.size
|
1487
|
+
assert_equal 5837, relation.get_rules.size
|
1488
|
+
end
|
1489
|
+
|
1490
|
+
def test_cli_watch_find
|
1491
|
+
model = SpecTools::Model.new('0x4000004b')
|
1492
|
+
assert_equal 8, model.cli_get_watches(@session).size
|
1493
|
+
assert_equal 8, model.get_watches(@session).size
|
1494
|
+
assert_raise ArgumentError do
|
1495
|
+
model.handle = 'bogus'
|
1496
|
+
model.cli_get_watches
|
1497
|
+
end
|
1498
|
+
|
1499
|
+
end
|
1500
|
+
|
1501
|
+
def test_model_cli_destroy
|
1502
|
+
assert Model.cli_destroy('0x40b42b',@session)
|
1503
|
+
assert Model.destroy('0x40b42b',@session)
|
1504
|
+
model = Model.new('0x40b42b',@session)
|
1505
|
+
assert model.cli_destroy(@session)
|
1506
|
+
assert model.destroy(@session)
|
1507
|
+
assert_raise ArgumentError do
|
1508
|
+
model.handle = 'bogus'
|
1509
|
+
model.destroy(@session)
|
1510
|
+
end
|
1511
|
+
end
|
1512
|
+
|
1513
|
+
def test_association_destroy
|
1514
|
+
assert Association.cli_destroy('0x4065e8','0x40b63e','Connects_to',@session)
|
1515
|
+
assert Association.destroy('0x4065e8','0x40b63e','Connects_to',@session)
|
1516
|
+
assoc = Association.new(Model.new('0x4065e8'),Model.new('0x40b63e'),Relation.new('Connects_to'))
|
1517
|
+
assert assoc.cli_destroy(@session)
|
1518
|
+
assert assoc.destroy(@session)
|
1519
|
+
assert_raise ArgumentError do
|
1520
|
+
assoc.left_model.handle = 'bogus'
|
1521
|
+
assoc.cli_destroy(@session)
|
1522
|
+
end
|
1523
|
+
end
|
1524
|
+
|
1525
|
+
def test_alarm_destroy
|
1526
|
+
assert Alarm.cli_destroy('7888881',nil,@session)
|
1527
|
+
assert Alarm.destroy('7888881',Landscape.new('0x4000000'),@session)
|
1528
|
+
Alarm.new('7888881').destroy(nil,@session)
|
1529
|
+
end
|
1530
|
+
|
1531
|
+
def teardown
|
1532
|
+
@session = nil
|
1533
|
+
SpecTools::Config.default_access_method = @orig_default_access_method
|
1534
|
+
destroy_temp_vnmsh
|
1535
|
+
end
|
1536
|
+
|
1537
|
+
end
|