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
Alain Takoudjou
slapos
Commits
e95f1e0c
Commit
e95f1e0c
authored
May 17, 2023
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/theia: Add resiliency test
Test that takeover of theia with an initial embedded instance succeeds.
parent
1aa17677
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
software/theia/test/test.py
software/theia/test/test.py
+4
-0
software/theia/test/test_resiliency.py
software/theia/test/test_resiliency.py
+51
-2
No files found.
software/theia/test/test.py
View file @
e95f1e0c
...
@@ -538,6 +538,10 @@ class ResilientTheiaMixin(object):
...
@@ -538,6 +538,10 @@ class ResilientTheiaMixin(object):
def
getPartitionPath
(
cls
,
instance_type
=
'export'
,
*
paths
):
def
getPartitionPath
(
cls
,
instance_type
=
'export'
,
*
paths
):
return
os
.
path
.
join
(
cls
.
slap
.
_instance_root
,
cls
.
getPartitionId
(
instance_type
),
*
paths
)
return
os
.
path
.
join
(
cls
.
slap
.
_instance_root
,
cls
.
getPartitionId
(
instance_type
),
*
paths
)
@
classmethod
def
getPath
(
cls
,
*
components
):
# patch getPath
return
cls
.
getPartitionPath
(
'export'
,
*
components
)
@
classmethod
@
classmethod
def
_getSlapos
(
cls
,
instance_type
=
'export'
):
def
_getSlapos
(
cls
,
instance_type
=
'export'
):
return
cls
.
getPartitionPath
(
instance_type
,
'srv'
,
'runner'
,
'bin'
,
'slapos'
)
return
cls
.
getPartitionPath
(
instance_type
,
'srv'
,
'runner'
,
'bin'
,
'slapos'
)
...
...
software/theia/test/test_resiliency.py
View file @
e95f1e0c
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
errno
import
errno
import
json
import
os
import
os
import
re
import
re
import
shutil
import
shutil
...
@@ -38,11 +39,15 @@ import requests
...
@@ -38,11 +39,15 @@ import requests
from
slapos.proxy.db_version
import
DB_VERSION
from
slapos.proxy.db_version
import
DB_VERSION
from
slapos.slap.slap
import
DEFAULT_SOFTWARE_TYPE
from
slapos.testing.testcase
import
SlapOSNodeCommandError
,
installSoftwareUrlList
from
slapos.testing.testcase
import
SlapOSNodeCommandError
,
installSoftwareUrlList
import
test
from
test
import
TheiaTestCase
,
ResilientTheiaMixin
,
theia_software_release_url
from
test
import
TheiaTestCase
,
ResilientTheiaMixin
,
theia_software_release_url
dummy_software_url
=
os
.
path
.
abspath
(
dummy_software_url
=
os
.
path
.
abspath
(
os
.
path
.
join
(
'resilience_dummy'
,
'software.cfg'
))
os
.
path
.
join
(
'resilience_dummy'
,
'software.cfg'
))
...
@@ -82,8 +87,7 @@ class ResilientTheiaTestCase(ResilientTheiaMixin, TheiaTestCase):
...
@@ -82,8 +87,7 @@ class ResilientTheiaTestCase(ResilientTheiaMixin, TheiaTestCase):
cls
.
checkSlapos
(
'node'
,
'instance'
,
instance_type
=
instance_type
)
cls
.
checkSlapos
(
'node'
,
'instance'
,
instance_type
=
instance_type
)
@
classmethod
@
classmethod
def
_deployEmbeddedSoftware
(
cls
,
software_url
,
instance_name
,
retries
=
0
,
instance_type
=
'export'
):
def
_processEmbeddedSoftware
(
cls
,
retries
=
0
,
instance_type
=
'export'
):
cls
.
callSlapos
(
'supply'
,
software_url
,
'slaprunner'
,
instance_type
=
instance_type
)
for
_
in
range
(
retries
):
for
_
in
range
(
retries
):
try
:
try
:
output
=
cls
.
captureSlapos
(
'node'
,
'software'
,
instance_type
=
instance_type
,
stderr
=
subprocess
.
STDOUT
)
output
=
cls
.
captureSlapos
(
'node'
,
'software'
,
instance_type
=
instance_type
,
stderr
=
subprocess
.
STDOUT
)
...
@@ -96,6 +100,11 @@ class ResilientTheiaTestCase(ResilientTheiaMixin, TheiaTestCase):
...
@@ -96,6 +100,11 @@ class ResilientTheiaTestCase(ResilientTheiaMixin, TheiaTestCase):
print
(
"Wait before running slapos node software one last time"
)
print
(
"Wait before running slapos node software one last time"
)
time
.
sleep
(
120
)
time
.
sleep
(
120
)
cls
.
checkSlapos
(
'node'
,
'software'
,
instance_type
=
instance_type
)
cls
.
checkSlapos
(
'node'
,
'software'
,
instance_type
=
instance_type
)
@
classmethod
def
_deployEmbeddedSoftware
(
cls
,
software_url
,
instance_name
,
retries
=
0
,
instance_type
=
'export'
):
cls
.
callSlapos
(
'supply'
,
software_url
,
'slaprunner'
,
instance_type
=
instance_type
)
cls
.
_processEmbeddedSoftware
(
retries
,
instance_type
)
cls
.
callSlapos
(
'request'
,
instance_name
,
software_url
,
instance_type
=
instance_type
)
cls
.
callSlapos
(
'request'
,
instance_name
,
software_url
,
instance_type
=
instance_type
)
cls
.
_processEmbeddedInstance
(
retries
,
instance_type
)
cls
.
_processEmbeddedInstance
(
retries
,
instance_type
)
...
@@ -602,3 +611,43 @@ class TestTheiaFrontendForwarding(TheiaSyncMixin, ResilientTheiaTestCase):
...
@@ -602,3 +611,43 @@ class TestTheiaFrontendForwarding(TheiaSyncMixin, ResilientTheiaTestCase):
def
_doTakeover
(
self
):
def
_doTakeover
(
self
):
# do nothing
# do nothing
pass
pass
class
TestTheiaResilienceWithInitialInstance
(
TestTheiaResilience
,
test
.
TestTheiaWithEmbeddedInstance
):
backup_max_tries
=
70
backup_wait_interval
=
10
sr_url
=
dummy_software_url
sr_type
=
DEFAULT_SOFTWARE_TYPE
sr_config
=
{}
@
classmethod
def
getInstanceParameterDict
(
cls
,
sr_url
=
None
,
sr_type
=
None
,
sr_config
=
None
):
d
=
test
.
TestTheiaWithEmbeddedInstance
.
getInstanceParameterDict
.
__func__
(
cls
,
sr_url
,
sr_type
,
sr_config
)
d
.
update
(
autorun
=
'stopped'
)
return
d
def
_prepareExport
(
self
):
# Check that there is an export and import instance and get their partition IDs
self
.
export_id
=
self
.
getPartitionId
(
'export'
)
self
.
import_id
=
self
.
getPartitionId
(
'import'
)
# Remember content of ~/etc in the import theia
self
.
etc_listdir
=
os
.
listdir
(
self
.
getPartitionPath
(
'import'
,
'etc'
))
# Check initial embedded instance
test
.
TestTheiaWithEmbeddedInstance
.
test
(
self
)
self
.
_processEmbeddedSoftware
()
self
.
_processEmbeddedInstance
()
def
_checkTakeover
(
self
):
# Check takeover
TestTheiaResilience
.
_checkTakeover
(
self
)
# Check that embedded instance still exists
test
.
TestTheiaWithEmbeddedInstance
.
test
(
self
)
self
.
_processEmbeddedSoftware
()
self
.
_processEmbeddedInstance
()
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