本文整理汇总了Python中OSConf.get_app_url方法的典型用法代码示例。如果您正苦于以下问题:Python OSConf.get_app_url方法的具体用法?Python OSConf.get_app_url怎么用?Python OSConf.get_app_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSConf
的用法示例。
在下文中一共展示了OSConf.get_app_url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: number_of_gears
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def number_of_gears(self):
time.sleep(30)
app_url = OSConf.get_app_url(self.app_name)
gears = list()
suffix = {
"php" : ".php",
"nodejs" : '.js',
"ruby" : ".rb",
"ruby-1.9" : ".rb",
"rack" : ".rb",
"jbossas" : ".jsp",
"jbosseap" : ".jsp",
"perl" : ".pl",
"python" : ".py",
"wsgi" : ".py",
"python-3.3" : ".py",
"python-2.7" : ".py",
}
# Checking the output of gear dns script more times
for i in range(1, 11):
gear = common.fetch_page(app_url + "/gear" + suffix[self.test_variant])
#let's check the format
if self.config.options.run_mode == 'OnPremise':
re_str="example.com"
else:
re_str="rhcloud.com"
if re.search(r".*%s$"%(re_str), gear):
if gear not in gears:
self.info("GEAR: [%s]"%gear)
gears.append(gear)
return len(gears)
示例2: verify
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def verify(app_name):
url = OSConf.get_app_url(app_name)
r = common.grep_web_page("%s/data1.js"%url, 'Please visit /show.js to see the data')
r += common.grep_web_page("%s/show.js"%url, 'OPENSHIFT_1')
r += common.grep_web_page("%s/data2.js"%url, 'Please visit /show.js to see the data')
r += common.grep_web_page("%s/show.js"%url, 'OPENSHIFT_2')
return r
示例3: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def test_method(self):
self.info("Create a %s application" %(self.app_type))
ret = common.create_app(self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd)
self.assert_equal(ret, 0, "App should be created successfully")
source_file = "%s/data/qpid_fuzzing_stage.php" %(WORK_DIR)
target_file = "%s/php/index.php" %(self.app_name)
self.info("2.Copying test files to app git repo")
ret = common.command_get_status("cp -f %s %s" %(source_file, target_file))
self.assert_equal(ret, 0)
self.info("3. Do git commit")
ret = common.command_get_status("cd %s && git add . && git commit -m test && git push" %(self.app_name))
self.assert_equal(ret, 0, "File and directories are added to your git repo successfully")
self.info("4. Get app url")
app_url = OSConf.get_app_url(self.app_name)
self.info("Access app's URL to tigger test")
ret = common.grep_web_page("%s/index.php?action=create"%app_url, "###RESULT###: PASS")
self.assert_equal(ret, 0)
return self.passed("%s passed" % self.__class__.__name__)
示例4: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def test_method(self):
self.info("1. Create a %s application" %(self.app_type))
ret = common.create_app(self.app_name,
self.app_type,
self.config.OPENSHIFT_user_email,
self.config.OPENSHIFT_user_passwd)
self.assert_equal(ret, 0,"%s app should be created successfully" %(self.app_name))
file_name1 = "execute_risky_system_binaries.php"
file_name2 = "execute_risky_system_binaries.sh"
source_file1 = "%s/data/%s" %(WORK_DIR, file_name1)
source_file2 = "%s/data/%s" %(WORK_DIR, file_name2)
target_file1 = "%s/php/index.php" %(self.app_name)
target_file2 = "%s/php/%s" %(self.app_name, file_name2)
self.info("2. Copying test files to app git repo")
ret = common.command_get_status("cp -f %s %s && cp -f %s %s" %(source_file1, target_file1, source_file2, target_file2))
self.assert_equal(ret, 0,"File and directories are added to your git repo successfully")
self.info("3. Do git commit")
ret = common.command_get_status("cd %s && git add . && git commit -m test && git push" %(self.app_name))
self.assert_equal(ret, 0, "File and directories are added to your git repo successfully")
app_url = OSConf.get_app_url(self.app_name)
self.info("4. Access app's URL to tigger test")
ret = common.grep_web_page(app_url, "###RESULT###: PASS")
self.assert_equal(ret, 0, "###RESULT###: PASS must be in %s"%app_url)
return self.passed("%s passed" % self.__class__.__name__)
示例5: run_rhc_tail
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def run_rhc_tail(self, app_name, arguments=None):
"Should return non zero if the command"
global rhc_tail
url = OSConf.get_app_url(app_name)
for i in range(1): #touch that app
common.grep_web_page(url,'OpenShift')
cmd="rhc-tail-files -a %s -l %s -p %s "%(app_name, self.user_email, self.user_passwd)
if arguments!=None:
cmd += arguments
print "CMD=%s"%cmd
rhc_tail = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
# make stdin a non-blocking file
try:
fd = rhc_tail.stdout.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
except Exception as e:
print "ERROR: %s"%str(e)
return 1
time.sleep(10)
st = rhc_tail.poll()
if (st==None):
st=777
return st
示例6: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def test_method(self):
self.info("1. Create a %s application" %(self.app_type))
ret = common.create_app(self.app_name1, self.app_type,
self.config.OPENSHIFT_user_email,
self.config.OPENSHIFT_user_passwd)
self.assert_equal(0, ret, "App#1 should be created successfully")
self.info("2. Copying test files to app git repo")
ret = common.command_get_status("cp -f %s %s" %(self.source_file, self.target_file1))
self.assert_equal(0, ret)
self.info("3. Do git commit")
ret = common.command_get_status("cd %s && git add . && git commit -m test && git push" %(self.app_name1))
self.assert_equal(0, ret, "File and directories are added to your git repo successfully")
app_url = OSConf.get_app_url(self.app_name1)
self.info("4. Access app's URL to create files in tmp directory")
ret = common.grep_web_page("%s/%s" %(app_url, self.url_path1), ["RESULT=0"])
self.assert_equal(0, ret, "RESULT=0 should be seen in output of %s"%app_url)
self.info("5. Create another %s application" %(self.app_type))
ret = common.create_app(self.app_name2,
self.app_type,
self.config.OPENSHIFT_user_email,
self.config.OPENSHIFT_user_passwd)
self.assert_equal(0, ret, "App#2 should be created successfully")
self.info("6. Copying test files to app git repo")
common.command_get_status("cp -f %s %s" %(self.source_file, self.target_file2))
self.assert_equal(0, ret, "Copy should be done.")
self.info("7. Do git commit")
ret = common.command_get_status("cd %s && git add . && git commit -m test && git push" %(self.app_name2))
self.assert_equal(0, ret, "File and directories are added to your git repo successfully")
self.info("8. Get app url")
app_url = OSConf.get_app_url(self.app_name2)
self.info("9. Access app's URL to check files in tmp directory")
common.grep_web_page("%s/%s" %(app_url, self.url_path2),
["RESULT=1", "No such file or directory"])
self.assert_equal(ret, 0,"Files is created in tmp directory")
return self.passed("%s passed" % self.__class__.__name__)
示例7: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def test_method(self):
self.step("Create %s app: %s" % (self.app_type, self.app_name))
ret = common.create_app(self.app_name,
self.app_type,
self.config.OPENSHIFT_user_email,
self.config.OPENSHIFT_user_passwd,
scalable=self.scalable,
disable_autoscaling=False)
self.assert_equal(ret, 0, "Failed to create %s app: %s" % (self.app_type, self.app_name))
self.step("Add databases to the app")
ret = common.embed(self.app_name, "add-" + common.cartridge_types["mysql"], self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd)
self.assert_equal(ret, 0, "Failed to add mysql")
ret = common.embed(self.app_name, "add-" + common.cartridge_types["postgresql"], self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd)
self.assert_equal(ret, 0, "Failed to add postgresql")
#ret = common.embed(self.app_name, "add-" + common.cartridge_types["mongodb"], self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd)
#self.assert_equal(ret, 0, "Failed to add mongodb")
self.step("Applications must be accessed by their URL before you can take a thread dump")
app_url = OSConf.get_app_url(self.app_name)
cmd = "curl %s" %(app_url)
(ret, output) = common.command_getstatusoutput(cmd)
self.assert_equal(ret, 0, "Fail to access app")
self.step("Generate threaddump file")
cmd = "rhc threaddump %s -l %s -p '%s' %s" % ( self.app_name,
self.config.OPENSHIFT_user_email,
self.config.OPENSHIFT_user_passwd,
common.RHTEST_RHC_CLIENT_OPTIONS)
(ret, output) = common.command_getstatusoutput(cmd)
self.assert_equal(ret, 0, "Failed to generate threaddump file for %s app: %s" % (self.app_type, self.app_name))
self.debug("OUTPUT: %s" % output)
match = re.search(r'(?<=The thread dump file will be available via: ).*$', output, re.M)
#match = re.search(r'(?<=rhc tail %s )-f \S+' % (self.app_name), output)
self.assert_not_equal(match, None, "Failed to find command to see the threaddump file")
self.step("Check the threaddump file")
#tail_cmd = "rhc tail %s " % (self.app_name) + match.group(0) + " -l %s -p '%s'" % (self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd)
tail_cmd = match.group(0) + " -l %s -p '%s'" % (self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd)
print "Command: %s" % (tail_cmd)
self.child = pexpect.spawn(tail_cmd)
time.sleep(10)
match_num = 0.0
for s in self.str_list:
try:
# increase the timeout from 3 to 10
self.child.expect(s, timeout=20)
match_num += 1
except pexpect.TIMEOUT:
pass
rate = match_num/len(self.str_list)
if rate >= self.match_rate:
self.info("Successfully matched %d%% strings in the list" % (int(rate*100)))
return self.passed()
else:
self.info("Only matched %d%% strings in the list. The lowest match rate is %f%%" % (int(rate*100), int(self.match_rate*100)))
return self.failed()
示例8: grep_app
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def grep_app(self, *args, **kwargs):
last_output = self.get_output_from_last_step()
print "DEBUG: previous output:", last_output
url=OSConf.get_app_url(self.app_name)
if len(args)>0:
find_str = args[0]
else:
find_str = 'OpenShift'
return common.grep_web_page(url, find_str)
示例9: finalize
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def finalize(self):
self.remove_apps_from_mongo()
for app_name in [ self.app_name, self.app_name2 ]:
uuid = OSConf.get_app_uuid(app_name)
app_url = OSConf.get_app_url(app_name)
common.destroy_app(app_name)
if uuid != 1:
common.run_remote_cmd_as_root("rm -Rf /var/lib/openshift/%s" % uuid, app_url)
common.run_remote_cmd_as_root("rm -Rf /var/lib/openshift/%s-*" % app_name, app_url)
示例10: check_variables
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def check_variables(self, *vars_to_check):
app_url = OSConf.get_app_url(self.app_name)
output = common.fetch_page(app_url+"/checker.php")
for arr in vars_to_check:
for var in arr:
obj = re.search(r"%s="%var, output)
if not obj:
self.error("Unable to find %s in environemnt"%var)
return False
return True
示例11: verification
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def verification(self):
self.log_info("Verifying")
sleep(30) # Waiting 30 seconds before checking
app_url = OSConf.get_app_url(self.config.application_name)
ret_code = common.grep_web_page(
"http://%s/" % app_url,
self.config.page_pattern,
options = "-L -H 'Pragma: no-cache' -u wiki:wiki"
)
self.assert_equal(ret_code, 0, "Pattern %s must be found" % self.config.page_pattern)
示例12: get_app_ip
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def get_app_ip(self):
app_url = OSConf.get_app_url(self.app_name)
(status, output) = common.command_getstatusoutput("ping -c 3 %s"%app_url)
obj = re.search(r"(?<=\()(\d{1,3}.){3}\d{1,3}(?=\))", output)
if obj:
app_ip = obj.group(0)
print "Got ip: %s" %(app_ip)
return app_ip
else:
raise Exception("ERROR Unable to get IP address of app")
示例13: number_of_gears
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def number_of_gears(self, app_name):
app_url = OSConf.get_app_url(app_name)
gears = list()
# Checking the output of gear dns script more times
for i in range(1, 11):
gear = common.fetch_page(str(app_url) + "/gear.php")
if gear not in gears:
gears.append(gear)
return len(gears)
示例14: check_the_cron
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def check_the_cron(self):
self.info("Waiting for a minute to get some results from cron...")
uuid = OSConf.get_app_uuid(self.app_name)
app_url = OSConf.get_app_url(self.app_name)
time.sleep(65)
p = pexpect.spawn('ssh -t -o ConnectTimeout=20 %[email protected]%s "cat $OPENSHIFT_DATA_DIR/date.txt"' % (uuid, app_url))
p.wait()
try:
ret = p.expect("\d{2}:\d{2}:\d{2}@\d{4}-\d{2}-\d{2}")
return ret
except pexpect.TIMEOUT, e:
print "Failed to find data generated by cron job. %s" % (e)
示例15: get_auth
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url [as 别名]
def get_auth(self, app_name):
app_url = OSConf.get_app_url(app_name)
for i in range(4):
(ret, output) = common.command_getstatusoutput("curl -H 'Pragma: no-cache' '%s'" % (app_url), True)
if ret == 0:
break
time.sleep(5)
lst = re.findall(r"(?<=<td>).*?(?=</td>)", output, re.S)
tokens = dict()
for i in range(0, len(lst), 2):
tokens[lst[i]] = lst[i+1]
return tokens