Updated Branches: refs/heads/master e442e3a7c -> e38db6943
remove tools/testClient as they are moved to tools/marvin/marvin already Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/e38db694 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/e38db694 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/e38db694 Branch: refs/heads/master Commit: e38db6943454e5d202f817635eaabd00c81f041f Parents: e442e3a Author: Edison Su <[email protected]> Authored: Fri Jun 22 10:57:28 2012 -0700 Committer: Edison Su <[email protected]> Committed: Fri Jun 22 10:57:53 2012 -0700 ---------------------------------------------------------------------- tools/testClient/.project | 17 - tools/testClient/.pydevproject | 10 - tools/testClient/README | 24 - tools/testClient/TestCaseExecuteEngine.py | 74 - tools/testClient/asyncJobMgr.py | 230 - tools/testClient/automated/automated.sh | 60 - tools/testClient/automated/automated.xml | 4425 --------------- tools/testClient/cloudstackConnection.py | 174 - tools/testClient/cloudstackException.py | 36 - tools/testClient/cloudstackTestCase.py | 53 - tools/testClient/cloudstackTestClient.py | 153 - tools/testClient/codegenerator.py | 289 - tools/testClient/configGenerator.py | 396 -- tools/testClient/dbConnection.py | 92 - tools/testClient/demo/README | 4 - tools/testClient/demo/demo.cfg | 25 - tools/testClient/demo/testDeployVM.py | 98 - tools/testClient/demo/testSshDeployVM.py | 143 - tools/testClient/deployAndRun.py | 44 - tools/testClient/deployDataCenter.py | 395 -- tools/testClient/jsonHelper.py | 192 - tools/testClient/pymysql/__init__.py | 143 - tools/testClient/pymysql/charset.py | 186 - tools/testClient/pymysql/connections.py | 940 --- tools/testClient/pymysql/constants/CLIENT.py | 32 - tools/testClient/pymysql/constants/COMMAND.py | 35 - tools/testClient/pymysql/constants/ER.py | 484 -- tools/testClient/pymysql/constants/FIELD_TYPE.py | 44 - tools/testClient/pymysql/constants/FLAG.py | 27 - .../testClient/pymysql/constants/SERVER_STATUS.py | 24 - tools/testClient/pymysql/constants/__init__.py | 12 - tools/testClient/pymysql/converters.py | 360 -- tools/testClient/pymysql/cursors.py | 309 - tools/testClient/pymysql/err.py | 159 - tools/testClient/pymysql/tests/__init__.py | 25 - tools/testClient/pymysql/tests/base.py | 32 - tools/testClient/pymysql/tests/test_DictCursor.py | 68 - tools/testClient/pymysql/tests/test_basic.py | 205 - tools/testClient/pymysql/tests/test_example.py | 44 - tools/testClient/pymysql/tests/test_issues.py | 280 - .../pymysql/tests/thirdparty/__init__.py | 17 - .../tests/thirdparty/test_MySQLdb/__init__.py | 19 - .../tests/thirdparty/test_MySQLdb/capabilities.py | 304 - .../tests/thirdparty/test_MySQLdb/dbapi20.py | 856 --- .../test_MySQLdb/test_MySQLdb_capabilities.py | 127 - .../test_MySQLdb/test_MySQLdb_dbapi20.py | 217 - .../test_MySQLdb/test_MySQLdb_nonstandard.py | 102 - tools/testClient/pymysql/times.py | 28 - tools/testClient/pymysql/util.py | 31 - tools/testClient/remoteSSHClient.py | 48 - tools/testClient/resourceMgrTest/__init__.py | 12 - tools/testClient/resourceMgrTest/setup.py | 85 - .../resourceMgrTest/testDeploy100Host.py | 106 - tools/testClient/sandbox/advanced/advanced_env.py | 131 - tools/testClient/sandbox/advanced/kvm.properties | 37 - tools/testClient/sandbox/advanced/setup.properties | 36 - .../sandbox/advanced/tests/test_scenarios.py | 138 - tools/testClient/sandbox/advanced/xen.properties | 36 - tools/testClient/sandbox/basic/basic_env.py | 129 - tools/testClient/sandbox/basic/setup.properties | 34 - tools/testClient/sandbox/simulator/sandbox.cfg | 138 - tools/testClient/sandbox/simulator/setup.py | 128 - .../sandbox/simulator/simulator.properties | 35 - .../sandbox/simulator/tests/testProvision.py | 131 - tools/testClient/testcase/test_1.py | 31 - tools/testClient/testcase/test_2.py | 35 - tools/testClient/testcase/test_3.py | 122 - tools/testClient/testcase/test_userDecorator.py | 69 - tools/testClient/translator.py | 212 - tools/testClient/unitTest/test_advanced.py | 107 - tools/testClient/unitTest/test_async.py | 70 - tools/testClient/unitTest/test_basic_zone.py | 227 - tools/testClient/unitTest/test_local_storage.py | 255 - 73 files changed, 0 insertions(+), 14396 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e38db694/tools/testClient/.project ---------------------------------------------------------------------- diff --git a/tools/testClient/.project b/tools/testClient/.project deleted file mode 100644 index c6e95d9..0000000 --- a/tools/testClient/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>testClient</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.python.pydev.PyDevBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.python.pydev.pythonNature</nature> - </natures> -</projectDescription> http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e38db694/tools/testClient/.pydevproject ---------------------------------------------------------------------- diff --git a/tools/testClient/.pydevproject b/tools/testClient/.pydevproject deleted file mode 100644 index 505117b..0000000 --- a/tools/testClient/.pydevproject +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?eclipse-pydev version="1.0"?> - -<pydev_project> -<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> -<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> -<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> -<path>/testClient/</path> -</pydev_pathproperty> -</pydev_project> http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e38db694/tools/testClient/README ---------------------------------------------------------------------- diff --git a/tools/testClient/README b/tools/testClient/README deleted file mode 100644 index d2fc512..0000000 --- a/tools/testClient/README +++ /dev/null @@ -1,24 +0,0 @@ -CloudStack Test Client - -0. Generate API XML spec file - ant build-apidocs, the output xml file is dist/commands.xml - -1. generate Cloudstack API python code from an API XML spec file generated by step 0 - python codegenerator.py -o where-to-put-the-cloudstack-api -s where-the-spec-file - -1a. If you will be running XML based tests, you will need to run them through the - translator script. To do that execute translator.py -h for command line help. - Example: - python translator.py -i example.xml - - this will create an example.xml.py script in the current directory. Run - that to run the test. - - -2. Facility it provides: - 1. very handy cloudstack API python wrapper - 2. support async job executing in parallel - 3. remote ssh login/execute command - 4. mysql query - -3. sample code is under unitTest http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e38db694/tools/testClient/TestCaseExecuteEngine.py ---------------------------------------------------------------------- diff --git a/tools/testClient/TestCaseExecuteEngine.py b/tools/testClient/TestCaseExecuteEngine.py deleted file mode 100644 index 77ca95b..0000000 --- a/tools/testClient/TestCaseExecuteEngine.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2012 Citrix Systems, Inc. Licensed under the -# Apache License, Version 2.0 (the "License"); you may not use this -# file except in compliance with the License. Citrix Systems, Inc. -# reserves all rights not expressly granted by the License. -# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Automatically generated by addcopyright.py at 04/03/2012 -try: - import unittest2 as unittest -except ImportError: - import unittest - -from functools import partial -import os -import sys -import logging - -def testCaseLogger(message, logger=None): - if logger is not None: - logger.debug(message) - -class TestCaseExecuteEngine(object): - def __init__(self, testclient, testCaseFolder, testcaseLogFile=None, testResultLogFile=None): - self.testclient = testclient - self.testCaseFolder = testCaseFolder - self.logformat = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s") - - if testcaseLogFile is not None: - self.logfile = testcaseLogFile - self.logger = logging.getLogger("TestCaseExecuteEngine") - fh = logging.FileHandler(self.logfile) - fh.setFormatter(self.logformat) - self.logger.addHandler(fh) - self.logger.setLevel(logging.DEBUG) - if testResultLogFile is not None: - ch = logging.StreamHandler() - ch.setLevel(logging.ERROR) - ch.setFormatter(self.logformat) - self.logger.addHandler(ch) - fp = open(testResultLogFile, "w") - self.testResultLogFile = fp - else: - self.testResultLogFile = sys.stdout - - def injectTestCase(self, testSuites): - for test in testSuites: - if isinstance(test, unittest.BaseTestSuite): - self.injectTestCase(test) - else: - #logger bears the name of the test class - testcaselogger = logging.getLogger("testclient.testcase.%s"%test.__class__.__name__) - fh = logging.FileHandler(self.logfile) - fh.setFormatter(self.logformat) - testcaselogger.addHandler(fh) - testcaselogger.setLevel(logging.DEBUG) - - #inject testclient and logger into each unittest - setattr(test, "testClient", self.testclient) - setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger)) - setattr(test.__class__, "clstestclient", self.testclient) - if hasattr(test, "UserName"): - self.testclient.createNewApiClient(test.UserName, test.DomainName, test.AcctType) - - def run(self): - loader = unittest.loader.TestLoader() - suite = loader.discover(self.testCaseFolder) - self.injectTestCase(suite) - - unittest.TextTestRunner(stream=self.testResultLogFile, verbosity=2).run(suite) http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e38db694/tools/testClient/asyncJobMgr.py ---------------------------------------------------------------------- diff --git a/tools/testClient/asyncJobMgr.py b/tools/testClient/asyncJobMgr.py deleted file mode 100644 index 0b4499b..0000000 --- a/tools/testClient/asyncJobMgr.py +++ /dev/null @@ -1,230 +0,0 @@ -# Copyright 2012 Citrix Systems, Inc. Licensed under the -# Apache License, Version 2.0 (the "License"); you may not use this -# file except in compliance with the License. Citrix Systems, Inc. -# reserves all rights not expressly granted by the License. -# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Automatically generated by addcopyright.py at 04/03/2012 -import threading -import cloudstackException -import time -import Queue -import copy -import sys -import jsonHelper -import datetime - -class job(object): - def __init__(self): - self.id = None - self.cmd = None -class jobStatus(object): - def __init__(self): - self.result = None - self.status = None - self.startTime = None - self.endTime = None - self.duration = None - self.jobId = None - self.responsecls = None - def __str__(self): - return '{%s}' % str(', '.join('%s : %s' % (k, repr(v)) for (k, v) in self.__dict__.iteritems())) -class workThread(threading.Thread): - def __init__(self, in_queue, outqueue, apiClient, db=None, lock=None): - threading.Thread.__init__(self) - self.inqueue = in_queue - self.output = outqueue - self.connection = apiClient.connection.__copy__() - self.db = None - self.lock = lock - - def queryAsynJob(self, job): - if job.jobId is None: - return job - - try: - self.lock.acquire() - result = self.connection.pollAsyncJob(job.jobId, job.responsecls).jobresult - except cloudstackException.cloudstackAPIException, e: - result = str(e) - finally: - self.lock.release() - - job.result = result - return job - - def executeCmd(self, job): - cmd = job.cmd - - jobstatus = jobStatus() - jobId = None - try: - self.lock.acquire() - - if cmd.isAsync == "false": - jobstatus.startTime = datetime.datetime.now() - - result = self.connection.make_request(cmd) - jobstatus.result = result - jobstatus.endTime = datetime.datetime.now() - jobstatus.duration = time.mktime(jobstatus.endTime.timetuple()) - time.mktime(jobstatus.startTime.timetuple()) - else: - result = self.connection.make_request(cmd, None, True) - if result is None: - jobstatus.status = False - else: - jobId = result.jobid - jobstatus.jobId = jobId - try: - responseName = cmd.__class__.__name__.replace("Cmd", "Response") - jobstatus.responsecls = jsonHelper.getclassFromName(cmd, responseName) - except: - pass - jobstatus.status = True - except cloudstackException.cloudstackAPIException, e: - jobstatus.result = str(e) - jobstatus.status = False - except: - jobstatus.status = False - jobstatus.result = sys.exc_info() - finally: - self.lock.release() - - return jobstatus - - def run(self): - while self.inqueue.qsize() > 0: - job = self.inqueue.get() - if isinstance(job, jobStatus): - jobstatus = self.queryAsynJob(job) - else: - jobstatus = self.executeCmd(job) - - self.output.put(jobstatus) - self.inqueue.task_done() - - '''release the resource''' - self.connection.close() - -class jobThread(threading.Thread): - def __init__(self, inqueue, interval): - threading.Thread.__init__(self) - self.inqueue = inqueue - self.interval = interval - def run(self): - while self.inqueue.qsize() > 0: - job = self.inqueue.get() - try: - job.run() - '''release the api connection''' - job.apiClient.connection.close() - except: - pass - - self.inqueue.task_done() - time.sleep(self.interval) - -class outputDict(object): - def __init__(self): - self.lock = threading.Condition() - self.dict = {} - -class asyncJobMgr(object): - def __init__(self, apiClient, db): - self.inqueue = Queue.Queue() - self.output = outputDict() - self.outqueue = Queue.Queue() - self.apiClient = apiClient - self.db = db - - def submitCmds(self, cmds): - if not self.inqueue.empty(): - return False - id = 0 - ids = [] - for cmd in cmds: - asyncjob = job() - asyncjob.id = id - asyncjob.cmd = cmd - self.inqueue.put(asyncjob) - id += 1 - ids.append(id) - return ids - - def updateTimeStamp(self, jobstatus): - jobId = jobstatus.jobId - if jobId is not None and self.db is not None: - result = self.db.execute("select job_status, created, last_updated from async_job where id=%s"%jobId) - if result is not None and len(result) > 0: - if result[0][0] == 1: - jobstatus.status = True - else: - jobstatus.status = False - jobstatus.startTime = result[0][1] - jobstatus.endTime = result[0][2] - delta = jobstatus.endTime - jobstatus.startTime - jobstatus.duration = delta.total_seconds() - - def waitForComplete(self, workers=10): - self.inqueue.join() - lock = threading.Lock() - resultQueue = Queue.Queue() - '''intermediate result is stored in self.outqueue''' - for i in range(workers): - worker = workThread(self.outqueue, resultQueue, self.apiClient, self.db, lock) - worker.start() - - self.outqueue.join() - - asyncJobResult = [] - while resultQueue.qsize() > 0: - jobstatus = resultQueue.get() - self.updateTimeStamp(jobstatus) - asyncJobResult.append(jobstatus) - - return asyncJobResult - - '''put commands into a queue at first, then start workers numbers threads to execute this commands''' - def submitCmdsAndWait(self, cmds, workers=10): - self.submitCmds(cmds) - lock = threading.Lock() - for i in range(workers): - worker = workThread(self.inqueue, self.outqueue, self.apiClient, self.db, lock) - worker.start() - - return self.waitForComplete(workers) - - '''submit one job and execute the same job ntimes, with nums_threads of threads''' - def submitJobExecuteNtimes(self, job, ntimes=1, nums_threads=1, interval=1): - inqueue1 = Queue.Queue() - lock = threading.Condition() - for i in range(ntimes): - newjob = copy.copy(job) - setattr(newjob, "apiClient", copy.copy(self.apiClient)) - setattr(newjob, "lock", lock) - inqueue1.put(newjob) - - for i in range(nums_threads): - work = jobThread(inqueue1, interval) - work.start() - inqueue1.join() - - '''submit n jobs, execute them with nums_threads of threads''' - def submitJobs(self, jobs, nums_threads=1, interval=1): - inqueue1 = Queue.Queue() - lock = threading.Condition() - - for job in jobs: - setattr(job, "apiClient", copy.copy(self.apiClient)) - setattr(job, "lock", lock) - inqueue1.put(job) - - for i in range(nums_threads): - work = jobThread(inqueue1, interval) - work.start() - inqueue1.join() http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e38db694/tools/testClient/automated/automated.sh ---------------------------------------------------------------------- diff --git a/tools/testClient/automated/automated.sh b/tools/testClient/automated/automated.sh deleted file mode 100644 index cf7588c..0000000 --- a/tools/testClient/automated/automated.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# Copyright 2012 Citrix Systems, Inc. Licensed under the -# Apache License, Version 2.0 (the "License"); you may not use this -# file except in compliance with the License. Citrix Systems, Inc. -# reserves all rights not expressly granted by the License. -# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Automatically generated by addcopyright.py at 04/03/2012 - -# wec -export CATALINA_HOME=${HOME}/automated -# macos tomcat -#ORIG_TOMCAT=/usr/local/tomcat -# linux/jenkins host tomcat -ORIG_TOMCAT=/usr/share/tomcat6 - -mkdir_copy_files() { - if [ -z "$1" ]; then - return 0 - fi - - echo "Copying $1 files to $2..." - - mkdir -p $2 - cp -R $1/* $2 - return $? -} - -if [ ! -d ${ORIG_TOMCAT} ]; then - echo "Tomcat must be installed on this system" - exit 1 -fi - -if [ -d ${CATALINA_HOME} ]; then - echo "Existing test Tomcat exists!!!" - exit 1 -fi - -# now let's copy over the required files... -mkdir_copy_files ${ORIG_TOMCAT}/conf ${CATALINA_HOME}/conf -mkdir_copy_files ${ORIG_TOMCAT}/bin ${CATALINA_HOME}/bin -mkdir_copy_files ${ORIG_TOMCAT}/lib ${CATALINA_HOME}/lib -mkdir_copy_files ${ORIG_TOMCAT}/logs ${CATALINA_HOME}/logs -mkdir_copy_files ${ORIG_TOMCAT}/temp ${CATALINA_HOME}/temp -mkdir_copy_files ${ORIG_TOMCAT}/webapps ${CATALINA_HOME}/webapps -mkdir_copy_files ${ORIG_TOMCAT}/work ${CATALINA_HOME}/work - -ant clean-all - -ant automated-test-run - -# clean up our temp tomcat! -rm -rf ${CATALINA_HOME} - -exit $?
