Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
19
Merge Requests
19
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
cbd66d9c
Commit
cbd66d9c
authored
Oct 09, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test proving Usage Report behaves correctly even in weird cases
parent
cc783201
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+74
-0
No files found.
slapos/tests/slapgrid.py
View file @
cbd66d9c
...
@@ -1153,6 +1153,80 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1153,6 +1153,80 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
'destroyedComputerPartition'
])
'destroyedComputerPartition'
])
self
.
assertEqual
(
instance
.
state
,
'destroyed'
)
self
.
assertEqual
(
instance
.
state
,
'destroyed'
)
def
test_slapgrid_destroys_instance_to_be_destroyed_without_sr_uri
(
self
):
"""
Test than an instance in "destroyed" state but without SR informations
is correctly destroyed
"""
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
instance
=
computer
.
instance_list
[
0
]
instance
.
requested_state
=
'started'
instance
.
software
.
name
=
None
computer
.
sequence
=
[]
instance
.
requested_state
=
'destroyed'
self
.
assertTrue
(
self
.
grid
.
agregateAndSendUsage
())
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
# Assert supervisor stopped process
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
exists
=
False
while
tries
>
0
:
tries
-=
1
if
os
.
path
.
exists
(
wrapper_log
):
exists
=
True
break
time
.
sleep
(
0.1
)
self
.
assertFalse
(
exists
)
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'stoppedComputerPartition'
,
'destroyedComputerPartition'
])
self
.
assertEqual
(
instance
.
state
,
'destroyed'
)
def
test_slapgrid_destroys_instance_to_be_destroyed_without_sr
(
self
):
"""
Test than an instance in "destroyed" state but without SR at all
is correctly destroyed
"""
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
instance
=
computer
.
instance_list
[
0
]
instance
.
requested_state
=
'started'
instance
.
software
=
None
computer
.
sequence
=
[]
instance
.
requested_state
=
'destroyed'
self
.
assertTrue
(
self
.
grid
.
agregateAndSendUsage
())
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
# Assert supervisor stopped process
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
exists
=
False
while
tries
>
0
:
tries
-=
1
if
os
.
path
.
exists
(
wrapper_log
):
exists
=
True
break
time
.
sleep
(
0.1
)
self
.
assertFalse
(
exists
)
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'stoppedComputerPartition'
,
'destroyedComputerPartition'
])
self
.
assertEqual
(
instance
.
state
,
'destroyed'
)
def
test_slapgrid_not_destroy_bad_instance
(
self
):
def
test_slapgrid_not_destroy_bad_instance
(
self
):
"""
"""
Checks that slapgrid-ur don't destroy instance not to be destroyed.
Checks that slapgrid-ur don't destroy instance not to be destroyed.
...
...
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