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

Commit

Permalink
Merge pull request #3893 from Aircloak/sebastian/datasource-definitio…
Browse files Browse the repository at this point in the history
…n-error-fix

Do not warn on differing data sources due to incomplete bounds
  • Loading branch information
sebastian authored Sep 18, 2019
2 parents 1a335ed + 72f96f2 commit c021753
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 c021753

Please sign in to comment.