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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ophélie Gagnard
slapos.core
Commits
7191925a
Commit
7191925a
authored
Nov 15, 2019
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testcase: wip/example of how we could run an integration upgrade test
parent
7a4b44d1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
29 deletions
+93
-29
slapos/testing/testcase.py
slapos/testing/testcase.py
+93
-29
No files found.
slapos/testing/testcase.py
View file @
7191925a
...
...
@@ -241,27 +241,8 @@ def installSoftwareUrlList(cls, software_url_list, max_retry=2, debug=False):
raise
e
class
SlapOSInstanceTestCase
(
unittest
.
TestCase
):
"""Install one slapos instance.
This test case install software(s) and request one instance
during `setUpClass` and destroy that instance during `tearDownClass`.
Software Release URL, Instance Software Type and Instance Parameters
can be defined on the class.
All tests from the test class will run with the same instance.
The following class attributes are available:
* `computer_partition`: the `slapos.slap.slap.ComputerPartition`
computer partition instance.
* `computer_partition_root_path`: the path of the instance root
directory.
This class is not supposed to be imported directly, but needs to be setup by
calling makeModuleSetUpAndTestCaseClass.
class
BaseSlapOSInstanceTestCase
(
unittest
.
TestCase
):
"""TODO: docs
"""
# can set this to true to enable debugging utilities
_debug
=
False
...
...
@@ -283,6 +264,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
slap
=
None
# type: StandaloneSlapOS
_ipv4_address
=
""
_ipv6_address
=
""
_software_url
=
""
# the "current" software URL
# a short name of that software URL.
# eg. helloworld instead of
...
...
@@ -325,11 +307,8 @@ class SlapOSInstanceTestCase(unittest.TestCase):
"""
return
""
# Unittest methods
@
classmethod
def
setUpClass
(
cls
):
"""Request an instance.
"""
cls
.
_instance_parameter_dict
=
cls
.
getInstanceParameterDict
()
try
:
...
...
@@ -345,7 +324,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
getattr
(
cls
,
'__partition_reference__'
,
'{}-'
.
format
(
cls
.
__name__
)))
# request
cls
.
requestDefaultInstance
()
cls
.
requestDefaultInstance
(
cls
.
_software_url
)
# slapos node instance
cls
.
logger
.
debug
(
"Waiting for instance"
)
...
...
@@ -365,7 +344,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
# expose some class attributes so that tests can use them:
# the main ComputerPartition instance, to use getInstanceParameterDict
cls
.
computer_partition
=
cls
.
requestDefaultInstance
()
cls
.
computer_partition
=
cls
.
requestDefaultInstance
(
cls
.
_software_url
)
# the path of the instance on the filesystem, for low level inspection
cls
.
computer_partition_root_path
=
os
.
path
.
join
(
...
...
@@ -475,15 +454,100 @@ class SlapOSInstanceTestCase(unittest.TestCase):
@
classmethod
def
requestDefaultInstance
(
cls
,
state
=
'started'
):
software_url
=
cls
.
getSoftwareURL
()
software_type
=
cls
.
getInstanceSoftwareType
()
cls
.
logger
.
debug
(
'requesting "%s" software:%s type:%s state:%s parameters:%s'
,
cls
.
default_partition_reference
,
software_url
,
software_type
,
state
,
cls
.
default_partition_reference
,
cls
.
_
software_url
,
software_type
,
state
,
cls
.
_instance_parameter_dict
)
return
cls
.
slap
.
request
(
software_release
=
software_url
,
software_release
=
cls
.
_
software_url
,
software_type
=
software_type
,
partition_reference
=
cls
.
default_partition_reference
,
partition_parameter_kw
=
cls
.
_instance_parameter_dict
,
state
=
state
)
class
SlapOSInstanceTestCase
(
BaseSlapOSInstanceTestCase
):
"""Install one slapos instance.
This test case install software(s) and request one instance
during `setUpClass` and destroy that instance during `tearDownClass`.
Software Release URL, Instance Software Type and Instance Parameters
can be defined on the class.
All tests from the test class will run with the same instance.
The following class attributes are available:
* `computer_partition`: the `slapos.slap.slap.ComputerPartition`
computer partition instance.
* `computer_partition_root_path`: the path of the instance root
directory.
This class is not supposed to be imported directly, but needs to be setup by
calling makeModuleSetUpAndTestCaseClass.
"""
# Methods to be defined by subclasses.
@
classmethod
def
getSoftwareURL
(
cls
):
"""Return URL of software release to request instance.
This method will be defined when initialising the class
with makeModuleSetUpAndTestCaseClass.
"""
raise
NotImplementedError
()
# Unittest methods
@
classmethod
def
setUpClass
(
cls
):
"""Request an instance.
"""
cls
.
_software_url
=
cls
.
getSoftwareURL
()
super
(
SlapOSInstanceTestCase
).
setUpClass
()
class
SlapOSInstanceUpgradeTestCase
(
BaseSlapOSInstanceTestCase
):
"""SlapOSInstanceTestCase for upgrades.
This provides a starting point for the typical scenario:
- install old software
- create an instance
- create some data in instance
- install new software
- update the instance to use new software
and check that the instance is in correct state after upgrade.
"""
# Methods to be defined by subclasses.
@
classmethod
def
getOldSoftwareUrl
(
cls
):
"""Software URL before upgrade
"""
raise
NotImplementedError
()
@
classmethod
def
getNewSoftwareUrl
(
cls
):
"""Software URL after upgrade
"""
raise
NotImplementedError
()
# hooks
@
classmethod
def
prepareOldInstance
(
cls
):
"""Prepare the instance before upgrade process.
This can be used also to create some initial data.
"""
# unittest methods
@
classmethod
def
setUpClass
(
cls
):
cls
.
_software_url
=
cls
.
getOldSoftwareUrl
()
super
(
SlapOSInstanceUpgradeTestCase
,
cls
).
setUpClass
()
cls
.
prepareOldInstance
()
cls
.
_software_url
=
cls
.
getNewSoftwareUrl
()
cls
.
requestDefaultInstance
()
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