Skip to content

build(deps-dev): bump moto from 5.1.11 to 5.1.16

9003434
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Closed

build(deps-dev): bump moto from 5.1.11 to 5.1.16 #50

build(deps-dev): bump moto from 5.1.11 to 5.1.16
9003434
Select commit
Loading
Failed to load commit list.
GitHub Actions / JUnit Test Report failed Nov 10, 2025 in 0s

15 tests run, 13 passed, 0 skipped, 2 failed.

Annotations

Check failure on line 126 in tests/test_emit_metrics.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_emit_metrics.test_alb_discovery_scrape_and_emit

TypeError: can't compare offset-naive and offset-aware datetimes
Raw output
temp_queue = sqs.Queue(url='https://sqs.eu-west-2.amazonaws.com/123456789012/test-queue-5a6adfbc80b845b98a8aa9ff6fce5502')
temp_alb = ('app/test-alb-147f8c48751f499bb922d1d543963431/c8182a4455c7219c', 'test-alb-147f8c48751f499bb922d1d543963431')

    async def test_alb_discovery_scrape_and_emit(temp_queue, temp_alb):
        alb_id, _alb_name = temp_alb
    
        conf = {
            "discovery": {
                "jobs": [
                    {
                        "type": "alb",
                        "regions": ["eu-west-2"],
                        "metrics": [
                            {
                                "name": "RequestCount",
                                "stats": ["Sum", "SampleCount", "Maximum"],
                            }
                        ],
                    }
                ]
            }
        }
    
        sqs_client = _get_sqs_client(temp_queue.url)
        with temp_config(conf):
            config = ScrapeConfig(
                rtf_overrides={"AWS/ApplicationELB": ["elasticloadbalancing:loadbalancer"]}
            )
            client_factory = ClientFactory(config.sts_region)
    
            executor = Executor(config, client_factory, sqs_client)
            with temp_metrics(
                [
                    MetricDatum(
                        namespace="AWS/ApplicationELB",
                        name="RequestCount",
                        value=10,
                        dimensions=[
                            {"Name": "LoadBalancer", "Value": alb_id},
                        ],
                        timestamp=datetime.now(tz=UTC).replace(second=0, microsecond=0)
                        - relativedelta(minutes=1),
                        unit="Count",
                    )
                ]
            ):
    
>               results = await executor.scrape_and_emit()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_emit_metrics.py:126: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/executor.py:90: in scrape_and_emit
    results = await asyncio.gather(*tasks)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/executor.py:85: in _scrape
    metrics = await ex.scrape_and_emit()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
src/executor.py:236: in scrape_and_emit
    raise e
