Skip to content

Commit

Permalink
[vax-392] Fix sysbench_ws lux and cowboy listenter shutdown in ExUnit…
Browse files Browse the repository at this point in the history
… tests (#65)
  • Loading branch information
define-null authored Nov 11, 2022
1 parent f2dc00b commit 5b8b48e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
5 changes: 3 additions & 2 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ if config_env() == :prod do
# set to the database.cluster_slug
global_cluster_id = System.fetch_env!("GLOBAL_CLUSTER_ID")

config :electric, Electric.Satellite, global_cluster_id: global_cluster_id
config :electric,
global_cluster_id: global_cluster_id

# key = :crypto.strong_rand_bytes(32) |> Base.encode64()
auth_secret_key = System.fetch_env!("SATELLITE_AUTH_SIGNING_KEY") |> Base.decode64!()
Expand All @@ -86,6 +87,6 @@ if config_env() == :prod do
provider:
{Electric.Satellite.Auth.JWT,
issuer: "electric-sql.com",
secret_key: auth_secret_key,
secret_key: Base.decode64!("AgT/MeUiP3SKzw5gC6BZKXk4t1ulnUvZy2d/O73R0sQ="),
global_cluster_id: global_cluster_id}
end
10 changes: 10 additions & 0 deletions integration_tests/single_dc/electric.exs
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,13 @@ config :electric, Electric.Replication.SQConnectors,
vaxine_connection_timeout: 5000

config :logger, backends: [:console], level: :debug

config :electric,
global_cluster_id: "fake-global-id-for-tests"

config :electric, Electric.Satellite.Auth,
provider:
{Electric.Satellite.Auth.JWT,
issuer: "dev.electric-sql.com",
secret_key: Base.decode64!("AgT/MeUiP3SKzw5gC6BZKXk4t1ulnUvZy2d/O73R0sQ="),
global_cluster_id: "fake-global-id-for-tests"}
10 changes: 10 additions & 0 deletions integration_tests/single_dc/electric_b.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ config :electric, Electric.Replication.SQConnectors,
vaxine_connection_timeout: 5000

config :logger, backends: [:console], level: :debug

config :electric, Electric.Satellite,
global_cluster_id: "fake-global-id-for-tests"

config :electric, Electric.Satellite.Auth,
provider:
{Electric.Satellite.Auth.JWT,
issuer: "dev.electric-sql.com",
secret_key: Base.decode64!("AgT/MeUiP3SKzw5gC6BZKXk4t1ulnUvZy2d/O73R0sQ="),
global_cluster_id: "fake-global-id-for-tests"}
6 changes: 5 additions & 1 deletion integration_tests/single_dc/sysbench_ws.lux
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@
[shell ws1]
[invoke log "Start WS client and start consuming data"]
[invoke start_elixir_test]
!provider = {Electric.Satellite.Auth.JWT, issuer: "dev.electric-sql.com", \
secret_key: Base.decode64!("AgT/MeUiP3SKzw5gC6BZKXk4t1ulnUvZy2d/O73R0sQ="), \
global_cluster_id: "fake-global-id-for-tests"}
?$eprompt
!Electric.Test.SatelliteWsClient.connect_and_spawn( \
[ \
{:auth, %{user_id: "5a9a8b1d-263d-4cad-90f8-9190396161d7"}}, \
{:auth, %{auth_provider: provider, user_id: "5a9a8b1d-263d-4cad-90f8-9190396161d7"}}, \
{:id, "ws1"}, \
{:sub, "0"}, \
{:auto_in_sub, true}, \
Expand Down
17 changes: 11 additions & 6 deletions test/electric/satellite/satellite_ws_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ defmodule Electric.Satellite.WsServerTest do
issuer: "electric-sql.com",
secret_key: Base.decode64!("BdvUDsCk5QbwkxI0fpEFmM/LNtFvwPZeMfHxvcOoS7s=")}

start_supervised(
{Electric.Satellite.WsServer, name: :ws_test, port: port, auth_provider: auth_provider},
restart: :temporary
)

on_exit(fn -> SchemaRegistry.clear_replicated_tables(@test_publication) end)
sup_pid =
Electric.Satellite.WsServer.start_link(
name: :ws_test,
port: port,
auth_provider: auth_provider
)

on_exit(fn ->
SchemaRegistry.clear_replicated_tables(@test_publication)
:cowboy.stop_listener(:ws_test)
end)

{:ok, auth_provider: auth_provider, port: port, global_cluster_id: global_cluster_id}
end
Expand Down

0 comments on commit 5b8b48e

Please sign in to comment.