Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
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
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos
Commits
c56a9556
Commit
c56a9556
authored
Jun 22, 2023
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/theia: Add upgrade tests
parent
4078d3d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
203 additions
and
12 deletions
+203
-12
software/theia/test/test_resiliency.py
software/theia/test/test_resiliency.py
+15
-12
software/theia/test/upgrade_tests.py
software/theia/test/upgrade_tests.py
+188
-0
No files found.
software/theia/test/test_resiliency.py
View file @
c56a9556
...
@@ -498,8 +498,18 @@ class TakeoverMixin(ExportAndImportMixin):
...
@@ -498,8 +498,18 @@ class TakeoverMixin(ExportAndImportMixin):
self
.
assertIn
(
"Success"
,
resp
.
text
,
"An Error occured: %s"
%
resp
.
text
)
self
.
assertIn
(
"Success"
,
resp
.
text
,
"An Error occured: %s"
%
resp
.
text
)
return
resp
.
text
return
resp
.
text
def
_doTakeover
(
self
):
# Takeover
takeover_url
,
takeover_password
=
self
.
_getTakeoverUrlAndPassword
()
self
.
_requestTakeover
(
takeover_url
,
takeover_password
)
class
TheiaSyncMixin
(
ResilienceMixin
,
TakeoverMixin
):
# Wait for import instance to become export instance and new import to be allocated
# This also checks that all promises of theia instances succeed
self
.
slap
.
waitForInstance
(
self
.
instance_max_retry
)
self
.
computer_partition
=
self
.
requestDefaultInstance
()
class
TheiaSyncMixin
(
TakeoverMixin
,
ResilienceMixin
):
def
_doSync
(
self
,
max_tries
=
None
,
wait_interval
=
None
):
def
_doSync
(
self
,
max_tries
=
None
,
wait_interval
=
None
):
max_tries
=
max_tries
or
self
.
backup_max_tries
max_tries
=
max_tries
or
self
.
backup_max_tries
wait_interval
=
wait_interval
or
self
.
backup_wait_interval
wait_interval
=
wait_interval
or
self
.
backup_wait_interval
...
@@ -547,17 +557,10 @@ class TestTheiaResilience(TheiaSyncMixin, ResilientTheiaTestCase):
...
@@ -547,17 +557,10 @@ class TestTheiaResilience(TheiaSyncMixin, ResilientTheiaTestCase):
def
_checkSync
(
self
):
def
_checkSync
(
self
):
# Check that ~/etc still contains everything it did before
# Check that ~/etc still contains everything it did before
etc_listdir
=
os
.
listdir
(
self
.
getPartitionPath
(
'import'
,
'etc'
))
etc_listdir
=
os
.
listdir
(
self
.
getPartitionPath
(
'import'
,
'etc'
))
self
.
assertTrue
(
set
(
self
.
etc_listdir
).
issubset
(
etc_listdir
))
try
:
self
.
assertTrue
(
set
(
self
.
etc_listdir
).
issubset
(
etc_listdir
))
def
_doTakeover
(
self
):
except
AssertionError
:
# Takeover
breakpoint
()
takeover_url
,
takeover_password
=
self
.
_getTakeoverUrlAndPassword
()
self
.
_requestTakeover
(
takeover_url
,
takeover_password
)
# Wait for import instance to become export instance and new import to be allocated
# This also checks that all promises of theia instances succeed
self
.
slap
.
waitForInstance
(
self
.
instance_max_retry
)
self
.
computer_partition
=
self
.
requestDefaultInstance
()
def
_checkTakeover
(
self
):
def
_checkTakeover
(
self
):
# Check that there is an export, import and frozen instance and get their new partition IDs
# Check that there is an export, import and frozen instance and get their new partition IDs
...
...
software/theia/test/upgrade_tests.py
0 → 100644
View file @
c56a9556
import
json
import
os
from
slapos.testing.testcase
import
(
installSoftwareUrlList
,
makeModuleSetUpAndTestCaseClass
,
SlapOSNodeCommandError
,
)
import
test
import
test_resiliency
stable_software_url
=
"https://lab.nexedi.com/nexedi/slapos/raw/1.0.324/software/theia/software.cfg"
dev_software_url
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
))
software_url_list
=
[
stable_software_url
,
dev_software_url
]
_
,
SlapOSInstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
stable_software_url
)
class
UpgradeTestCase
(
SlapOSInstanceTestCase
):
_current_software_url
=
stable_software_url
@
classmethod
def
getSoftwareURL
(
cls
):
return
cls
.
_current_software_url
@
classmethod
def
upgrade
(
cls
):
# request instance on dev software
cls
.
_current_software_url
=
dev_software_url
cls
.
logger
.
debug
(
'Requesting instance on dev software'
)
cls
.
requestDefaultInstance
()
# wait for slapos node instance
snapshot_name
=
"{}.{}.dev.setUpClass"
.
format
(
cls
.
__module__
,
cls
.
__name__
)
with
cls
.
_snapshotManager
(
snapshot_name
):
try
:
for
_
in
range
(
2
):
# propagation
cls
.
waitForInstance
()
cls
.
logger
.
debug
(
"Instance on dev software done"
)
except
BaseException
:
cls
.
logger
.
exception
(
"Error during instance on dev software"
)
raise
cls
.
computer_partition
=
cls
.
requestDefaultInstance
()
@
classmethod
def
beforeUpgrade
(
cls
):
pass
@
classmethod
def
setUpClass
(
cls
):
# request and instantiate with old software url
super
().
setUpClass
()
# before upgrade hook
cls
.
beforeUpgrade
()
# upgrade
cls
.
upgrade
()
def
setUpModule
():
installSoftwareUrlList
(
SlapOSInstanceTestCase
,
software_url_list
,
debug
=
SlapOSInstanceTestCase
.
_debug
,
)
class
TestTheia
(
UpgradeTestCase
,
test
.
TestTheia
):
pass
class
TestTheiaWithEmbeddedInstance
(
UpgradeTestCase
,
test
.
TestTheiaWithEmbeddedInstance
):
pass
class
TestTheiaResilientInterface
(
UpgradeTestCase
,
test
.
TestTheiaResilientInterface
):
pass
class
TestTheiaResilientWithEmbeddedInstance
(
UpgradeTestCase
,
test
.
TestTheiaResilientWithEmbeddedInstance
):
pass
class
TestTheiaResilienceWithInitialInstance
(
UpgradeTestCase
,
test_resiliency
.
TestTheiaResilienceWithInitialInstance
):
@
classmethod
def
beforeUpgrade
(
cls
):
# Check initial embedded instance
test
.
TestTheiaWithEmbeddedInstance
.
test
(
cls
())
class
TestResilientTheiaUpgradeWithInitialInstance
(
UpgradeTestCase
,
test_resiliency
.
ResilientTheiaTestCase
,
test_resiliency
.
TheiaSyncMixin
):
backup_max_tries
=
70
backup_wait_interval
=
10
old_flag_file
=
os
.
path
.
join
(
'etc'
,
'embedded-instance-config.json.done'
)
old_exitcode_file
=
os
.
path
.
join
(
'etc'
,
'embedded-request-exitcode'
)
flag_file
=
os
.
path
.
join
(
'var'
,
'state'
,
'standalone-ran-before.flag'
)
exitcode_file
=
os
.
path
.
join
(
'var'
,
'state'
,
'embedded-request.exitcode'
)
@
classmethod
def
getInstanceParameterDict
(
cls
):
return
{
'initial-embedded-instance'
:
json
.
dumps
({
'software-url'
:
test_resiliency
.
dummy_software_url
}),
}
def
assertExists
(
self
,
path
):
self
.
assertTrue
(
os
.
path
.
exists
(
path
))
def
assertNotFound
(
self
,
path
):
self
.
assertFalse
(
os
.
path
.
exists
(
path
))
@
classmethod
def
beforeUpgrade
(
cls
):
self
=
cls
()
self
.
assertExists
(
cls
.
getPartitionPath
(
'export'
,
self
.
old_flag_file
))
self
.
assertExists
(
cls
.
getPartitionPath
(
'export'
,
self
.
old_exitcode_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'import'
,
self
.
old_flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
old_exitcode_file
))
def
_prepareExport
(
self
):
# after upgrade
self
.
assertNotFound
(
self
.
getPartitionPath
(
'export'
,
self
.
old_flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'export'
,
self
.
old_exitcode_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
old_flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
old_exitcode_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'export'
,
self
.
flag_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'export'
,
self
.
exitcode_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'import'
,
self
.
flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
exitcode_file
))
def
_checkSync
(
self
):
self
.
assertExists
(
self
.
getPartitionPath
(
'export'
,
self
.
flag_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'export'
,
self
.
exitcode_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'import'
,
self
.
flag_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'import'
,
self
.
exitcode_file
))
def
_checkTakeover
(
self
):
self
.
assertNotFound
(
self
.
getPartitionPath
(
'export'
,
self
.
old_flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'export'
,
self
.
old_exitcode_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
old_flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
old_exitcode_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'export'
,
self
.
flag_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'export'
,
self
.
exitcode_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'import'
,
self
.
flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
exitcode_file
))
class
TestResilientTheiaUpgradeWithInitialInstanceAndSync
(
TestResilientTheiaUpgradeWithInitialInstance
):
@
classmethod
def
beforeUpgrade
(
cls
):
cls
().
_doSync
()
def
_prepareExport
(
self
):
# after upgrade
self
.
assertNotFound
(
self
.
getPartitionPath
(
'export'
,
self
.
old_flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'export'
,
self
.
old_exitcode_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
old_flag_file
))
self
.
assertNotFound
(
self
.
getPartitionPath
(
'import'
,
self
.
old_exitcode_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'export'
,
self
.
flag_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'export'
,
self
.
exitcode_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'import'
,
self
.
flag_file
))
self
.
assertExists
(
self
.
getPartitionPath
(
'import'
,
self
.
exitcode_file
))
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