本文整理匯總了Python中revizor2.api.Farm.create方法的典型用法代碼示例。如果您正苦於以下問題:Python Farm.create方法的具體用法?Python Farm.create怎麽用?Python Farm.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類revizor2.api.Farm
的用法示例。
在下文中一共展示了Farm.create方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: farm
# 需要導入模塊: from revizor2.api import Farm [as 別名]
# 或者: from revizor2.api.Farm import create [as 別名]
def farm(request: FixtureRequest) -> Farm:
if CONF.main.farm_id is None:
LOG.info('Farm ID not set, create a new farm for test')
test_farm = Farm.create(f'tmprev-{datetime.now().strftime("%d%m%H%M%f")}',
'Revizor farm for tests\n'
f'RV_BRANCH={CONF.feature.branch}\n'
f'RV_PLATFORM={CONF.feature.platform.name}\n'
f'RV_DIST={CONF.feature.dist.dist}\n')
CONF.main.farm_id = test_farm.id
else:
LOG.info(f'Farm ID is set in config, use it: {CONF.main.farm_id}')
test_farm = Farm.get(CONF.main.farm_id)
lib_farm.clear(test_farm)
LOG.info(f'Returning test farm: {test_farm.id}')
try:
yield test_farm
finally:
failed_count = request.session.testsfailed
LOG.info('Failed tests: %s' % failed_count)
if (failed_count == 0 and CONF.feature.stop_farm) or (CONF.feature.stop_farm and CONF.scalr.te_id):
LOG.info('Clear and stop farm...')
test_farm.terminate()
IMPL.farm.clear_roles(test_farm.id)
if test_farm.name.startswith('tmprev'):
LOG.info('Delete working temporary farm')
try:
LOG.info('Wait all servers in farm terminated before delete')
wait_until(lib_server.farm_servers_state,
args=(test_farm, 'terminated'),
timeout=1800,
error_text='Servers in farm not terminated too long')
test_farm.destroy()
except Exception as e:
LOG.warning(f'Farm cannot be deleted: {str(e)}')
LOG.info('Farm finalize complete')
示例2: give_empty_farm
# 需要導入模塊: from revizor2.api import Farm [as 別名]
# 或者: from revizor2.api.Farm import create [as 別名]
def give_empty_farm(launched=False):
if CONF.main.farm_id is None:
LOG.info('Farm ID not setted, create a new farm for test')
world.farm = Farm.create('tmprev-%s' % datetime.now().strftime('%d%m%H%M%f'),
"Revizor farm for tests\n"
"RV_BRANCH={}\n"
"RV_PLATFORM={}\n"
"RV_DIST={}\n".format(
CONF.feature.branch,
CONF.feature.platform.name,
CONF.feature.dist.dist
))
CONF.main.farm_id = world.farm.id
else:
LOG.info('Farm ID is setted in config use it: %s' % CONF.main.farm_id)
world.farm = Farm.get(CONF.main.farm_id)
world.farm.roles.reload()
if len(world.farm.roles):
LOG.info('Clear farm roles')
IMPL.farm.clear_roles(world.farm.id)
world.farm.vhosts.reload()
for vhost in world.farm.vhosts:
LOG.info('Delete vhost: %s' % vhost.name)
vhost.delete()
try:
world.farm.domains.reload()
for domain in world.farm.domains:
LOG.info('Delete domain: %s' % domain.name)
domain.delete()
except Exception:
pass
if world.farm.terminated and launched:
world.farm.launch()
elif world.farm.running and not launched:
world.farm.terminate()
LOG.info('Return empty running farm: %s' % world.farm.id)