-
Notifications
You must be signed in to change notification settings - Fork 8
473 lines (411 loc) · 18.1 KB
/
integration-tests.yml
File metadata and controls
473 lines (411 loc) · 18.1 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
name: Integration Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch: # Allow manual trigger
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
defaults:
run:
working-directory: test/integration
jobs:
integration-tests:
name: Integration Tests
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Build seaweed-up binary
working-directory: .
run: go build -v -o seaweed-up .
- name: Create Docker network
run: |
docker network create --driver bridge --subnet 172.28.0.0/16 seaweed-up-net
- name: Start containers with docker run
run: |
# Use docker run with --cgroupns=host which is required for systemd on GitHub Actions
docker run -d \
--name seaweed-up-host1 \
--hostname host1 \
--privileged \
--cgroupns=host \
--network seaweed-up-net \
--ip 172.28.0.10 \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
geerlingguy/docker-ubuntu2204-ansible:latest
docker run -d \
--name seaweed-up-host2 \
--hostname host2 \
--privileged \
--cgroupns=host \
--network seaweed-up-net \
--ip 172.28.0.11 \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
geerlingguy/docker-ubuntu2204-ansible:latest
docker run -d \
--name seaweed-up-host3 \
--hostname host3 \
--privileged \
--cgroupns=host \
--network seaweed-up-net \
--ip 172.28.0.12 \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
geerlingguy/docker-ubuntu2204-ansible:latest
# Wait for containers to start
echo "Waiting for containers to start..."
sleep 10
echo "=== Container Status ==="
docker ps -a
# Check if containers are running
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
status=$(docker inspect -f '{{.State.Status}}' $host 2>/dev/null || echo "not found")
echo "Container $host status: $status"
if [ "$status" != "running" ]; then
echo "=== Logs for $host ==="
docker logs $host 2>&1 || true
echo "=== Inspect $host ==="
docker inspect $host 2>&1 | head -80 || true
exit 1
fi
done
# Wait for systemd to be ready in each container
echo "Waiting for systemd to initialize..."
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo "Checking systemd on $host..."
for i in {1..60}; do
status=$(docker inspect -f '{{.State.Status}}' $host 2>/dev/null || echo "not found")
if [ "$status" != "running" ]; then
echo "Container $host is not running (status: $status)"
echo "=== Container logs ==="
docker logs $host 2>&1 || true
exit 1
fi
state=$(docker exec $host systemctl is-system-running 2>/dev/null || echo "starting")
if [ "$state" = "running" ] || [ "$state" = "degraded" ]; then
echo "Systemd ready on $host (state: $state)"
break
fi
if [ $i -eq 60 ]; then
echo "Timeout waiting for systemd on $host"
echo "=== Container logs ==="
docker logs $host 2>&1 || true
echo "=== Systemd status ==="
docker exec $host systemctl status 2>&1 || true
echo "=== Journal ==="
docker exec $host journalctl -xe --no-pager 2>&1 | tail -100 || true
exit 1
fi
echo "Waiting for systemd on $host... ($i/60, state: $state)"
sleep 2
done
done
- name: Install SSH on containers
run: |
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo "Installing SSH on $host..."
docker exec $host bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y openssh-server curl netcat-openbsd"
docker exec $host bash -c "mkdir -p /run/sshd"
docker exec $host bash -c "sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config"
docker exec $host bash -c "sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config"
docker exec $host bash -c "systemctl enable ssh && systemctl start ssh"
echo "SSH installed and started on $host"
done
# Wait for SSH to be ready
echo "Waiting for SSH to be ready..."
sleep 5
for ip in 172.28.0.10 172.28.0.11 172.28.0.12; do
for j in {1..30}; do
if nc -z $ip 22 2>/dev/null; then
echo "SSH ready on $ip"
break
fi
if [ $j -eq 30 ]; then
echo "SSH not ready on $ip after 30 attempts"
exit 1
fi
sleep 1
done
done
- name: Setup SSH keys
run: |
mkdir -p .ssh
ssh-keygen -t rsa -b 2048 -f .ssh/id_rsa_test -N "" -q
# Read public key content
PUB_KEY=$(cat .ssh/id_rsa_test.pub)
# Copy public key to all hosts using docker exec (more reliable than docker cp)
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo "Setting up SSH key on $host..."
docker exec $host bash -c "mkdir -p /root/.ssh && chmod 700 /root/.ssh"
docker exec $host bash -c "echo '$PUB_KEY' > /root/.ssh/authorized_keys"
docker exec $host bash -c "chmod 600 /root/.ssh/authorized_keys && chown root:root /root/.ssh/authorized_keys"
# Verify the key was written correctly
docker exec $host bash -c "cat /root/.ssh/authorized_keys | head -c 50"
echo ""
done
- name: Verify SSH connectivity
run: |
for ip in 172.28.0.10 172.28.0.11 172.28.0.12; do
echo "Testing SSH to $ip..."
ssh -i .ssh/id_rsa_test -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 root@$ip "echo 'SSH OK to $ip'"
done
- name: Run single-node deployment test
run: |
../../seaweed-up cluster deploy test-single \
-f testdata/cluster-single.yaml \
-u root \
--identity .ssh/id_rsa_test \
--yes
# Wait for services to start
sleep 15
# Verify master is running
nc -z 172.28.0.10 9333 || (echo "Master not running" && exit 1)
echo "Master server verified running"
- name: Check cluster status
run: |
../../seaweed-up cluster status test-single || true
../../seaweed-up cluster list || true
# Note: Go integration tests are skipped in CI because they use docker-compose
# which conflicts with the network created by the shell-based tests above.
# The shell-based tests provide equivalent coverage.
- name: Save logs
if: always()
run: |
echo "=== Container Status ===" > docker-compose.log
docker ps -a >> docker-compose.log
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo "=== Logs for $host ===" >> docker-compose.log
docker logs $host >> docker-compose.log 2>&1 || true
done
echo "=== Host1 Processes ===" >> docker-compose.log
docker exec seaweed-up-host1 ps aux >> docker-compose.log 2>&1 || true
echo "=== Host1 SeaweedFS Logs ===" >> docker-compose.log
docker exec seaweed-up-host1 cat /opt/seaweed/*.log >> docker-compose.log 2>&1 || true
- name: Archive logs
if: always()
uses: actions/upload-artifact@v7
with:
name: integration-test-logs
path: test/integration/docker-compose.log
retention-days: 7
- name: Cleanup
if: always()
run: |
docker stop seaweed-up-host1 seaweed-up-host2 seaweed-up-host3 || true
docker rm seaweed-up-host1 seaweed-up-host2 seaweed-up-host3 || true
docker network rm seaweed-up-net || true
rm -rf .ssh
multi-node-test:
name: Multi-Node Deployment Test
runs-on: ubuntu-22.04
timeout-minutes: 30
needs: integration-tests # Run after single-node test
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Build seaweed-up binary
working-directory: .
run: go build -v -o seaweed-up .
- name: Create Docker network
working-directory: test/integration
run: |
docker network create --driver bridge --subnet 172.28.0.0/16 seaweed-up-net
- name: Start containers with docker run
working-directory: test/integration
run: |
# Use docker run with --cgroupns=host which is required for systemd on GitHub Actions
docker run -d \
--name seaweed-up-host1 \
--hostname host1 \
--privileged \
--cgroupns=host \
--network seaweed-up-net \
--ip 172.28.0.10 \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
geerlingguy/docker-ubuntu2204-ansible:latest
docker run -d \
--name seaweed-up-host2 \
--hostname host2 \
--privileged \
--cgroupns=host \
--network seaweed-up-net \
--ip 172.28.0.11 \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
geerlingguy/docker-ubuntu2204-ansible:latest
docker run -d \
--name seaweed-up-host3 \
--hostname host3 \
--privileged \
--cgroupns=host \
--network seaweed-up-net \
--ip 172.28.0.12 \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
geerlingguy/docker-ubuntu2204-ansible:latest
# Wait for containers to start
echo "Waiting for containers to start..."
sleep 10
echo "=== Container Status ==="
docker ps -a
# Check if containers are running
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
status=$(docker inspect -f '{{.State.Status}}' $host 2>/dev/null || echo "not found")
echo "Container $host status: $status"
if [ "$status" != "running" ]; then
echo "=== Logs for $host ==="
docker logs $host 2>&1 || true
exit 1
fi
done
# Wait for systemd to be ready in each container
echo "Waiting for systemd to initialize..."
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo "Checking systemd on $host..."
for i in {1..60}; do
status=$(docker inspect -f '{{.State.Status}}' $host 2>/dev/null || echo "not found")
if [ "$status" != "running" ]; then
echo "Container $host is not running (status: $status)"
docker logs $host 2>&1 || true
exit 1
fi
state=$(docker exec $host systemctl is-system-running 2>/dev/null || echo "starting")
if [ "$state" = "running" ] || [ "$state" = "degraded" ]; then
echo "Systemd ready on $host (state: $state)"
break
fi
if [ $i -eq 60 ]; then
echo "Timeout waiting for systemd on $host"
docker logs $host 2>&1 || true
docker exec $host journalctl -xe --no-pager 2>&1 | tail -100 || true
exit 1
fi
echo "Waiting for systemd on $host... ($i/60, state: $state)"
sleep 2
done
done
- name: Install SSH on containers
run: |
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo "Installing SSH on $host..."
docker exec $host bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y openssh-server curl netcat-openbsd"
docker exec $host bash -c "mkdir -p /run/sshd"
docker exec $host bash -c "sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config"
docker exec $host bash -c "sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config"
docker exec $host bash -c "systemctl enable ssh && systemctl start ssh"
done
sleep 5
for ip in 172.28.0.10 172.28.0.11 172.28.0.12; do
for j in {1..30}; do
if nc -z $ip 22 2>/dev/null; then
echo "SSH ready on $ip"
break
fi
sleep 1
done
done
- name: Setup SSH keys
working-directory: test/integration
run: |
mkdir -p .ssh
ssh-keygen -t rsa -b 2048 -f .ssh/id_rsa_test -N "" -q
# Read public key content
PUB_KEY=$(cat .ssh/id_rsa_test.pub)
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo "Setting up SSH key on $host..."
docker exec $host bash -c "mkdir -p /root/.ssh && chmod 700 /root/.ssh"
docker exec $host bash -c "echo '$PUB_KEY' > /root/.ssh/authorized_keys"
docker exec $host bash -c "chmod 600 /root/.ssh/authorized_keys && chown root:root /root/.ssh/authorized_keys"
done
- name: Run multi-node deployment test
working-directory: test/integration
run: |
../../seaweed-up cluster deploy test-multi \
-f testdata/cluster-multi.yaml \
-u root \
--identity .ssh/id_rsa_test \
--yes
# Debug: show systemd service status on each host
echo "=== Debugging service status ==="
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo ""
echo "========== $host =========="
echo "IP address:"
docker exec $host hostname -I 2>&1 || true
echo "Binary check:"
docker exec $host ls -la /usr/local/bin/weed 2>&1 || echo "weed binary NOT FOUND"
echo ""
echo "Systemd services:"
docker exec $host systemctl list-units 'seaweed*' --all --no-pager 2>&1 || true
echo ""
echo "Journal logs for seaweed services:"
docker exec $host journalctl -u 'seaweed*' --no-pager -n 30 2>&1 || true
done
# Give services time to initialize (volume servers need to connect to master)
echo "Waiting 30 seconds for services to fully initialize..."
sleep 30
# Show what ports are listening on each host
echo "=== Checking listening ports ==="
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo ""
echo "========== $host =========="
echo "--- weed processes ---"
docker exec $host ps aux | grep -v grep | grep weed || echo "No weed processes"
echo "--- listening ports ---"
docker exec $host ss -tlnp 2>&1 || echo "No ports"
echo "--- log directory contents ---"
docker exec $host ls -la /opt/seaweed/*/ 2>&1 || echo "No log dirs"
echo "--- recent log content ---"
docker exec $host bash -c "cat /opt/seaweed/*/*.log 2>/dev/null | tail -50" || echo "No logs"
done
# Verify services - fail if any service is not running
echo "=== Verifying services ==="
FAILED=0
nc -z 172.28.0.10 9333 && echo "Master verified on 172.28.0.10:9333" || { echo "Master NOT running"; FAILED=1; }
nc -z 172.28.0.11 8080 && echo "Volume1 verified on 172.28.0.11:8080" || { echo "Volume1 NOT running"; FAILED=1; }
nc -z 172.28.0.12 8080 && echo "Volume2 verified on 172.28.0.12:8080" || { echo "Volume2 NOT running"; FAILED=1; }
nc -z 172.28.0.10 8888 && echo "Filer verified on 172.28.0.10:8888" || { echo "Filer NOT running"; FAILED=1; }
if [ $FAILED -eq 1 ]; then
echo "Some services failed to start"
exit 1
fi
echo "All services verified running!"
- name: List clusters
working-directory: test/integration
run: ../../seaweed-up cluster list
- name: Archive logs
if: always()
working-directory: test/integration
run: |
echo "=== Container Status ===" > multi-node.log
docker ps -a >> multi-node.log
for host in seaweed-up-host1 seaweed-up-host2 seaweed-up-host3; do
echo "=== Logs for $host ===" >> multi-node.log
docker logs $host >> multi-node.log 2>&1 || true
done
- name: Upload logs
if: always()
uses: actions/upload-artifact@v7
with:
name: multi-node-test-logs
path: test/integration/multi-node.log
retention-days: 7
- name: Cleanup
if: always()
working-directory: test/integration
run: |
docker stop seaweed-up-host1 seaweed-up-host2 seaweed-up-host3 || true
docker rm seaweed-up-host1 seaweed-up-host2 seaweed-up-host3 || true
docker network rm seaweed-up-net || true
rm -rf .ssh