def test_schedule_analysis_in_the_past(appliance, current_server_time, request): """ Polarion: assignee: jhenner casecomponent: Reporting caseimportance: high initialEstimate: 1/4h """ current_time, _ = current_server_time past_time = current_time - relativedelta.relativedelta(minutes=5) if round_min(past_time.minute) == 0: past_time = past_time + relativedelta.relativedelta(hours=1) past_time_minute = '0' else: past_time_minute = str(round_min(past_time.minute)) schedule = appliance.collections.system_schedules.create( name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), start_hour=str(past_time.hour), start_minute=past_time_minute) request.addfinalizer(schedule.delete) view = appliance.browser.create_view(BaseLoggedInPage) view.flash.assert_message( "Warning: This 'Run Once' timer is in the past and will never run as currently configured" )
def test_inactive_schedule(appliance, current_server_time): """ Polarion: assignee: jhenner caseimportance: high casecomponent: Reporting initialEstimate: 1/4h """ current_time, _ = current_server_time start_date = current_time + relativedelta.relativedelta(minutes=5) schedule = appliance.collections.system_schedules.create( name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), start_date=start_date, start_hour=str(start_date.hour), start_minute=str(round_min(start_date.minute)), ) assert schedule.next_run_date schedule.disable() assert not schedule.next_run_date
def test_automate_task_schedule(appliance, custom_automate_setup, current_server_time, request): """ Polarion: assignee: dgaikwad initialEstimate: 1/8h caseposneg: positive casecomponent: Automate setup: 1. Create domain, namespace, class and instance 2. Also create automate method with below ruby code: >> $evm.log(:info, "Hello World") testSteps: 1. Go to Configuration > Settings > Zones > Schedules 2. Create schedule with required fields: >> Action - Automation Tasks >> Object Details(Request) - Call_Instance >> Attribute/Value Pairs >> domain - domain_name >> namespace - namespace_name >> class - class_name >> instance - instance_name >> Timer Options 3. Check automation logs more than 1 times expectedResults: 1. 2. 3. Automate method should be executed on scheduled time. Bugzilla: 1713072 """ domain, namespace, auto_class, instance = custom_automate_setup current_time, tz_num = current_server_time start_date = current_time + relativedelta.relativedelta(minutes=5) view = navigate_to(appliance.collections.system_schedules, 'Add') available_list = view.form.time_zone.all_options tz_select = next(tz.text for tz in available_list if f'{tz_num[0:3]}:00' in tz.text) if round_min(start_date.minute) == 0: start_date = start_date + relativedelta.relativedelta( minutes=60 - start_date.minute) start_date_minute = str(start_date.minute) else: start_date_minute = str(round_min(start_date.minute)) attribute_value_pairs = { "domain": domain.name, "namespace": namespace.name, "class": auto_class.name, "instance": instance.name, } schedule = appliance.collections.system_schedules.create( name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), action_type="Automation Tasks", request="Call_Instance", attribute_value_pairs=attribute_value_pairs, run_type="Hourly", time_zone=tz_select, start_hour=str(start_date.hour), start_minute=start_date_minute, ) @request.addfinalizer def _finalize(): try: schedule.delete_if_exists() except TypeError: # Delete failing only on PRT with type error pass matched_pattern = ".*INFO.* : Q-task_id.* Hello World" def _check_automation_log(): log = LogValidator("/var/www/miq/vmdb/log/automation.log", matched_patterns=[matched_pattern]) log.start_monitoring() log.validate(wait="15m") _check_automation_log() next_run_date = start_date + relativedelta.relativedelta(minutes=-5, hours=1) appliance.ssh_client.run_command( f"date {next_run_date.strftime('%m%d%H%M%Y')}") _check_automation_log()
def test_schedule_timer(appliance, run_types, host_with_credentials, request, current_server_time): """ Polarion: assignee: jhenner caseimportance: critical casecomponent: Reporting initialEstimate: 1/4h """ run_time, time_diff, time_num = run_types current_time, tz_num = current_server_time start_date = current_time + relativedelta.relativedelta(minutes=5) view = navigate_to(appliance.collections.system_schedules, 'Add') # bz is here 1559904 available_list = view.form.time_zone.all_options for tz in available_list: if '{}:00'.format( tz_num[0:3] ) in tz.text and 'Atlantic Time (Canada)' not in tz.text: tz_select = tz.text break if round_min(start_date.minute) == 0: start_date = start_date + relativedelta.relativedelta( minutes=60 - start_date.minute) start_date_minute = str(start_date.minute) else: start_date_minute = str(round_min(start_date.minute)) schedule = appliance.collections.system_schedules.create( name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), action_type='Host Analysis', filter_level1='A single Host', filter_level2=host_with_credentials.name, run_type=run_time, start_date=start_date, time_zone=tz_select, start_hour=str(start_date.hour), start_minute=start_date_minute, ) @request.addfinalizer def _finalize(): if schedule.exists: schedule.delete() wait_for(lambda: schedule.last_run_date != '', delay=60, timeout="10m", fail_func=appliance.server.browser.refresh, message="Scheduled task didn't run in first time") if time_diff: next_date = parser.parse(schedule.next_run_date) up = {time_diff: time_num} next_run_date = start_date + relativedelta.relativedelta(minutes=-5, **up) appliance.ssh_client.run_command("date {}".format( next_run_date.strftime('%m%d%H%M%Y'))) wait_for(lambda: next_date.strftime('%m%d%H') == parser.parse( schedule.last_run_date).strftime('%m%d%H'), delay=60, timeout="10m", fail_func=appliance.server.browser.refresh, message="Scheduled task didn't run in appropriate time set")