Commit 020d0bde authored by Benjamin Blanc's avatar Benjamin Blanc

tests: add launcher draft, update testnode

parent ebfd9cef
#!/usr/bin/env python
import argparse
import os
import time
import sys
import multiprocessing
import errno
from .argument import ArgumentType
from .performance_tester import PerformanceTester
from erp5.util import taskdistribution
class ScalabilityTest(object):
def __init__(self, title, count):
self.title = title
self.count = count
def dump(self):
print '<ScalabilityTest>'
print 'self.title: %s' %(str(self.title))
print 'self.count: %s' %(str(self.count))
class ScalabilityLauncher(object):
def __init__(self, namespace=None):
if not namespace:
self.__argumentNamespace = self._parseArguments(argparse.ArgumentParser(
description='Run ERP5 benchmarking scalability suites.'))
else:
self.__argumentNamespace = namespace
# Here make a connection with erp5 master
@staticmethod
def _addParserArguments(parser):
# Mandatory arguments
parser.add_argument('--erp5-url',
metavar='ERP5_URL',
help='Main url of ERP5 instance to test')
parser.add_argument('--erp5-test-result-url',
metavar='ERP5_TEST_RESULT_URL',
help='ERP5 URL to find test results corresponding '
'to the current running test_suite')
parser.add_argument('--revision',
metavar='REVISION',
help='Revision of the test_suite')
parser.add_argument('--node-title',
metavar='NODE_TITLE',
help='Title of the testnode which is running this'
'launcher')
@staticmethod
def _checkParsedArguments(namespace):
return namespace
@staticmethod
def _parseArguments(parser):
ScalabilityLauncher._addParserArguments(parser)
namespace = parser.parse_args()
ScalabilityLauncher._checkParsedArguments(namespace)
return namespace
def checkERP5Instance(self):
"""
Check if erp5_instance is accessible
"""
pass
def updateTestResultLineStatus(self, state):
"""
Update state of a test_result_line
"""
pass
def _getNextTest(self):
"""
Get testsuite parameters
"""
title = "My Sweet Title"
count = 1
next_test = ScalabilityTest(title, count)
return next_test
def run(self):
max_time = 10
start_time = time.time()
error_message_set, exit_status = set(), 0
print self.__argumentNamespace.erp5_test_result_url
print self.__argumentNamespace.erp5_url
print self.__argumentNamespace.revision
print self.__argumentNamespace.node_title
while time.time()-start_time < max_time:
current_test = self._getNextTest()
current_test.dump()
time.sleep(2)
return error_message_set, exit_status
def main():
error_message_set, exit_status = ScalabilityLauncher().run()
for error_message in error_message_set:
print >>sys.stderr, "ERROR: %s" % error_message
sys.exit(exit_status)
\ No newline at end of file
......@@ -95,17 +95,30 @@ class ScalabilityTestRunner():
instance_title += "-"
instance_title += time.strftime('%d/%m/%y_%H:%M:%S',time.localtime())
return instance_title
def _createInstance(self, software_path, software_configuration, instance_title):
def _generateInstanceXML(self, software_path, software_configuration,
test_result):
"""
Generate a complete scalability instance XML configuration
"""
config = software_configuration.copy()
# Add here zope partition into launcher node to
# watch activities etc... ? or do it into buildout ?
#config.update({'launcher-partition-list':self.launcher_nodes_computer_guid})
config.update({'scalability-launcher-computer-guid':self.launcher_nodes_computer_guid[0]})
config.update({'scalability-launcher-title':'MyTestNodeTitle'})
config.update({'test-result-path':test_result.test_result_path})
config.update({'test-suite-revision':test_result.revision})
return config
def _createInstance(self, software_path, software_configuration, instance_title,
test_result):
"""
Launch instance
Create scalability instance
"""
if self.authorize_request:
config = software_configuration.copy()
# Add here zope partition into launcher node to
# watch activities etc... ?
#config.update({'launcher-partition-list':self.launcher_nodes_computer_guid})
config.update({'scalability-launcher-computer-guid':self.launcher_nodes_computer_guid[0]})
config = _generateInstanceXML(software_path, software_configuration,
instance_title, test_result)
self.log("testnode, request : %s", instance_title)
self.slapos_controler.request(instance_title, software_path,
"scalability", {"_" : config})
......@@ -170,6 +183,7 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
"""
Just a proxy to SlapOSControler.updateInstanceXML.
"""
# use _generateInstanceXML...;
self.slapos_controler.updateInstanceXML(software_path, computer_guid, xml)
def prepareSlapOSForTestSuite(self, node_test_suite):
......@@ -267,7 +281,7 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
# Launch instance
instance_title = self._generateInstancetitle(node_test_suite.test_suite_title)
self._createInstance(self.reachable_profile, configuration_list[0],
instance_title)
instance_title, node_test_suite.test_result)
self.log("Scalability instance requested")
time.sleep(15)
self.log("Trying to update instance XML...")
......
......@@ -379,6 +379,7 @@ from the distributor.")
# as partitions can be of any kind we have and likely will never have
# a reliable way to check if they are up or not ...
time.sleep(20)
node_test_suite.test_result = test_result
runner.runTestSuite(node_test_suite, portal_url)
# break the loop to get latest priorities from master
break
......
......@@ -69,6 +69,8 @@ setup(name=name,
'erp5.util.benchmark.performance_tester:main [benchmark]',
'scalability_tester_erp5 = '\
'erp5.util.benchmark.scalability_tester:main [scalability_tester]',
'scalability_launcher_erp5 = '\
'erp5.util.benchmark.scalability_launcher:main',
'generate_erp5_tester_report = '\
'erp5.util.benchmark.report:generateReport [benchmark-report]',
'web_checker_utility = erp5.util.webchecker:web_checker_utility'
......
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