Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/sequin/transforms/transforms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ defmodule Sequin.Transforms do

defp encrypted_headers(%HttpEndpoint{encrypted_headers: nil}), do: %{}

defp encrypted_headers(%HttpEndpoint{encrypted_headers: encrypted_headers})
when is_map(encrypted_headers) and map_size(encrypted_headers) == 0,
do: %{}

Comment on lines +406 to +409
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice addition

defp encrypted_headers(%HttpEndpoint{encrypted_headers: encrypted_headers}) do
"(#{map_size(encrypted_headers)} encrypted header(s)) - sha256sum: #{sha256sum(encrypted_headers)}"
end
Expand Down Expand Up @@ -597,6 +601,9 @@ defmodule Sequin.Transforms do
"max_retry_count" when is_integer(value) and value >= 0 ->
{:cont, {:ok, Map.put(acc, :max_retry_count, value)}}

"max_retry_count" when is_nil(value) ->
{:cont, {:ok, acc}}
Comment on lines +604 to +605
Copy link
Contributor

Choose a reason for hiding this comment

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

great catch!


"max_retry_count" ->
{:halt, {:error, Error.validation(summary: "max_retry_count must be a non-negative integer")}}

Expand All @@ -611,6 +618,10 @@ defmodule Sequin.Transforms do
"consumer_start" ->
{:cont, {:ok, acc}}

# Ignore until it is properly implemented
"active_backfill" ->
{:cont, {:ok, acc}}

# Ignore internal fields that might be present in the external data
ignored when ignored in ~w(id inserted_at updated_at account_id replication_slot_id sequence_id) ->
{:cont, {:ok, acc}}
Expand Down
70 changes: 70 additions & 0 deletions test/sequin_web/controllers/yaml_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
alias Sequin.Databases.PostgresDatabase
alias Sequin.Databases.Sequence
alias Sequin.Test.UnboxedRepo
alias Sequin.TestSupport.Models.Character
alias Sequin.TestSupport.ReplicationSlots

@moduletag :unboxed
Expand Down Expand Up @@ -108,6 +109,75 @@
"summary" => "Error creating database 'test-db': - database: can't be blank"
}
end

test "successfully plans configuration with wider set of fields", %{conn: conn} do

Check failure on line 113 in test/sequin_web/controllers/yaml_controller_test.exs

View workflow job for this annotation

GitHub Actions / signoff

test plan/2 successfully plans configuration with wider set of fields (SequinWeb.YamlControllerTest)
yaml = """
change_retentions:
- name: test_retention
filters: []
destination_database: sequin_test
source_database: sequin_test
actions:
- insert
- update
- delete
source_table_name: #{Character.table_name()}
source_table_schema: public
destination_table_name: sequin_events
destination_table_schema: public
databases:
- name: sequin_test
port: 5432
ssl: false
ipv6: false
hostname: localhost
pool_size: 10
username: postgres
password: '********'
database: sequin_test
slot_name: sequin_slot
use_local_tunnel: false
publication_name: characters_publication
http_endpoints:
- name: test_http_endpoint
url: http://localhost:4000/something
headers: {}
sinks:
- name: accounts_sink
status: active
table: public.#{Character.table_name()}
filters: []
destination:
port: 4222
type: nats
host: localhost
tls: false
database: sequin_test
transform: record-transform
active_backfill:
batch_size: 1
load_shedding_policy: pause_on_full
max_retry_count:
timestamp_format: iso8601
actions:
- insert
- update
- delete
group_column_names:
- id
transforms:
- name: record-transform
type: path
path: record
description: Extracts just the record from the Sequin message shape.
"""

conn = post(conn, ~p"/api/config/plan", %{yaml: yaml})

response = json_response(conn, 200)
assert %{"changes" => changes} = response
assert is_list(changes)
end
end

describe "apply/2" do
Expand Down
4 changes: 4 additions & 0 deletions test/support/models/character.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ defmodule Sequin.TestSupport.Models.Character do
timestamps(type: :naive_datetime_usec)
end

def table_name do
"Characters"
end

def quoted_table_name do
~s{"Characters"}
end
Expand Down
Loading