Skip to content

test: silence BigQuery IAM/schema noise from background mocks#3550

Open
nelsonmestevao wants to merge 1 commit into
Logflare:mainfrom
nelsonmestevao:ne/mimic-mock-logs-bigquery
Open

test: silence BigQuery IAM/schema noise from background mocks#3550
nelsonmestevao wants to merge 1 commit into
Logflare:mainfrom
nelsonmestevao:ne/mimic-mock-logs-bigquery

Conversation

@nelsonmestevao

Copy link
Copy Markdown
Contributor

Tests were logging (and occasionally failing on) Mimic errors caused by BigQuery calls. By globally stubbing BigQueryAdaptor calls to update_iam_policy/0,1 and patch_dataset_access/1 we reduce the noise.

test "updates correctly" do
prev_config = Application.get_env(:logflare, Schema)
Application.put_env(:logflare, Schema, updates_per_minute: 1)
on_exit(fn -> Application.put_env(:logflare, Schema, prev_config) end)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Force updates_per_minute: 1 so the Schema throttle actually engages. With the test config's 900_000, the throttle window is ~0ms, so the second update raced past expect(:bigquery_tables_patch, 1) and crashed the GenServer. This way we avoid flakyness introduced by the crash.

@nelsonmestevao
nelsonmestevao force-pushed the ne/mimic-mock-logs-bigquery branch from c13fe35 to fb434c5 Compare June 2, 2026 17:21
@nelsonmestevao
nelsonmestevao force-pushed the ne/mimic-mock-logs-bigquery branch 9 times, most recently from 1a05382 to e6bfab2 Compare June 8, 2026 12:36
@nelsonmestevao
nelsonmestevao force-pushed the ne/mimic-mock-logs-bigquery branch 3 times, most recently from 524d14d to 90f65c2 Compare June 22, 2026 19:14
@nelsonmestevao
nelsonmestevao force-pushed the ne/mimic-mock-logs-bigquery branch 5 times, most recently from 2383e77 to b856ceb Compare July 1, 2026 21:40

@amokan amokan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should keep the shared stubs, but prob need to revisit some of the expects we removed from things like users_test.exs and single_tenant_test.exs unless I'm missing something bigger picture as these changes seem to cost us some coverage. Totally a fan of reducing noise, but my hope is that we can do so without sacrificing legit test cases 🙏

Part of me also wonders if the blanket stub should be in the data case at all or if it would be better suited as a narrower opt-in for the test files that produce the most noise.

Comment thread test/support/data_case.ex
func.()
end)

stub(BigQueryAdaptor, :update_iam_policy, fn -> :ok end)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Robot reviewer callout 🤖

The blanket update_iam_policy stub breaks 4 existing tests that exercise the real code path (CI-confirmed). These tests were not given the call_original escape hatch that the controller tests got, so the stub swallows the call before it reaches the GoogleApi mocks, and their expects fail at verify_on_exit!. Failing in this PR's CI run: test/logflare/users/users_test.exs:47 (delete_user/1), test/logflare/partners_test.exs:80, and test/logflare/backends/bigquery_adaptor_test.exs:501 and :568 — the latter two are the unit tests of update_iam_policy/0 itself, which now test the stub rather than the adaptor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I fixed those in last push! 🙏

The idea is to never think about the update_iam_policy noise in the logs and only do the call_original when we really are testing these.

cc/ @Ziinc that requested this #3484 (comment)

@nelsonmestevao
nelsonmestevao force-pushed the ne/mimic-mock-logs-bigquery branch 3 times, most recently from 7dff0ff to 855aed1 Compare July 2, 2026 21:40
Tests were logging (and occasionally failing on) Mimic errors caused by BigQuery calls. By globally stubbing `BigQueryAdaptor` calls to update_iam_policy/0,1 and patch_dataset_access/1 we reduce the noise.
@nelsonmestevao
nelsonmestevao force-pushed the ne/mimic-mock-logs-bigquery branch from 855aed1 to 588b5d7 Compare July 9, 2026 11:50
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