Commit e95f1e0c authored by Xavier Thompson's avatar Xavier Thompson

software/theia: Add resiliency test

Test that takeover of theia with an initial embedded instance succeeds.
parent 1aa17677
......@@ -538,6 +538,10 @@ class ResilientTheiaMixin(object):
def getPartitionPath(cls, instance_type='export', *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
def _getSlapos(cls, instance_type='export'):
return cls.getPartitionPath(instance_type, 'srv', 'runner', 'bin', 'slapos')
......
......@@ -27,6 +27,7 @@
from __future__ import unicode_literals
import errno
import json
import os
import re
import shutil
......@@ -38,11 +39,15 @@ import requests
from slapos.proxy.db_version import DB_VERSION
from slapos.slap.slap import DEFAULT_SOFTWARE_TYPE
from slapos.testing.testcase import SlapOSNodeCommandError, installSoftwareUrlList
import test
from test import TheiaTestCase, ResilientTheiaMixin, theia_software_release_url
dummy_software_url = os.path.abspath(
os.path.join('resilience_dummy', 'software.cfg'))
......@@ -82,8 +87,7 @@ class ResilientTheiaTestCase(ResilientTheiaMixin, TheiaTestCase):
cls.checkSlapos('node', 'instance', 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)
def _processEmbeddedSoftware(cls, retries=0, instance_type='export'):
for _ in range(retries):
try:
output = cls.captureSlapos('node', 'software', instance_type=instance_type, stderr=subprocess.STDOUT)
......@@ -96,6 +100,11 @@ class ResilientTheiaTestCase(ResilientTheiaMixin, TheiaTestCase):
print("Wait before running slapos node software one last time")
time.sleep(120)
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._processEmbeddedInstance(retries, instance_type)
......@@ -602,3 +611,43 @@ class TestTheiaFrontendForwarding(TheiaSyncMixin, ResilientTheiaTestCase):
def _doTakeover(self):
# do nothing
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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment