-
Notifications
You must be signed in to change notification settings - Fork 11
feat: migrate test infrastructure to xnet #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4475890
feat: add xnet.toml and update env files for xnet migration
neekolas d0dcf30
refactor: simplify docker-compose to use xnet network
neekolas 2e74804
refactor: rewrite dev scripts to use xnet-cli
neekolas 54321b1
fix: correct xnet-cli commands and port after experimentation
neekolas 4c91915
feat: restore custom xmtpd/gateway images in xnet.toml
neekolas 1c8f260
refactor: update XMTP node address from localhost:25556 to localhost:…
neekolas 0c41ee5
test: add selective unsubscribe, sender filtering, and unregister int…
neekolas 300188a
ci: update test workflow to use xnet-cli with v3 and v4 integration s…
neekolas c3f388c
feat: add gatewayUrl support for V4-writes integration tests
neekolas 3faebc6
ci: build xnet-cli from source branch with fixes
neekolas fd51608
ci: use Nix + Cachix to install xnet-cli
neekolas 554e994
fix: use ubuntu:24.04 base for integration tests
neekolas 1620534
fix: filter notifications by installationId in integration tests
neekolas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| DB_CONNECTION_STRING="postgres://postgres:xmtp@db:5432/postgres?sslmode=disable" | ||
| XMTP_GRPC_ADDRESS="node:5556" | ||
| XMTP_GRPC_ADDRESS="xnet-100:5050" | ||
| LOG_ENCODING=console | ||
| API_PORT="8080" | ||
| API_PORT="8080" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| DB_CONNECTION_STRING="postgres://postgres:xmtp@localhost:25432/postgres?sslmode=disable" | ||
| XMTP_GRPC_ADDRESS="localhost:25556" | ||
| XMTP_GRPC_ADDRESS="localhost:5556" | ||
| LOG_ENCODING=console | ||
| API_PORT="8080" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: "Setup xnet" | ||
| description: "Install Nix and xnet-cli for XMTP network testing" | ||
|
|
||
| inputs: | ||
| github-token: | ||
| description: "GitHub token for Nix installation" | ||
| required: true | ||
| cachix-auth-token: | ||
| description: "Cachix auth token for cache pushes" | ||
| required: false | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - uses: cachix/install-nix-action@v31 | ||
| with: | ||
| github_access_token: ${{ inputs.github-token }} | ||
| extra_nix_config: | | ||
| accept-flake-config = true | ||
| extra-trusted-public-keys = xmtp.cachix.org-1:nFPFrqLQ9kjYQKiWL7gKq6llcNEeaV4iI+Ka1F+Tmq0= | ||
| extra-substituters = https://xmtp.cachix.org | ||
| - uses: cachix/cachix-action@v16 | ||
| with: | ||
| name: xmtp | ||
| authToken: ${{ inputs.cachix-auth-token }} | ||
| - name: Install xnet-cli | ||
| shell: bash | ||
| run: ./dev/install-xnet | ||
| - name: Setup DNS | ||
| shell: bash | ||
| run: | | ||
| sudo mkdir -p /etc/systemd/resolved.conf.d | ||
| sudo tee /etc/systemd/resolved.conf.d/xmtp.conf <<EOF | ||
| [Resolve] | ||
| DNS=127.0.0.1:5354 | ||
| Domains=~xmtpd.local | ||
| EOF | ||
| sudo systemctl restart systemd-resolved | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,11 @@ | ||
| #!/bin/bash | ||
| set -eou pipefail | ||
|
|
||
| docker compose down | ||
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" | ||
| xnet() { "$SCRIPT_DIR/xnet" "$@"; } | ||
|
|
||
| docker compose down -v | ||
|
|
||
| if docker network inspect xnet >/dev/null 2>&1; then | ||
| xnet delete | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| XNET_COMMIT="001ce0a76a8727319e3209b1bd509792388d67d2" | ||
| XNET_FLAKE="github:xmtp/libxmtp/${XNET_COMMIT}" | ||
| XNET_REF="${XNET_FLAKE}#xnet-cli" | ||
| XNET_LOCKED_PREFIX="${XNET_FLAKE}" | ||
|
|
||
| have_command() { command -v "$1" >/dev/null 2>&1; } | ||
|
|
||
| ensure_nix_profile_path() { | ||
| local nix_path | ||
|
|
||
| for nix_path in \ | ||
| "$HOME/.nix-profile/bin" \ | ||
| "$HOME/.local/state/nix/profile/bin" \ | ||
| "/nix/var/nix/profiles/default/bin" | ||
| do | ||
| if [[ -d "$nix_path" ]] && [[ ":$PATH:" != *":$nix_path:"* ]]; then | ||
| PATH="$nix_path:$PATH" | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| ensure_nix_profile_path | ||
|
|
||
| if ! have_command nix; then | ||
| echo "Nix is required to install xnet-cli." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if nix profile list --json --no-pretty | jq -e --arg locked_prefix "$XNET_LOCKED_PREFIX" ' | ||
| .elements | ||
| | [to_entries[] | ||
| | select( | ||
| .value.active | ||
| and ((.value.attrPath // "") | endswith(".xnet-cli")) | ||
| ) | ||
| ] as $xnet_entries | ||
| | ($xnet_entries | length) > 0 | ||
| and all( | ||
| $xnet_entries[]; | ||
| ((.value.url // "") | startswith($locked_prefix)) | ||
| ) | ||
| ' >/dev/null; then | ||
| echo "xnet-cli already matches pinned commit $XNET_COMMIT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Installing xnet-cli from $XNET_REF" | ||
| nix profile remove xnet-cli >/dev/null 2>&1 || true | ||
| nix --accept-flake-config profile add "$XNET_REF" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,47 @@ | ||
| #!/bin/bash | ||
| set -eou pipefail | ||
|
|
||
| docker compose up -d node | ||
| docker compose up integration | ||
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| # message-source controls both how the XMTP client writes messages and what | ||
| # listener topology the notification server is expected to exercise: | ||
| # - v3-direct: | ||
| # client writes directly to node-go and the notification server listens to the | ||
| # same v3 node with the v3 listener. | ||
| # - v4-with-migrator: | ||
| # client writes to node-go, the migrator forwards those messages into xmtpd, | ||
| # and the notification server listens to xmtpd with the v4 listener. | ||
| # - v4-direct: | ||
| # client writes to xmtpd after cutover + d14n activation, and the | ||
| # notification server also listens directly to xmtpd with the v4 listener. | ||
| MESSAGE_SOURCE="${1:-v3-direct}" | ||
| source "$SCRIPT_DIR/xnet-env" "$MESSAGE_SOURCE" | ||
|
|
||
| "$SCRIPT_DIR/down" | ||
| "$SCRIPT_DIR/up" "$MESSAGE_SOURCE" | ||
|
|
||
| echo "message-source=$MESSAGE_SOURCE listener_type=$LISTENER_TYPE listener_address=$XMTP_LISTENER_ADDRESS migrator_running=$XMTP_MIGRATOR_RUNNING xmtp_client_url=$XMTP_CLIENT_URL xmtp_gateway_url=${XMTP_GATEWAY_URL:-<unset>}" | ||
|
|
||
| docker compose build -q notification_server integration | ||
|
|
||
| # Get CoreDNS container IP for DNS resolution inside containers | ||
| COREDNS_IP=$(docker inspect xnet-coredns -f '{{.NetworkSettings.Networks.xnet.IPAddress}}') | ||
| export COREDNS_IP | ||
|
|
||
| docker compose up -d notification_server | ||
| notification_server_container_id="$(docker compose ps -q notification_server)" | ||
| for _ in $(seq 1 30); do | ||
| if [ "$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' "$notification_server_container_id")" = "healthy" ]; then | ||
| break | ||
| fi | ||
| sleep 1 | ||
| done | ||
|
|
||
| if [ "$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' "$notification_server_container_id")" != "healthy" ]; then | ||
| echo "notification_server did not become healthy for message-source $MESSAGE_SOURCE" >&2 | ||
| docker compose logs notification_server >&2 || true | ||
| exit 1 | ||
| fi | ||
|
|
||
| docker compose run --rm --use-aliases integration npx vitest run | ||
| exit $? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,89 @@ | ||
| #!/bin/bash | ||
| set -eou pipefail | ||
|
|
||
| docker compose up -d node | ||
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" | ||
| ensure_nix_profile_path() { | ||
| local nix_path | ||
|
|
||
| for nix_path in \ | ||
| "$HOME/.nix-profile/bin" \ | ||
| "$HOME/.local/state/nix/profile/bin" \ | ||
| "/nix/var/nix/profiles/default/bin" | ||
| do | ||
| if [[ -d "$nix_path" ]] && [[ ":$PATH:" != *":$nix_path:"* ]]; then | ||
| PATH="$nix_path:$PATH" | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| ensure_xnet_cli() { | ||
| "$SCRIPT_DIR/install-xnet" | ||
| ensure_nix_profile_path | ||
|
|
||
| if ! command -v xnet-cli >/dev/null 2>&1; then | ||
| echo "xnet-cli is required. Install Nix and rerun ./dev/up, or install xnet-cli manually." >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| xnet() { "$SCRIPT_DIR/xnet" "$@"; } | ||
| is_node_running() { docker inspect xnet-100 --format '{{.State.Running}}' 2>/dev/null | grep -q '^true$'; } | ||
| is_node_registered() { xnet addresses 2>&1 | grep -q "xnet-100"; } | ||
| is_v3_node_running() { docker inspect xnet-node --format '{{.State.Running}}' 2>/dev/null | grep -q '^true$'; } | ||
|
|
||
| MESSAGE_SOURCE="${1:-v3-direct}" | ||
| source "$SCRIPT_DIR/xnet-env" "$MESSAGE_SOURCE" | ||
|
|
||
| ensure_xnet_cli | ||
| xnet up --paused | ||
|
|
||
| if [[ "$XMTP_CLIENT_URL" == "http://xnet-node:5556" ]]; then | ||
| for _ in $(seq 1 30); do | ||
| if is_v3_node_running; then | ||
| break | ||
| fi | ||
| sleep 1 | ||
| done | ||
|
|
||
| if ! is_v3_node_running; then | ||
| echo "xnet-node did not become ready for message-source $MESSAGE_SOURCE" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [[ "$XMTP_NEEDS_XMTPD_NODE" == "true" ]]; then | ||
| xnet node add --migrator | ||
|
|
||
| if [[ "$XMTP_SHOULD_ENABLE_D14N" == "true" ]]; then | ||
| xnet migrate | ||
| xnet activate-d14n | ||
| fi | ||
|
|
||
| for _ in $(seq 1 30); do | ||
| if is_node_running; then | ||
| break | ||
| fi | ||
| sleep 1 | ||
| done | ||
|
|
||
| if ! is_node_running; then | ||
| echo "xnet-100 did not become ready for message-source $MESSAGE_SOURCE" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$XMTP_SHOULD_ENABLE_D14N" == "true" ]]; then | ||
| for _ in $(seq 1 90); do | ||
| if is_node_registered; then | ||
| break | ||
| fi | ||
| sleep 1 | ||
| done | ||
|
|
||
| if ! is_node_registered; then | ||
| echo "xnet-100 did not become registered for message-source $MESSAGE_SOURCE" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| docker compose up -d db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| set -eou pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| xnet-cli -c "$SCRIPT_DIR/../xnet.toml" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/bin/bash | ||
|
|
||
| MESSAGE_SOURCE="${1:-v3-direct}" | ||
|
|
||
| case "$MESSAGE_SOURCE" in | ||
| v3-direct) | ||
| export MESSAGE_SOURCE | ||
| export LISTENER_TYPE="v3" | ||
| export XMTP_LISTENER_ADDRESS="xnet-node:5556" | ||
| export XMTP_CLIENT_URL="http://xnet-node:5556" | ||
| export XMTP_GATEWAY_URL="" | ||
| export XMTP_NEEDS_XMTPD_NODE="false" | ||
| export XMTP_SHOULD_ENABLE_D14N="false" | ||
| export XMTP_MIGRATOR_RUNNING="false" | ||
| ;; | ||
| v4-with-migrator) | ||
| export MESSAGE_SOURCE | ||
| export LISTENER_TYPE="v4" | ||
| export XMTP_LISTENER_ADDRESS="xnet-100:5050" | ||
| export XMTP_CLIENT_URL="http://xnet-node:5556" | ||
| export XMTP_GATEWAY_URL="" | ||
| export XMTP_NEEDS_XMTPD_NODE="true" | ||
| export XMTP_SHOULD_ENABLE_D14N="false" | ||
| export XMTP_MIGRATOR_RUNNING="true" | ||
| ;; | ||
| v4-direct) | ||
| export MESSAGE_SOURCE | ||
| export LISTENER_TYPE="v4" | ||
| export XMTP_LISTENER_ADDRESS="xnet-100:5050" | ||
| export XMTP_CLIENT_URL="http://xnet-100:5050" | ||
| export XMTP_GATEWAY_URL="http://xnet-gateway:5050" | ||
| export XMTP_NEEDS_XMTPD_NODE="true" | ||
| export XMTP_SHOULD_ENABLE_D14N="true" | ||
| export XMTP_MIGRATOR_RUNNING="false" | ||
| ;; | ||
| *) | ||
| echo "Unknown message-source: $MESSAGE_SOURCE (use v3-direct, v4-with-migrator, or v4-direct)" >&2 | ||
| return 1 2>/dev/null || exit 1 | ||
| ;; | ||
| esac |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.