ruby-libvirt-catphish 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +510 -0
- data/NEWS +141 -0
- data/README +219 -0
- data/README.rdoc +28 -0
- data/Rakefile +166 -0
- data/ext/libvirt/_libvirt.c +1033 -0
- data/ext/libvirt/common.c +490 -0
- data/ext/libvirt/common.h +285 -0
- data/ext/libvirt/connect.c +3501 -0
- data/ext/libvirt/connect.h +12 -0
- data/ext/libvirt/domain.c +5907 -0
- data/ext/libvirt/domain.h +11 -0
- data/ext/libvirt/extconf.h +392 -0
- data/ext/libvirt/extconf.rb +506 -0
- data/ext/libvirt/interface.c +200 -0
- data/ext/libvirt/interface.h +8 -0
- data/ext/libvirt/network.c +555 -0
- data/ext/libvirt/network.h +8 -0
- data/ext/libvirt/nodedevice.c +299 -0
- data/ext/libvirt/nodedevice.h +8 -0
- data/ext/libvirt/nwfilter.c +138 -0
- data/ext/libvirt/nwfilter.h +8 -0
- data/ext/libvirt/secret.c +268 -0
- data/ext/libvirt/secret.h +8 -0
- data/ext/libvirt/storage.c +1022 -0
- data/ext/libvirt/storage.h +6 -0
- data/ext/libvirt/stream.c +392 -0
- data/ext/libvirt/stream.h +9 -0
- data/lib/libvirt.rb +40 -0
- data/tests/test_conn.rb +818 -0
- data/tests/test_domain.rb +1443 -0
- data/tests/test_interface.rb +100 -0
- data/tests/test_network.rb +175 -0
- data/tests/test_nodedevice.rb +90 -0
- data/tests/test_nwfilter.rb +60 -0
- data/tests/test_open.rb +250 -0
- data/tests/test_secret.rb +114 -0
- data/tests/test_storage.rb +527 -0
- data/tests/test_stream.rb +171 -0
- data/tests/test_utils.rb +254 -0
- metadata +84 -0
data/tests/test_conn.rb
ADDED
@@ -0,0 +1,818 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# Test the conn methods the bindings support
|
4
|
+
|
5
|
+
$: << File.dirname(__FILE__)
|
6
|
+
|
7
|
+
require 'libvirt'
|
8
|
+
require 'test_utils.rb'
|
9
|
+
|
10
|
+
set_test_object("connect")
|
11
|
+
|
12
|
+
conn = Libvirt::open("qemu:///system")
|
13
|
+
|
14
|
+
cleanup_test_domain(conn)
|
15
|
+
cleanup_test_network(conn)
|
16
|
+
|
17
|
+
# test setup
|
18
|
+
begin
|
19
|
+
`rm -f /etc/sysconfig/network-scripts/ifcfg-rb-libvirt-test`
|
20
|
+
`brctl delbr rb-libvirt-test >& /dev/null`
|
21
|
+
rescue
|
22
|
+
end
|
23
|
+
`qemu-img create -f qcow2 #{$GUEST_DISK} 5G`
|
24
|
+
`rm -rf #{$POOL_PATH}; mkdir #{$POOL_PATH} ; echo $?`
|
25
|
+
|
26
|
+
cpu_xml = <<EOF
|
27
|
+
<cpu>
|
28
|
+
<arch>x86_64</arch>
|
29
|
+
<model>athlon</model>
|
30
|
+
</cpu>
|
31
|
+
EOF
|
32
|
+
|
33
|
+
# TESTGROUP: conn.close
|
34
|
+
conn2 = Libvirt::open("qemu:///system")
|
35
|
+
expect_too_many_args(conn2, "close", 1)
|
36
|
+
expect_success(conn2, "no args", "close")
|
37
|
+
|
38
|
+
# TESTGROUP: conn.closed?
|
39
|
+
conn2 = Libvirt::open("qemu:///system")
|
40
|
+
|
41
|
+
expect_too_many_args(conn2, "closed?", 1)
|
42
|
+
expect_success(conn2, "no args", "closed?") {|x| x == false }
|
43
|
+
conn2.close
|
44
|
+
expect_success(conn2, "no args", "closed?") {|x| x == true }
|
45
|
+
|
46
|
+
# TESTGROUP: conn.type
|
47
|
+
expect_too_many_args(conn, "type", 1)
|
48
|
+
|
49
|
+
expect_success(conn, "no args", "type") {|x| x == "QEMU"}
|
50
|
+
|
51
|
+
# TESTGROUP: conn.version
|
52
|
+
expect_too_many_args(conn, "version", 1)
|
53
|
+
|
54
|
+
expect_success(conn, "no args", "version")
|
55
|
+
|
56
|
+
# TESTGROUP: conn.libversion
|
57
|
+
expect_too_many_args(conn, "libversion", 1)
|
58
|
+
|
59
|
+
expect_success(conn, "no args", "libversion")
|
60
|
+
|
61
|
+
# TESTGROUP: conn.hostname
|
62
|
+
expect_too_many_args(conn, "hostname", 1)
|
63
|
+
|
64
|
+
expect_success(conn, "no args", "hostname")
|
65
|
+
|
66
|
+
# TESTGROUP: conn.uri
|
67
|
+
expect_too_many_args(conn, "uri", 1)
|
68
|
+
|
69
|
+
expect_success(conn, "no args", "uri") {|x| x == "qemu:///system" }
|
70
|
+
|
71
|
+
# TESTGROUP: conn.max_vcpus
|
72
|
+
expect_too_many_args(conn, "max_vcpus", 'kvm', 1)
|
73
|
+
expect_fail(conn, Libvirt::RetrieveError, "invalid arg", "max_vcpus", "foo")
|
74
|
+
|
75
|
+
expect_success(conn, "no args", "max_vcpus")
|
76
|
+
expect_success(conn, "nil arg", "max_vcpus")
|
77
|
+
expect_success(conn, "kvm arg", "max_vcpus")
|
78
|
+
expect_success(conn, "qemu arg", "max_vcpus")
|
79
|
+
|
80
|
+
# TESTGROUP: conn.node_get_info
|
81
|
+
expect_too_many_args(conn, "node_get_info", 1)
|
82
|
+
|
83
|
+
expect_success(conn, "no args", "node_get_info")
|
84
|
+
|
85
|
+
# TESTGROUP: conn.node_free_memory
|
86
|
+
expect_too_many_args(conn, "node_free_memory", 1)
|
87
|
+
|
88
|
+
expect_success(conn, "no args", "node_free_memory")
|
89
|
+
|
90
|
+
# TESTGROUP: conn.node_cells_free_memory
|
91
|
+
expect_too_many_args(conn, "node_cells_free_memory", 1, 2, 3)
|
92
|
+
expect_invalid_arg_type(conn, "node_cells_free_memory", 'start')
|
93
|
+
expect_invalid_arg_type(conn, "node_cells_free_memory", 0, 'end')
|
94
|
+
|
95
|
+
expect_success(conn, "no args", "node_cells_free_memory")
|
96
|
+
expect_success(conn, "start cell", "node_cells_free_memory", 0)
|
97
|
+
expect_success(conn, "start cell and max cells", "node_cells_free_memory", 0, 1)
|
98
|
+
|
99
|
+
# TESTGROUP: conn.node_get_security_model
|
100
|
+
expect_too_many_args(conn, "node_get_security_model", 1)
|
101
|
+
expect_success(conn, "no args", "node_get_security_model")
|
102
|
+
|
103
|
+
# TESTGROUP: conn.encrypted?
|
104
|
+
expect_too_many_args(conn, "encrypted?", 1)
|
105
|
+
expect_success(conn, "no args", "encrypted?")
|
106
|
+
|
107
|
+
# TESTGROUP: conn.secure?
|
108
|
+
expect_too_many_args(conn, "secure?", 1)
|
109
|
+
expect_success(conn, "no args", "secure?") {|x| x == true}
|
110
|
+
|
111
|
+
# TESTGROUP: conn.capabilities
|
112
|
+
expect_too_many_args(conn, "capabilities", 1)
|
113
|
+
expect_success(conn, "no args", "capabilities")
|
114
|
+
|
115
|
+
# TESTGROUP: conn.compare_cpu
|
116
|
+
expect_too_many_args(conn, "compare_cpu", 1, 2, 3)
|
117
|
+
expect_too_few_args(conn, "compare_cpu")
|
118
|
+
expect_invalid_arg_type(conn, "compare_cpu", 1)
|
119
|
+
expect_invalid_arg_type(conn, "compare_cpu", "hello", 'bar')
|
120
|
+
expect_fail(conn, Libvirt::RetrieveError, "invalid XML", "compare_cpu", "hello")
|
121
|
+
expect_success(conn, "CPU XML", "compare_cpu", cpu_xml)
|
122
|
+
|
123
|
+
# TESTGROUP: conn.baseline_cpu
|
124
|
+
expect_too_many_args(conn, "baseline_cpu", 1, 2, 3)
|
125
|
+
expect_too_few_args(conn, "baseline_cpu")
|
126
|
+
expect_invalid_arg_type(conn, "baseline_cpu", 1)
|
127
|
+
expect_invalid_arg_type(conn, "baseline_cpu", [cpu_xml], "foo")
|
128
|
+
expect_fail(conn, ArgumentError, "empty array", "baseline_cpu", [])
|
129
|
+
expect_success(conn, "CPU XML", "baseline_cpu", [cpu_xml])
|
130
|
+
|
131
|
+
# TESTGROUP: conn.domain_event_register_any
|
132
|
+
dom_event_callback_proc = lambda {|connect, dom, event, detail, opaque|
|
133
|
+
}
|
134
|
+
|
135
|
+
# def dom_event_callback_symbol(conn, dom, event, detail, opaque)
|
136
|
+
# end
|
137
|
+
|
138
|
+
expect_too_many_args(conn, "domain_event_register_any", 1, 2, 3, 4, 5)
|
139
|
+
expect_too_few_args(conn, "domain_event_register_any")
|
140
|
+
expect_too_few_args(conn, "domain_event_register_any", 1)
|
141
|
+
expect_invalid_arg_type(conn, "domain_event_register_any", "hello", 1)
|
142
|
+
expect_invalid_arg_type(conn, "domain_event_register_any", Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE, 1)
|
143
|
+
expect_invalid_arg_type(conn, "domain_event_register_any", Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE, dom_event_callback_proc, 1)
|
144
|
+
expect_fail(conn, ArgumentError, "invalid event ID", "domain_event_register_any", 456789, dom_event_callback_proc)
|
145
|
+
|
146
|
+
# callbackID = expect_success(conn, "eventID and proc", "domain_event_register_any", Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE, dom_event_callback_proc)
|
147
|
+
# conn.domain_event_deregister_any(callbackID)
|
148
|
+
|
149
|
+
# callbackID = expect_success(conn, "eventID and symbol", "domain_event_register_any", Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE, :dom_event_callback_symbol)
|
150
|
+
# conn.domain_event_deregister_any(callbackID)
|
151
|
+
|
152
|
+
# callbackID = expect_success(conn, "eventID, proc, nil domain", "domain_event_register_any", Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE, dom_event_callback_proc, nil)
|
153
|
+
# conn.domain_event_deregister_any(callbackID)
|
154
|
+
|
155
|
+
# callbackID = expect_success(conn, "eventID, proc, nil domain, opaque", "domain_event_register_any", Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE, dom_event_callback_proc, nil, "opaque user data")
|
156
|
+
# conn.domain_event_deregister_any(callbackID)
|
157
|
+
|
158
|
+
# # TESTGROUP: conn.domain_event_deregister_any
|
159
|
+
# dom_event_callback_proc = lambda {|conn, dom, event, detail, opaque|
|
160
|
+
# }
|
161
|
+
|
162
|
+
# callbackID = conn.domain_event_register_any(Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE, dom_event_callback_proc)
|
163
|
+
|
164
|
+
expect_too_many_args(conn, "domain_event_deregister_any", 1, 2)
|
165
|
+
expect_too_few_args(conn, "domain_event_deregister_any")
|
166
|
+
expect_invalid_arg_type(conn, "domain_event_deregister_any", "hello")
|
167
|
+
|
168
|
+
# expect_success(conn, "callbackID", "domain_event_deregister_any", callbackID)
|
169
|
+
|
170
|
+
# TESTGROUP: conn.domain_event_register
|
171
|
+
# dom_event_callback_proc = lambda {|conn, dom, event, detail, opaque|
|
172
|
+
# }
|
173
|
+
|
174
|
+
# def dom_event_callback_symbol(conn, dom, event, detail, opaque)
|
175
|
+
# end
|
176
|
+
|
177
|
+
expect_too_many_args(conn, "domain_event_register", 1, 2, 3)
|
178
|
+
expect_too_few_args(conn, "domain_event_register")
|
179
|
+
expect_invalid_arg_type(conn, "domain_event_register", "hello")
|
180
|
+
|
181
|
+
# expect_success(conn, "proc", "domain_event_register", dom_event_callback_proc)
|
182
|
+
# conn.domain_event_deregister
|
183
|
+
|
184
|
+
# expect_success(conn, "symbol", "domain_event_register", :dom_event_callback_symbol)
|
185
|
+
# conn.domain_event_deregister
|
186
|
+
|
187
|
+
# expect_success(conn, "proc and opaque", "domain_event_register", dom_event_callback_proc, "opaque user data")
|
188
|
+
# conn.domain_event_deregister
|
189
|
+
|
190
|
+
# # TESTGROUP: conn.domain_event_deregister
|
191
|
+
# dom_event_callback_proc = lambda {|conn, dom, event, detail, opaque|
|
192
|
+
# }
|
193
|
+
|
194
|
+
# conn.domain_event_register(dom_event_callback_proc)
|
195
|
+
|
196
|
+
expect_too_many_args(conn, "domain_event_deregister", 1)
|
197
|
+
# expect_success(conn, "no args", "domain_event_deregister")
|
198
|
+
|
199
|
+
# TESTGROUP: conn.num_of_domains
|
200
|
+
expect_too_many_args(conn, "num_of_domains", 1)
|
201
|
+
expect_success(conn, "no args", "num_of_domains")
|
202
|
+
|
203
|
+
# TESTGROUP: conn.list_domains
|
204
|
+
expect_too_many_args(conn, "list_domains", 1)
|
205
|
+
expect_success(conn, "no args", "list_domains")
|
206
|
+
|
207
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
208
|
+
sleep 1
|
209
|
+
|
210
|
+
expect_success(conn, "no args", "list_domains")
|
211
|
+
|
212
|
+
newdom.destroy
|
213
|
+
|
214
|
+
# TESTGROUP: conn.num_of_defined_domains
|
215
|
+
expect_too_many_args(conn, "num_of_defined_domains", 1)
|
216
|
+
expect_success(conn, "no args", "num_of_defined_domains")
|
217
|
+
|
218
|
+
# TESTGROUP: conn.list_defined_domains
|
219
|
+
expect_too_many_args(conn, "list_defined_domains", 1)
|
220
|
+
expect_success(conn, "no args", "list_defined_domains")
|
221
|
+
|
222
|
+
# TESTGROUP: conn.create_domain_linux
|
223
|
+
expect_too_many_args(conn, "create_domain_linux", $new_dom_xml, 0, 1)
|
224
|
+
expect_too_few_args(conn, "create_domain_linux")
|
225
|
+
expect_invalid_arg_type(conn, "create_domain_linux", nil)
|
226
|
+
expect_invalid_arg_type(conn, "create_domain_linux", 1)
|
227
|
+
expect_invalid_arg_type(conn, "create_domain_linux", $new_dom_xml, "foo")
|
228
|
+
expect_fail(conn, Libvirt::Error, "invalid xml", "create_domain_linux", "hello")
|
229
|
+
newdom = expect_success(conn, "domain xml", "create_domain_linux", $new_dom_xml) {|x| x.class == Libvirt::Domain}
|
230
|
+
sleep 1
|
231
|
+
|
232
|
+
expect_fail(conn, Libvirt::Error, "already existing domain", "create_domain_linux", $new_dom_xml)
|
233
|
+
|
234
|
+
newdom.destroy
|
235
|
+
|
236
|
+
# TESTGROUP: conn.create_domain_xml
|
237
|
+
expect_too_many_args(conn, "create_domain_xml", $new_dom_xml, 0, 1)
|
238
|
+
expect_too_few_args(conn, "create_domain_xml")
|
239
|
+
expect_invalid_arg_type(conn, "create_domain_xml", nil)
|
240
|
+
expect_invalid_arg_type(conn, "create_domain_xml", 1)
|
241
|
+
expect_invalid_arg_type(conn, "create_domain_xml", $new_dom_xml, "foo")
|
242
|
+
expect_fail(conn, Libvirt::Error, "invalid xml", "create_domain_xml", "hello")
|
243
|
+
newdom = expect_success(conn, "domain xml", "create_domain_xml", $new_dom_xml) {|x| x.class == Libvirt::Domain}
|
244
|
+
sleep 1
|
245
|
+
|
246
|
+
expect_fail(conn, Libvirt::Error, "already existing domain", "create_domain_xml", $new_dom_xml)
|
247
|
+
|
248
|
+
newdom.destroy
|
249
|
+
|
250
|
+
# TESTGROUP: conn.lookup_domain_by_name
|
251
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
252
|
+
sleep 1
|
253
|
+
|
254
|
+
expect_too_many_args(conn, "lookup_domain_by_name", 1, 2)
|
255
|
+
expect_too_few_args(conn, "lookup_domain_by_name")
|
256
|
+
expect_invalid_arg_type(conn, "lookup_domain_by_name", 1)
|
257
|
+
expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_domain_by_name", "foobarbazsucker")
|
258
|
+
|
259
|
+
expect_success(conn, "name arg for running domain", "lookup_domain_by_name", "rb-libvirt-test") {|x| x.name == "rb-libvirt-test"}
|
260
|
+
newdom.destroy
|
261
|
+
|
262
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
263
|
+
expect_success(conn, "name arg for defined domain", "lookup_domain_by_name", "rb-libvirt-test") {|x| x.name == "rb-libvirt-test"}
|
264
|
+
newdom.undefine
|
265
|
+
|
266
|
+
# TESTGROUP: conn.lookup_domain_by_id
|
267
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
268
|
+
sleep 1
|
269
|
+
|
270
|
+
expect_too_many_args(conn, "lookup_domain_by_id", 1, 2)
|
271
|
+
expect_too_few_args(conn, "lookup_domain_by_id")
|
272
|
+
expect_invalid_arg_type(conn, "lookup_domain_by_id", "foo")
|
273
|
+
expect_fail(conn, Libvirt::Error, "with negative value", "lookup_domain_by_id", -1)
|
274
|
+
|
275
|
+
expect_success(conn, "id arg for running domain", "lookup_domain_by_id", newdom.id)
|
276
|
+
newdom.destroy
|
277
|
+
|
278
|
+
# TESTGROUP: conn.lookup_domain_by_uuid
|
279
|
+
newdom = conn.create_domain_xml($new_dom_xml)
|
280
|
+
sleep 1
|
281
|
+
|
282
|
+
expect_too_many_args(conn, "lookup_domain_by_uuid", 1, 2)
|
283
|
+
expect_too_few_args(conn, "lookup_domain_by_uuid")
|
284
|
+
expect_invalid_arg_type(conn, "lookup_domain_by_uuid", 1)
|
285
|
+
expect_fail(conn, Libvirt::RetrieveError, "invalid UUID", "lookup_domain_by_uuid", "abcd")
|
286
|
+
|
287
|
+
expect_success(conn, "UUID arg for running domain", "lookup_domain_by_uuid", newdom.uuid) {|x| x.uuid == $GUEST_UUID}
|
288
|
+
newdom.destroy
|
289
|
+
|
290
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
291
|
+
expect_success(conn, "UUID arg for defined domain", "lookup_domain_by_uuid", newdom.uuid) {|x| x.uuid == $GUEST_UUID}
|
292
|
+
newdom.undefine
|
293
|
+
|
294
|
+
# TESTGROUP: conn.define_domain_xml
|
295
|
+
expect_too_many_args(conn, "define_domain_xml", 1, 2, 3)
|
296
|
+
expect_too_few_args(conn, "define_domain_xml")
|
297
|
+
expect_invalid_arg_type(conn, "define_domain_xml", 1)
|
298
|
+
expect_invalid_arg_type(conn, "define_domain_xml", nil)
|
299
|
+
expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_domain_xml", "hello")
|
300
|
+
|
301
|
+
newdom = expect_success(conn, "domain xml arg", "define_domain_xml", $new_dom_xml)
|
302
|
+
newdom.undefine
|
303
|
+
|
304
|
+
# TESTGROUP: conn.domain_xml_from_native
|
305
|
+
expect_too_many_args(conn, "domain_xml_from_native", 1, 2, 3, 4)
|
306
|
+
expect_too_few_args(conn, "domain_xml_from_native")
|
307
|
+
expect_too_few_args(conn, "domain_xml_from_native", 1)
|
308
|
+
expect_invalid_arg_type(conn, "domain_xml_from_native", 1, 2)
|
309
|
+
expect_invalid_arg_type(conn, "domain_xml_from_native", nil, 2)
|
310
|
+
expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", 2)
|
311
|
+
expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", nil)
|
312
|
+
expect_invalid_arg_type(conn, "domain_xml_from_native", "qemu-argv", "foo", "bar")
|
313
|
+
expect_fail(conn, Libvirt::Error, "unsupported first arg", "domain_xml_from_native", "foo", "bar")
|
314
|
+
|
315
|
+
expect_success(conn, "qemu-argv and qemu_cmd_line", "domain_xml_from_native", "qemu-argv", $qemu_cmd_line)
|
316
|
+
|
317
|
+
# TESTGROUP: conn.domain_xml_to_native
|
318
|
+
expect_too_many_args(conn, "domain_xml_to_native", 1, 2, 3, 4)
|
319
|
+
expect_too_few_args(conn, "domain_xml_to_native")
|
320
|
+
expect_too_few_args(conn, "domain_xml_to_native", 1)
|
321
|
+
expect_invalid_arg_type(conn, "domain_xml_to_native", 1, 2)
|
322
|
+
expect_invalid_arg_type(conn, "domain_xml_to_native", nil, 2)
|
323
|
+
expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", 2)
|
324
|
+
expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", nil)
|
325
|
+
expect_invalid_arg_type(conn, "domain_xml_to_native", "qemu-argv", "foo", "bar")
|
326
|
+
expect_fail(conn, Libvirt::Error, "unsupported first arg", "domain_xml_to_native", "foo", "bar")
|
327
|
+
|
328
|
+
expect_success(conn, "qemu-argv and domain XML", "domain_xml_to_native", "qemu-argv", $new_dom_xml)
|
329
|
+
|
330
|
+
# TESTGROUP: conn.num_of_interfaces
|
331
|
+
expect_too_many_args(conn, "num_of_interfaces", 1)
|
332
|
+
expect_success(conn, "no args", "num_of_interfaces")
|
333
|
+
|
334
|
+
# TESTGROUP: conn.list_interfaces
|
335
|
+
expect_too_many_args(conn, "list_interfaces", 1)
|
336
|
+
expect_success(conn, "no args", "list_interfaces")
|
337
|
+
|
338
|
+
# TESTGROUP: conn.num_of_defined_interfaces
|
339
|
+
expect_too_many_args(conn, "num_of_defined_interfaces", 1)
|
340
|
+
expect_success(conn, "no args", "num_of_defined_interfaces")
|
341
|
+
|
342
|
+
# TESTGROUP: conn.list_defined_interfaces
|
343
|
+
expect_too_many_args(conn, "list_defined_interfaces", 1)
|
344
|
+
expect_success(conn, "no args", "list_defined_interfaces")
|
345
|
+
|
346
|
+
# TESTGROUP: conn.lookup_interface_by_name
|
347
|
+
newiface = conn.define_interface_xml($new_interface_xml)
|
348
|
+
|
349
|
+
expect_too_many_args(conn, "lookup_interface_by_name", 1, 2)
|
350
|
+
expect_too_few_args(conn, "lookup_interface_by_name")
|
351
|
+
expect_invalid_arg_type(conn, "lookup_interface_by_name", 1)
|
352
|
+
expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_interface_by_name", "foobarbazsucker")
|
353
|
+
|
354
|
+
expect_success(conn, "name arg", "lookup_interface_by_name", "rb-libvirt-test")
|
355
|
+
|
356
|
+
expect_success(conn, "name arg", "lookup_interface_by_name", "rb-libvirt-test")
|
357
|
+
|
358
|
+
newiface.undefine
|
359
|
+
|
360
|
+
# TESTGROUP: conn.lookup_interface_by_mac
|
361
|
+
newiface = conn.define_interface_xml($new_interface_xml)
|
362
|
+
|
363
|
+
expect_too_many_args(conn, "lookup_interface_by_mac", 1, 2)
|
364
|
+
expect_too_few_args(conn, "lookup_interface_by_mac")
|
365
|
+
expect_invalid_arg_type(conn, "lookup_interface_by_mac", 1)
|
366
|
+
expect_fail(conn, Libvirt::RetrieveError, "non-existent mac arg", "lookup_interface_by_mac", "foobarbazsucker")
|
367
|
+
|
368
|
+
# FIXME: we can't look up an interface by MAC address on an inactive interface,
|
369
|
+
# but we also can't start up the interface without a /etc/sysconfig file.
|
370
|
+
#expect_success(conn, "mac arg", "lookup_interface_by_mac", $NEW_INTERFACE_MAC) {|x| x.mac == $NEW_INTERFACE_MAC}
|
371
|
+
|
372
|
+
newiface.undefine
|
373
|
+
|
374
|
+
# TESTGROUP: conn.define_interface_xml
|
375
|
+
expect_too_many_args(conn, "define_interface_xml", 1, 2, 3)
|
376
|
+
expect_too_few_args(conn, "define_interface_xml")
|
377
|
+
expect_invalid_arg_type(conn, "define_interface_xml", 1)
|
378
|
+
expect_invalid_arg_type(conn, "define_interface_xml", nil)
|
379
|
+
expect_invalid_arg_type(conn, "define_interface_xml", "hello", 'foo')
|
380
|
+
expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_interface_xml", "hello")
|
381
|
+
|
382
|
+
expect_success(conn, "interface XML", "define_interface_xml", $new_interface_xml)
|
383
|
+
newiface.undefine
|
384
|
+
|
385
|
+
# TESTGROUP: conn.num_of_networks
|
386
|
+
expect_too_many_args(conn, "num_of_networks", 1)
|
387
|
+
expect_success(conn, "no args", "num_of_networks")
|
388
|
+
|
389
|
+
# TESTGROUP: conn.list_networks
|
390
|
+
expect_too_many_args(conn, "list_networks", 1)
|
391
|
+
expect_success(conn, "no args", "list_networks")
|
392
|
+
|
393
|
+
# TESTGROUP: conn.num_of_defined_networks
|
394
|
+
expect_too_many_args(conn, "num_of_defined_networks", 1)
|
395
|
+
expect_success(conn, "no args", "num_of_defined_networks")
|
396
|
+
|
397
|
+
# TESTGROUP: conn.list_defined_networks
|
398
|
+
expect_too_many_args(conn, "list_defined_networks", 1)
|
399
|
+
expect_success(conn, "no args", "list_defined_networks")
|
400
|
+
|
401
|
+
# TESTGROUP: conn.lookup_network_by_name
|
402
|
+
newnet = conn.create_network_xml($new_net_xml)
|
403
|
+
|
404
|
+
expect_too_many_args(conn, "lookup_network_by_name", 1, 2)
|
405
|
+
expect_too_few_args(conn, "lookup_network_by_name")
|
406
|
+
expect_invalid_arg_type(conn, "lookup_network_by_name", 1)
|
407
|
+
expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_network_by_name", "foobarbazsucker")
|
408
|
+
|
409
|
+
expect_success(conn, "name arg", "lookup_network_by_name", "rb-libvirt-test")
|
410
|
+
newnet.destroy
|
411
|
+
|
412
|
+
newnet = conn.define_network_xml($new_net_xml)
|
413
|
+
expect_success(conn, "name arg", "lookup_network_by_name", "rb-libvirt-test")
|
414
|
+
newnet.undefine
|
415
|
+
|
416
|
+
# TESTGROUP: conn.lookup_network_by_uuid
|
417
|
+
newnet = conn.create_network_xml($new_net_xml)
|
418
|
+
|
419
|
+
expect_too_many_args(conn, "lookup_network_by_uuid", 1, 2)
|
420
|
+
expect_too_few_args(conn, "lookup_network_by_uuid")
|
421
|
+
expect_invalid_arg_type(conn, "lookup_network_by_uuid", 1)
|
422
|
+
expect_fail(conn, Libvirt::RetrieveError, "non-existent uuid arg", "lookup_network_by_uuid", "foobarbazsucker")
|
423
|
+
|
424
|
+
expect_success(conn, "uuid arg", "lookup_network_by_uuid", $NETWORK_UUID)
|
425
|
+
newnet.destroy
|
426
|
+
|
427
|
+
newnet = conn.define_network_xml($new_net_xml)
|
428
|
+
expect_success(conn, "uuid arg", "lookup_network_by_uuid", $NETWORK_UUID)
|
429
|
+
newnet.undefine
|
430
|
+
|
431
|
+
# TESTGROUP: conn.create_network_xml
|
432
|
+
expect_too_many_args(conn, "create_network_xml", $new_net_xml, 0)
|
433
|
+
expect_too_few_args(conn, "create_network_xml")
|
434
|
+
expect_invalid_arg_type(conn, "create_network_xml", nil)
|
435
|
+
expect_invalid_arg_type(conn, "create_network_xml", 1)
|
436
|
+
expect_fail(conn, Libvirt::Error, "invalid xml", "create_network_xml", "hello")
|
437
|
+
|
438
|
+
newnet = expect_success(conn, "network XML", "create_network_xml", $new_net_xml)
|
439
|
+
|
440
|
+
expect_fail(conn, Libvirt::Error, "already existing network", "create_network_xml", $new_net_xml)
|
441
|
+
|
442
|
+
newnet.destroy
|
443
|
+
|
444
|
+
# TESTGROUP: conn.define_network_xml
|
445
|
+
expect_too_many_args(conn, "define_network_xml", 1, 2)
|
446
|
+
expect_too_few_args(conn, "define_network_xml")
|
447
|
+
expect_invalid_arg_type(conn, "define_network_xml", 1)
|
448
|
+
expect_invalid_arg_type(conn, "define_network_xml", nil)
|
449
|
+
expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_network_xml", "hello")
|
450
|
+
|
451
|
+
newnet = expect_success(conn, "network XML", "define_network_xml", $new_net_xml)
|
452
|
+
newnet.undefine
|
453
|
+
|
454
|
+
# TESTGROUP: conn.num_of_nodedevices
|
455
|
+
expect_too_many_args(conn, "num_of_nodedevices", 1, 2, 3)
|
456
|
+
expect_invalid_arg_type(conn, "num_of_nodedevices", 1)
|
457
|
+
expect_invalid_arg_type(conn, "num_of_nodedevices", 'foo', 'bar')
|
458
|
+
expect_success(conn, "no args", "num_of_nodedevices")
|
459
|
+
|
460
|
+
# TESTGROUP: conn.list_nodedevices
|
461
|
+
expect_too_many_args(conn, "list_nodedevices", 1, 2, 3)
|
462
|
+
expect_invalid_arg_type(conn, "list_nodedevices", 1)
|
463
|
+
expect_invalid_arg_type(conn, "list_nodedevices", 'foo', 'bar')
|
464
|
+
expect_success(conn, "no args", "list_nodedevices")
|
465
|
+
|
466
|
+
# TESTGROUP: conn.lookup_nodedevice_by_name
|
467
|
+
testnode = conn.lookup_nodedevice_by_name(conn.list_nodedevices[0])
|
468
|
+
|
469
|
+
expect_too_many_args(conn, "lookup_nodedevice_by_name", 1, 2)
|
470
|
+
expect_too_few_args(conn, "lookup_nodedevice_by_name")
|
471
|
+
expect_invalid_arg_type(conn, "lookup_nodedevice_by_name", 1)
|
472
|
+
expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_nodedevice_by_name", "foobarbazsucker")
|
473
|
+
|
474
|
+
expect_success(conn, "name arg", "lookup_nodedevice_by_name", testnode.name)
|
475
|
+
|
476
|
+
# TESTGROUP: conn.create_nodedevice_xml
|
477
|
+
expect_too_many_args(conn, "create_nodedevice_xml", 1, 2, 3)
|
478
|
+
expect_too_few_args(conn, "create_nodedevice_xml")
|
479
|
+
expect_invalid_arg_type(conn, "create_nodedevice_xml", 1)
|
480
|
+
expect_invalid_arg_type(conn, "create_nodedevice_xml", "foo", 'bar')
|
481
|
+
expect_fail(conn, Libvirt::Error, "invalid XML", "create_nodedevice_xml", "hello")
|
482
|
+
|
483
|
+
#expect_success(conn, "nodedevice XML", "create_nodedevice_xml", "<nodedevice/>")
|
484
|
+
|
485
|
+
# TESTGROUP: conn.num_of_nwfilters
|
486
|
+
expect_too_many_args(conn, "num_of_nwfilters", 1)
|
487
|
+
expect_success(conn, "no args", "num_of_nwfilters")
|
488
|
+
|
489
|
+
# TESTGROUP: conn.list_nwfilters
|
490
|
+
expect_too_many_args(conn, "list_nwfilters", 1)
|
491
|
+
expect_success(conn, "no args", "list_nwfilters")
|
492
|
+
|
493
|
+
# TESTGROUP: conn.lookup_nwfilter_by_name
|
494
|
+
newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
|
495
|
+
|
496
|
+
expect_too_many_args(conn, "lookup_nwfilter_by_name", 1, 2)
|
497
|
+
expect_too_few_args(conn, "lookup_nwfilter_by_name")
|
498
|
+
expect_invalid_arg_type(conn, "lookup_nwfilter_by_name", 1)
|
499
|
+
|
500
|
+
expect_success(conn, "name arg", "lookup_nwfilter_by_name", "rb-libvirt-test")
|
501
|
+
|
502
|
+
newnw.undefine
|
503
|
+
|
504
|
+
# TESTGROUP: conn.lookup_nwfilter_by_uuid
|
505
|
+
newnw = conn.define_nwfilter_xml($new_nwfilter_xml)
|
506
|
+
|
507
|
+
expect_too_many_args(conn, "lookup_nwfilter_by_uuid", 1, 2)
|
508
|
+
expect_too_few_args(conn, "lookup_nwfilter_by_uuid")
|
509
|
+
expect_invalid_arg_type(conn, "lookup_nwfilter_by_uuid", 1)
|
510
|
+
|
511
|
+
expect_success(conn, "uuid arg", "lookup_nwfilter_by_uuid", $NWFILTER_UUID) {|x| x.uuid == $NWFILTER_UUID}
|
512
|
+
|
513
|
+
newnw.undefine
|
514
|
+
|
515
|
+
# TESTGROUP: conn.define_nwfilter_xml
|
516
|
+
expect_too_many_args(conn, "define_nwfilter_xml", 1, 2)
|
517
|
+
expect_too_few_args(conn, "define_nwfilter_xml")
|
518
|
+
expect_invalid_arg_type(conn, "define_nwfilter_xml", 1)
|
519
|
+
expect_invalid_arg_type(conn, "define_nwfilter_xml", nil)
|
520
|
+
expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_nwfilter_xml", "hello")
|
521
|
+
|
522
|
+
newnw = expect_success(conn, "nwfilter XML", "define_nwfilter_xml", $new_nwfilter_xml)
|
523
|
+
|
524
|
+
newnw.undefine
|
525
|
+
|
526
|
+
# TESTGROUP: conn.num_of_secrets
|
527
|
+
expect_too_many_args(conn, "num_of_secrets", 1)
|
528
|
+
expect_success(conn, "no args", "num_of_secrets")
|
529
|
+
|
530
|
+
# TESTGROUP: conn.list_secrets
|
531
|
+
expect_too_many_args(conn, "list_secrets", 1)
|
532
|
+
expect_success(conn, "no args", "list_secrets")
|
533
|
+
|
534
|
+
# TESTGROUP: conn.lookup_secret_by_uuid
|
535
|
+
newsecret = conn.define_secret_xml($new_secret_xml)
|
536
|
+
|
537
|
+
expect_too_many_args(conn, "lookup_secret_by_uuid", 1, 2)
|
538
|
+
expect_too_few_args(conn, "lookup_secret_by_uuid")
|
539
|
+
expect_invalid_arg_type(conn, "lookup_secret_by_uuid", 1)
|
540
|
+
|
541
|
+
expect_success(conn, "uuid arg", "lookup_secret_by_uuid", $SECRET_UUID) {|x| x.uuid == $SECRET_UUID}
|
542
|
+
|
543
|
+
newsecret.undefine
|
544
|
+
|
545
|
+
# TESTGROUP: conn.lookup_secret_by_usage
|
546
|
+
newsecret = conn.define_secret_xml($new_secret_xml)
|
547
|
+
|
548
|
+
expect_too_many_args(conn, "lookup_secret_by_usage", 1, 2, 3)
|
549
|
+
expect_too_few_args(conn, "lookup_secret_by_usage")
|
550
|
+
expect_invalid_arg_type(conn, "lookup_secret_by_usage", 'foo', 1)
|
551
|
+
expect_invalid_arg_type(conn, "lookup_secret_by_usage", 1, 2)
|
552
|
+
expect_fail(conn, Libvirt::RetrieveError, "invalid secret", "lookup_secret_by_usage", Libvirt::Secret::USAGE_TYPE_VOLUME, "foo")
|
553
|
+
|
554
|
+
expect_success(conn, "usage type and key", "lookup_secret_by_usage", Libvirt::Secret::USAGE_TYPE_VOLUME, "/var/lib/libvirt/images/mail.img")
|
555
|
+
|
556
|
+
newsecret.undefine
|
557
|
+
|
558
|
+
# TESTGROUP: conn.define_secret_xml
|
559
|
+
expect_too_many_args(conn, "define_secret_xml", 1, 2, 3)
|
560
|
+
expect_too_few_args(conn, "define_secret_xml")
|
561
|
+
expect_invalid_arg_type(conn, "define_secret_xml", 1)
|
562
|
+
expect_invalid_arg_type(conn, "define_secret_xml", nil)
|
563
|
+
expect_invalid_arg_type(conn, "define_secret_xml", "hello", 'foo')
|
564
|
+
expect_fail(conn, Libvirt::DefinitionError, "invalid XML", "define_secret_xml", "hello")
|
565
|
+
|
566
|
+
expect_success(conn, "secret XML", "define_secret_xml", $new_secret_xml)
|
567
|
+
|
568
|
+
newsecret.undefine
|
569
|
+
|
570
|
+
# TESTGROUP: conn.list_storage_pools
|
571
|
+
expect_too_many_args(conn, "list_storage_pools", 1)
|
572
|
+
expect_success(conn, "no args", "list_storage_pools")
|
573
|
+
|
574
|
+
# TESTGROUP: conn.num_of_storage_pools
|
575
|
+
expect_too_many_args(conn, "num_of_storage_pools", 1)
|
576
|
+
expect_success(conn, "no args", "num_of_storage_pools")
|
577
|
+
|
578
|
+
# TESTGROUP: conn.list_defined_storage_pools
|
579
|
+
expect_too_many_args(conn, "list_defined_storage_pools", 1)
|
580
|
+
expect_success(conn, "no args", "list_defined_storage_pools")
|
581
|
+
|
582
|
+
# TESTGROUP: conn.num_of_defined_storage_pools
|
583
|
+
expect_too_many_args(conn, "num_of_defined_storage_pools", 1)
|
584
|
+
expect_success(conn, "no args", "num_of_defined_storage_pools")
|
585
|
+
|
586
|
+
# TESTGROUP: conn.lookup_storage_pool_by_name
|
587
|
+
newpool = conn.create_storage_pool_xml($new_storage_pool_xml)
|
588
|
+
|
589
|
+
expect_too_many_args(conn, "lookup_storage_pool_by_name", 1, 2)
|
590
|
+
expect_too_few_args(conn, "lookup_storage_pool_by_name")
|
591
|
+
expect_invalid_arg_type(conn, "lookup_storage_pool_by_name", 1)
|
592
|
+
expect_fail(conn, Libvirt::RetrieveError, "non-existent name arg", "lookup_storage_pool_by_name", "foobarbazsucker")
|
593
|
+
|
594
|
+
expect_success(conn, "name arg", "lookup_storage_pool_by_name", "rb-libvirt-test")
|
595
|
+
|
596
|
+
newpool.destroy
|
597
|
+
|
598
|
+
newpool = conn.define_storage_pool_xml($new_storage_pool_xml)
|
599
|
+
expect_success(conn, "name arg", "lookup_storage_pool_by_name", "rb-libvirt-test")
|
600
|
+
newpool.undefine
|
601
|
+
|
602
|
+
# TESTGROUP: conn.lookup_storage_pool_by_uuid
|
603
|
+
newpool = conn.create_storage_pool_xml($new_storage_pool_xml)
|
604
|
+
|
605
|
+
expect_too_many_args(conn, "lookup_storage_pool_by_uuid", 1, 2)
|
606
|
+
expect_too_few_args(conn, "lookup_storage_pool_by_uuid")
|
607
|
+
expect_invalid_arg_type(conn, "lookup_storage_pool_by_uuid", 1)
|
608
|
+
expect_fail(conn, Libvirt::RetrieveError, "non-existent uuid arg", "lookup_storage_pool_by_uuid", "foobarbazsucker")
|
609
|
+
|
610
|
+
expect_success(conn, "uuid arg", "lookup_storage_pool_by_uuid", $POOL_UUID)
|
611
|
+
|
612
|
+
newpool.destroy
|
613
|
+
|
614
|
+
newpool = conn.define_storage_pool_xml($new_storage_pool_xml)
|
615
|
+
|
616
|
+
expect_success(conn, "uuid arg", "lookup_storage_pool_by_uuid", $POOL_UUID)
|
617
|
+
|
618
|
+
newpool.undefine
|
619
|
+
|
620
|
+
# TESTGROUP: conn.create_storage_pool_xml
|
621
|
+
expect_too_many_args(conn, "create_storage_pool_xml", $new_storage_pool_xml, 0, 1)
|
622
|
+
expect_too_few_args(conn, "create_storage_pool_xml")
|
623
|
+
expect_invalid_arg_type(conn, "create_storage_pool_xml", nil)
|
624
|
+
expect_invalid_arg_type(conn, "create_storage_pool_xml", 1)
|
625
|
+
expect_invalid_arg_type(conn, "create_storage_pool_xml", $new_storage_pool_xml, "foo")
|
626
|
+
expect_fail(conn, Libvirt::Error, "invalid xml", "create_storage_pool_xml", "hello")
|
627
|
+
|
628
|
+
expect_success(conn, "storage pool XML", "create_storage_pool_xml", $new_storage_pool_xml)
|
629
|
+
|
630
|
+
expect_fail(conn, Libvirt::Error, "already existing domain", "create_storage_pool_xml", $new_storage_pool_xml)
|
631
|
+
|
632
|
+
newpool.destroy
|
633
|
+
|
634
|
+
# TESTGROUP: conn.define_storage_pool_xml
|
635
|
+
expect_too_many_args(conn, "define_storage_pool_xml", $new_storage_pool_xml, 0, 1)
|
636
|
+
expect_too_few_args(conn, "define_storage_pool_xml")
|
637
|
+
expect_invalid_arg_type(conn, "define_storage_pool_xml", nil)
|
638
|
+
expect_invalid_arg_type(conn, "define_storage_pool_xml", 1)
|
639
|
+
expect_invalid_arg_type(conn, "define_storage_pool_xml", $new_storage_pool_xml, "foo")
|
640
|
+
expect_fail(conn, Libvirt::Error, "invalid xml", "define_storage_pool_xml", "hello")
|
641
|
+
|
642
|
+
expect_success(conn, "storage pool XML", "define_storage_pool_xml", $new_storage_pool_xml)
|
643
|
+
|
644
|
+
newpool.undefine
|
645
|
+
|
646
|
+
# TESTGROUP: conn.discover_storage_pool_sources
|
647
|
+
expect_too_many_args(conn, "discover_storage_pool_sources", 1, 2, 3, 4)
|
648
|
+
expect_too_few_args(conn, "discover_storage_pool_sources")
|
649
|
+
expect_invalid_arg_type(conn, "discover_storage_pool_sources", 1)
|
650
|
+
expect_invalid_arg_type(conn, "discover_storage_pool_sources", "foo", 1)
|
651
|
+
expect_invalid_arg_type(conn, "discover_storage_pool_sources", "foo", "bar", "baz")
|
652
|
+
|
653
|
+
expect_fail(conn, Libvirt::Error, "invalid pool type", "discover_storage_pool_sources", "foo")
|
654
|
+
|
655
|
+
expect_success(conn, "pool type", "discover_storage_pool_sources", "logical")
|
656
|
+
|
657
|
+
# TESTGROUP: conn.sys_info
|
658
|
+
expect_too_many_args(conn, "sys_info", 1, 2)
|
659
|
+
expect_invalid_arg_type(conn, "sys_info", "foo")
|
660
|
+
|
661
|
+
expect_success(conn, "system info", "sys_info")
|
662
|
+
|
663
|
+
# TESTGROUP: conn.interface_change_begin
|
664
|
+
expect_too_many_args(conn, "interface_change_begin", 1, 2)
|
665
|
+
expect_invalid_arg_type(conn, "interface_change_begin", 'hello')
|
666
|
+
|
667
|
+
expect_success(conn, "interface change begin", "interface_change_begin")
|
668
|
+
|
669
|
+
conn.interface_change_rollback
|
670
|
+
|
671
|
+
# TESTGROUP: conn.interface_change_commit
|
672
|
+
expect_too_many_args(conn, "interface_change_commit", 1, 2)
|
673
|
+
expect_invalid_arg_type(conn, "interface_change_commit", 'foo')
|
674
|
+
|
675
|
+
# FIXME: libvirt throws an error on commit with no changes. What changes can
|
676
|
+
# we do here?
|
677
|
+
#expect_success(conn, "interface change commit", "interface_change_commit")
|
678
|
+
|
679
|
+
# TESTGROUP: conn.interface_change_rollback
|
680
|
+
conn.interface_change_begin
|
681
|
+
|
682
|
+
expect_too_many_args(conn, "interface_change_rollback", 1, 2)
|
683
|
+
expect_invalid_arg_type(conn, "interface_change_rollback", 'foo')
|
684
|
+
|
685
|
+
expect_success(conn, "interface change rollback", "interface_change_rollback")
|
686
|
+
|
687
|
+
# TESTGROUP: conn.node_cpu_stats
|
688
|
+
expect_too_many_args(conn, "node_cpu_stats", 1, 2, 3)
|
689
|
+
expect_invalid_arg_type(conn, "node_cpu_stats", 'foo')
|
690
|
+
expect_invalid_arg_type(conn, "node_cpu_stats", 1, 'bar')
|
691
|
+
|
692
|
+
expect_success(conn, "node cpu stats", "node_cpu_stats")
|
693
|
+
|
694
|
+
# TESTGROUP: conn.node_memory_stats
|
695
|
+
expect_too_many_args(conn, "node_memory_stats", 1, 2, 3)
|
696
|
+
expect_invalid_arg_type(conn, "node_memory_stats", 'foo')
|
697
|
+
expect_invalid_arg_type(conn, "node_memory_stats", 1, 'bar')
|
698
|
+
|
699
|
+
expect_success(conn, "node memory status", "node_memory_stats")
|
700
|
+
|
701
|
+
# TESTGROUP: conn.save_image_xml_desc
|
702
|
+
newdom = conn.define_domain_xml($new_dom_xml)
|
703
|
+
newdom.create
|
704
|
+
sleep 1
|
705
|
+
newdom.save($GUEST_SAVE)
|
706
|
+
|
707
|
+
expect_too_many_args(conn, "save_image_xml_desc", 1, 2, 3)
|
708
|
+
expect_too_few_args(conn, "save_image_xml_desc")
|
709
|
+
expect_invalid_arg_type(conn, "save_image_xml_desc", nil)
|
710
|
+
expect_invalid_arg_type(conn, "save_image_xml_desc", 1)
|
711
|
+
expect_invalid_arg_type(conn, "save_image_xml_desc", 'foo', 'bar')
|
712
|
+
|
713
|
+
expect_success(conn, "save image path", "save_image_xml_desc", $GUEST_SAVE)
|
714
|
+
`rm -f #{$GUEST_SAVE}`
|
715
|
+
|
716
|
+
# TESTGROUP: conn.define_save_image_xml
|
717
|
+
expect_too_many_args(conn, "define_save_image_xml", 1, 2, 3, 4)
|
718
|
+
expect_too_few_args(conn, "define_save_image_xml")
|
719
|
+
expect_too_few_args(conn, "define_save_image_xml", 'foo')
|
720
|
+
expect_invalid_arg_type(conn, "define_save_image_xml", nil, 'foo')
|
721
|
+
expect_invalid_arg_type(conn, "define_save_image_xml", 1, 'foo')
|
722
|
+
expect_invalid_arg_type(conn, "define_save_image_xml", 'foo', nil)
|
723
|
+
expect_invalid_arg_type(conn, "define_save_image_xml", 'foo', 1)
|
724
|
+
expect_invalid_arg_type(conn, "define_save_image_xml", 'foo', 'bar', 'baz')
|
725
|
+
|
726
|
+
# TESTGROUP: conn.alive?
|
727
|
+
expect_too_many_args(conn, "alive?", 1)
|
728
|
+
|
729
|
+
expect_success(conn, "alive connection", "alive?") {|x| x == true}
|
730
|
+
|
731
|
+
# TESTGROUP: conn.list_all_nwfilters
|
732
|
+
expect_too_many_args(conn, "list_all_nwfilters", 1, 2)
|
733
|
+
expect_invalid_arg_type(conn, "list_all_nwfilters", "foo")
|
734
|
+
|
735
|
+
expect_success(conn, "no args", "list_all_nwfilters")
|
736
|
+
|
737
|
+
# TESTGROUP: conn.list_all_storage_pools
|
738
|
+
expect_too_many_args(conn, "list_all_storage_pools", 1, 2)
|
739
|
+
expect_invalid_arg_type(conn, "list_all_storage_pools", "foo")
|
740
|
+
|
741
|
+
expect_success(conn, "no args", "list_all_storage_pools")
|
742
|
+
|
743
|
+
# TESTGROUP: conn.list_all_nodedevices
|
744
|
+
expect_too_many_args(conn, "list_all_nodedevices", 1, 2)
|
745
|
+
expect_invalid_arg_type(conn, "list_all_nodedevices", "foo")
|
746
|
+
|
747
|
+
expect_success(conn, "no args", "list_all_nodedevices")
|
748
|
+
|
749
|
+
# TESTGROUP: conn.list_all_secrets
|
750
|
+
expect_too_many_args(conn, "list_all_secrets", 1, 2)
|
751
|
+
expect_invalid_arg_type(conn, "list_all_secrets", "foo")
|
752
|
+
|
753
|
+
expect_success(conn, "no args", "list_all_secrets")
|
754
|
+
|
755
|
+
# TESTGROUP: conn.list_all_interfaces
|
756
|
+
expect_too_many_args(conn, "list_all_interfaces", 1, 2)
|
757
|
+
expect_invalid_arg_type(conn, "list_all_interfaces", "foo")
|
758
|
+
|
759
|
+
expect_success(conn, "no args", "list_all_interfaces")
|
760
|
+
|
761
|
+
# TESTGROUP: conn.list_all_networks
|
762
|
+
expect_too_many_args(conn, "list_all_networks", 1, 2)
|
763
|
+
expect_invalid_arg_type(conn, "list_all_networks", "foo")
|
764
|
+
|
765
|
+
expect_success(conn, "no args", "list_all_networks")
|
766
|
+
|
767
|
+
# TESTGROUP: conn.list_all_domains
|
768
|
+
expect_too_many_args(conn, "list_all_domains", 1, 2)
|
769
|
+
expect_invalid_arg_type(conn, "list_all_domains", "foo")
|
770
|
+
|
771
|
+
expect_success(conn, "no args", "list_all_domains")
|
772
|
+
|
773
|
+
# TESTGROUP: conn.set_keepalive
|
774
|
+
expect_too_many_args(conn, "set_keepalive", 1, 2, 3, 4)
|
775
|
+
expect_too_few_args(conn, "set_keepalive")
|
776
|
+
expect_too_few_args(conn, "set_keepalive", 1)
|
777
|
+
expect_invalid_arg_type(conn, "set_keepalive", 'foo', 0)
|
778
|
+
expect_invalid_arg_type(conn, "set_keepalive", 0, 'foo')
|
779
|
+
|
780
|
+
# FIXME: somehow we need an event loop implementation for this to work
|
781
|
+
#expect_success(conn, "interval and count", "set_keepalive", 1, 10)
|
782
|
+
|
783
|
+
# TESTGROUP: conn.node_suspend_for_duration
|
784
|
+
expect_too_many_args(conn, "node_suspend_for_duration", 1, 2, 3, 4)
|
785
|
+
expect_too_few_args(conn, "node_suspend_for_duration")
|
786
|
+
expect_too_few_args(conn, "node_suspend_for_duration", 1)
|
787
|
+
expect_invalid_arg_type(conn, "node_suspend_for_duration", 'foo', 1)
|
788
|
+
expect_invalid_arg_type(conn, "node_suspend_for_duration", 1, 'foo')
|
789
|
+
expect_invalid_arg_type(conn, "node_suspend_for_duration", 1, 2, 'foo')
|
790
|
+
|
791
|
+
# TESTGROUP: conn.node_memory_parameters
|
792
|
+
expect_too_many_args(conn, "node_memory_parameters", 1, 2)
|
793
|
+
expect_invalid_arg_type(conn, "node_memory_parameters", 'foo')
|
794
|
+
|
795
|
+
expect_success(conn, "no args", "node_memory_parameters")
|
796
|
+
|
797
|
+
# TESTGROUP: conn.node_memory_paramters=
|
798
|
+
expect_too_many_args(conn, "node_memory_parameters=", 1, 2)
|
799
|
+
expect_invalid_arg_type(conn, "node_memory_parameters=", nil)
|
800
|
+
expect_invalid_arg_type(conn, "node_memory_parameters=", ['foo', 0])
|
801
|
+
expect_invalid_arg_type(conn, "node_memory_parameters=", [{}, 'foo'])
|
802
|
+
|
803
|
+
# TESTGROUP: conn.keepalive=
|
804
|
+
expect_too_many_args(conn, "keepalive=", 1, 2)
|
805
|
+
expect_too_few_args(conn, "keepalive=", [])
|
806
|
+
expect_too_few_args(conn, "keepalive=", [1])
|
807
|
+
expect_invalid_arg_type(conn, "keepalive=", 1)
|
808
|
+
expect_invalid_arg_type(conn, "keepalive=", ['foo', 1])
|
809
|
+
expect_invalid_arg_type(conn, "keepalive=", [1, 'foo'])
|
810
|
+
|
811
|
+
# FIXME: somehow we need an event loop implementation for this to work
|
812
|
+
#expect_success(conn, "interval and count", "keepalive=", 1, 10)
|
813
|
+
|
814
|
+
# END TESTS
|
815
|
+
|
816
|
+
conn.close
|
817
|
+
|
818
|
+
finish_tests
|