src/executor.py:214: in scrape_and_emit
    discovery_results = await asyncio.gather(*discovery_tasks)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/executor.py:317: in get_discovered_batch_and_emit
    async for page in self.cloudwatch.get_metric_data(
src/clients.py:177: in get_metric_data
    async for page in self._paginate(
src/clients.py:79: in _paginate
    page = await run_in_executor(_get_next_page)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/clients.py:42: in run_in_executor
    result = cast(T, await loop.run_in_executor(None, to_execute))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/concurrent/futures/thread.py:59: in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/clients.py:74: in _get_next_page
    return page_iterator.__next__()
           ^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/paginate.py:272: in __iter__
    response = self._make_request(current_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/context.py:123: in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/paginate.py:360: in _make_request
    return self._method(**current_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/client.py:602: in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/context.py:123: in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/client.py:1060: in _make_api_call
    http, parsed_response = self._make_request(
.venv/lib/python3.12/site-packages/botocore/client.py:1084: in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/endpoint.py:119: in make_request
    return self._send_request(request_dict, operation_model)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/endpoint.py:200: in _send_request
    while self._needs_retry(
.venv/lib/python3.12/site-packages/botocore/endpoint.py:360: in _needs_retry
    responses = self._event_emitter.emit(
.venv/lib/python3.12/site-packages/botocore/hooks.py:412: in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/hooks.py:256: in emit
    return self._emit(event_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/hooks.py:239: in _emit
    response = handler(**kwargs)
               ^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/retryhandler.py:207: in __call__
    if self._checker(**checker_kwargs):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/retryhandler.py:284: in __call__
    should_retry = self._should_retry(
.venv/lib/python3.12/site-packages/botocore/retryhandler.py:307: in _should_retry
    return self._checker(
.venv/lib/python3.12/site-packages/botocore/retryhandler.py:363: in __call__
    checker_response = checker(
.venv/lib/python3.12/site-packages/botocore/retryhandler.py:247: in __call__
    return self._check_caught_exception(
.venv/lib/python3.12/site-packages/botocore/retryhandler.py:416: in _check_caught_exception
    raise caught_exception
.venv/lib/python3.12/site-packages/botocore/endpoint.py:276: in _do_get_response
    responses = self._event_emitter.emit(event_name, request=request)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/hooks.py:412: in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/hooks.py:256: in emit
    return self._emit(event_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/botocore/hooks.py:239: in _emit
    response = handler(**kwargs)
               ^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/moto/core/botocore_stubber.py:38: in __call__
    response = self.process_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/moto/core/botocore_stubber.py:88: in process_request
    status, headers, body = method_to_execute(
.venv/lib/python3.12/site-packages/moto/core/responses.py:364: in dispatch
    return cls()._dispatch(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/moto/core/responses.py:565: in _dispatch
    return self.call_action()
           ^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/moto/core/responses.py:695: in call_action
    response = method()
               ^^^^^^^^
.venv/lib/python3.12/site-packages/moto/cloudwatch/responses.py:176: in get_metric_data
    results = self.cloudwatch_backend.get_metric_data(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <moto.cloudwatch.models.CloudWatchBackend object at 0x7f0e82129160>
queries = [{'Id': 'm0', 'MetricStat': {'Metric': {'Dimensions': [{'Name': 'LoadBalancer', 'Value': 'app/test-alb-147f8c48751f499...MetricName': 'RequestCount', 'Namespace': 'AWS/ApplicationELB'}, 'Period': 60, 'Stat': 'Maximum'}, 'ReturnData': True}]
start_time = datetime.datetime(2025, 11, 10, 3, 38)
end_time = datetime.datetime(2025, 11, 10, 3, 39)
scan_by = 'TimestampDescending'

    def get_metric_data(
        self,
        queries: list[dict[str, Any]],
        start_time: datetime,
        end_time: datetime,
        scan_by: str = "TimestampAscending",
    ) -> list[dict[str, Any]]:
        start_time = start_time.replace(microsecond=0)
        end_time = end_time.replace(microsecond=0)
    
        if start_time > end_time:
            raise ValidationError(
                "The parameter EndTime must be greater than StartTime."
            )
        if start_time == end_time:
            raise ValidationError(
                "The parameter StartTime must not equal parameter EndTime."
            )
    
        period_data = [
>           md for md in self.get_all_metrics() if start_time <= md.timestamp < end_time
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ]
E       TypeError: can't compare offset-naive and offset-aware datetimes

.venv/lib/python3.12/site-packages/moto/cloudwatch/models.py:666: TypeError

Check failure on line 150 in tests/test_metric_discovery.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_metric_discovery.test_alb_metric_discovery

AssertionError: assert 2 == 1
 +  where 2 = len([CloudwatchMetricTask(ns='AWS/ApplicationELB', metric_name='RequestCount', resource_name='global', dimensions={'LoadBalancer': 'app/test-alb-147f8c48751f499bb922d1d543963431/c8182a4455c7219c'}, statistic='Sum', nil_to_zero=False, add_cw_timestamp=True, unit=None, tags={}, result=None, signature=('AWS/ApplicationELB', 'RequestCount', (('LoadBalancer', 'app/test-alb-147f8c48751f499bb922d1d543963431/c8182a4455c7219c'),), ())), CloudwatchMetricTask(ns='AWS/ApplicationELB', metric_name='RequestCount', resource_name='global', dimensions={'LoadBalancer': 'app/test-alb-a91d3c40189241b1b6ec57ba0f59cb6e/ca8c4ef5aa75cd21'}, statistic='Sum', nil_to_zero=False, add_cw_timestamp=True, unit=None, tags={}, result=None, signature=('AWS/ApplicationELB', 'RequestCount', (('LoadBalancer', 'app/test-alb-a91d3c40189241b1b6ec57ba0f59cb6e/ca8c4ef5aa75cd21'),), ()))])
Raw output
test_bucket = s3.Bucket(name='temp-c2d47ad7dd3342c4bc335e38f013154a')
temp_alb = ('app/test-alb-a91d3c40189241b1b6ec57ba0f59cb6e/ca8c4ef5aa75cd21', 'test-alb-a91d3c40189241b1b6ec57ba0f59cb6e')

    async def test_alb_metric_discovery(test_bucket, temp_alb):
    
        alb_id, _alb_name = temp_alb
        conf = {
            "discovery": {
                "jobs": [
                    {
                        "type": "alb",
                        "regions": ["eu-west-2"],
                        "metrics": [{"name": "RequestCount", "stats": ["Sum"]}],
                    }
                ]
            }
        }
    
        with temp_config(conf):
            config = ScrapeConfig(
                rtf_overrides={"AWS/ApplicationELB": ["elasticloadbalancing:loadbalancer"]}
            )
            client_factory = ClientFactory(config.sts_region)
            executor = Executor(config, client_factory, None)  # type: ignore[arg-type]
    
            with temp_metrics(
                [
                    MetricDatum(
                        namespace="AWS/ApplicationELB",
                        name="RequestCount",
                        value=10,
                        dimensions=[
                            {"Name": "LoadBalancer", "Value": alb_id},
                        ],
                        timestamp=datetime.now(tz=UTC).replace(second=0, microsecond=0),
                        unit="Count",
                    )
                ]
            ):
                discovered = await executor.discover_metrics(init_clients=True)
            assert discovered
            assert len(discovered) == 1
            region_result = discovered.get(("eu-west-2", None), {})
            assert region_result
            assert len(region_result) == 1
            metrics = region_result.get((60, 0, 60))
            assert metrics
>           assert len(metrics) == 1
E           AssertionError: assert 2 == 1
E            +  where 2 = len([CloudwatchMetricTask(ns='AWS/ApplicationELB', metric_name='RequestCount', resource_name='global', dimensions={'LoadBalancer': 'app/test-alb-147f8c48751f499bb922d1d543963431/c8182a4455c7219c'}, statistic='Sum', nil_to_zero=False, add_cw_timestamp=True, unit=None, tags={}, result=None, signature=('AWS/ApplicationELB', 'RequestCount', (('LoadBalancer', 'app/test-alb-147f8c48751f499bb922d1d543963431/c8182a4455c7219c'),), ())), CloudwatchMetricTask(ns='AWS/ApplicationELB', metric_name='RequestCount', resource_name='global', dimensions={'LoadBalancer': 'app/test-alb-a91d3c40189241b1b6ec57ba0f59cb6e/ca8c4ef5aa75cd21'}, statistic='Sum', nil_to_zero=False, add_cw_timestamp=True, unit=None, tags={}, result=None, signature=('AWS/ApplicationELB', 'RequestCount', (('LoadBalancer', 'app/test-alb-a91d3c40189241b1b6ec57ba0f59cb6e/ca8c4ef5aa75cd21'),), ()))])

tests/test_metric_discovery.py:150: AssertionError