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)
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')
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)
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')
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')
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)
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)
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)
def test_chef_solo_bootstrapping(self, context: dict, cloud: Cloud, farm: Farm, role_options: str): """Bootstrapping role with chef-solo""" lib_farm.clear(farm) farm.terminate() lib_farm.add_role_to_farm(context, farm, role_options=[role_options]) farm.launch() server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING) node = cloud.get_node(server) lib_server.assert_file_exist(node, f'C:\{role_options}') provision.assert_script_data_deleted(cloud, server)
def test_chef_bootstrap_failure(self, context: dict, cloud: Cloud, farm: Farm): """Chef bootstrap failure""" lib_farm.clear(farm) farm.terminate() lib_farm.add_role_to_farm(context, farm, role_options=['chef-fail']) farm.launch() server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.FAILED) lib_server.validate_failed_status_message(server, "beforeHostUp", "/usr/bin/chef-client exited with code 1") provision.assert_chef_log_contains_text(server, "ERROR: undefined method `fatal!'") provision.assert_chef_bootstrap_failed(cloud, server)
def test_eph_bootstrap(self, context: dict, cloud: Cloud, farm: Farm, servers: dict): """Bootstraping with ephemeral""" lib_farm.clear(farm) farm.terminate() lib_farm.add_role_to_farm(context, farm, role_options=['ephemeral']) farm.launch() server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING) servers['M1'] = server lifecycle.assert_vcpu_count(server) windows.assert_attached_disks_size(cloud, server, [('Z:\\', 'test_label', 4)]) lifecycle.assert_szr_version_last(server)
def test_bootstrapping_form_chef_role(self, context: dict, cloud: Cloud, farm: Farm): """Bootstrapping from chef role""" lib_farm.clear(farm) farm.terminate() lib_farm.add_role_to_farm(context, farm, role_options=['winchef-role']) farm.launch() server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING) node = cloud.get_node(server) lib_server.assert_file_exist(node, 'C:\chef_result_file') lib_server.assert_scalarizr_log_errors(cloud, server) lifecycle.assert_szr_version_last(server) lifecycle.assert_hostname(server)
def test_bootstrapping_from_chef_role(self, context: dict, cloud: Cloud, farm: Farm): """Bootstrapping from chef role""" lib_farm.clear(farm) farm.terminate() lib_farm.add_role_to_farm(context, farm, role_options=['chef-role']) farm.launch() server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING) lib_server.assert_scalarizr_log_errors(cloud, server) lifecycle.assert_szr_version_last(server) provision.assert_node_exists_on_chef_server(server) provision.assert_chef_node_name_equal_hostname(cloud, server) provision.assert_chef_log_contains_text(server, "revizor_chef_variable=REVIZOR_CHEF_VARIABLE_VALUE_WORK")
def test_chef_bootstrapping_via_cookbooks_with_hostname_configured(self, context: dict, cloud: Cloud, farm: Farm): """Chef bootstrapping with hostname configured via cookbooks""" hostname = f'hostname-LIX{uuid4().hex[16:24]}' lib_farm.clear(farm) farm.terminate() context['chef_hostname_for_cookbook'] = hostname lib_farm.add_role_to_farm(context, farm, role_options=['chef-hostname']) farm.launch() server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING) lib_server.assert_scalarizr_log_errors(cloud, server) server.reload() assert server.hostname == hostname, \ f'Hostname on server "{saerver.hostname}" != chef hostname configured via the cookbook "{hostname}"'
def test_server_rebundle(self, context: dict, cloud: Cloud, farm: Farm): """Verify server rebundle work""" 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) bundle_id = rebundle.start_server_rebundle(server) rebundle.assert_bundle_task_created(server, bundle_id) new_role_id = rebundle.wait_bundle_complete(server, bundle_id) farm.clear_roles() lib_farm.add_role_to_farm(context, farm, role=Role.get(new_role_id)) server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING) lifecycle.assert_szr_version_last(server) lib_server.assert_scalarizr_log_errors(cloud, server)
def test_attach_disk_to_running_server(self, context: dict, cloud: Cloud, farm: Farm): """Attach disk to running server""" 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) volume_id = lifecycle.create_and_attach_volume(server, size=1) assert volume_id, f'New volume for server {server.id} not created!' for _ in range(6): server.details.reload() volume_ids = [vol['id'] for vol in server.details['volumes']] if len(volume_ids) > 1: break time.sleep(5) else: raise AssertionError(f'Servers {server.id} has only 1 volume after 30 seconds') assert volume_id in volume_ids, f'Server {server.id} not have volume {volume_id}'
def test_reboot_bootstrap(self, context: dict, cloud: Cloud, farm: Farm, servers: dict): """Reboot on bootstraping""" lib_farm.clear(farm) farm.terminate() lib_farm.add_role_to_farm(context, farm, role_options=['init_reboot', 'small_linux_orchestration']) farm.launch() server = lib_server.wait_server_status(context, cloud, farm, status=ServerStatus.RUNNING) servers['M1'] = server lib_server.assert_last_script_result(context, cloud, server, name='Revizor last reboot', event='HostInit', user='******', exitcode=0) lib_server.assert_last_script_result(context, cloud, server, name='Revizor last reboot', event='HostUp', user='******', exitcode=0) lifecycle.validate_scripts_launch_amt(server, 'Revizor last reboot') lifecycle.assert_hostname(server)
def test_checking_deletion_chef_fixtures(self, farm: Farm, servers: dict): """Verify Scalr delete chef-fixtures""" server = servers['M1'] farm.terminate() lib_server.wait_servers_state(farm, 'terminated') provision.assert_node_exists_on_chef_server(server, exist=False)
def test_verify_node_deletion_from_at(self, farm: Farm, servers: dict): """Verify Scalr delete node from AT server""" farm.terminate() lib_server.wait_servers_state(farm, 'terminated') server = servers['M1'] provision.assert_hostname_exists_on_at_server(server, negation=True)
def test_stop_farm(self, farm: Farm): """Stop farm""" farm.terminate() lib_server.wait_servers_state(farm, 'terminated')
def cleanup(self, farm: Farm): farm.terminate() lib_farm.clear(farm)