Commit 110c6d3a authored by Benjamin Blanc's avatar Benjamin Blanc

Testnode: Test _updateInstanceXML

parent c6689f17
...@@ -545,19 +545,21 @@ branch = foo ...@@ -545,19 +545,21 @@ branch = foo
original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate
original_generateConfiguration = TaskDistributor.generateConfiguration original_generateConfiguration = TaskDistributor.generateConfiguration
original_isMasterTestnode = TaskDistributor.isMasterTestnode original_isMasterTestnode = TaskDistributor.isMasterTestnode
original_updateInstanceXML = RunnerClass._updateInstanceXML
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
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
original_getTestType = TaskDistributor.getTestType original_getTestType = TaskDistributor.getTestType
original_createTestResult = TaskDistributionTool.createTestResult
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType TaskDistributor.getTestType = patch_getTestType
original_createTestResult = TaskDistributionTool.createTestResult
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributionTool.createTestResult = patch_createTestResult
# TestNode # TestNode
test_node = self.getTestNode() test_node = self.getTestNode()
# Modify class UnitTestRunner(or more after) method # Modify class UnitTestRunner(or more after) method
...@@ -576,6 +578,7 @@ branch = foo ...@@ -576,6 +578,7 @@ branch = foo
TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate
TaskDistributor.generateConfiguration = original_generateConfiguration TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.isMasterTestnode = original_isMasterTestnode TaskDistributor.isMasterTestnode = original_isMasterTestnode
RunnerClass._updateInstanceXML = original_updateInstanceXML
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributionTool.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode TaskDistributionTool.subscribeNode = original_subscribeNode
...@@ -688,12 +691,14 @@ branch = foo ...@@ -688,12 +691,14 @@ branch = foo
original_isMasterTestnode = TaskDistributor.isMasterTestnode original_isMasterTestnode = TaskDistributor.isMasterTestnode
original_supply = SlapOSControler.supply original_supply = SlapOSControler.supply
original_request = SlapOSControler.request original_request = SlapOSControler.request
original_updateInstanceXML = RunnerClass._updateInstanceXML
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
SlapOSControler.supply = doNothing SlapOSControler.supply = doNothing
SlapOSControler.request = doNothing SlapOSControler.request = doNothing
RunnerClass._updateInstanceXML = doNothing
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
original_getTestType = TaskDistributor.getTestType original_getTestType = TaskDistributor.getTestType
...@@ -721,6 +726,7 @@ branch = foo ...@@ -721,6 +726,7 @@ branch = foo
TaskDistributor.isMasterTestnode = original_isMasterTestnode TaskDistributor.isMasterTestnode = original_isMasterTestnode
SlapOSControler.supply =original_supply SlapOSControler.supply =original_supply
SlapOSControler.request = original_request SlapOSControler.request = original_request
SlapOSControler._updateInstanceXML = original_updateInstanceXML
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributionTool.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode TaskDistributionTool.subscribeNode = original_subscribeNode
...@@ -915,6 +921,8 @@ branch = foo ...@@ -915,6 +921,8 @@ branch = foo
original_runTestSuite = RunnerClass.runTestSuite original_runTestSuite = RunnerClass.runTestSuite
original_supply = SlapOSControler.supply original_supply = SlapOSControler.supply
original_request = SlapOSControler.request original_request = SlapOSControler.request
original_updateInstanceXML = SlapOSControler._updateInstanceXML
# #
time.sleep = doNothing time.sleep = doNothing
TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey
...@@ -929,6 +937,7 @@ branch = foo ...@@ -929,6 +937,7 @@ branch = foo
RunnerClass.runTestSuite = doNothing RunnerClass.runTestSuite = doNothing
SlapOSControler.supply = doNothing SlapOSControler.supply = doNothing
SlapOSControler.request = doNothing SlapOSControler.request = doNothing
SlapOSControler._updateInstanceXML = doNothing
# Run # Run
test_node = self.getTestNode() test_node = self.getTestNode()
test_node.run() test_node.run()
...@@ -945,4 +954,5 @@ branch = foo ...@@ -945,4 +954,5 @@ branch = foo
RunnerClass.runTestSuite = original_runTestSuite RunnerClass.runTestSuite = original_runTestSuite
SlapOSControler.supply = original_supply SlapOSControler.supply = original_supply
SlapOSControler.request = original_request SlapOSControler.request = original_request
SlapOSControler._updateInstanceXML = original_updateInstanceXML
time.sleep =original_sleep time.sleep =original_sleep
...@@ -165,6 +165,12 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -165,6 +165,12 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
del self.remaining_software_installation_dict[computer_guid] del self.remaining_software_installation_dict[computer_guid]
# Not empty grid means that all softwares are not installed # Not empty grid means that all softwares are not installed
return len(self.remaining_software_installation_dict) > 0 return len(self.remaining_software_installation_dict) > 0
def _updateInstanceXML(self, software_path, computer_guid, xml):
"""
Just a proxy to SlapOSControler.updateInstanceXML.
"""
self.slapos_controler.updateInstanceXML(software_path, computer_guid, xml)
def prepareSlapOSForTestSuite(self, node_test_suite): def prepareSlapOSForTestSuite(self, node_test_suite):
""" """
...@@ -263,6 +269,16 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -263,6 +269,16 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
self._createInstance(self.reachable_profile, configuration_list[0], self._createInstance(self.reachable_profile, configuration_list[0],
instance_title) instance_title)
self.log("Scalability instance requested") self.log("Scalability instance requested")
time.sleep(15)
self.log("Trying to update instance XML...")
time.sleep(2)
try:
self._updateInstanceXML(self.reachable_profile, "COMP-1564", configuration_list[1])
self.log("Instance XML updated...")
except:
raise ValueError("Unable to update instance XML")
return {'status_code' : 1}
except: except:
self.log("Unable to launch instance") self.log("Unable to launch instance")
raise ValueError("Unable to launch instance") raise ValueError("Unable to launch instance")
......
...@@ -107,9 +107,9 @@ class SlapOSControler(object): ...@@ -107,9 +107,9 @@ class SlapOSControler(object):
config = client.Config() config = client.Config()
config.setConfig(args, args.configuration_file) config.setConfig(args, args.configuration_file)
try: try:
local = client.init(config) local = client.init(config)
local['supply'](software_url, computer_guid=computer_id, state=state) local['supply'](software_url, computer_guid=computer_id, state=state)
self.log('SlapOSControler : supply %s %s %s' %(software_url, computer_id, state)) self.log('SlapOSControler : supply %s %s %s' %(software_url, computer_id, state))
except: except:
self.log("SlapOSControler.supply, \ self.log("SlapOSControler.supply, \
exception in registerOpenOrder", exc_info=sys.exc_info()) exception in registerOpenOrder", exc_info=sys.exc_info())
...@@ -168,6 +168,36 @@ class SlapOSControler(object): ...@@ -168,6 +168,36 @@ class SlapOSControler(object):
else: else:
raise ValueError("Configuration file not found.") raise ValueError("Configuration file not found.")
def updateInstanceXML(self, software_url, computer_id, xml):
"""
Update the XML configuration of an instance
# If doesn't work, try to re-request same instance just with an other
xml onfiguration.
"""
self.log('SlapOSControler : updateInstanceXML')
parser = argparse.ArgumentParser()
parser.add_argument("configuration_file")
parser.add_argument("software_url")
parser.add_argument("node")
if os.path.exists(self.configuration_file_path):
args = parser.parse_args([self.configuration_file_path, software_url, computer_id])
config = client.Config()
config.setConfig(args, args.configuration_file)
try:
slap = slapos.slap.slap()
slap.initializeConnection(config.master_url,
key_file=config.key_file,
cert_file=config.cert_file)
computer = slap.registerComputer(computer_id)
computer.updateConfiguration(xml)
self.log('SlapOSControler : updateInstanceXML %s' %(xml,))
except:
self.log("SlapOSControler.updateInstanceXML, \
exception in registerOpenOrder", exc_info=sys.exc_info())
raise ValueError("Unable to updateInstanceXML")
else:
raise ValueError("Configuration file not found.")
def _resetSoftware(self): def _resetSoftware(self):
self.log('SlapOSControler : GOING TO RESET ALL SOFTWARE : %r' % self.log('SlapOSControler : GOING TO RESET ALL SOFTWARE : %r' %
(self.software_root,)) (self.software_root,))
......
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