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
b67509f5
Commit
b67509f5
authored
1 year ago
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing: Factor snapshot management
parent
6f9e279e
Pipeline
#28851
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
slapos/testing/testcase.py
slapos/testing/testcase.py
+22
-12
No files found.
slapos/testing/testcase.py
View file @
b67509f5
...
...
@@ -26,12 +26,13 @@
#
##############################################################################
import
unittest
import
os
import
contextlib
import
fnmatch
import
glob
import
logging
import
os
import
shutil
import
unittest
import
warnings
from
six.moves.urllib.parse
import
urlparse
...
...
@@ -409,6 +410,18 @@ class SlapOSInstanceTestCase(unittest.TestCase):
cls
.
computer_partition_root_path
=
os
.
path
.
join
(
cls
.
slap
.
_instance_root
,
cls
.
computer_partition
.
getId
())
@
classmethod
@
contextlib
.
contextmanager
def
_snapshotManager
(
cls
,
snapshot_name
):
try
:
yield
except
BaseException
:
cls
.
_storeSystemSnapshot
(
snapshot_name
)
cls
.
_cleanup
(
snapshot_name
)
raise
else
:
cls
.
_storeSystemSnapshot
(
snapshot_name
)
@
classmethod
def
setUpClass
(
cls
):
"""Request an instance.
...
...
@@ -417,16 +430,13 @@ class SlapOSInstanceTestCase(unittest.TestCase):
cls
.
_instance_parameter_dict
=
cls
.
getInstanceParameterDict
()
snapshot_name
=
"{}.{}.setUpClass"
.
format
(
cls
.
__module__
,
cls
.
__name__
)
with
cls
.
_snapshotManager
(
snapshot_name
):
try
:
cls
.
_setUpClass
()
except
BaseException
:
cls
.
logger
.
exception
(
"Error during setUpClass"
)
cls
.
_storeSystemSnapshot
(
snapshot_name
)
cls
.
_cleanup
(
snapshot_name
)
cls
.
setUp
=
lambda
self
:
self
.
fail
(
'Setup Class failed.'
)
raise
else
:
cls
.
_storeSystemSnapshot
(
snapshot_name
)
cls
.
logger
.
debug
(
"setUpClass done"
)
@
classmethod
...
...
This diff is collapsed.
Click to expand it.
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