Exemplo n.º 1
0
 def test_keep_duplicit_values_when_are_not_valid_interval(self):
     operation_list = [
         _operation_fixture("monitor", "some"),
         _operation_fixture("monitor", "some"),
     ]
     (
         report_list,
         new_operation_list,
     ) = operations.uniquify_operations_intervals(operation_list)
     assert_report_item_list_equal(report_list, [])
     self.assertEqual(new_operation_list, operation_list)
Exemplo n.º 2
0
def get_agent_default_operations(
    lib_env: LibraryEnvironment,
    agent_name: ResourceAgentNameDto,
    necessary_only: bool = False,
) -> ListCibResourceOperationDto:
    report_list, operation_list = uniquify_operations_intervals(
        get_default_operations(
            _get_agent_metadata(lib_env.cmd_runner(), lib_env.report_processor,
                                agent_name),
            necessary_only,
        ))
    lib_env.report_processor.report_list(report_list)
    return ListCibResourceOperationDto(operations=operation_list)
Exemplo n.º 3
0
 def test_return_copy_input_when_no_interval_duplication(self):
     operation_list = [
         _operation_fixture("monitor", "10s"),
         _operation_fixture("monitor", "5s"),
         _operation_fixture("monitor"),
         _operation_fixture("start", "5s"),
     ]
     (
         report_list,
         new_operation_list,
     ) = operations.uniquify_operations_intervals(operation_list)
     assert_report_item_list_equal(report_list, [])
     self.assertEqual(operation_list, new_operation_list)
Exemplo n.º 4
0
    def test_adopt_duplicit_values(self):
        (
            report_list,
            new_operation_list,
        ) = operations.uniquify_operations_intervals([
            _operation_fixture("monitor", "60s"),
            _operation_fixture("monitor", "1m"),
            _operation_fixture("monitor", "5s"),
            _operation_fixture("monitor", "6s"),
            _operation_fixture("monitor", "5s"),
            _operation_fixture("start", "5s"),
        ])
        self.assertEqual(
            new_operation_list,
            [
                _operation_fixture("monitor", "60s"),
                _operation_fixture("monitor", "61"),
                _operation_fixture("monitor", "5s"),
                _operation_fixture("monitor", "6s"),
                _operation_fixture("monitor", "7"),
                _operation_fixture("start", "5s"),
            ],
        )

        assert_report_item_list_equal(
            report_list,
            [
                (
                    severities.WARNING,
                    report_codes.RESOURCE_OPERATION_INTERVAL_ADAPTED,
                    {
                        "operation_name": "monitor",
                        "original_interval": "1m",
                        "adapted_interval": "61",
                    },
                ),
                (
                    severities.WARNING,
                    report_codes.RESOURCE_OPERATION_INTERVAL_ADAPTED,
                    {
                        "operation_name": "monitor",
                        "original_interval": "5s",
                        "adapted_interval": "7",
                    },
                ),
            ],
        )