Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Do not warn on differing data sources due to incomplete bounds
Browse files Browse the repository at this point in the history
We produced warnings on the data sources being different
while the bounds were being computed. In a multi-cloak
setup and with a large dataset this would cause the warning
coming up more or less always.
  • Loading branch information
sebastian committed Sep 18, 2019
1 parent 2d1869e commit 72f96f2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions air/lib/air/service/cloak.ex
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,15 @@ defmodule Air.Service.Cloak do
|> Lens.to_list(datasource_tables)
|> Enum.empty?()

defp pending?(column), do: column[:shadow_table] == :pending or column[:isolated] == :pending
defp pending?(column),
do: column[:shadow_table] == :pending or column[:isolated] == :pending or column[:bounds] == :pending

defp strip_tables_of_temporary_state(tables),
do:
Lens.all()
|> Lens.key(:columns)
|> Lens.all()
|> Lens.map(tables, &Map.drop(&1, [:isolated, :shadow_table, :shadow_table_size]))
|> Lens.map(tables, &Map.drop(&1, [:isolated, :shadow_table, :shadow_table_size, :bounds]))

defp add_error_on_different_salts(data_sources, cloak_info) do
for data_source <- data_sources do
Expand Down
33 changes: 33 additions & 0 deletions air/test/air/service/cloak_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,38 @@ defmodule Air.Service.Cloak.Test do
assert error =~ ~r/differs between .+ cloaks/
end

test "should not record differences in bounds stats when not all data sources done" do
data_sources_done = [data_source_with_columns()]

data_sources_pending = [
data_source_with_columns([
table_column(%{bounds: :pending})
])
]

Cloak.register(TestRepoHelper.cloak_info(), data_sources_pending)
Cloak.register(TestRepoHelper.cloak_info("other_cloak"), data_sources_done)
assert [] == Jason.decode!(Repo.get_by!(DataSource, name: @data_source_name).errors)
end

test "should record differences in bounds stats when all data sources done" do
data_sources_done1 = [
data_source_with_columns([
table_column(%{bounds: :ok})
])
]

data_sources_done2 = [
data_source_with_columns([
table_column(%{bounds: :failed})
])
]

Cloak.register(TestRepoHelper.cloak_info(), data_sources_done1)
Cloak.register(TestRepoHelper.cloak_info("other_cloak"), data_sources_done2)
refute [] == Jason.decode!(Repo.get_by!(DataSource, name: @data_source_name).errors)
end

test "should not record differences in isolating stats when not all data sources done" do
data_sources_done = [data_source_with_columns()]

Expand Down Expand Up @@ -213,6 +245,7 @@ defmodule Air.Service.Cloak.Test do
defp table_column(params \\ %{}) do
Map.merge(
%{
bounds: :ok,
isolated: true,
name: "column_name",
shadow_table: :ok,
Expand Down

0 comments on commit 72f96f2

Please sign in to comment.