Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
059b4bc4
Commit
059b4bc4
authored
Apr 15, 2020
by
Francesc Guasch
Browse files
test(KVM): check for duplicated MACs in 2nd eth
issue #1294
parent
01e8d17f
Changes
2
Hide whitespace changes
Inline
Side-by-side
t/kvm/72_add_nic.t
View file @
059b4bc4
...
...
@@ -72,16 +72,8 @@ sub test_req_prepare_base{
$domain
->
is_public
(
1
);
}
sub
test_add_nic
{
my
$vm_name
=
shift
;
# diag("Testing add description $vm_name");
my
$vm
=
rvd_back
->
search_vm
(
$vm_name
);
my
$domain
=
test_create_domain
(
$vm_name
);
#Read xml
sub
read_mac
{
#Read xml
sub
read_mac
{
my
$domain
=
shift
;
my
$xml
=
XML::
LibXML
->
load_xml
(
string
=>
$domain
->
get_xml_base
());
my
@mac
;
...
...
@@ -91,7 +83,15 @@ sub test_add_nic {
push
@mac
,
$mac
;
}
return
(
@mac
);
}
}
sub
test_add_nic
{
my
$vm_name
=
shift
;
# diag("Testing add description $vm_name");
my
$vm
=
rvd_back
->
search_vm
(
$vm_name
);
my
$domain
=
test_create_domain
(
$vm_name
);
my
$domain_other
=
test_create_domain
(
$vm_name
);
#Prepare base
test_req_prepare_base
(
$domain
->
name
);
...
...
@@ -112,10 +112,15 @@ sub test_add_nic {
my
$domain_clon
=
$RAVADA
->
search_domain
(
$name
);
my
@mac
=
read_mac
(
$domain
);
my
@mac_other
=
read_mac
(
$domain_other
);
my
@mac2
=
read_mac
(
$domain_clon
);
isnt
(
$mac
[
0
],
$mac2
[
0
],
"
1st MAC from 1st NIC cloned are the same
");
isnt
(
$mac
[
1
],
$mac2
[
1
],
"
2nd MAC from 2nd NIC cloned are the same
");
my
%dupe_mac
=
();
for
my
$mac
(
@mac
,
@mac_other
,
@mac2
)
{
ok
(
!
$dupe_mac
{
$mac
}
++
,"
MAC
$mac
duplicated
");
}
}
...
...
t/mojo/10_login.t
View file @
059b4bc4
...
...
@@ -98,6 +98,7 @@ sub test_many_clones($base) {
};
test_re_expose
(
$base
)
if
$base
->
type
eq
'
Void
';
test_different_mac
(
$base
,
$base
->
clones
)
if
$base
->
type
ne
'
Void
';
for
my
$clone
(
$base
->
clones
)
{
my
$req
=
Ravada::
Request
->
remove_domain
(
name
=>
$clone
->
{
name
}
...
...
@@ -106,6 +107,22 @@ sub test_many_clones($base) {
}
}
sub
test_different_mac
(@domain) {
my
%found
;
for
my
$domain
(
@domain
)
{
$domain
=
Ravada::Front::
Domain
->
open
(
$domain
->
{
id
})
if
ref
(
$domain
)
!~
/^Ravada/
;
my
$xml
=
XML::
LibXML
->
load_xml
(
string
=>
$domain
->
_data_extra
('
xml
'));
my
(
@if_mac
)
=
$xml
->
findnodes
('
/domain/devices/interface/mac
');
for
my
$if_mac
(
@if_mac
)
{
my
$mac
=
$if_mac
->
getAttribute
('
address
');
ok
(
!
exists
$found
{
$mac
},"
Error: MAC
$mac
from
"
.
$domain
->
name
.
"
also in domain :
"
.
(
$found
{
$mac
}
or
''))
or
exit
;
$found
{
$mac
}
=
$domain
->
name
;
}
}
}
sub
test_re_expose
($base) {
diag
("
Test re-expose
");
for
my
$clone
(
$base
->
clones
)
{
...
...
@@ -196,6 +213,9 @@ for my $vm_name ( vm_names() ) {
ok
(
$base
)
or
next
;
push
@bases
,(
$base
->
name
);
mojo_request
(
$t
,
"
add_hardware
",
{
id_domain
=>
$base
->
id
,
name
=>
'
network
'
});
wait_request
(
debug
=>
1
,
check_error
=>
1
,
background
=>
1
,
timeout
=>
120
);
$t
->
get_ok
("
/machine/prepare/
"
.
$base
->
id
.
"
.json
")
->
status_is
(
200
);
_wait_request
(
debug
=>
0
,
background
=>
1
);
$base
=
rvd_front
->
search_domain
(
$name
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment