Esempio n. 1
0
    def healthstore_writes_helper(self, health_store_id, maintenance_run_id,
                                  expected_patch_version):
        current_time = datetime.datetime.utcnow()
        td = datetime.timedelta(hours=0, minutes=20)
        job_start_time = (current_time -
                          td).strftime("%Y-%m-%dT%H:%M:%S.9999Z")
        argument_composer = ArgumentComposer()
        argument_composer.maximum_duration = 'PT1H'
        argument_composer.start_time = job_start_time
        argument_composer.health_store_id = health_store_id
        argument_composer.maintenance_run_id = maintenance_run_id
        runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                    True, Constants.YUM)

        runtime.set_legacy_test_type('SuccessInstallPath')
        installed_update_count, update_run_successful, maintenance_window_exceeded = runtime.patch_installer.install_updates(
            runtime.maintenance_window, runtime.package_manager, simulate=True)
        runtime.patch_installer.mark_installation_completed()

        with runtime.env_layer.file_system.open(
                runtime.execution_config.status_file_path, 'r') as file_handle:
            substatus_file_data = json.load(
                file_handle)[0]["status"]["substatus"][1]

        self.assertEqual(
            True,
            json.loads(substatus_file_data['formattedMessage']['message'])
            ['shouldReportToHealthStore'])
        self.assertEqual(
            expected_patch_version,
            json.loads(substatus_file_data['formattedMessage']['message'])
            ['patchVersion'])
        runtime.stop()
 def test_check_available_time(self):
     argument_composer = ArgumentComposer()
     argument_composer.start_time = (
         datetime.datetime.utcnow() -
         datetime.timedelta(minutes=39)).strftime("%Y-%m-%dT%H:%M:%S.9999Z")
     argument_composer.maximum_duration = "PT1H"
     runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                 True)
     self.assertEqual(
         runtime.maintenance_window.is_package_install_time_available(),
         True)
     runtime.stop()
    def test_RemainingTime_after_duration_complete(self):
        argument_composer = ArgumentComposer()
        argument_composer.start_time = "2017-02-15T18:15:12.9828835Z"
        argument_composer.maximum_duration = "PT1H"
        runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                    True)

        current_time = datetime.datetime.strptime('2017-02-15 19:16:20',
                                                  "%Y-%m-%d %H:%M:%S")
        remaining_time = runtime.maintenance_window.get_remaining_time_in_minutes(
            current_time)

        self.assertEqual(int(remaining_time), 0)
        runtime.stop()
Esempio n. 4
0
 def test_zypper_install_updates_maintenance_window_exceeded(self):
     current_time = datetime.datetime.utcnow()
     td = datetime.timedelta(hours=1, minutes=2)
     job_start_time = (current_time -
                       td).strftime("%Y-%m-%dT%H:%M:%S.9999Z")
     argument_composer = ArgumentComposer()
     argument_composer.maximum_duration = 'PT1H'
     argument_composer.start_time = job_start_time
     runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                 True, Constants.ZYPPER)
     # Path change
     runtime.set_legacy_test_type('FailInstallPath')
     installed_update_count, update_run_successful, maintenance_window_exceeded = runtime.patch_installer.install_updates(
         runtime.maintenance_window, runtime.package_manager, simulate=True)
     self.assertEqual(0, installed_update_count)
     self.assertTrue(update_run_successful)
     self.assertTrue(maintenance_window_exceeded)
     runtime.stop()