def cleanUp(self): chdir(self.TEST_HOME) #kill any running java bash("killall -9 java") #cleanup installed VMs bash("xe vm-uninstall --force --multiple")
def run(worker, install_marvin): worker.cleanUp() repo_head = worker.fastForwardRepo() if worker.buildCloudStack(): if install_marvin: logging.debug("Installing marvin") worker.installMarvin() else: raise Exception("cloudstack build has failed. exiting") if worker.startManagement(): if not worker.configure(): raise Exception("failed to setup cloudstack zone") else: raise Exception("mgmt server didn't startup in time") #FIXME: override/db.properties should be able to update the host bash("mysql -uroot -Dcloud -e\"update configuration set value='%s' where " "name='host'\""%NetUtils.getIpAddress('xenbr0')) worker.cleanUp() if worker.startManagement(): worker.runTests(repo_head) else: raise Exception("mgmt server did not startup in time") return worker.getResultXml()
def configure(self): chdir(self.TEST_HOME) if path.exists(self.MARVIN_CFG): #reset tools/devcloud.cfg with testworkers' ip settings bash("sed -iv 's/%s/%s/g' %s"%(self.SED_DFLTIP1, self.SED_XENBR01, self.MARVIN_CFG)) bash("sed -iv 's/%s/%s/g' %s"%(self.SED_DFLTIP2, self.SED_XENBR02, self.MARVIN_CFG)) else: raise Exception("marvin configuration not found") return bash("mvn -Pdeveloper -pl tools/devcloud -Ddeploysvr").isSuccess()
def installMarvin(self): chdir(self.TEST_HOME) install_path = path.join(self.TEST_HOME, "tools/marvin/dist/Marvin-0.1.0.tar.gz") if path.exists(install_path): bash("pip install %s"%install_path) marvin_nose_path = path.join(self.TEST_HOME, "tools/marvin/marvin") chdir(marvin_nose_path) bash("pip install .")
def buildCloudStack(self): chdir(self.TEST_HOME) if bash("mvn -Pdeveloper clean install -Dsystemvm -DskipTests").isSuccess(): if bash("mvn -Pdeveloper -pl developer,tools/devcloud -Ddeploydb").isSuccess(): return True else: logging.error("deploydb has errored out") return False else: logging.error("cloudstack build failed. see logs for details") return False
def runTests(self, repo_head): chdir(self.TEST_HOME) if self.healthCheck(): result=bash("nosetests --with-xunit --xunit-file=%s.xml \ --with-marvin --marvin-config=%s -x \ --debug-log=nosedebug.log -a tags='devcloud' --load %s"%(repo_head, self.MARVIN_CFG, "test/integration/smoke/test_vm_life_cycle.py")) self.resultXml = path.join(path.abspath(curdir), repo_head+'.xml') if result.isSuccess(): logging.info("SUCCESS") else: logging.info("FAIL") else: logging.error("Health Check Failure. SystemVMs and/or built-in templates didn't come up") raise Exception("Health check fails!")
def startManagement(self): chdir(self.TEST_HOME) bash("export MAVEN_OPTS='-XX:MaxPermSize=512m -Xmx2g'") out = bash("mvn -P developer -pl :cloud-client-ui jetty:run &", background=True).isSuccess() bash("sleep 90") #TODO: Figure out working with listCapabilities return out
def healthCheck(self): chdir(self.TEST_HOME) return bash("nosetests -v --with-marvin --marvin-config=%s \ --load %s"%(self.MARVIN_CFG, "tools/marvin/marvin/testSetupSuccess.py")).isSuccess()
def fastForwardRepo(self, commit_id='HEAD'): bash("git fetch origin %s"%commit_id) bash("git reset --hard FETCH_HEAD") return bash("git log -1 --pretty=oneline | awk '{print $1}'").getStdout()