canonical / prometheus-k8s-operator

https://charmhub.io/prometheus-k8s
Apache License 2.0
21 stars 35 forks source link

Bugs in itests #416

Closed sed-i closed 1 year ago

sed-i commented 1 year ago

A recent CI failure exposed two issues in itests.

test_external_url

Missing await results in always evaluating as True.

tests/integration/test_external_url.py::test_jobs_are_up_via_traefik
  /home/runner/work/prometheus-k8s-operator/prometheus-k8s-operator/tests/integration/test_external_url.py:114: RuntimeWarning: coroutine 'Prometheus.is_ready' was never awaited
    lambda: all(Prometheus(ep).is_ready() for ep in ingressed_endpoints)

https://github.com/canonical/prometheus-k8s-operator/blob/e27996499d6f08f85780b1483e58cf0d5b559674/tests/integration/test_external_url.py#L114

test_rerelate

Seems like wait_for_idle after remove_relation is insufficient guarantee that a relation was indeed removed.

Traceback (most recent call last):
  File "/home/runner/work/prometheus-k8s-operator/prometheus-k8s-operator/tests/integration/test_rerelate.py", line 103, in test_rerelate
    await asyncio.gather(
  File "/home/runner/work/prometheus-k8s-operator/prometheus-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/model.py", line 1480, in add_relation
    return await self.relate(relation1, relation2)
  File "/home/runner/work/prometheus-k8s-operator/prometheus-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/model.py", line 1538, in relate
    result = await app_facade.AddRelation(endpoints=endpoints, via_cidrs=None)
  File "/home/runner/work/prometheus-k8s-operator/prometheus-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/client/facade.py", line 481, in wrapper
    reply = await f(*args, **kwargs)
  File "/home/runner/work/prometheus-k8s-operator/prometheus-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/client/old_clients/_client14.py", line 958, in AddRelation
    reply = await self.rpc(msg)
  File "/home/runner/work/prometheus-k8s-operator/prometheus-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/client/facade.py", line 654, in rpc
    result = await self.connection.rpc(msg, encoder=TypeEncoder)
  File "/home/runner/work/prometheus-k8s-operator/prometheus-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/client/connection.py", line 638, in rpc
    raise errors.JujuAPIError(result)
juju.errors.JujuAPIError: cannot add relation "grafana:grafana-source prometheus-k8s:grafana-source": relation grafana:grafana-source prometheus-k8s:grafana-source is dying, but not yet removed

https://github.com/canonical/prometheus-k8s-operator/blob/e27996499d6f08f85780b1483e58cf0d5b559674/tests/integration/test_rerelate.py#L108