def start_acmeair(self): """ Set the required env vars for cloudant and start the AcmeAir app locally If app is already running, check if it's functioning """ app_status = self.is_acmeair_running() if app_status == -1: raise RuntimeError( "AcmeAir is already running but malfunctioning. Please shut it down." ) elif app_status == 1: print( "AcmeAir app is already running, will not attempt to start\n") return cloudantUtils = CloudantDbUtils(self.test_properties) cloudantUtils.check_databases() # set the env vars required to start the app new_env = os.environ.copy() new_env["dbtype"] = "cloudant" new_env["CLOUDANT_URL"] = "https://{}:{}@{}".format( self.test_properties["cloudantusername"], self.test_properties["cloudantpassword"], self.test_properties["cloudanthost"]) # start the acmeair app os.chdir(self.acmehome) command = ["node", "app.js"] self.proc = subprocess.Popen(command, env=new_env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # wait at most 10 sec for app to come up timeout = time.time() + 10 while (True): if not self.is_acmeair_running() == 1: time.sleep(1) else: print("\nAcemAir started!") break if time.time() > timeout: raise RuntimeError("Cannot connect to AcmeAir!")
def start_acmeair(self): """ Set the required env vars for cloudant and start the AcmeAir app locally If app is already running, check if it's functioning """ app_status = self.is_acmeair_running(); if app_status == -1: raise RuntimeError("AcmeAir is already running but malfunctioning. Please shut it down.") elif app_status == 1: print ("AcmeAir app is already running, will not attempt to start\n") return cloudantUtils = CloudantDbUtils(self.test_properties) cloudantUtils.check_databases() # set the env vars required to start the app new_env = os.environ.copy() new_env["dbtype"] = "cloudant" new_env["CLOUDANT_URL"] = "https://{}:{}@{}".format( self.test_properties["cloudantusername"], self.test_properties["cloudantpassword"], self.test_properties["cloudanthost"]) # start the acmeair app os.chdir(self.acmehome) command = ["node", "app.js"] self.proc = subprocess.Popen(command, env=new_env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # wait at most 10 sec for app to come up timeout = time.time() + 10 while (True): if not self.is_acmeair_running() == 1: time.sleep(1) else: print ("\nAcemAir started!") break if time.time() > timeout: raise RuntimeError("Cannot connect to AcmeAir!")
def setup_test_databases(test_properties): from helpers.dbutils import CloudantDbUtils cloudantUtils = CloudantDbUtils(test_properties) cloudantUtils.check_databases()