本文整理匯總了Python中revizor2.api.Farm類的典型用法代碼示例。如果您正苦於以下問題:Python Farm類的具體用法?Python Farm怎麽用?Python Farm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Farm類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_import_server
def test_import_server(self, context: dict, cloud: Cloud, farm: Farm):
"""Import cloud server to Scalr"""
farm.launch()
node = discovery.run_server_in_cloud(cloud)
location = CONF.feature.platform.location
instance_id = node.id
if CONF.feature.platform.is_gce:
location = node.extra['zone'].name
instance_id = node.name
role_id = IMPL.discovery_manager.get_system_role_id(
node.cloud._name,
location,
CONF.feature.dist.id
)
role = Role(id=role_id)
farm_role_id = lib_farm.add_role_to_farm(context, farm, role=role).id
IMPL.discovery_manager.import_server(node.cloud._name, farm_role_id, instance_id=instance_id)
farm.roles.reload()
assert farm.roles[0].role_id == str(role_id)
assert len(farm.roles) == 1
assert len(farm.roles[0].servers) == 1
assert farm.roles[0].servers[0].cloud_server_id == instance_id
lifecycle.assert_server_status(farm.roles[0].servers[0], ServerStatus.RUNNING)
示例2: test_webhooks_in_proxy
def test_webhooks_in_proxy(self, context: dict, cloud: Cloud, farm: Farm, servers: dict, testenv):
server = servers.get('F1')
lib_farm.add_role_to_farm(context, farm, dist='ubuntu1404')
farm.launch()
proxy_server = lib_server.wait_server_status(
context, cloud, farm, status=ServerStatus.RUNNING)
servers['P1'] = proxy_server
lib_server.execute_script(context, farm, proxy_server,
script_name='https://git.io/vA52O',
is_local=True,
synchronous=True)
lib_scalr.configure_scalr_proxy(testenv, proxy_server, 'system.webhooks')
testenv.restart_service("workflow-engine")
testenv.restart_service("zmq_service")
webhooks = [
{'schema': 'http', 'endpoint': '/', 'trigger_event': 'AccountEvent', 'name': 'http_normal'},
{'schema': 'https', 'endpoint': '/', 'trigger_event': 'AccountEvent', 'name': 'https_normal'}
]
lib_webhooks.configure_webhooks(webhooks, server, farm, context)
result = lib_node.execute_command(cloud, server, 'szradm --fire-event AccountEvent')
assert not result.std_err, "Command szradm --fire-event AccountEvent failed with %s" % result.std_err
expected_results = [
{'webhook_name': 'http_normal', 'expected_response': 200, 'attempts': 1, 'error': None},
{'webhook_name': 'https_normal', 'expected_response': 200, 'attempts': 1, 'error': None}
]
lib_webhooks.assert_webhooks(context['test_webhooks'], expected_results, server_id=server.id)
assert not testenv.check_service_log("workflow-engine", "Traceback"), "Found Traceback in workflow-engine service log!"
示例3: test_efs_bootstrapping
def test_efs_bootstrapping(self, efs: dict, context: dict, farm: Farm, cloud: Cloud):
"""Attach EFS storage"""
lib_farm.clear(farm)
farm.terminate()
context['linked_services'] = {'efs': {'cloud_id': efs['fileSystemId']}}
efs_mount_point = "/media/efsmount"
lib_farm.link_efs_cloud_service_to_farm(farm, efs)
lib_farm.add_role_to_farm(context, farm, role_options=['efs'])
farm.launch()
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING)
lifecycle.assert_attached_disk_types(context, cloud, farm)
lifecycle.assert_path_exist(cloud, server, efs_mount_point)
lifecycle.create_files(cloud, server, count=100, directory=efs_mount_point)
mount_table = lifecycle.get_mount_table(cloud, server)
lifecycle.assert_mount_point_in_fstab(
cloud,
server,
mount_table=mount_table,
mount_point=efs_mount_point)
# Reboot server
lib_server.execute_server_action(server, 'reboot')
lib_server.assert_server_message(cloud, farm, msgtype='in', msg='RebootFinish', server=server)
# Check after reboot
lifecycle.assert_attached_disk_types(context, cloud, farm)
lifecycle.assert_path_exist(cloud, server, efs_mount_point)
lifecycle.assert_file_count(cloud, server, count=100, directory=efs_mount_point)
示例4: test_update_from_stable_to_branch_on_startup_and_new_package
def test_update_from_stable_to_branch_on_startup_and_new_package(self, context: dict, cloud: Cloud, farm: Farm,
servers: dict):
"""Update scalarizr from stable to branch on startup with new pkg"""
farm.terminate()
lib_farm.clear(farm)
image = update.get_clean_image(cloud)
role = lib_role.create_role(image)
farm.launch()
farm_role = lib_farm.add_role_to_farm(context, farm, role=Role.get(role['role']['id']))
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.PENDING)
szr_ver = lib_node.install_scalarizr_to_server(server, cloud, custom_branch='stable')
time.sleep(120)
lib_server.execute_server_action(server, 'reboot', hard=True)
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING, server=server)
update.assert_scalarizr_version(server, cloud, szr_ver)
update.create_branch_copy(context, branch='system')
update.waiting_new_package(context)
lib_role.change_branch_in_farm_role(farm_role, context['branch_copy_name'])
update.start_scalarizr_update_via_ui(server)
update.wait_szrupd_status(server, 'in-progress')
update.wait_szrupd_status(server, 'completed')
lifecycle.assert_szr_version_last(server, branch=context['branch_copy_name'])
lib_server.execute_script(context, farm, server, script_name='Windows ping-pong. CMD', synchronous=True)
lib_server.assert_last_script_result(context, cloud, server,
name='Windows ping-pong. CMD',
log_contains='pong',
new_only=True)
lib_node.reboot_scalarizr(cloud, server)
lib_server.execute_script(context, farm, server, script_name='Windows ping-pong. CMD', synchronous=True)
lib_server.assert_last_script_result(context, cloud, server,
name='Windows ping-pong. CMD',
log_contains='pong',
new_only=True)
lib_server.assert_scalarizr_log_errors(cloud, server, log_type='debug')
lib_server.assert_scalarizr_log_errors(cloud, server, log_type='update')
示例5: test_update_from_branch_to_stable_on_startup
def test_update_from_branch_to_stable_on_startup(self, context: dict, cloud: Cloud, farm: Farm, servers: dict):
"""Update scalarizr from branch to stable on startup"""
farm.terminate()
lib_farm.clear(farm)
image = update.get_clean_image(cloud)
role = lib_role.create_role(image)
farm.launch()
lib_farm.add_role_to_farm(context, farm, role=Role.get(role['role']['id']), role_options=['branch_stable'])
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.PENDING)
szr_ver = lib_node.install_scalarizr_to_server(server, cloud)
time.sleep(120)
lib_server.execute_server_action(server, 'reboot', hard=True)
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING, server=server)
update.assert_scalarizr_version(server, cloud, szr_ver)
lib_server.execute_script(context, farm, server, script_name='Windows ping-pong. CMD', synchronous=True)
lib_server.assert_last_script_result(context, cloud, server,
name='Windows ping-pong. CMD',
log_contains='pong',
new_only=True)
lib_node.reboot_scalarizr(cloud, server)
lib_server.execute_script(context, farm, server, script_name='Windows ping-pong. CMD', synchronous=True)
lib_server.assert_last_script_result(context, cloud, server,
name='Windows ping-pong. CMD',
log_contains='pong',
new_only=True)
lib_server.assert_scalarizr_log_errors(cloud, server, log_type='debug')
lib_server.assert_scalarizr_log_errors(cloud, server, log_type='update')
示例6: test_failed_hostname
def test_failed_hostname(self, context: dict, cloud: Cloud, farm: Farm):
"""Failed bootstrap by hostname"""
lib_farm.clear(farm)
farm.terminate()
lib_farm.add_role_to_farm(context, farm, role_options=['failed_hostname'])
farm.launch()
lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.FAILED)
示例7: test_update_to_branch_from_ui
def test_update_to_branch_from_ui(self, context: dict, cloud: Cloud, farm: Farm, servers: dict, branch: str):
"""Update scalarizr from release to branch via UI"""
farm.terminate()
lib_farm.clear(farm)
farm.launch()
farm_role = lib_farm.add_role_to_farm(context, farm, role_options=['branch_{}'.format(branch)])
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING)
lifecycle.assert_szr_version_last(server, branch=branch)
lib_role.change_branch_in_farm_role(farm_role, 'system')
update.start_scalarizr_update_via_ui(server)
update.wait_szrupd_status(server, 'completed')
lib_server.assert_server_message(cloud, farm, msgtype='in', msg='HostUpdate', server=server)
lifecycle.assert_szr_version_last(server, branch='system')
lib_server.execute_script(context, farm, server, script_name='Windows ping-pong. CMD', synchronous=True)
lib_server.assert_last_script_result(context, cloud, server,
name='Windows ping-pong. CMD',
log_contains='pong',
new_only=True)
lib_node.reboot_scalarizr(cloud, server)
lib_server.execute_script(context, farm, server, script_name='Windows ping-pong. CMD', synchronous=True)
lib_server.assert_last_script_result(context, cloud, server,
name='Windows ping-pong. CMD',
log_contains='pong',
new_only=True)
lib_server.assert_scalarizr_log_errors(cloud, server, log_type='debug')
lib_server.assert_scalarizr_log_errors(cloud, server, log_type='update')
示例8: test_update_from_branch_on_startup
def test_update_from_branch_on_startup(self, context: dict, cloud: Cloud, farm: Farm, servers: dict, branch: str):
"""Update scalarizr from release to branch on startup"""
image = update.get_clean_image(cloud)
role = lib_role.create_role(image)
farm.launch()
lib_farm.add_role_to_farm(context, farm, role=Role.get(role['role']['id']))
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.PENDING)
szr_ver = lib_node.install_scalarizr_to_server(server, cloud, custom_branch=branch)
lib_server.execute_server_action(server, 'reboot', hard=True)
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING, server=server)
update.assert_scalarizr_version(server, cloud, szr_ver)
lib_server.execute_script(context, farm, server, script_name='Linux ping-pong', synchronous=True)
lib_server.assert_last_script_result(context, cloud, server,
name='Linux ping-pong',
log_contains='pong',
new_only=True)
lib_node.reboot_scalarizr(cloud, server)
lib_server.execute_script(context, farm, server, script_name='Linux ping-pong', synchronous=True)
lib_server.assert_last_script_result(context, cloud, server,
name='Linux ping-pong',
log_contains='pong',
new_only=True)
lib_server.assert_scalarizr_log_errors(cloud, server, log_type='debug')
lib_server.assert_scalarizr_log_errors(cloud, server, log_type='update')
示例9: farm
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')
示例10: test_start_farm
def test_start_farm(self, context: dict, cloud: Cloud, farm: Farm, servers: dict):
"""Start farm"""
if CONF.feature.platform.is_cloudstack:
time.sleep(1800)
farm.launch()
server = lib_server.expect_server_bootstraping_for_role(context, cloud, farm)
servers['M1'] = server
lib_node.assert_scalarizr_version(server, 'system')
示例11: test_bootstrapping_role_with_at
def test_bootstrapping_role_with_at(self, context: dict, cloud: Cloud, farm: Farm, servers: dict):
"""Bootstrapping role with Ansible Tower"""
lib_farm.add_role_to_farm(context, farm, role_options=['ansible-tower', 'ansible-orchestration'])
farm.launch()
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING)
servers['M1'] = server
provision.assert_hostname_exists_on_at_server(server)
provision.assert_at_user_on_server(cloud, server, 'scalr-ansible')
示例12: test_restart_farm
def test_restart_farm(self, context: dict, cloud: Cloud, farm: Farm, servers: dict):
"""Restart farm"""
farm.terminate()
lib_server.wait_servers_state(farm, 'terminated')
farm.launch()
server = lib_server.expect_server_bootstraping_for_role(context, cloud, farm)
servers['M1'] = server
lifecycle.assert_hostname(server)
示例13: test_nonblank_volume
def test_nonblank_volume(self, context: dict, cloud: Cloud, farm: Farm):
"""Check partition table recognized as a non-blank volume"""
lib_farm.clear(farm)
farm.terminate()
lib_farm.add_role_to_farm(context, farm)
snapshot_id = context['volume_snapshot_id']
lifecycle.add_storage_to_role(context, farm, snapshot_id)
farm.launch()
lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.FAILED)
示例14: test_restart_bootstrap
def test_restart_bootstrap(self, context: dict, cloud: Cloud, farm: Farm, servers: dict):
"""Bootstraping on restart"""
lib_farm.clear(farm)
farm.terminate()
lib_farm.add_role_to_farm(context, farm)
farm.launch()
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING)
servers['M1'] = server
lifecycle.assert_hostname(server)
示例15: test_bootstrapping
def test_bootstrapping(self, context: dict, cloud: Cloud, farm: Farm, servers: dict):
"""Bootstrapping"""
options = ['storages', 'chef', 'termination_preferences']
if CONF.feature.dist.is_windows:
options = ['winchef', 'termination_preferences']
lib_farm.add_role_to_farm(context, farm, role_options=options)
farm.launch()
server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING)
servers['M1'] = server
lifecycle.assert_szr_version_last(server)