Repository navigation
Expand file tree
/
Copy pathdocker-compose.cross.yml
More file actions
140 lines (131 loc) · 4.33 KB
/
Copy pathdocker-compose.cross.yml
File metadata and controls
140 lines (131 loc) · 4.33 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
# Cross-implementation interop test: hs-libp2p <-> go-libp2p.
#
# Prerequisites:
# git clone --depth 1 --branch v0.48.0 https://github.com/libp2p/go-libp2p.git go-libp2p
#
# hs-libp2p speaks the unified-testing "modern" contract (uppercase env vars,
# TEST_KEY-namespaced `<TEST_KEY>_listener_multiaddr` list key: the listener
# RPUSHes and the dialer BLPOPs). The pinned go-libp2p test app is a "legacy"
# test-plans app (lowercase env vars, `listenerAddr` list). The shim-*
# services translate between the two key schemes, mirroring the Redis proxy
# unified-testing runs for legacy images. Both sides are Redis lists, so each
# shim only rewrites the key name (legacy <-> modern); the value type is
# preserved. Each dialer pulls its shim in via depends_on, and a shim idles
# after translating so it never triggers --exit-code-from's abort-on-exit
# before the dialer finishes; the dialer's own timeout bounds the run.
#
# Test 1: go-libp2p listener, hs-libp2p dialer
# docker compose -f docker-compose.cross.yml up --build --exit-code-from hs-dialer redis go-listener hs-dialer
#
# Test 2: hs-libp2p listener, go-libp2p dialer
# docker compose -f docker-compose.cross.yml up --build --exit-code-from go-dialer redis hs-listener go-dialer
#
# --exit-code-from <dialer> makes `up` return the dialer's exit code (0 on success),
# so failures are not masked when another container exits 0 first.
x-test-key: &test-key "cafe0129"
x-hs-env: &hs-env
REDIS_ADDR: "redis:6379"
TEST_KEY: *test-key
TRANSPORT: tcp
SECURE_CHANNEL: noise
MUXER: yamux
LISTENER_IP: "0.0.0.0"
x-go-env: &go-env
transport: tcp
security: noise
muxer: yamux
redis_addr: "redis:6379"
test_timeout_seconds: "180"
services:
redis:
image: redis:7-alpine
# Disable persistence so a stale listener address never survives across runs.
command: ["redis-server", "--save", "", "--appendonly", "no"]
ports:
- "6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 1s
timeout: 3s
retries: 30
# --- Test 1: go listener (legacy), hs dialer (modern) ---
go-listener:
build:
context: ./go-libp2p
dockerfile: test-plans/PingDockerfile
depends_on:
redis:
condition: service_healthy
environment:
<<: *go-env
is_dialer: "false"
# Legacy -> modern: BLPOP the go listener's address off the legacy
# `listenerAddr` list and RPUSH it under the modern namespaced key.
shim-go-to-hs:
image: redis:7-alpine
depends_on:
redis:
condition: service_healthy
environment:
TEST_KEY: *test-key
entrypoint: ["sh", "-c"]
command:
- |
ADDR=$$(redis-cli -h redis blpop listenerAddr 0 | tail -1)
if [ -z "$$ADDR" ]; then echo "shim: no listener address" >&2; exit 1; fi
redis-cli -h redis rpush "$${TEST_KEY}_listener_multiaddr" "$$ADDR"
exec tail -f /dev/null
hs-dialer:
build: .
image: hs-libp2p-interop:latest
depends_on:
redis:
condition: service_healthy
go-listener:
condition: service_started
shim-go-to-hs:
condition: service_started
environment:
<<: *hs-env
IS_DIALER: "true"
# --- Test 2: hs listener (modern), go dialer (legacy) ---
hs-listener:
build: .
image: hs-libp2p-interop:latest
depends_on:
redis:
condition: service_healthy
environment:
<<: *hs-env
IS_DIALER: "false"
# Modern -> legacy: BLPOP the hs listener's address off the modern
# namespaced list and RPUSH it onto the legacy `listenerAddr` list for
# the go dialer's BLPOP.
shim-hs-to-go:
image: redis:7-alpine
depends_on:
redis:
condition: service_healthy
environment:
TEST_KEY: *test-key
entrypoint: ["sh", "-c"]
command:
- |
ADDR=$$(redis-cli -h redis blpop "$${TEST_KEY}_listener_multiaddr" 0 | tail -1)
if [ -z "$$ADDR" ]; then echo "shim: no listener address" >&2; exit 1; fi
redis-cli -h redis rpush listenerAddr "$$ADDR"
exec tail -f /dev/null
go-dialer:
build:
context: ./go-libp2p
dockerfile: test-plans/PingDockerfile
depends_on:
redis:
condition: service_healthy
hs-listener:
condition: service_started
shim-hs-to-go:
condition: service_started
environment:
<<: *go-env
is_dialer: "true"