class TestConfigWinDiagTask(unittest.TestCase): def setUp(self): self.state=State() self.state.put(StaticVariables.SERVERNAME,"win64-2") self.instance = ConfigWinDiagTask() def tearDown(self): pass def test_it(self): self.instance.execute(self.state) print self.instance.getStat()
def setUp(self): self.state = State() self.state.put(StaticVariables.SERVERNAME, "whe-rh563") self.state.put(StaticVariables.SERVERLOGIN, "root") self.state.put(StaticVariables.SERVERPASSWORD, "kramer5B") self.state.put(StaticVariables.SCREENLOGPATH, " build/screen ") self.state.put(StaticVariables.BUILDINSTALLPATH, "/build/9.5.0200.0057/DEBUG/BIN/Linux/bin") self.state.put(StaticVariables.COREDUMPPATH, "/build/9.5.0200.0057/DEBUG/BIN/Linux/") self.state.put(StaticVariables.OS, "Linux") self.testclass = StartServerTask() self.taskstatus = TaskStatus()
def execute(self, State): #init the variables. self.init(State) if self.logflag == True: self.logger.log(self.info) pass if self.OS == "Linux": # 1.connect to Linux machine self = Command.getClient(self) if self.stat == self.FAILED: return self.FAILED # 2.check Iserver path buildpath = Command.checkPath(self.buildInstallPath)+self.buildno+"/"+self.buildversion+"/" if not Command.checkPathExist(buildpath, self.client): self.info = "directory "+buildpath+" does not exist." self.stat = self.ABORT return self.ABORT # 3.stop Iserver if it is running cmd = buildpath+"BIN/Linux/bin/mstrctl -s IntelligenceServer gs" result = Command.executeSsh(cmd, self.client) serverStatus = re.search(r">\w+<\/state>", result).group(0) if serverStatus[1:-8] == "running": cmd = buildpath + "BIN/Linux/bin/mstrctl -s IntelligenceServer stop" Command.executeSsh(cmd, self.client) time.sleep(120) # 4.delete Iserver build cmd = buildpath+"BIN/Linux/bin/mstrctl -s IntelligenceServer gs" result = Command.executeSsh(cmd, self.client) serverStatus = re.search(r">\w+<\/state>", result).group(0) if (serverStatus[1:-8] == "stopped" or serverStatus[1:-8] == "terminated"): cmd = "rm -rf "+Command.checkPath(self.buildInstallPath)+self.buildno result = Command.executeSsh(cmd, self.client) if result != "": self.info = "Error in delete directory "+Command.checkPath(self.buildInstallPath)+self.buildno self.stat = self.FAILED else: self.info = "Successfully delete directory "+Command.checkPath(self.buildInstallPath)+self.buildno self.stat = self.PASS else: self.info = "Cannot delete build when IServer is not stopped." self.stat = self.FAILED else: # if os is windows. c = rpyc.classic.connect(State.get("server"))
def setUp(self): self.state=State() self.state.put(StaticVariables.SERVERNAME,"whe-rh56") self.state.put(StaticVariables.SERVERLOGIN,"root") self.state.put(StaticVariables.SERVERPASSWORD,"kramer5B") self.state.put(StaticVariables.BUILDVERSION,"DEBUG") self.state.put(StaticVariables.BUILDNO, "9.5.0200.0057") self.state.put(StaticVariables.BUILDINSTALLPATH,r"/build") self.state.put(StaticVariables.ISERVERPORT,34952) self.state.put(StaticVariables.OS, "Linux") self.state.put(StaticVariables.ISERVERDSN, "testdsn") self.state.put(StaticVariables.MDLOGIN, "eat-rw") self.state.put(StaticVariables.MDPWD, "eat-rw") self.state.put(StaticVariables.ISERVERDEF, "Sank") #self.state.put(StaticVariables.ISERVERLOGIN, "eat-rw") self.instance = ConfigUnixIServerTask()
self.stat = self.PASS else: self.info = "Cannot delete build when IServer is not stopped." self.stat = self.FAILED else: # if os is windows. c = rpyc.classic.connect(State.get("server")) # TO BE IMPLEMENTED if __name__ == "__main__": print "Clear up IServer build is running..." configlocation = sys.argv[1] cf = ConfigParser.ConfigParser() cf.read(configlocation) parameters=cf.items("Config") s = State() for item in parameters: s.put(item[0], item[1]) t = ClearupTask() Command.displayTaskState(t.getStat()) try: state = t.execute(s) except Exception as e: print "task failed."+str(e) Command.displayTaskState(t.getStat())
class TestStartServerTask(unittest.TestCase): def setUp(self): self.state = State() self.state.put(StaticVariables.SERVERNAME, "whe-rh563") self.state.put(StaticVariables.SERVERLOGIN, "root") self.state.put(StaticVariables.SERVERPASSWORD, "kramer5B") self.state.put(StaticVariables.SCREENLOGPATH, " build/screen ") self.state.put(StaticVariables.BUILDINSTALLPATH, "/build/9.5.0200.0057/DEBUG/BIN/Linux/bin") self.state.put(StaticVariables.COREDUMPPATH, "/build/9.5.0200.0057/DEBUG/BIN/Linux/") self.state.put(StaticVariables.OS, "Linux") self.testclass = StartServerTask() self.taskstatus = TaskStatus() def tearDown(self): pass def test_getClient(self): t = self.testclass.getClient(self.state) self.assertEqual(self.testclass.getClient(self.state), self.taskstatus.FAILED, "connect failed")
return self.stat sleep(10) url = "http://%s:8080/manager/text/list" % hostname res = self.httpRequestWithAuth(url, "manager", "manager") if self.logflag == True: self._log.log("List apps in Tomcat:") self._log.log(res) # Check the result if "/%s:" % context_root in res: self.info = "install tomcat web task succeeded." self.stat = self.PASS if self.logflag == True: self._log.log("deploy MicroStrategy web successfully.") return self.stat else: self.info = "install tomcat web task failed." self.stat = self.FAILED if self.logflag == True: self._log.log(context_root + " hasn't started, try %d times.") continue if __name__ == '__main__': #=============================================================================== t = InstallWebTCTask() S ={'tomcatservername':'statomcat','tomcatserverlogin':'******','tomcatserverpassword':'******','tomcatlocation':'/apache-tomcat-7.0.64','buildno':'10.2.0003.0052'} st = State() for d,x in S.items(): st.put(d, x) t.execute(st) #===============================================================================
def setUp(self): self.state=State() self.state.put(StaticVariables.SERVERNAME,"win64-2") self.instance = ConfigWinDiagTask()
class TestConfigUnixIserverTask(unittest.TestCase): def setUp(self): self.state=State() self.state.put(StaticVariables.SERVERNAME,"whe-rh56") self.state.put(StaticVariables.SERVERLOGIN,"root") self.state.put(StaticVariables.SERVERPASSWORD,"kramer5B") self.state.put(StaticVariables.BUILDVERSION,"DEBUG") self.state.put(StaticVariables.BUILDNO, "9.5.0200.0057") self.state.put(StaticVariables.BUILDINSTALLPATH,r"/build") self.state.put(StaticVariables.ISERVERPORT,34952) self.state.put(StaticVariables.OS, "Linux") self.state.put(StaticVariables.ISERVERDSN, "testdsn") self.state.put(StaticVariables.MDLOGIN, "eat-rw") self.state.put(StaticVariables.MDPWD, "eat-rw") self.state.put(StaticVariables.ISERVERDEF, "Sank") #self.state.put(StaticVariables.ISERVERLOGIN, "eat-rw") self.instance = ConfigUnixIServerTask() def tearDown(self): #unittest.TestCase.tearDown(self) pass def test_it(self): self.instance.execute(self.state) print self.instance.getStat() self.assertEqual(self.instance.stat, TaskStatus.PASS, "Test Fail")