Repository navigation
Expand file tree
/
Copy pathrun-e2e-tests.sh
More file actions
executable file
·145 lines (134 loc) · 4.19 KB
/
Copy pathrun-e2e-tests.sh
File metadata and controls
executable file
·145 lines (134 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# Copyright (c) 2022-2026 Super Durable, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
keep_running=false
test_args=()
for arg in "$@"; do
case "$arg" in
--keep-running)
keep_running=true
;;
*)
test_args+=("$arg")
;;
esac
done
export DEX_INTEG_ENGINE="${DEX_INTEG_ENGINE:-zd}"
if [[ "$DEX_INTEG_ENGINE" != zd ]]; then
echo "DEX_INTEG_ENGINE must be zd" >&2
exit 2
fi
if [[ -n "${DEX_SERVER_ZD_BINARY:-}" && "$DEX_SERVER_ZD_BINARY" == */* ]]; then
DEX_SERVER_ZD_BINARY="$(cd "$(dirname "$DEX_SERVER_ZD_BINARY")" && pwd)/$(basename "$DEX_SERVER_ZD_BINARY")"
fi
dex_port="${DEX_EXAMPLES_DEX_PORT:-19811}"
web_port="${DEX_EXAMPLES_WEB_PORT:-19911}"
dex_address="127.0.0.1:${dex_port}"
log_file="/tmp/test-python-examples-e2e-services.log"
test_log="/tmp/test-python-examples-e2e.log"
test_dir=$(mktemp -d)
binary_dir=$(mktemp -d)
dexcli_pid=""
script_dir=$(cd "$(dirname "$0")" && pwd)
repo_root=$(cd "$script_dir/../.." && pwd)
entity_store_dir="$repo_root/examples/entity-store"
compose_project="dex-python-examples-e2e-$$"
entity_store_started=false
cleanup() {
status=$?
if $keep_running; then
if [[ "$status" -ne 0 ]]; then
cat "$log_file" >&2
fi
exit "$status"
fi
if [[ -n "$dexcli_pid" ]] && kill -0 "$dexcli_pid" 2>/dev/null; then
kill -TERM "$dexcli_pid"
wait "$dexcli_pid" || true
fi
if $entity_store_started; then
if ! docker compose -p "$compose_project" \
-f "$entity_store_dir/docker-compose.yml" down --volumes >>"$log_file" 2>&1; then
echo "failed to stop the Python examples entity store" >&2
fi
fi
rm -r "$test_dir" "$binary_dir"
exit "$status"
}
trap cleanup EXIT
(
cd "$script_dir/../../cli"
GOWORK=off go build -trimpath -o "$binary_dir/dexcli" ./cmd/dexcli
)
: >"$log_file"
docker compose -p "$compose_project" \
-f "$entity_store_dir/docker-compose.yml" up --detach --wait
entity_store_started=true
if [[ -z "${DEX_SERVER_ZD_BINARY:-}" ]]; then
(cd "$repo_root" && cargo build --release --locked --manifest-path server-zd/Cargo.toml -p dexzd-server --bin dex-server-zd)
DEX_SERVER_ZD_BINARY="$repo_root/server-zd/target/release/dex-server-zd"
fi
# A config file, unlike a flag, also works with an older DEX_SERVER_ZD_BINARY.
printf 'dev:\n durabilityMode: processCrashSafe\n' >"$test_dir/zd-overrides.yaml"
dev_args=(-engine zd -zd-binary "$DEX_SERVER_ZD_BINARY" -zd-data-dir "$test_dir/zd" -zd-config "$test_dir/zd-overrides.yaml")
dev_args+=(-attribute-store-config "$entity_store_dir/attribute-store.yaml")
"$binary_dir/dexcli" dev \
"${dev_args[@]}" \
-bind-address 127.0.0.1 \
-dex-port "$dex_port" \
-web-port "$web_port" \
-open=false \
>>"$log_file" 2>&1 &
dexcli_pid=$!
dex_ready=false
for _ in {1..240}; do
if nc -z 127.0.0.1 "$dex_port"; then
dex_ready=true
break
fi
if ! kill -0 "$dexcli_pid" 2>/dev/null; then
echo "dexcli exited before Dex became ready" >&2
exit 1
fi
sleep 0.25
done
if ! $dex_ready; then
echo "Dex did not become ready" >&2
exit 1
fi
cd "$script_dir"
uv sync --locked
export DEXCLI_PATH="$binary_dir/dexcli"
run_pytest() {
if ((${#test_args[@]})); then
DEX_FLOW_SERVICE_ADDRESS="$dex_address" \
uv run --frozen pytest "$@" -v "${test_args[@]}"
else
DEX_FLOW_SERVICE_ADDRESS="$dex_address" \
uv run --frozen pytest "$@" -v
fi
}
# Pull tasks for shared Flow types can reach the async Worker, idle during sync tests.
{
run_pytest tests/unit tests/integ &&
run_pytest sync-python/sync_tests/integ
} 2>&1 | tee "$test_log"
if $keep_running; then
echo ""
echo "Dex Web: http://127.0.0.1:${web_port}"
echo "dexcli: --server ${dex_address}"
echo "Press Ctrl+C to stop dexcli dev"
wait "$dexcli_pid"
fi