def test_action_initiate_smartstate_analysis( request, configure_fleecing, vm, vm_off, policy_for_testing ): """ This test tests actions 'Initiate SmartState Analysis for VM'. This test sets the policy that it analyses VM after it's powered on. Then it checks whether that really happened. Metadata: test_flag: actions, provision Polarion: assignee: dgaikwad initialEstimate: 1/6h casecomponent: Control """ # Set up the policy and prepare finalizer policy_for_testing.assign_actions_to_event("VM Power On", ["Initiate SmartState Analysis for VM"]) @request.addfinalizer def _cleanup(): policy_for_testing.unassign_events("VM Power On") # Start the VM vm.power_control_from_cfme(option=vm.POWER_ON, cancel=False, from_details=True) wait_for_ssa_enabled(vm) try: do_scan(vm) except TimedOutError: pytest.fail(f"CFME did not finish analysing the VM {vm.name}")
def test_action_prevent_ssa(request, configure_fleecing, vm, vm_on, policy_for_testing): """Tests preventing Smart State Analysis. This test sets the policy that prevents VM analysis. Bugzilla: 1433084 Metadata: test_flag: actions, provision Polarion: assignee: jdupuy initialEstimate: 1/4h casecomponent: Control """ policy_for_testing.assign_actions_to_event( "VM Analysis Request", ["Prevent current event from proceeding"]) @request.addfinalizer def _cleanup(): policy_for_testing.unassign_events("VM Analysis Request") policy_result = LogValidator( "/var/www/miq/vmdb/log/policy.log", matched_patterns=[ '.*Prevent current event from proceeding.*VM Analysis Request.*{}'. format(vm.name) ]) policy_result.start_monitoring() wait_for_ssa_enabled(vm) try: do_scan(vm) except TimedOutError: assert policy_result.validate(wait="120s") else: pytest.fail("CFME did not prevent analysing the VM {}".format(vm.name))
def test_alert_hardware_reconfigured(request, appliance, configure_fleecing, smtp_test, create_vm, setup_for_alerts): """Tests alert based on "Hardware Reconfigured" evaluation. According https://bugzilla.redhat.com/show_bug.cgi?id=1396544 Hardware Reconfigured alerts require drift history. So here are the steps for triggering hardware reconfigured alerts based on CPU Count: 1. Run VM smart state analysis. 2. Change CPU count. 3. Run VM smart state analysis again. 4. Run VM reconfigure again. Then the alert for CPU count change should be triggered. It is either CPU increased or decreased depending on what has been done in your step 2, not the result of step 4. Step 4 is just to trigger the event. Bugzilla: 1396544 1730805 Metadata: test_flag: alerts, provision Polarion: assignee: tpapaioa casecomponent: Control initialEstimate: 1/4h """ vm = create_vm email = fauxfactory.gen_email() service_request_desc = ("VM Reconfigure for: {0} - Processor Sockets: {1}, " "Processor Cores Per Socket: 1, Total Processors: {1}") alert = appliance.collections.alerts.create( fauxfactory.gen_alpha(length=36, start="Trigger by hardware reconfigured "), active=True, based_on="VM and Instance", evaluate=( "Hardware Reconfigured", { "hardware_attribute": "Number of CPU Cores", "operator": "Increased", } ), notification_frequency="1 Minute", emails=email ) request.addfinalizer(alert.delete) setup_for_alerts(request, [alert], vm_name=vm.name) wait_for_ssa_enabled(vm) sockets_count = vm.configuration.hw.sockets for i in range(1, 3): do_scan(vm, rediscover=False) vm.reconfigure(changes={ "cpu": True, "sockets": str(sockets_count + i), "disks": (), "network_adapters": () }) service_request = appliance.collections.requests.instantiate( description=service_request_desc.format(vm.name, sockets_count + i)) service_request.wait_for_request(method="ui", num_sec=300, delay=10) wait_for_alert( smtp_test, alert, delay=30 * 60, additional_checks={"text": vm.name, "from_address": email} )