Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos
Commits
b6abea25
Commit
b6abea25
authored
Apr 06, 2021
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm: Review test for default instance
parent
49872dd2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
50 deletions
+55
-50
software/kvm/test/test.py
software/kvm/test/test.py
+55
-50
No files found.
software/kvm/test/test.py
View file @
b6abea25
...
@@ -112,34 +112,65 @@ bootstrap_machine_param_dict = {
...
@@ -112,34 +112,65 @@ bootstrap_machine_param_dict = {
"enable-monitor"
:
True
,
"enable-monitor"
:
True
,
"keyboard-layout-language"
:
"fr"
"keyboard-layout-language"
:
"fr"
}
}
@
skipUnlessKvm
class
ServicesTestCase
(
InstanceTestCase
):
def
test_hashes
(
self
):
class
KvmMixin
(
object
):
hash_files
=
[
def
getProcessInfo
(
self
):
hash_value
=
generateHashFromFiles
([
os
.
path
.
join
(
self
.
computer_partition_root_path
,
hash_file
)
for
hash_file
in
[
'software_release/buildout.cfg'
,
'software_release/buildout.cfg'
,
]
]
expected_process_names
=
[
])
'6tunnel-10022-{hash}-on-watch'
,
'6tunnel-10080-{hash}-on-watch'
,
'6tunnel-10443-{hash}-on-watch'
,
'certificate_authority-{hash}-on-watch'
,
'crond-{hash}-on-watch'
,
'kvm-{hash}-on-watch'
,
'websockify-{hash}-on-watch'
,
]
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
process_names
=
[
process
[
'name'
]
running_process_info
=
'
\
n
'
.
join
(
sorted
([
for
process
in
supervisor
.
getAllProcessInfo
()]
'%(group)s:%(name)s %(statename)s'
%
q
for
q
in
supervisor
.
getAllProcessInfo
()
if
q
[
'name'
]
!=
'watchdog'
and
q
[
'group'
]
!=
'watchdog'
]))
return
running_process_info
.
replace
(
hash_value
,
'{hash}'
)
hash_files
=
[
os
.
path
.
join
(
self
.
computer_partition_root_path
,
path
)
for
path
in
hash_files
]
for
name
in
expected_process_names
:
@
skipUnlessKvm
h
=
generateHashFromFiles
(
hash_files
)
class
TestInstance
(
InstanceTestCase
,
KvmMixin
):
expected_process_name
=
name
.
format
(
hash
=
h
)
__partition_reference__
=
'i'
self
.
assertIn
(
expected_process_name
,
process_names
)
def
test
(
self
):
connection_parameter_dict
=
self
\
.
computer_partition
.
getConnectionParameterDict
()
present_key_list
=
[]
assert_key_list
=
[
'backend-url'
,
'url'
,
'monitor-setup-url'
,
'ipv6-network-info'
,
'tap-ipv4'
,
'tap-ipv6'
]
for
k
in
assert_key_list
:
if
k
in
connection_parameter_dict
:
present_key_list
.
append
(
k
)
connection_parameter_dict
.
pop
(
k
)
self
.
assertEqual
(
connection_parameter_dict
,
{
'ipv6'
:
self
.
_ipv6_address
,
'maximum-extra-disk-amount'
:
'0'
,
'monitor-base-url'
:
'https://[%s]:8026'
%
(
self
.
_ipv6_address
,),
'nat-rule-port-tcp-22'
:
'%s : 10022'
%
(
self
.
_ipv6_address
,),
'nat-rule-port-tcp-443'
:
'%s : 10443'
%
(
self
.
_ipv6_address
,),
'nat-rule-port-tcp-80'
:
'%s : 10080'
%
(
self
.
_ipv6_address
,),
}
)
self
.
assertEqual
(
set
(
present_key_list
),
set
(
assert_key_list
))
self
.
assertEqual
(
"""i0:6tunnel-10022-{hash}-on-watch RUNNING
i0:6tunnel-10080-{hash}-on-watch RUNNING
i0:6tunnel-10443-{hash}-on-watch RUNNING
i0:bootstrap-monitor EXITED
i0:certificate_authority-{hash}-on-watch RUNNING
i0:crond-{hash}-on-watch RUNNING
i0:kvm-{hash}-on-watch RUNNING
i0:kvm_controller EXITED
i0:monitor-httpd-{hash}-on-watch RUNNING
i0:monitor-httpd-graceful EXITED
i0:websockify-{hash}-on-watch RUNNING"""
,
self
.
getProcessInfo
()
)
class
MonitorAccessMixin
(
object
):
class
MonitorAccessMixin
(
object
):
...
@@ -401,7 +432,7 @@ class TestAccessKvmClusterBootstrap(MonitorAccessMixin, InstanceTestCase):
...
@@ -401,7 +432,7 @@ class TestAccessKvmClusterBootstrap(MonitorAccessMixin, InstanceTestCase):
@
skipIfPython3
@
skipIfPython3
@
skipUnlessKvm
@
skipUnlessKvm
class
TestInstanceResilient
(
InstanceTestCase
):
class
TestInstanceResilient
(
InstanceTestCase
,
KvmMixin
):
__partition_reference__
=
'ir'
__partition_reference__
=
'ir'
instance_max_retry
=
20
instance_max_retry
=
20
...
@@ -409,20 +440,6 @@ class TestInstanceResilient(InstanceTestCase):
...
@@ -409,20 +440,6 @@ class TestInstanceResilient(InstanceTestCase):
def
getInstanceSoftwareType
(
cls
):
def
getInstanceSoftwareType
(
cls
):
return
'kvm-resilient'
return
'kvm-resilient'
def
getProcessInfo
(
self
):
hash_value
=
generateHashFromFiles
([
os
.
path
.
join
(
self
.
computer_partition_root_path
,
hash_file
)
for
hash_file
in
[
'software_release/buildout.cfg'
,
]
])
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
running_process_info
=
'
\
n
'
.
join
(
sorted
([
'%(group)s:%(name)s %(statename)s'
%
q
for
q
in
supervisor
.
getAllProcessInfo
()
if
q
[
'name'
]
!=
'watchdog'
and
q
[
'group'
]
!=
'watchdog'
]))
return
running_process_info
.
replace
(
hash_value
,
'{hash}'
)
def
test
(
self
):
def
test
(
self
):
connection_parameter_dict
=
self
\
connection_parameter_dict
=
self
\
.
computer_partition
.
getConnectionParameterDict
()
.
computer_partition
.
getConnectionParameterDict
()
...
@@ -449,18 +466,6 @@ class TestInstanceResilient(InstanceTestCase):
...
@@ -449,18 +466,6 @@ class TestInstanceResilient(InstanceTestCase):
)
)
self
.
assertEqual
(
set
(
present_key_list
),
set
(
assert_key_list
))
self
.
assertEqual
(
set
(
present_key_list
),
set
(
assert_key_list
))
hash_value
=
generateHashFromFiles
([
os
.
path
.
join
(
self
.
computer_partition_root_path
,
hash_file
)
for
hash_file
in
[
'software_release/buildout.cfg'
,
]
])
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
running_process_info
=
'
\
n
'
.
join
(
sorted
([
'%(group)s:%(name)s %(statename)s'
%
q
for
q
in
supervisor
.
getAllProcessInfo
()
if
q
[
'name'
]
!=
'watchdog'
and
q
[
'group'
]
!=
'watchdog'
]))
running_process_info
=
running_process_info
.
replace
(
hash_value
,
'{hash}'
)
self
.
assertEqual
(
self
.
assertEqual
(
"""ir0:bootstrap-monitor EXITED
"""ir0:bootstrap-monitor EXITED
ir0:certificate_authority-{hash}-on-watch RUNNING
ir0:certificate_authority-{hash}-on-watch RUNNING
...
...
Write
Preview
Markdown
is supported
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