本文整理汇总了Python中OSConf.get_app_url_X方法的典型用法代码示例。如果您正苦于以下问题:Python OSConf.get_app_url_X方法的具体用法?Python OSConf.get_app_url_X怎么用?Python OSConf.get_app_url_X使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSConf
的用法示例。
在下文中一共展示了OSConf.get_app_url_X方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
# 1.Create an app
self.steps_list.append(testcase.TestCaseStep("1. Create an php app",
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_description="the app should be created successfully",
expect_return=0))
# 2.Make some changes to the git repo
self.steps_list.append(testcase.TestCaseStep("2.Make some changes to the git repo",
"rm -rf %s/php/index.php && cp -f %s/app_template/php.template %s/php/index.php && cd %s && git add . && git commit -am t && git push" % (self.git_repo, WORK_DIR, self.git_repo, self.git_repo),
expect_description="Git repo successfully modified",
expect_return=0))
# 3.Check app via browser
test_html = "The Times-Tables"
self.steps_list.append(testcase.TestCaseStep("3.Check the app via browser",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name),
test_html, "-H 'Pragma: no-cache'", 3, 9],
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
case = testcase.TestCase(self.summary, self.steps_list)
try:
case.run()
except testcase.TestCaseStepFail:
return self.failed("%s failed" % self.__class__.__name__)
if case.testcase_status == 'PASSED':
return self.passed("%s passed" % self.__class__.__name__)
if case.testcase_status == 'FAILED':
return self.failed("%s failed" % self.__class__.__name__)
示例2: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
# 1.Create an app
self.steps_list.append( testcase.TestCaseStep("1. Create an perl app",
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_description="the app should be created successfully",
expect_return=0))
# 2.Setup perl config(No check)
cmd = "mkdir -p /usr/share/perl5/CPAN/ ; rm -f /usr/share/perl5/CPAN/Config.pm ; cp %s/app_template/Config.pm /usr/share/perl5/CPAN/Config.pm ; rm -rf /$HOME/.cpan" % (WORK_DIR)
self.steps_list.append( testcase.TestCaseStep("2.Setup perl config(No check)",
cmd,
expect_description="Successfully setup perl config"))
# 3.Install dancer and dependencies from CPAN
cmd = "cd %s/app_template && tar xzf local-lib-1.008004.tar.gz && cd local-lib-1.008004 && perl Makefile.PL --bootstrap=~/dancerlocalperl && make install && echo 'eval $(perl -I$HOME/dancerlocalperl/lib/perl5 -Mlocal::lib=$HOME/dancerlocalperl)' >>~/localperlshell && source ~/localperlshell && export PERL_MM_USE_DEFAULT=1 && cpan YAML Dancer Plack::Handler::Apache2 && cd %s && dancer -a myapp && git rm -r perl && ln -s myapp/public perl && cd libs && ln -s ../myapp/lib/myapp.pm . && cd .. && echo 'YAML\nDancer\nPlack::Handler::Apache2' >> deplist.txt" % (WORK_DIR, self.git_repo)
self.steps_list.append( testcase.TestCaseStep("3.Install dancer and dependencies from CPAN",
cmd,
expect_description="dancer should be installed successfully",
expect_return=0))
# 4.Create the index.pl
cmd = "cd %s/perl && cp dispatch.cgi index.pl && sed -i -e 's/.*use FindBin.*//g' index.pl && sed -i -e \"12s/RealBin.*/ENV{'DOCUMENT_ROOT'}, '..', 'myapp', 'bin', 'app.pl');/g\" index.pl" % (self.git_repo)
self.steps_list.append( testcase.TestCaseStep("4.Create the index.pl",
cmd,
expect_description="index.pl should be created",
expect_return=0))
# 5. Git push all the changes
self.steps_list.append( testcase.TestCaseStep("5.Git push all the changes",
"cd %s && git add -A && git commit -a -m 'lets dance' && git push" % (self.git_repo),
expect_description="index.pl should be created",
expect_return=0))
# 6.Check app via browser
test_html = "Perl is dancing"
self.steps_list.append( testcase.TestCaseStep("6.Check app via browser",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name), test_html, "-H 'Pragma: no-cache'", 5, 9],
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
case = testcase.TestCase(self.summary, self.steps_list)
try:
case.run()
except testcase.TestCaseStepFail:
return self.failed("%s failed" % self.__class__.__name__)
if case.testcase_status == 'PASSED':
return self.passed("%s passed" % self.__class__.__name__)
if case.testcase_status == 'FAILED':
return self.failed("%s failed" % self.__class__.__name__)
示例3: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
# 1.Create an app
self.steps_list.append(testcase.TestCaseStep("1. Create an php app: %s" % (self.app_name),
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_description="the app should be created successfully",
expect_return=0))
# 2.Make some change to the git repo
cmd = "cd %s/php && mkdir db && touch db/test && rm -f index.php" % (self.git_repo)
self.steps_list.append(testcase.TestCaseStep("2.Make some change to the git repo",
cmd,
expect_description="Successfully touched test and removed index.php",
expect_return=0))
# 3.Copy app template to the git repo and git push
cmd = "cp %s/app_template/php-sqlite.template %s/php/index.php && cd %s && git add . && git commit -am t && git push" %(WORK_DIR, self.git_repo, self.git_repo)
self.steps_list.append(testcase.TestCaseStep("3.Copy app template to the git repo and git push",
cmd,
expect_description="Copy and git push succeed",
expect_return=0))
# 4.Check app via browser
test_html = "done"
self.steps_list.append(testcase.TestCaseStep("4.Check the app via browser",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name),
test_html, "-H 'Pragma: no-cache'", 5, 9],
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
case = testcase.TestCase(self.summary, self.steps_list)
try:
case.run()
except testcase.TestCaseStepFail:
return self.failed("%s failed" % self.__class__.__name__)
if case.testcase_status == 'PASSED':
return self.passed()
if case.testcase_status == 'FAILED':
return self.failed()
if case.testcase_status == 'ERROR':
return self.incomplete()
示例4: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
testcase.TestCaseStep("Create an app",
common.create_app,
function_parameters=[self.app_name, self.app_type,
self.config.OPENSHIFT_user_email,
self.config.OPENSHIFT_user_passwd, False],
expect_return=0).run()
def get_pgrep_command():
uuid = OSConf.get_app_uuid(self.app_name)
return 'pgrep -u %s -P 1'%uuid
self.info("Log into express server, get app's process ID")
(status, output) = common.run_remote_cmd_as_root(get_pgrep_command())
self.assert_equal(status,0, "SSH Command must be run successfully")
pid1=output
self.assert_equal(status,0, "SSH Command must be run successfully")
self.info("Log into express server, restart libra service")
(status, output) = common.run_remote_cmd_as_root('/etc/init.d/libra restart')
self.assert_equal(status,0, "SSH Command must be run successfully")
self.info("Log into express server, get app's process ID")
(status, output) = common.run_remote_cmd_as_root(get_pgrep_command())
self.assert_equal(status,0, "SSH Command must be run successfully")
pid2=output
testcase.TestCaseStep("Access app's URL to confirm it is running fine",
"curl -H 'Pragma: no-cache' %s",
string_parameters = [OSConf.get_app_url_X(self.app_name)],
expect_return=0,
expect_string_list=["Welcome to OpenShift"],
expect_description="Access page successfully").run()
if pid1 == pid2:
self.info("App's process id before and after restart libra service does not have any change.")
return self.failed("%s failed" % self.__class__.__name__)
else:
return self.passed("%s passed" % self.__class__.__name__)
示例5: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
# 1.Create an app
self.steps_list.append(testcase.TestCaseStep("1. Create an rack app",
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_description="the app should be created successfully",
expect_return=0))
# 2.Create deploy_rails_app.sh under local git repo
self.steps_list.append(testcase.TestCaseStep("2.Create deploy_rails_app.sh under local git repo",
self.create_script,
expect_description="Successfully created deploy_rails_app.sh under local git repo",
expect_return=0))
# 3.Run deploy_rails_app.sh
self.steps_list.append(testcase.TestCaseStep("3.Run deploy_rails_app.sh",
"bash %s" % (self.deploy_rails_file),
expect_description="Script executed successfully",
expect_return=0))
# 4.Check app via browser
test_html = "Hello, Rails"
self.steps_list.append(testcase.TestCaseStep("4.Check the app via browser",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name), test_html, "-H 'Pragma: no-cache'", 3, 9],
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
case = testcase.TestCase(self.summary, self.steps_list)
try:
case.run()
except testcase.TestCaseStepFail:
return self.failed("%s failed" % self.__class__.__name__)
if case.testcase_status == 'PASSED':
return self.passed("%s passed" % self.__class__.__name__)
if case.testcase_status == 'FAILED':
return self.failed("%s failed" % self.__class__.__name__)
示例6: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
# Create an php app
self.steps_list.append(testcase.TestCaseStep("Create an php app",
common.create_app,
function_parameters=[self.app_name, self.app_type, self.user_email, self.user_passwd],
expect_description="the app should be created successfully",
expect_return=0))
# Get the ip address of the app
self.steps_list.append(testcase.TestCaseStep("Get the ip address of the app",
self.get_app_ip,
expect_description="app's ip address should be got"))
aliases = ["%s.bar.com" %(common.getRandomString(3)),"%s.bar.com" %(common.getRandomString(3))]
for alias in aliases:
# Add an alias to the app
self.steps_list.append(testcase.TestCaseStep("Add an alias to the app",
"rhc alias add %s %s -l %s -p '%s' %s"
% (self.app_name, alias, self.user_email, self.user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS),
expect_description="alias: %s should be added" % (alias),
expect_return=0))
# Try to add the same alias to the app
self.steps_list.append(testcase.TestCaseStep("Add the same alias again to the app",
"rhc alias add %s %s -l %s -p '%s' %s"
% (self.app_name, alias, self.user_email, self.user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS),
expect_description="alias: %s should be added" % (alias),
expect_return="!0"))
# Make some changes in the git repo and git push
test_html = "Welcome to %s test page" % (alias)
self.steps_list.append(testcase.TestCaseStep(
"Make some changes in the git repo and git push",
"cd %s && echo '%s' > php/index.php && git commit -am t && git push" % (self.git_repo, test_html),
expect_description="Successfully changed git repo and git push",
expect_return=0))
# sleep to wait it takes effect
self.steps_list.append(testcase.TestCaseStep("Waiting.. 5 seconds",
common.sleep,
function_parameters=[5]))
# Access the app using custom DNS to see if changes have taken effect
self.steps_list.append(testcase.TestCaseStep(
"Access the app using custom DNS to see if changes have taken effect",
"http_proxy='' curl -s -H 'Host: %s' -H 'Pragma: no-cache' __OUTPUT__[2] | grep '%s'" % (alias, test_html),
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
# Remove one of the aliases
self.steps_list.append(testcase.TestCaseStep("Remove one of the aliases",
"rhc alias remove %s %s -l %s -p '%s' %s" % (self.app_name, aliases[0], self.user_email, self.user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS),
expect_description="alias: %s should be removed" % (aliases[0]),
expect_return=0))
# Access the app using the custom DNS again to see it's unavailable
self.steps_list.append( testcase.TestCaseStep("Access the app using the custom DNS again to see it's unavailable",
"http_proxy='' curl -s -H 'Host: %s' -H 'Pragma: no-cache' __OUTPUT__[2] | grep '%s'" % (aliases[0], test_html),
expect_description="The custom DNS: %s should be unavailable" % (aliases[0]),
expect_return="!0"))
# Access the other alias to see it's available
self.steps_list.append(testcase.TestCaseStep(
"Access the other alias to see it's available",
"http_proxy='' curl -s -H 'Host: %s' -H 'Pragma: no-cache' __OUTPUT__[2] | grep '%s'" % (aliases[1], test_html),
expect_description="The custom DNS: %s should be available" % (aliases[1]),
expect_return=0))
# Remove the other alias
self.steps_list.append(testcase.TestCaseStep("Remove the other alias",
"rhc alias remove %s %s -l %s -p '%s' %s" % (self.app_name, aliases[1], self.user_email, self.user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS),
expect_description="alias: %s should be removed" % (aliases[1]),
expect_return=0))
# Access the app using the custom DNS again to see it's unavailable
self.steps_list.append(testcase.TestCaseStep("Access the app using the custom DNS again to see it's unavailable",
"http_proxy='' curl -s -H 'Host: %s' -H 'Pragma: no-cache' __OUTPUT__[2] | grep '%s'" % (aliases[1], test_html),
expect_description="The custom DNS: %s should be unavailable" % (aliases[1]),
expect_return="!0"))
# Access the app using the rhcloud.com url to see it's available
self.steps_list.append(testcase.TestCaseStep(
"Access the app using the rhcloud.com url to see it's available",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name), test_html, "-H 'Pragma: no-cache'", 5, 9],
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
case = testcase.TestCase(self.summary, self.steps_list)
try:
case.run()
except testcase.TestCaseStepFail:
return self.failed("%s failed" % self.__class__.__name__)
if case.testcase_status == 'PASSED':
return self.passed("%s passed" % self.__class__.__name__)
if case.testcase_status == 'FAILED':
return self.failed("%s failed" % self.__class__.__name__)
示例7: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
app_name = self.app_name
self.steps_list.append(testcase.TestCaseStep("Create a %s application" %(self.app_type),
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_return=0,
expect_description="App should be created successfully"))
#this will be as __OUTPUT__[2]
self.steps_list.append(testcase.TestCaseStep("Get app url",
OSConf.get_app_url_X,
function_parameters = [self.app_name]))
#this will be as __OUTPUT__[3]
self.steps_list.append(testcase.TestCaseStep("Get app uuid",
OSConf.get_app_uuid_X,
function_parameters = [self.app_name]))
#4
self.steps_list.append(testcase.TestCaseStep("Embed MongoDB to this app",
common.embed,
function_parameters=[self.app_name,
"add-%s"%common.cartridge_types['mongodb'],
self.config.OPENSHIFT_user_email,
self.config.OPENSHIFT_user_passwd],
expect_return=0))
#5
self.steps_list.append(testcase.TestCaseStep("Get embeded mongo info - password",
OSConf.get_embed_info_X,
function_parameters=[self.app_name, common.cartridge_types["mongodb"], "password"]))
#6
self.steps_list.append(testcase.TestCaseStep("Get embeded mongo info - url",
OSConf.get_embed_info_X,
function_parameters=[self.app_name, common.cartridge_types["mongodb"], "url"]))
mongo_shell_write_input_file = "./mongo_shell_write_input"
mongo_shell_read_input_file = "./config.mongo_shell_read_input"
test_Collection_name = "test"
test_data = "TesterName"
#7
command = """echo -e 'use %s\ndb\nshow collections\ndb.%s.save({"name":"%s"})\nexit\n' >%s""" %(self.app_name, test_Collection_name, test_data, mongo_shell_write_input_file)
self.steps_list.append(testcase.TestCaseStep("Write mongo shell input file - write",
command,
expect_return=0))
command = """echo -e 'use %s\ndb\nshow collections\ndb.%s.find()\nexit\n' >%s""" %(self.app_name, test_Collection_name, mongo_shell_read_input_file)
#8
self.steps_list.append(testcase.TestCaseStep("Write mongo shell input file - read",
command,
expect_return=0))
#9
self.steps_list.append(testcase.TestCaseStep("Do some write operation to mongodb",
"""ssh -t -t %[email protected]%s rhcsh mongo < %s""" ,
#%("__OUTPUT__[3]", "__OUTPUT__[2]", mongo_shell_write_input_file),
string_parameters = [OSConf.get_app_uuid_X(self.app_name),
OSConf.get_app_url_X(self.app_name),
mongo_shell_write_input_file],
expect_return=0,
expect_string_list=["Welcome to OpenShift shell", "MongoDB shell", self.app_name],
unexpect_string_list=["errmsg"]))
#10
self.steps_list.append(testcase.TestCaseStep(
"Do some query operation to mongodb to check write operation is succesful",
"""ssh -t -t %[email protected]%s rhcsh mongo < %s""",
#%("__OUTPUT__[3]", "__OUTPUT__[2]", mongo_shell_read_input_file),
string_parameters = [OSConf.get_app_uuid_X(self.app_name),
OSConf.get_app_url_X(self.app_name),
mongo_shell_read_input_file],
expect_return=0,
expect_string_list=["Welcome to OpenShift shell", "MongoDB shell", app_name, test_Collection_name, test_data],
unexpect_string_list=["errmsg"]))
#11
self.steps_list.append(testcase.TestCaseStep("Stop this embed db using 'rhc cartridge stop'",
"rhc cartridge stop %s -a %s -l %s -p '%s' %s"
%(common.cartridge_types['mongodb'], app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS),
expect_return=0))
self.steps_list.append(testcase.TestCaseStep("Check this db status",
"rhc cartridge status %s -a %s -l %s -p '%s' %s" %(common.cartridge_types['mongodb'], app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS),
expect_return=0,
expect_string_list=["MongoDB is stopped"]))
#12
self.steps_list.append(testcase.TestCaseStep(
"Try to do some query operation to mongodb to check db is NOT running",
"""ssh -t -t %[email protected]%s rhcsh mongo < %s""" ,
#%("__OUTPUT__[3]", "__OUTPUT__[2]", mongo_shell_read_input_file),
string_parameters = [OSConf.get_app_uuid_X(self.app_name),
OSConf.get_app_url_X(self.app_name),
mongo_shell_read_input_file],
expect_return = "!0",
expect_string_list=["Welcome to OpenShift shell", "MongoDB shell", "connect failed"],
unexpect_string_list=[test_data,]))
#.........这里部分代码省略.........
示例8: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
# 1.Create an app
self.steps_list.append( testcase.TestCaseStep("1. Create an %s app" % (self.test_variant),
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_description="the app should be created successfully",
expect_return=0))
# Clean environment variable: SSH_AUTH_SOCK
if os.environ.has_key("SSH_AUTH_SOCK"):
del os.environ["SSH_AUTH_SOCK"]
# 2.Stop Application
self.steps_list.append( testcase.TestCaseStep("2. Stop Application",
"rhc app stop %s -l %s -p '%s' %s"
% (self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS),
expect_description="App is stopped successfully",
expect_return=0))
# 3.Check the app is unavailable via browser
self.steps_list.append( testcase.TestCaseStep("3.Check the app is unavailable via browser",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name), "Service Temporarily Unavailable", "-H 'Pragma: no-cache'", 3, 6],
expect_description="The app is unavailable",
expect_return=0))
# 4.Custom git hook file
hook_file_path = "%s/.openshift/action_hooks/build" % (self.app_name)
key_string = "@@@[email protected]@@"
self.steps_list.append( testcase.TestCaseStep("4.Custom git hook file",
"""echo '\necho "%s"' >> %s && chmod +x %s""" % (key_string, hook_file_path, hook_file_path),
expect_description="Added 1 line to %s" % (hook_file_path),
expect_return=0))
# 5.Git push
self.steps_list.append( testcase.TestCaseStep("5.Git push all the changes",
"cd %s && git add . && git commit -am t && git push" % (self.git_repo),
expect_description="Git push succeeds and '%s' should be found in the output" % (key_string),
expect_return=0,
expect_string_list=[key_string]))
# 6.Check to see if the app is available
test_html = "Welcome to OpenShift"
self.steps_list.append( testcase.TestCaseStep(
"6.Check to see if the app is available",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name), test_html, "-H 'Pragma: no-cache'", 5, 8],
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
case = testcase.TestCase(self.summary, self.steps_list)
try:
case.run()
except testcase.TestCaseStepFail:
return self.failed("%s failed" % self.__class__.__name__)
if case.testcase_status == 'PASSED':
return self.passed("%s passed" % self.__class__.__name__)
if case.testcase_status == 'FAILED':
return self.failed("%s failed" % self.__class__.__name__)
示例9: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
# env vars should be found without mysql embedded
env_lst = 'OPENSHIFT_LOG_DIR OPENSHIFT_APP_NAME OPENSHIFT_APP_UUID OPENSHIFT_TMP_DIR OPENSHIFT_HOMEDIR OPENSHIFT_REPO_DIR OPENSHIFT_GEAR_NAME OPENSHIFT_INTERNAL_PORT OPENSHIFT_RUN_DIR OPENSHIFT_INTERNAL_IP OPENSHIFT_GEAR_DIR OPENSHIFT_GEAR_TYPE OPENSHIFT_GEAR_DNS OPENSHIFT_DATA_DIR OPENSHIFT_GEAR_UUID'.split()
# env vars should be found with mysql embedded
env_mysql_lst = 'OPENSHIFT_DB_HOST OPENSHIFT_LOG_DIR OPENSHIFT_APP_NAME OPENSHIFT_APP_UUID OPENSHIFT_TMP_DIR OPENSHIFT_HOMEDIR OPENSHIFT_REPO_DIR OPENSHIFT_GEAR_NAME OPENSHIFT_INTERNAL_PORT OPENSHIFT_DB_PASSWORD OPENSHIFT_DB_USERNAME OPENSHIFT_RUN_DIR OPENSHIFT_INTERNAL_IP OPENSHIFT_GEAR_DIR OPENSHIFT_GEAR_TYPE OPENSHIFT_GEAR_DNS OPENSHIFT_DB_URL OPENSHIFT_DATA_DIR OPENSHIFT_GEAR_UUID OPENSHIFT_DB_TYPE OPENSHIFT_DB_PORT'.split()
env_mongodb_lst = 'OPENSHIFT_NOSQL_DB_USERNAME OPENSHIFT_NOSQL_DB_TYPE OPENSHIFT_LOG_DIR OPENSHIFT_APP_NAME OPENSHIFT_APP_UUID OPENSHIFT_NOSQL_DB_URL OPENSHIFT_TMP_DIR OPENSHIFT_HOMEDIR OPENSHIFT_REPO_DIR OPENSHIFT_GEAR_NAME OPENSHIFT_INTERNAL_PORT OPENSHIFT_NOSQL_DB_PASSWORD OPENSHIFT_RUN_DIR OPENSHIFT_NOSQL_DB_PORT OPENSHIFT_INTERNAL_IP OPENSHIFT_GEAR_DIR OPENSHIFT_NOSQL_DB_HOST OPENSHIFT_GEAR_TYPE OPENSHIFT_GEAR_DNS OPENSHIFT_DATA_DIR OPENSHIFT_GEAR_UUID'.split()
# 1. Create an app
self.steps_list.append( testcase.TestCaseStep("1. Create an %s app" % (self.test_variant),
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_description="the app should be created successfully",
expect_return=0))
# 2. Append cmd 'env' into file '<repo_path>/.openshift/action_hooks/build'
self.steps_list.append( testcase.TestCaseStep("2.Append cmd 'env' into file '<repo_path>/.openshift/action_hooks/build'",
"echo '\nenv' >> %s/.openshift/action_hooks/build" % (self.git_repo),
expect_description="Successfully added 1 line to .openshift/action_hooks/build",
expect_return=0))
# 3.copy template to git repo and git push
if self.test_variant == "wsgi":
cmd = "cd %s/wsgi && rm -f application && cp -f %s/app_template/env_var/python/application application && git add . && git commit -am t && git push" % (self.git_repo, WORK_DIR)
elif self.test_variant == "php":
cmd = "cd %s/php && rm -f index.php && cp -f %s/app_template/env_var/php/index.php index.php && git add . && git commit -am t && git push" % (self.git_repo, WORK_DIR)
elif self.test_variant == "perl":
cmd = "cd %s/perl && rm -f index.pl && cp %s/app_template/env_var/perl/index.pl index.pl && git add . && git commit -am t && git push" % (self.git_repo, WORK_DIR)
elif self.test_variant == "rack":
cmd = "cd %s && rm -f config.ru && cp %s/app_template/env_var/ruby/config.ru config.ru && git add . && git commit -am t && git push" % (self.git_repo, WORK_DIR)
elif self.test_variant == "nodejs":
cmd = "cd %s && rm -f server.js && cp %s/app_template/env_var/nodejs/server.js server.js && git add . && git commit -am t && git push" % (self.git_repo, WORK_DIR)
elif self.test_variant == "jbossas" or self.test_variant == "diy":
cmd = "cd %s && touch testfile && git add . && git commit -am t && git push" % (self.git_repo)
self.steps_list.append(testcase.TestCaseStep(
"3.copy template to git repo and git push",
cmd,
output_callback = self.store_output,
expect_description="Successfully copy template to git repo and git push",
expect_return=0))
# 4.Check env vars from the output of git push
self.steps_list.append(testcase.TestCaseStep(
"4.Check env vars from the output of git push",
self.compare,
function_parameters=[self.get_last_output, env_lst],
expect_description="The openshift env vars should found in the output of git push",
expect_return=True))
if self.test_variant == "jbossas" or self.test_variant == "diy":
self.info("%s app doesn't need to check the web page" % (self.test_variant))
else:
# 5.Fetch the home page of the app
# 6.Check env vars from the web page
self.steps_list.append( testcase.TestCaseStep("6.Check env vars from the web page",
self.compare,
function_parameters=[self.get_page, env_lst],
expect_description="The openshift env vars should found in the web page",
expect_return=True))
i = 7
for (cart,lst) in (("mysql-5.1",env_mysql_lst), ("mongodb-2.2",env_mongodb_lst)):
# 7.Embed database to this app
self.steps_list.append( testcase.TestCaseStep("%d.Embed %s to this app" % (i,cart),
common.embed,
function_parameters=[self.app_name, "add-" + cart, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_description="%s should be embedded successfully" % (cart),
expect_return=0))
# 8.Make some change and git push again
self.steps_list.append( testcase.TestCaseStep("%d.Make some change and git push again" % (i),
"cd %s && echo '\n' >> .openshift/action_hooks/build && git add . && git commit -am t && git push" % (self.git_repo),
output_callback=self.store_output,
expect_description="Git push should succeed",
expect_return=0))
# 9.Check env vars from the output of git push after embedded database
self.steps_list.append( testcase.TestCaseStep("%d.Check env vars from the output of git push after embedding %s" % (i,cart),
self.compare,
function_parameters=[self.get_last_output, lst],
expect_description="The openshift env vars should found in the output of git push",
expect_return=True))
# 10.Fetch the home page of the app
if self.test_variant == "jbossas" or self.test_variant == "diy":
self.info("%s app doesn't need to check the web page" % (self.test_variant))
else:
self.steps_list.append( testcase.TestCaseStep("%d.Fetch the home page of the app" % (i),
"curl -s -H 'Pragma: no-cache' '%s'",
string_parameters = [OSConf.get_app_url_X(self.app_name)],
expect_description="Successfully get the web page",
expect_return=0))
# 11.Check env vars from the web page
self.steps_list.append( testcase.TestCaseStep("%d.Check env vars from the web page" % (i),
self.compare,
function_parameters=[self.get_last_output, lst],
expect_description="The openshift env vars should found in the web page",
expect_return=True))
# 12.Remove embedded database
self.steps_list.append( testcase.TestCaseStep("%d.Remove embedded database" % (i),
#.........这里部分代码省略.........
示例10: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
instance_ip = get_instance_ip()
if self.config.options.run_mode == 'DEV':
instance_ip = 'dev.rhcloud.com'
global code_dict
# 1. Create app
self.steps_list.append(testcase.TestCaseStep("Create an %s app: %s" % (self.test_variant, self.app_name),
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, True, "./", True, "small", -1, False],
expect_description="the app should be created successfully",
expect_return=0))
# 2. Write some code to show the gear DNS
file_path = { "jbosseap" : "%s/src/main/webapp/index.jsp" % (self.git_repo),
"jbossas" : "%s/src/main/webapp/index.jsp" % (self.git_repo),
"php" : "%s/php/index.php" % (self.git_repo),
"perl" : "%s/perl/index.pl" % (self.git_repo),
"python" : "%s/wsgi/application" % (self.git_repo),
"python-2.7" : "%s/wsgi/application" % (self.git_repo),
"python-3.3" : "%s/wsgi/application" % (self.git_repo),
"ruby" : "%s/config.ru" % (self.git_repo),
"nodejs" : "%s/server.js" % (self.git_repo),
}
cmd = "rm -f %s/src/main/webapp/index.html ; echo '%s' > '%s'" % (self.git_repo, code_dict[self.test_variant], file_path[self.test_variant])
#cmd = "rm -f %s; echo '%s' > '%s'" % (file_path[self.test_variant], code_dict[self.test_variant], file_path[self.test_variant])
if self.test_variant in ("jbossas", "jbosseap"):
cmd += """; sed -i '/<system-properties>/ a\\\n<property name="org.apache.catalina.session.StandardManager.MAX_ACTIVE_SESSIONS" value="-1"/>' %s/.openshift/config/standalone.xml""" % (self.git_repo)
self.steps_list.append(testcase.TestCaseStep("Write some code to show the gear DNS",
cmd,
expect_description="the code should be written successfully",
expect_return=0))
# 3. Git push all the changes
self.steps_list.append(testcase.TestCaseStep("Git push all the changes",
"cd %s && git add . && git commit -amt && git push && sleep 30" % (self.git_repo),
expect_description="the changes should be git push successfully",
expect_return=0))
# 4. Confirm the app is available
self.steps_list.append(testcase.TestCaseStep("Confirm the app is available",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name), "App DNS", "-H 'Pragma: no-cache' -L", 5, 30],
expect_description="the app should be avaiable",
expect_return=0))
# 5. Establish multiple parallel connections to the app to trigger auto-scaling
self.steps_list.append(testcase.TestCaseStep("Establish multiple parallel connections to the app to trigger auto-scaling",
self.trigger_autoscale,
expect_description="auto-scaling should be triggered",
))
# 6. Confirm auto-scaling is triggered
self.steps_list.append(testcase.TestCaseStep("Confirm auto-scaling is triggered",
self.confirm_autoscale,
expect_description="auto-scaling should be triggered",
try_count=60,
try_interval=10,
expect_return=0))
case = testcase.TestCase(self.summary, self.steps_list)
try:
case.run()
except testcase.TestCaseStepFail:
return self.failed("%s failed" % self.__class__.__name__)
if case.testcase_status == 'PASSED':
return self.passed("%s passed" % self.__class__.__name__)
if case.testcase_status == 'FAILED':
return self.failed("%s failed" % self.__class__.__name__)
示例11: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_app_url_X [as 别名]
def test_method(self):
# 1. Create an app
self.steps_list.append(testcase.TestCaseStep("1. Create an %s app" % (self.test_variant),
common.create_app,
function_parameters=[self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd],
expect_description="the app should be created successfully",
expect_return=0))
# 2.Custom git hook
hook_file_path = "%s/.openshift/action_hooks/build" % (self.git_repo)
key_string = "sleep 30"
testcode = """
echo "%s"
%s
""" %(key_string, key_string)
cmd = "echo '%s' >> %s && chmod +x %s" % (testcode, hook_file_path, hook_file_path)
self.steps_list.append(testcase.TestCaseStep("2.Custom git hook",
cmd,
expect_description=".openshift/action_hooks/build modified successfully",
expect_return=0))
def create_proc(self, cmd):
self.proc = proc.Proc(cmd)
# 3.Git push in a subprocess
self.steps_list.append(testcase.TestCaseStep("3.Git push in a subprocess(No Check)",
create_proc,
function_parameters=[self, "cd %s && git add . && git commit -am t && git push" % (self.git_repo),],
expect_description="Git push should be started"))
# 4.Waiting for stop to finish
def grep_output(self, t, x, y):
return self.proc.grep_output(t, x, y)
self.steps_list.append(testcase.TestCaseStep("4.Waiting for stop to finish",
grep_output,
function_parameters=[self, r"Waiting for stop to finish", 2 ,20],
expect_description="app stop should succeed",
expect_return=0))
# 5.Check if the key_string exists in the output
self.steps_list.append(testcase.TestCaseStep("5.Check if the '%s' exists in the output" % (key_string),
grep_output,
function_parameters=[self, key_string, 2, 20],
expect_description="'%s' should be found in the output" % (key_string),
expect_return=0))
# 6.Check app is unavailable before git push finish
test_html = "Service Temporarily Unavailable"
self.steps_list.append(testcase.TestCaseStep("6.Check app is unavailable before git push finish",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name), test_html, "-H 'Pragma: no-cache'", 2, 9],
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
# 7.Wait for git push to finish
def wait(self, x, y):
return self.proc.wait(x,y)
self.steps_list.append(testcase.TestCaseStep("7.Wait for git push to finish",
wait,
function_parameters=[self, 5, 10],
expect_description="git push should finish within given time and return 0",
expect_return=0))
# 8.Check app is available after git push
test_html = "Welcome to OpenShift"
self.steps_list.append(testcase.TestCaseStep("8.Check app is available after git push",
common.grep_web_page,
function_parameters=[OSConf.get_app_url_X(self.app_name), test_html, "-H 'Pragma: no-cache'", 5, 8],
expect_description="'%s' should be found in the web page" % (test_html),
expect_return=0))
case = testcase.TestCase(self.summary, self.steps_list)
try:
case.run()
except testcase.TestCaseStepFail:
return self.failed("%s failed" % self.__class__.__name__)
if case.testcase_status == 'PASSED':
return self.passed("%s passed" % self.__class__.__name__)
if case.testcase_status == 'FAILED':
return self.failed("%s failed" % self.__class__.__name__)