Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
alco committed Jun 10, 2024
1 parent ef6a0f3 commit 48b807a
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 43 deletions.
17 changes: 10 additions & 7 deletions e2e/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ DOCKER_REGISTRY = europe-docker.pkg.dev/vaxine/vaxine-io

# using a realistic password for the proxy to prevent accidentally working tests
# with some default "password"
export PG_PROXY_PASSWORD?=49_G1JYY0BXWldjnA2EFxhWl
export PG_PROXY_PORT?=65432
PG_PROXY_PASSWORD?=49_G1JYY0BXWldjnA2EFxhWl
PG_PROXY_PORT?=65432

export UID=$(shell id -u)
export GID=$(shell id -g)
Expand Down Expand Up @@ -73,13 +73,16 @@ stop_electric_%:

run_electric_%:
docker run --rm \
-e LOG_LEVEL=debug \
-e AUTH_JWT_ALG=HS256 \
-e AUTH_JWT_KEY=integration-tests-signing-key-example \
-e AUTH_MODE \
-e AUTH_JWT_ALG \
-e AUTH_JWT_KEY \
-e DATABASE_URL \
-e ELECTRIC_TELEMETRY=disabled \
-e ELECTRIC_WRITE_TO_PG_MODE \
-e LOG_LEVEL \
-e LOGICAL_PUBLISHER_HOST \
-e PG_PROXY_PASSWORD \
-e LOGICAL_PUBLISHER_HOST=electric_$* \
--name electric_$* \
--name e2e_test_electric_$* \
${ELECTRIC_IMAGE}

stop_dev_env:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[doc Validate Electric's error reporting when it encounters configuration problems]
[include _shared.luxinc]

[macro match_error_prologue]
??CONFIGURATION ERROR
??The following required configuration options have invalid or missing values:
[endmacro]

[macro match_error_epilogue]
??Please review the official configuration reference at
??https://electric-sql.com/docs/api/service
??••• Shutting down •••
[endmacro]

[newshell electric]
[timeout 4]

[invoke run_electric 1]
[invoke match_error_prologue]
??* AUTH_JWT_ALG not set
??* DATABASE_URL not set
??* LOGICAL_PUBLISHER_HOST not set
??* PG_PROXY_PASSWORD not set
[invoke match_error_epilogue]

[invoke run_electric_with_env 1 "AUTH_MODE=foo DATABASE_URL=http://"]
[invoke match_error_prologue]
??* AUTH_MODE has invalid value: "foo". Must be one of ["secure", "insecure"]
??* DATABASE_URL has invalid URL scheme: "http"
[invoke match_error_epilogue]

[invoke run_electric_with_env 1 "AUTH_JWT_ALG=unknown"]
[invoke match_error_prologue]
??* AUTH_JWT_ALG has invalid value: "unknown". Must be one of [\
"HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "ES256", "ES384", "ES512"]
[invoke match_error_epilogue]

[invoke run_electric_with_env 1 "AUTH_JWT_ALG=HS256 AUTH_JWT_KEY=foo"]
[invoke match_error_prologue]
??* AUTH_JWT_KEY has to be at least 32 bytes long for HS256
[invoke match_error_epilogue]

[shell electric]
[invoke run_electric_with_env 1 "DATABASE_URL=postgresql://user:pass@invalid/db AUTH_MODE=insecure ELECTRIC_WRITE_TO_PG_MODE=direct_writes PG_PROXY_PASSWORD=foo"]
??INITIALISATION ERROR

??Failed to resolve the database domain name to an IP address.

??Double-check the value of DATABASE_URL and make sure to set
??DATABASE_USE_IPV6=true if your database is only reachable using IPv6.
??••• Shutting down •••

# [newshell electric_2]
# [invoke run_electric 2]
# ??Successfully initialized Postgres connector "postgres_1"

# [shell electric]
# [invoke run_electric 1]
# -

# ??Failed to establish replication connection to Postgres:
# ?? #{msg}
# ??
# ??Another instance of Electric appears to be connected to this database.
# ??Refer to https://github.com/electric-sql/electric/issues/971 for additional info.

# [cleanup]
# [invoke teardown]

This file was deleted.

4 changes: 2 additions & 2 deletions e2e/tests/_shared.luxinc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
!make run_electric_${n}
[endmacro]

[macro run_electric_with_env env_str]
!USER_ENV="${env_str}" make run_electric_1
[macro run_electric_with_env n env_str]
!${env_str} make run_electric_${n}
[endmacro]

[macro teardown]
Expand Down

0 comments on commit 48b807a

Please sign in to comment.