Commit e028637b authored by Benjamin Blanc's avatar Benjamin Blanc

testnode: add isHostingSubscriptionCorrectly method

parent 392574e7
...@@ -500,7 +500,7 @@ revision = %(revision2)s ...@@ -500,7 +500,7 @@ revision = %(revision2)s
"launchable": False, "randomized_path" : "azertyuiop"}) "launchable": False, "randomized_path" : "azertyuiop"})
def patch_isMasterTestnode(self, *args, **kw): def patch_isMasterTestnode(self, *args, **kw):
return (grade == 'master') return (grade == 'master')
def patch_isInstanceCorrectly(self, *args, **kw): def patch_isHostingSubscriptionCorrectly(self, *args, **kw):
return True return True
test_self = self test_self = self
test_result_path_root = os.path.join(test_self._temp_dir,'test/results') test_result_path_root = os.path.join(test_self._temp_dir,'test/results')
...@@ -567,14 +567,14 @@ revision = %(revision2)s ...@@ -567,14 +567,14 @@ revision = %(revision2)s
original_generateConfiguration = TaskDistributor.generateConfiguration original_generateConfiguration = TaskDistributor.generateConfiguration
original_isMasterTestnode = TaskDistributor.isMasterTestnode original_isMasterTestnode = TaskDistributor.isMasterTestnode
original_updateInstanceXML = RunnerClass._updateInstanceXML original_updateInstanceXML = RunnerClass._updateInstanceXML
original_isInstanceCorrectly = SlapOSMasterCommunicator.isInstanceCorrectly original_isHostingSubscriptionCorrectly = SlapOSMasterCommunicator.isHostingSubscriptionCorrectly
original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__ original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__
TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey
TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate
TaskDistributor.generateConfiguration = patch_generateConfiguration TaskDistributor.generateConfiguration = patch_generateConfiguration
TaskDistributor.isMasterTestnode = patch_isMasterTestnode TaskDistributor.isMasterTestnode = patch_isMasterTestnode
RunnerClass._updateInstanceXML = doNothing RunnerClass._updateInstanceXML = doNothing
SlapOSMasterCommunicator.isInstanceCorrectly = patch_isInstanceCorrectly SlapOSMasterCommunicator.isHostingSubscriptionCorrectly = patch_isHostingSubscriptionCorrectly
SlapOSMasterCommunicator.__init__ = doNothing SlapOSMasterCommunicator.__init__ = doNothing
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
...@@ -604,7 +604,7 @@ revision = %(revision2)s ...@@ -604,7 +604,7 @@ revision = %(revision2)s
TaskDistributor.generateConfiguration = original_generateConfiguration TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.isMasterTestnode = original_isMasterTestnode TaskDistributor.isMasterTestnode = original_isMasterTestnode
RunnerClass._updateInstanceXML = original_updateInstanceXML RunnerClass._updateInstanceXML = original_updateInstanceXML
SlapOSMasterCommunicator.isInstanceCorrectly = original_isInstanceCorrectly SlapOSMasterCommunicator.isHostingSubscriptionCorrectly = original_isHostingSubscriptionCorrectly
SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__ SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributionTool.createTestResult = original_createTestResult
...@@ -666,7 +666,7 @@ revision = %(revision2)s ...@@ -666,7 +666,7 @@ revision = %(revision2)s
"launchable": False, "randomized_path" : "azertyuiop"}) "launchable": False, "randomized_path" : "azertyuiop"})
def patch_isMasterTestnode(self, *args, **kw): def patch_isMasterTestnode(self, *args, **kw):
return grade == 'master' return grade == 'master'
def patch_isInstanceCorrectly(self, *args, **kw): def patch_isHostingSubscriptionCorrectly(self, *args, **kw):
return True return True
test_self = self test_self = self
test_result_path_root = os.path.join(test_self._temp_dir,'test/results') test_result_path_root = os.path.join(test_self._temp_dir,'test/results')
...@@ -721,7 +721,7 @@ revision = %(revision2)s ...@@ -721,7 +721,7 @@ revision = %(revision2)s
original_supply = SlapOSControler.supply original_supply = SlapOSControler.supply
original_request = SlapOSControler.request original_request = SlapOSControler.request
original_updateInstanceXML = RunnerClass._updateInstanceXML original_updateInstanceXML = RunnerClass._updateInstanceXML
original_isInstanceCorrectly = SlapOSMasterCommunicator.isInstanceCorrectly original_isHostingSubscriptionCorrectly = SlapOSMasterCommunicator.isHostingSubscriptionCorrectly
original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__ original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__
TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey
TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate
...@@ -730,7 +730,7 @@ revision = %(revision2)s ...@@ -730,7 +730,7 @@ revision = %(revision2)s
SlapOSControler.supply = doNothing SlapOSControler.supply = doNothing
SlapOSControler.request = doNothing SlapOSControler.request = doNothing
RunnerClass._updateInstanceXML = doNothing RunnerClass._updateInstanceXML = doNothing
SlapOSMasterCommunicator.isInstanceCorrectly = patch_isInstanceCorrectly SlapOSMasterCommunicator.isHostingSubscriptionCorrectly = patch_isHostingSubscriptionCorrectly
SlapOSMasterCommunicator.__init__ = doNothing SlapOSMasterCommunicator.__init__ = doNothing
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
...@@ -760,7 +760,7 @@ revision = %(revision2)s ...@@ -760,7 +760,7 @@ revision = %(revision2)s
SlapOSControler.supply =original_supply SlapOSControler.supply =original_supply
SlapOSControler.request = original_request SlapOSControler.request = original_request
SlapOSControler.updateInstanceXML = original_updateInstanceXML SlapOSControler.updateInstanceXML = original_updateInstanceXML
SlapOSMasterCommunicator.isInstanceCorrectly = original_isInstanceCorrectly SlapOSMasterCommunicator.isHostingSubscriptionCorrectly = original_isHostingSubscriptionCorrectly
SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__ SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributionTool.createTestResult = original_createTestResult
...@@ -936,7 +936,7 @@ revision = %(revision2)s ...@@ -936,7 +936,7 @@ revision = %(revision2)s
return "Certificate" return "Certificate"
def patch_getTestType(self, *args, **kw): def patch_getTestType(self, *args, **kw):
return "ScalabilityTest" return "ScalabilityTest"
def patch_isInstanceCorrectly(self, *args, **kw): def patch_isHostingSubscriptionCorrectly(self, *args, **kw):
return True return True
test_self = self test_self = self
test_result_path_root = os.path.join(test_self._temp_dir,'test/results') test_result_path_root = os.path.join(test_self._temp_dir,'test/results')
...@@ -959,7 +959,7 @@ revision = %(revision2)s ...@@ -959,7 +959,7 @@ revision = %(revision2)s
original_supply = SlapOSControler.supply original_supply = SlapOSControler.supply
original_request = SlapOSControler.request original_request = SlapOSControler.request
original_updateInstanceXML = SlapOSControler.updateInstanceXML original_updateInstanceXML = SlapOSControler.updateInstanceXML
original_isInstanceCorrectly = SlapOSMasterCommunicator.isInstanceCorrectly original_isHostingSubscriptionCorrectly = SlapOSMasterCommunicator.isHostingSubscriptionCorrectly
original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__ original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__
# #
...@@ -977,7 +977,7 @@ revision = %(revision2)s ...@@ -977,7 +977,7 @@ revision = %(revision2)s
SlapOSControler.supply = doNothing SlapOSControler.supply = doNothing
SlapOSControler.request = doNothing SlapOSControler.request = doNothing
SlapOSControler.updateInstanceXML = doNothing SlapOSControler.updateInstanceXML = doNothing
SlapOSMasterCommunicator.isInstanceCorrectly = patch_isInstanceCorrectly SlapOSMasterCommunicator.isHostingSubscriptionCorrectly = patch_isHostingSubscriptionCorrectly
SlapOSMasterCommunicator.__init__ = doNothing SlapOSMasterCommunicator.__init__ = doNothing
# Run # Run
test_node = self.getTestNode() test_node = self.getTestNode()
...@@ -996,6 +996,6 @@ revision = %(revision2)s ...@@ -996,6 +996,6 @@ revision = %(revision2)s
SlapOSControler.supply = original_supply SlapOSControler.supply = original_supply
SlapOSControler.request = original_request SlapOSControler.request = original_request
SlapOSControler.updateInstanceXML = original_updateInstanceXML SlapOSControler.updateInstanceXML = original_updateInstanceXML
SlapOSMasterCommunicator.isInstanceCorrectly = original_isInstanceCorrectly SlapOSMasterCommunicator.isHostingSubscriptionCorrectly = original_isHostingSubscriptionCorrectly
SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__ SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
time.sleep =original_sleep time.sleep =original_sleep
...@@ -46,6 +46,7 @@ from erp5.util import taskdistribution ...@@ -46,6 +46,7 @@ from erp5.util import taskdistribution
# for dummy slapos answer # for dummy slapos answer
import signal import signal
MAX_INSTANCE_TIME = 60*60 # 1 hour
class ScalabilityTestRunner(): class ScalabilityTestRunner():
def __init__(self, testnode): def __init__(self, testnode):
...@@ -181,7 +182,7 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -181,7 +182,7 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
Return true if the specified instance is ready. Return true if the specified instance is ready.
This method should communicates with SlapOS Master. This method should communicates with SlapOS Master.
""" """
return self.slapos_communicator.isInstanceCorrectly(instance_title, state) return self.slapos_communicator.isHostingSubscriptionCorrectly(instance_title, state)
def remainSoftwareToInstall(self): def remainSoftwareToInstall(self):
""" """
...@@ -209,9 +210,13 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -209,9 +210,13 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
# Used to simulate slapOS answer # Used to simulate slapOS answer
def _waitInstance(self, instance_title, state): def _waitInstance(self, instance_title, state):
self.log("Wait for instance state: %s" %state) self.log("Wait for instance state: %s" %state)
while (not self.isInstanceReady(instance_title, state)): #TODO: add a time limit
max_time = MAX_INSTANCE_TIME
start_time = 0
while (not self.isInstanceReady(instance_title, state)
and (max_time > (time.time()-start_time))):
time.sleep(15) time.sleep(15)
pass
def prepareSlapOSForTestSuite(self, node_test_suite): def prepareSlapOSForTestSuite(self, node_test_suite):
""" """
......
...@@ -116,7 +116,8 @@ class SlapOSMasterCommunicator(object): ...@@ -116,7 +116,8 @@ class SlapOSMasterCommunicator(object):
if excepted_news_text != news['news'][0]['text']: if excepted_news_text != news['news'][0]['text']:
return False return False
return len(related_instance_link_list) > 0 return len(related_instance_link_list) > 0
# check if requested state = status
def isInstanceCorrect(self, instance_link): def isInstanceCorrect(self, instance_link):
""" """
Return True if instance status and instance news text ~looks corresponding. Return True if instance status and instance news text ~looks corresponding.
...@@ -128,7 +129,20 @@ class SlapOSMasterCommunicator(object): ...@@ -128,7 +129,20 @@ class SlapOSMasterCommunicator(object):
text = news['news'][0]['text'] text = news['news'][0]['text']
requested_status = instance['status'] requested_status = instance['status']
return ('Instance' in text) and ('correctly' in text) and (requested_status in text) return ('Instance' in text) and ('correctly' in text) and (requested_status in text)
# check if requested state = status
def isHostingSubscriptionCorrect(self, hosting_subscription_title):
"""
Return True if all instance news related to hosting_subscription_title
correspond to the requested status.
"""
instance_link_list = self._getRelatedInstanceLink(hosting_subscription_title)
for instance_link in instance_link_list:
if not communicator.isInstanceCorrect(instance_link):
return False
return len(instance_link_list) > 0
# check if provided 'status' = status
def isInstanceCorrectly(self, instance_link, status): def isInstanceCorrectly(self, instance_link, status):
""" """
Return True if instance status and instance news text ~looks corresponding. Return True if instance status and instance news text ~looks corresponding.
...@@ -137,14 +151,16 @@ class SlapOSMasterCommunicator(object): ...@@ -137,14 +151,16 @@ class SlapOSMasterCommunicator(object):
text = self.getNewsFromInstanceLink(instance_link)['news'][0]['text'] text = self.getNewsFromInstanceLink(instance_link)['news'][0]['text']
return ('Instance' in text) and ('correctly' in text) and (status in text) return ('Instance' in text) and ('correctly' in text) and (status in text)
def isHostingSubscriptionCorrect(self, hosting_subscription_title): # check if provided 'status' = status
def isHostingSubscriptionCorrectly(self, hosting_subscription_title, status):
""" """
Return True if all instance news related to hosting_subscription_title Return True if all instance status and instance news text ~looks corresponding.
correspond to the requested status. ( use the matching of 'correctly' and 'Instance' and status ).
""" """
instance_link_list = self._getRelatedInstanceLink('TestScalability_21423104630420') instance_link_list = self._getRelatedInstanceLink(hosting_subscription_title)
for instance_link in instance_link_list: for instance_link in instance_link_list:
if not communicator.isInstanceCorrect(instance_link): if not communicator.isInstanceCorrectly(instance_link, status):
return False return False
return len(instance_link_list) > 0 return len(instance_link_list) > 0
\ No newline at end of file
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