Skip to content

Adding explicit call for apicast-production metrics#1017

Open
cathal-bailey wants to merge 1 commit into3scale-qe:mainfrom
cathal-bailey:apicast-production-test-metrics
Open

Adding explicit call for apicast-production metrics#1017
cathal-bailey wants to merge 1 commit into3scale-qe:mainfrom
cathal-bailey:apicast-production-test-metrics

Conversation

@cathal-bailey
Copy link
Copy Markdown
Collaborator

@cathal-bailey cathal-bailey commented Mar 13, 2026

  • The test queries Prometheus for metrics for "apicast-staging" and "apicast-production"
  • Since production has never received HTTP traffic, request-dependent metrics don't exist and the test fails
  • For production metrics, promotes staging config to production and sends a GET request to /get endpoint
  • This generates the missing metrics (apicast_status, upstream_status, threescale_backend_calls, and response time histograms - 5 tests now passing)
  • prometheus.wait_on_next_scrape so that metrics appear in db, as seen elsewhere for prometheus/apicast in testsuite
  • All metrics passing on Alpha with this change, but considerable increase in test time (now ~4 mins)
  • Marking apicast-prodiuction as disruptive to ensure apicast restart does not impact other tests.
  • Adding idempotent check to prod_client fixture to prevent duplicate promotion errors

@cathal-bailey cathal-bailey force-pushed the apicast-production-test-metrics branch from 251432f to 2a799d4 Compare March 13, 2026 14:14
Comment on lines +63 to +65
service = application.service
version = service.proxy.list().configs.latest()["version"]
service.proxy.list().promote(version=version)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not liking this code reminded me that .promote on a apicast-production will cause restart of apicast, which can affect running tests in parallel, so apicast-production would need to set pytest.mark.disruptive

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay understood, my thinking is that .promote is required to in order for the GET request to work.
So would it be safer to split-out test for production metrics and mark disruptive to facilitate the .promote? I think we can leave staging as is, there doesn't seem to be any issues there atm.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to promote it by hand? cant you just use api_client or prod_client (depenging on request.param)?

It might be better to just call either way and add # TODO: and github issue to look at this closer later.

@cathal-bailey cathal-bailey changed the title Adding explicit call for apicast-product metrics Adding explicit call for apicast-production metrics Mar 18, 2026
Comment thread testsuite/tests/conftest.py Outdated
Comment on lines +424 to +427
# Check if already promoted
prod_config = app.service.proxy.list().configs.latest(env="production")
if prod_config is None or prod_config["version"] != version:
app.service.proxy.list().promote(version=version)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not change this, prod_client should throw exception if promote=True and it was already promoted.
this is used across whole testsuite and this behavior should stay as is.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, this change is a proposed fix for an issue I was seeing when I ran the test locally. test_apicast_status_metrics was failing with as it tried to promote production metrics that had already been promoted by metrics. The prod_client change resolved this. I'll add this check into the test file instead so I don't have to touch the contest.py.

@cathal-bailey cathal-bailey force-pushed the apicast-production-test-metrics branch 2 times, most recently from 935d7e8 to f27a4c1 Compare March 18, 2026 15:52
  - Mark apicast-production parameter as disruptive in metrics fixture
  - Use prod_client fixture for production promotion instead of manual code
  - Skip re-promotion in test_apicast_status_metrics with promote=False
@cathal-bailey cathal-bailey force-pushed the apicast-production-test-metrics branch from ac46efc to 245a26f Compare March 18, 2026 16:12
@cathal-bailey cathal-bailey marked this pull request as ready for review March 19, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants