Repository navigation
Expand file tree
/
Copy pathrustfs-s3-compat-test.sh
More file actions
executable file
·3601 lines (3368 loc) · 171 KB
/
Copy pathrustfs-s3-compat-test.sh
File metadata and controls
executable file
·3601 lines (3368 loc) · 171 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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# rustfs-s3-compat-test.sh
# RustFS S3 compatibility test suite (backlog #2024)
#
# Runs the S3C-* cases (bucket/object/multipart/listing/versioning/lock/tags/
# lifecycle/policy/encryption/signing/conditional/errors) against a RustFS
# cluster in three topologies, in order:
# 1. single-node single-disk (vm000, /data/rustfs1/mnmd)
# 2. single-node multi-disk (vm000, /data/rustfs{1...4}/mnmd)
# 3. multi-node multi-disk (vm000+vm001+vm002, 3x4)
#
# Driven from the admin host (heal). Environment setup follows the Obsidian
# note "RustFS Environment Setup.md"; each case has an explicit pass criterion and
# reports PASS / FAIL / UNSUPPORTED with error detail on failure.
#
# Usage:
# ./rustfs-s3-compat-test.sh --all-topologies -y --package-url <deb url>
# ./rustfs-s3-compat-test.sh --topology single-single -y --version 1.0.0-rc.4-preview.1
# ./rustfs-s3-compat-test.sh --topology single-single -y --suite worm --package-url <deb url>
# ./rustfs-s3-compat-test.sh --all-topologies --dry-run
# Deep Object Lock against an already-running endpoint (no deploy):
# ./scripts/campaign/run-worm-object-lock.sh --endpoint http://127.0.0.1:9000
#
set -Eeuo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Per-run temp dir (shared runners may leave stale /tmp files owned by other users)
TEST_TMP="$(mktemp -d "${TMPDIR:-/tmp}/rustfs-test.XXXXXX")"
trap 'rm -rf "${TEST_TMP}"' EXIT
# ==================== Configuration ====================
NODES=(vm000 vm001 vm002 vm003) # hardcoded per request
SSH_USER="${RUSTFS_SSH_USER:-azureuser}"
SSH_PORT="${RUSTFS_SSH_PORT:-22}"
SSH_OPTS=(-o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new -p "${SSH_PORT}")
RUSTFS_VERSION="${RUSTFS_VERSION:-1.0.0-rc.4-preview.1}"
PACKAGE_URL="${PACKAGE_URL:-}"
ARCH="${RUSTFS_ARCH:-amd64}"
PACKAGES_DIR="/home/rustfs/packages"
PACKAGE_FILE="rustfs.deb"
PACKAGE_SHA256="${PACKAGE_SHA256:-}"
ACCESS_KEY="${RUSTFS_ACCESS_KEY:-rustfs@test}"
SECRET_KEY="${RUSTFS_SECRET_KEY:-rustfs@test}"
REGION="us-east-1"
# Test SSE-S3 master key (base64 of a 32-byte key) and a dummy notify target so
# SSE-S3 and notification-config CRUD work without external services.
SSE_S3_MASTER_KEY="${RUSTFS_SSE_S3_MASTER_KEY:-MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=}"
# Public dummy host: the outbound policy rejects loopback notify targets; only
# config CRUD is tested, delivery is not asserted.
NOTIFY_WEBHOOK_ENDPOINT="${RUSTFS_NOTIFY_WEBHOOK_ENDPOINT:-http://example.com/notify}"
RUSTFS_CONFIG_FILE="/etc/default/rustfs"
RUSTFS_SERVICE="rustfs"
RUSTFS_PACKAGE_NAME="rustfs"
RUSTFS_USER="rustfs"
RUSTFS_ADDRESS=":9000"
RUSTFS_CONSOLE_ADDRESS=":9001"
RUSTFS_CONSOLE_ENABLE=true
RUSTFS_OBS_LOGGER_LEVEL=error
RUSTFS_OBS_LOG_DIRECTORY="/var/log/rustfs/"
TOPO_SINGLE_SINGLE="single-single"
TOPO_SINGLE_MULTI="single-multi"
TOPO_MULTI_MULTI="multi-multi"
# Endpoint used by the S3 clients for each topology.
ENDPOINT_SINGLE_SINGLE="http://rustfs-node1:9000"
ENDPOINT_SINGLE_MULTI="http://rustfs-node1:9000"
ENDPOINT_MULTI_MULTI="http://rustfs-node1:9000"
# Volumes per topology (from the Obsidian setup note).
VOLUMES_SINGLE_SINGLE="/data/rustfs1/mnmd"
VOLUMES_SINGLE_MULTI="/data/rustfs{1...4}/mnmd"
VOLUMES_MULTI_MULTI="http://rustfs-node{1...4}:9000/data/rustfs{1...4}/mnmd"
SERVICE_TIMEOUT=300
POLL_INTERVAL=15
# ==================== Runtime options ====================
DRY_RUN=0
ASSUME_YES=0
KEEP_ENV=0
LOG_FILE=""
SELECTED_TOPOLOGIES=()
VALIDATION_CASE=""
VALIDATION_SELECTED_CASE=""
VALIDATION_ARTIFACTS_DIR=""
VALIDATION_CANDIDATE_MANIFEST=""
VALIDATION_TESTING_COMMIT=""
VALIDATION_OBJECT_CLEANUP_STATUS=PASS
VALIDATION_BINARY_SHA256=""
ENDPOINT=""
VOLUMES=""
S3_BULK_RESULTS_DIR="${RUSTFS_S3_BULK_RESULTS_DIR:-}"
S3_BULK_PROFILE="compatibility"
S3_BULK_KEY_SHAPE="short"
S3_BULK_KEY_BYTES=""
S3_BULK_PYTHON="${RUSTFS_S3_BULK_PYTHON:-python3}"
# ==================== Helpers ====================
log() { printf '\033[1;36m[INFO]\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m[WARN]\033[0m %s\n' "$*"; }
die() { printf '\033[1;31m[ERROR]\033[0m %s\n' "$*" >&2; exit 1; }
confirm() {
[ "${ASSUME_YES}" -eq 1 ] && return 0
printf '\033[1;33m[CONFIRM]\033[0m %s (y/N) ' "$1"
read -r answer
case "${answer}" in y|Y|yes|YES) return 0 ;; *) die "cancelled" ;; esac
}
need_cmd() {
[ "${DRY_RUN}" -eq 1 ] && return 0
command -v "$1" >/dev/null 2>&1 || die "missing command: $1 ($2); install it first"
}
build_package_url() {
local tag="${RUSTFS_VERSION#v}" asset
asset="${tag//-/.}"
printf 'https://github.com/rustfs/rustfs/releases/download/%s/rustfs_%s_%s.deb' "${tag}" "${asset}" "${ARCH}"
}
resolve_package_url() {
if [ -n "${PACKAGE_URL}" ]; then printf '%s' "${PACKAGE_URL}";
else build_package_url; fi
}
run_remote() {
local node="$1" script
script="$(cat)"
if [ "${DRY_RUN}" -eq 1 ]; then
log "DRY-RUN: ssh ${SSH_USER}@${node} <<'REMOTE'"
printf '%s\n' "${script}" | sed 's/^/ | /'
return 0
fi
ssh "${SSH_OPTS[@]}" "${SSH_USER}@${node}" 'bash -s' <<<"${script}"
}
# run_remote_all_of <node>... — run the stdin script on the given nodes in
# parallel; nonzero if any node fails (like run_remote_all but for a subset,
# e.g. only the nodes of the current topology).
run_remote_all_of() {
local nodes=("$@") script pids=() i=0 fail=0
script="$(cat)"
for node in "${nodes[@]}"; do
if [ "${DRY_RUN}" -eq 1 ]; then
log "DRY-RUN: ssh ${SSH_USER}@${node} <<'REMOTE'"
printf '%s\n' "${script}" | sed 's/^/ | /'
else
( ssh "${SSH_OPTS[@]}" "${SSH_USER}@${node}" 'bash -s' <<<"${script}" ) &
pids[$i]=$!; i=$((i+1))
fi
done
for pid in "${pids[@]}"; do wait "${pid}" || fail=1; done
return "${fail}"
}
run_remote_all() {
local script pids=() i=0 fail=0
script="$(cat)"
for node in "${NODES[@]}"; do
if [ "${DRY_RUN}" -eq 1 ]; then
log "DRY-RUN: ssh ${SSH_USER}@${node} <<'REMOTE'"
printf '%s\n' "${script}" | sed 's/^/ | /'
else
( ssh "${SSH_OPTS[@]}" "${SSH_USER}@${node}" 'bash -s' <<<"${script}" ) &
pids[$i]=$!; i=$((i+1))
fi
done
if [ "${#pids[@]}" -gt 0 ]; then
for pid in "${pids[@]}"; do wait "${pid}" || fail=1; done
fi
[ "${fail}" -eq 0 ] || die "one or more nodes failed"
}
wait_service_active() {
local node="$1" waited=0
[ "${DRY_RUN}" -eq 1 ] && { log "DRY-RUN: wait ${RUSTFS_SERVICE} active on ${node}"; return 0; }
while [ "${waited}" -lt "${SERVICE_TIMEOUT}" ]; do
if ssh "${SSH_OPTS[@]}" "${SSH_USER}@${node}" "systemctl is-active --quiet ${RUSTFS_SERVICE}" 2>/dev/null; then
log "${node}: ${RUSTFS_SERVICE} is active"; return 0
fi
sleep 5; waited=$((waited+5))
done
die "${node}: timed out waiting for ${RUSTFS_SERVICE} (${SERVICE_TIMEOUT}s)"
}
rustfs_config_body() {
local volumes="$1"
cat <<EOF
RUSTFS_ACCESS_KEY=${ACCESS_KEY}
RUSTFS_SECRET_KEY=${SECRET_KEY}
RUSTFS_VOLUMES="${volumes}"
RUSTFS_SSE_S3_MASTER_KEY=${SSE_S3_MASTER_KEY}
RUSTFS_NOTIFY_ENABLE=true
RUSTFS_NOTIFY_WEBHOOK_ENABLE_PRIMARY=true
RUSTFS_NOTIFY_WEBHOOK_ENDPOINT_PRIMARY=${NOTIFY_WEBHOOK_ENDPOINT}
RUSTFS_ADDRESS="${RUSTFS_ADDRESS}"
RUSTFS_CONSOLE_ADDRESS="${RUSTFS_CONSOLE_ADDRESS}"
RUSTFS_CONSOLE_ENABLE=${RUSTFS_CONSOLE_ENABLE}
RUSTFS_OBS_LOGGER_LEVEL=${RUSTFS_OBS_LOGGER_LEVEL}
RUSTFS_OBS_LOG_DIRECTORY="${RUSTFS_OBS_LOG_DIRECTORY}"
EOF
}
write_rustfs_config() {
local node="$1" volumes="$2" body
body="$(rustfs_config_body "${volumes}")"
log "${node}: writing config ${RUSTFS_CONFIG_FILE} (volumes=${volumes})"
{
printf 'set -euo pipefail\n'
printf 'SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO="sudo -n"\n'
printf 'if [ -f %s ]; then ${SUDO} cp -a %s %s.bak.$(date +%%Y%%m%%d%%H%%M%%S); fi\n' "${RUSTFS_CONFIG_FILE}" "${RUSTFS_CONFIG_FILE}" "${RUSTFS_CONFIG_FILE}"
printf '%s tee %s >/dev/null <<RUSTFS_EOF\n' '${SUDO}' "${RUSTFS_CONFIG_FILE}"
printf '%s' "${body}"
printf '\nRUSTFS_EOF\n'
printf '${SUDO} systemctl daemon-reload\n'
} | run_remote "${node}"
}
service_action() {
local action="$1" node="$2"
log "${node}: systemctl ${action} ${RUSTFS_SERVICE}"
[ "${DRY_RUN}" -eq 1 ] && return 0
ssh "${SSH_OPTS[@]}" "${SSH_USER}@${node}" \
"if [ \"\$(id -u)\" -ne 0 ]; then sudo -n systemctl ${action} ${RUSTFS_SERVICE}; else systemctl ${action} ${RUSTFS_SERVICE}; fi" \
|| die "${node}: systemctl ${action} failed"
}
start_and_wait_nodes() {
local nodes=("$@") pids=() i=0 fail=0
for node in "${nodes[@]}"; do service_action start "${node}" & pids[$i]=$!; i=$((i+1)); done
if [ "${#pids[@]}" -gt 0 ]; then
for pid in "${pids[@]}"; do wait "${pid}" || fail=1; done
fi
[ "${fail}" -eq 0 ] || die "systemctl start failed on one or more nodes"
for node in "${nodes[@]}"; do wait_service_active "${node}"; done
}
# Clean a node: purge rustfs + remove data dirs (from the setup note's cleanup).
cleanup_node() {
local node="$1"
log "cleanup: purge ${RUSTFS_PACKAGE_NAME} and remove data dirs on ${node}"
{
printf 'set -euo pipefail\n'
printf 'SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO="sudo -n"\n'
printf '${SUDO} systemctl stop %s 2>/dev/null || true\n' "${RUSTFS_SERVICE}"
printf 'if ${SUDO} dpkg -l %s 2>/dev/null | grep -q "^ii"; then ${SUDO} dpkg -P %s; fi\n' "${RUSTFS_PACKAGE_NAME}" "${RUSTFS_PACKAGE_NAME}"
printf 'for i in 1 2 3 4; do ${SUDO} rm -rf /data/rustfs${i}/mnmd; done\n'
printf '${SUDO} rm -rf /var/log/rustfs\n'
} | run_remote "${node}"
}
# Ensure volume dirs exist with the service user as owner.
ensure_volume_dirs() {
local node="$1" volumes="$2" dirs=() d
while IFS= read -r d; do dirs+=("${d}"); done < <(volume_dirs "${volumes}" | sort -u)
log "${node}: ensuring data dirs (${dirs[*]})"
{
printf 'set -euo pipefail\n'
printf 'SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO="sudo -n"\n'
printf 'id -u %s >/dev/null 2>&1 || ${SUDO} useradd -r -s /bin/false -d /opt/%s %s\n' "${RUSTFS_USER}" "${RUSTFS_USER}" "${RUSTFS_USER}"
for d in "${dirs[@]}"; do
printf '${SUDO} mkdir -p %s\n' "${d}"
printf '${SUDO} chown -R %s:%s %s\n' "${RUSTFS_USER}" "${RUSTFS_USER}" "${d}"
done
} | run_remote "${node}"
}
# Expand a volume expression's {N...M} ranges (path part) into local paths.
volume_dirs() {
local volumes="$1" expr path prefix suffix i start end
for expr in ${volumes}; do
path="${expr#*://}"; path="${path#*/}"; path="/${path}"
if [[ "${path}" =~ \{([0-9]+)\.\.\.([0-9]+)\} ]]; then
start="${BASH_REMATCH[1]}"; end="${BASH_REMATCH[2]}"
prefix="${path%%\{*}"; suffix="${path#*\}}"
for ((i=start; i<=end; i++)); do printf '%s%s%s\n' "${prefix}" "${i}" "${suffix}"; done
else
printf '%s\n' "${path}"
fi
done
}
# ==================== Topology / environment ====================
resolve_topology() {
case "$1" in
"${TOPO_SINGLE_SINGLE}") ENDPOINT="${ENDPOINT_SINGLE_SINGLE}"; VOLUMES="${VOLUMES_SINGLE_SINGLE}"; return 0 ;;
"${TOPO_SINGLE_MULTI}") ENDPOINT="${ENDPOINT_SINGLE_MULTI}"; VOLUMES="${VOLUMES_SINGLE_MULTI}"; return 0 ;;
"${TOPO_MULTI_MULTI}") ENDPOINT="${ENDPOINT_MULTI_MULTI}"; VOLUMES="${VOLUMES_MULTI_MULTI}"; return 0 ;;
*) die "unknown topology: $1 (single-single|single-multi|multi-multi)" ;;
esac
}
topology_nodes() {
case "$1" in
"${TOPO_SINGLE_SINGLE}"|"${TOPO_SINGLE_MULTI}") printf '%s' "${NODES[0]}" ;;
*) printf '%s' "${NODES[*]}" ;;
esac
}
env_setup() {
local topo="$1" nodes_str nodes=() url script
resolve_topology "${topo}"
read -r -a nodes <<<"$(topology_nodes "${topo}")"
url="$(resolve_package_url)"
log "environment setup: topology=${topo} nodes=${nodes[*]} endpoint=${ENDPOINT}"
# Clean slate on all three nodes (even if only some are used by this topology).
for node in "${NODES[@]}"; do cleanup_node "${node}"; done
# Download the package on the nodes used by this topology.
script="$(cat <<EOF
set -euo pipefail
SUDO=""; [ "\$(id -u)" -ne 0 ] && SUDO="sudo -n"
\${SUDO} mkdir -p "${PACKAGES_DIR}"
curl -fSL --retry 3 -o "/tmp/${PACKAGE_FILE}" "${url}"
\${SUDO} install -m 0644 "/tmp/${PACKAGE_FILE}" "${PACKAGES_DIR}/${PACKAGE_FILE}"
\${SUDO} rm -f "/tmp/${PACKAGE_FILE}"
if [ -n "${PACKAGE_SHA256}" ]; then
echo "${PACKAGE_SHA256} ${PACKAGES_DIR}/${PACKAGE_FILE}" | sha256sum -c - || exit 1
fi
ls -lh "${PACKAGES_DIR}/${PACKAGE_FILE}"
EOF
)"
printf '%s\n' "${script}" | run_remote_all
# Install on the nodes used by this topology.
script="$(cat <<'EOF'
set -euo pipefail
SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO="sudo -n"
${SUDO} dpkg -i --force-confold /home/rustfs/packages/rustfs.deb
${SUDO} systemctl daemon-reload
EOF
)"
for node in "${nodes[@]}"; do printf '%s\n' "${script}" | run_remote "${node}"; done
# Write config + dirs on the nodes used by this topology.
for node in "${nodes[@]}"; do
write_rustfs_config "${node}" "${VOLUMES}"
ensure_volume_dirs "${node}" "${VOLUMES}"
done
start_and_wait_nodes "${nodes[@]}"
if [ "${DRY_RUN}" -eq 0 ]; then
# Wait for the S3 endpoint to answer.
local waited=0
while [ "${waited}" -lt "${SERVICE_TIMEOUT}" ]; do
if curl -fsS --max-time 5 "${ENDPOINT}/minio/health/live" >/dev/null 2>&1; then
log "S3 endpoint ready: ${ENDPOINT}"; break
fi
sleep 5; waited=$((waited+5))
done
[ "${waited}" -lt "${SERVICE_TIMEOUT}" ] || die "S3 endpoint ${ENDPOINT} not ready"
# rc alias (named "local" to match the backlog #2024 table) and AWS env.
rc alias set local "${ENDPOINT}" "${ACCESS_KEY}" "${SECRET_KEY}" >/dev/null 2>&1 \
|| die "rc alias set failed for ${ENDPOINT}"
export AWS_ACCESS_KEY_ID="${ACCESS_KEY}"
export AWS_SECRET_ACCESS_KEY="${SECRET_KEY}"
export AWS_DEFAULT_REGION="${REGION}"
export AWS_EC2_METADATA_DISABLED=true
log "rc alias 'local' -> ${ENDPOINT}; aws env configured (region ${REGION})"
fi
}
env_teardown() {
local topo="$1" nodes_str nodes=() failed=0 node
read -r -a nodes <<<"$(topology_nodes "${topo}")"
log "environment teardown: ${topo}"
for node in "${NODES[@]}"; do cleanup_node "${node}" || failed=1; done
return "${failed}"
}
# ==================== Server-domain / virtual-hosted-style helpers ====================
# Topology currently under test (set by main; needed by cases that touch
# every node of the topology, like S3C-1006's config restart).
CURRENT_TOPOLOGY=""
# Append RUSTFS_SERVER_DOMAINS to the config file on every topology node and
# restart the service. Empty arg removes the line (restore). The restart
# preserves the data dirs, so buckets survive; the caller must wait for the
# endpoint again if it needs readiness.
set_server_domains() {
local domains="$1" nodes=() line
read -r -a nodes <<<"$(topology_nodes "${CURRENT_TOPOLOGY}")"
if [ -n "${domains}" ]; then line="RUSTFS_SERVER_DOMAINS=\"${domains}\""; fi
log "setting RUSTFS_SERVER_DOMAINS='${domains}' on ${nodes[*]} (restart)"
{
printf 'set -euo pipefail\n'
printf 'SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO="sudo -n"\n'
printf '${SUDO} sed -i "/^RUSTFS_SERVER_DOMAINS=/d" %s\n' "${RUSTFS_CONFIG_FILE}"
if [ -n "${domains}" ]; then
# Appended via heredoc + tee: the value contains spaces and colons, and
# sudo cannot redirect, so sed append and >> are both awkward here.
printf '${SUDO} tee -a %s >/dev/null <<"EOF_DOMAINS"\n%s\nEOF_DOMAINS\n' "${RUSTFS_CONFIG_FILE}" "${line}"
fi
printf '${SUDO} systemctl restart %s\n' "${RUSTFS_SERVICE}"
} | run_remote_all_of "${nodes[@]}" || { echo "failed to set RUSTFS_SERVER_DOMAINS"; return 1; }
# The overlap crash (#7042) kills the process within ~1s of start, long
# before systemd gives up, so poll for real readiness, not just "active".
local waited=0 node
sleep 3
while [ "${waited}" -lt "${SERVICE_TIMEOUT}" ]; do
local ready=1
for node in "${nodes[@]}"; do
ssh "${SSH_OPTS[@]}" "${SSH_USER}@${node}" "systemctl is-active --quiet ${RUSTFS_SERVICE}" 2>/dev/null || ready=0
done
if [ "${ready}" -eq 1 ] && curl -fsS --max-time 5 "${ENDPOINT}/minio/health/live" >/dev/null 2>&1; then
log "endpoint ready with RUSTFS_SERVER_DOMAINS='${domains}'"
return 0
fi
sleep 5; waited=$((waited+5))
done
echo "endpoint not ready after RUSTFS_SERVER_DOMAINS='${domains}' restart (waited ${waited}s)"
return 1
}
# Like s3_signed_curl but sends a virtual-hosted-style Host header (<bucket>
# .<domain>[:port]) so the server must resolve the bucket from the host, not
# the path. Prints the HTTP status code; body lands in ${TEST_TMP}/curl.out.
vhost_curl() {
local vhost="$1" method="$2" path="$3"
local host_port amz_date date_stamp canonical_headers signed_headers
local canonical_request string_to_sign scope k_date k_region k_service k_signing signature
local p="${path%%\?*}" q="${path#*\?}"
[ "${q}" = "${path}" ] && q=""
host_port="${ENDPOINT#*://}"
amz_date="$(date -u +%Y%m%dT%H%M%SZ)"
date_stamp="${amz_date:0:8}"
canonical_headers="host:${vhost}
x-amz-content-sha256:UNSIGNED-PAYLOAD
x-amz-date:${amz_date}
"
signed_headers="host;x-amz-content-sha256;x-amz-date"
canonical_request="${method}
${p}
${q}
${canonical_headers}
${signed_headers}
UNSIGNED-PAYLOAD"
scope="${date_stamp}/${REGION}/s3/aws4_request"
string_to_sign="AWS4-HMAC-SHA256
${amz_date}
${scope}
$(printf '%s' "${canonical_request}" | openssl dgst -sha256 -hex 2>/dev/null | awk '{print $NF}')"
k_date="$(printf '%s' "${date_stamp}" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$(printf 'AWS4%s' "${SECRET_KEY}" | od -An -vtx1 | tr -d ' \n')" -hex 2>/dev/null | awk '{print $NF}')"
k_region="$(printf '%s' "${REGION}" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:${k_date}" -hex 2>/dev/null | awk '{print $NF}')"
k_service="$(printf '%s' "s3" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:${k_region}" -hex 2>/dev/null | awk '{print $NF}')"
k_signing="$(printf '%s' "aws4_request" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:${k_service}" -hex 2>/dev/null | awk '{print $NF}')"
signature="$(printf '%s' "${string_to_sign}" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:${k_signing}" -hex 2>/dev/null | awk '{print $NF}')"
curl -s -o "${TEST_TMP}/curl.out" -w '%{http_code}' \
-H "Host: ${vhost}" \
-H "x-amz-content-sha256: UNSIGNED-PAYLOAD" \
-H "x-amz-date: ${amz_date}" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=${ACCESS_KEY}/${scope}, SignedHeaders=${signed_headers}, Signature=${signature}" \
-X "${method}" "http://${host_port}${path}"
}
# ==================== Test harness ====================
PASS=0; FAIL=0; UNSUPPORTED=0; SCHEDULED=0
FAILED_TESTS=()
# Comma-separated case ids. Empty runs the whole suite. --suite worm sets
# S3C-602..605 so a campaign can select deep Object Lock without a new harness.
SELECTED_CASES=""
# run_test <id> <name> <function>
run_test() {
local id="$1" name="$2" fn="$3" out rc
if [ -n "${SELECTED_CASES:-}" ]; then
case ",${SELECTED_CASES:-}," in
*",${id},"*) ;;
*) return 0 ;;
esac
fi
SCHEDULED=$((SCHEDULED+1))
if [ "${DRY_RUN}" -eq 1 ]; then
printf ' [DRY-RUN] %s %s\n' "${id}" "${name}"
return 0
fi
printf '\n--- %s %s ---\n' "${id}" "${name}"
if "${fn}" > "${TEST_TMP}/test.out" 2>&1; then
PASS=$((PASS+1)); printf '\033[1;32m[PASS]\033[0m %s %s\n' "${id}" "${name}"
else
rc=$?
if [ "${rc}" -eq 2 ]; then
UNSUPPORTED=$((UNSUPPORTED+1)); printf '\033[1;33m[UNSUPPORTED]\033[0m %s %s\n' "${id}" "${name}"
else
FAIL=$((FAIL+1)); FAILED_TESTS+=("${id} ${name}")
printf '\033[1;31m[FAIL]\033[0m %s %s\n' "${id}" "${name}"
sed 's/^/ | /' "${TEST_TMP}/test.out" | tail -40
fi
fi
}
validation_write_evidence() {
local evidence_dir="${VALIDATION_ARTIFACTS_DIR}/evidence/${VALIDATION_CASE}"
local item
mkdir -p "${evidence_dir}"
cp "${TEST_TMP}/test.out" "${evidence_dir}/test.log"
if [ "${VALIDATION_CASE}" = "s3.basic-object-round-trip" ]; then
for item in validation-put.json validation-head.json validation-list.json validation-missing.txt; do
if [ -f "${TEST_TMP}/${item}" ]; then cp "${TEST_TMP}/${item}" "${evidence_dir}/${item}"; fi
done
fi
}
validation_write_result() {
local verdict="$1" reason="$2" cleanup_status="$3"
local result_file="${VALIDATION_ARTIFACTS_DIR}/cases/${VALIDATION_CASE}.json"
local args=(
"${SCRIPT_DIR}/scripts/validation_result.py"
--case-id "${VALIDATION_CASE}"
--profile "single-1disk"
--result-file "${result_file}"
--verdict "${verdict}"
--cleanup-status "${cleanup_status}"
)
if [ -n "${reason}" ]; then args+=(--reason "${reason}"); fi
if [ "${verdict}" != RUNNING ]; then
[ -n "${VALIDATION_CANDIDATE_MANIFEST}" ] || die "validation result requires --candidate-manifest"
[ -n "${VALIDATION_TESTING_COMMIT}" ] || die "validation result requires --testing-commit"
args+=(
--candidate-manifest "${VALIDATION_CANDIDATE_MANIFEST}"
--rc-bin "$(command -v rc)"
--testing-commit "${VALIDATION_TESTING_COMMIT}"
--binary-sha256 "${VALIDATION_BINARY_SHA256}"
)
args+=(--evidence "evidence/${VALIDATION_CASE}/test.log")
fi
if [ "${verdict}" = PASS ]; then
if [ "${VALIDATION_CASE}" = "s3.basic-object-round-trip" ]; then
local item
for item in validation-put.json validation-head.json validation-list.json validation-missing.txt; do
args+=(--evidence "evidence/${VALIDATION_CASE}/${item}")
done
fi
fi
python3 "${args[@]}"
}
# rc helper: capture output + exit code. rc exit 7 = gated/unsupported.
rc_run() {
# usage: rc_run <args...>; sets RC_OUT, RC_CODE
RC_OUT="$(rc "$@" 2>&1)"; RC_CODE=$?
}
assert_rc_ok() {
if [ "${RC_CODE}" -eq 7 ]; then echo "rc gated (exit 7): $*"; return 2; fi
[ "${RC_CODE}" -eq 0 ] || { echo "rc failed (exit ${RC_CODE}): $*"; echo "${RC_OUT}"; return 1; }
}
assert_rc_code() {
local expected="$1"; shift
if [ "${RC_CODE}" -eq 7 ]; then echo "rc gated (exit 7): $*"; return 2; fi
[ "${RC_CODE}" -eq "${expected}" ] || { echo "rc exit ${RC_CODE}, expected ${expected}: $*"; echo "${RC_OUT}"; return 1; }
}
# aws helper: capture stdout+stderr and http status is not directly available;
# rely on aws exit code and output. Sets AWS_OUT, AWS_CODE.
aws_run() {
AWS_OUT="$(aws --endpoint-url "${ENDPOINT}" --region "${REGION}" "$@" 2>&1)"; AWS_CODE=$?
}
assert_aws_ok() {
[ "${AWS_CODE}" -eq 0 ] || { echo "aws failed (exit ${AWS_CODE}): $*"; echo "${AWS_OUT}"; return 1; }
}
assert_aws_fails_with() {
# $1: expected error substring
local needle="$1"; shift
[ "${AWS_CODE}" -ne 0 ] || { echo "aws unexpectedly succeeded: $*"; return 1; }
printf '%s' "${AWS_OUT}" | grep -qiE "${needle}" \
|| { echo "aws error did not contain '${needle}': ${AWS_OUT}"; return 1; }
}
# SigV4-signed raw HTTP request (for cases aws CLI validates client-side, or
# when we need custom headers such as conditional writes). Uses the S3
# UNSIGNED-PAYLOAD marker. Prints the HTTP status code.
# usage: s3_signed_curl <method> <path> [-H <header>...] [--data <file>] [--presign]
s3_signed_curl() {
S3_ACCESS_KEY="${ACCESS_KEY}" S3_SECRET_KEY="${SECRET_KEY}" \
python3 - "${ENDPOINT}" "${REGION}" "${TEST_TMP}/curl.out" "$@" <<'PY_SIGN'
import argparse
import datetime
import hashlib
import hmac
import os
import subprocess
from urllib.parse import parse_qsl, quote, urlsplit
parser = argparse.ArgumentParser()
parser.add_argument('endpoint')
parser.add_argument('region')
parser.add_argument('output')
parser.add_argument('method')
parser.add_argument('path')
parser.add_argument('-H', dest='headers', action='append', default=[])
parser.add_argument('--data')
parser.add_argument('--presign', action='store_true')
args = parser.parse_args()
amz_date = datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%dT%H%M%SZ')
date_stamp = amz_date[:8]
scope = f'{date_stamp}/{args.region}/s3/aws4_request'
headers = {'host': urlsplit(args.endpoint).netloc}
if not args.presign:
headers.update({'x-amz-content-sha256': 'UNSIGNED-PAYLOAD', 'x-amz-date': amz_date})
for header in args.headers:
name, separator, value = header.partition(':')
name = name.strip().lower()
if not separator or not name or name in ('host', 'authorization', 'x-amz-date', 'x-amz-content-sha256'):
parser.error(f'invalid or signer-owned header: {name}')
value = ' '.join(value.split())
headers[name] = f'{headers[name]},{value}' if name in headers else value
signed_headers = ';'.join(sorted(headers))
canonical_headers = ''.join(f'{name}:{headers[name]}\n' for name in sorted(headers))
path, _, raw_query = args.path.partition('?')
query = parse_qsl(raw_query, keep_blank_values=True)
if args.presign:
query.extend([
('X-Amz-Algorithm', 'AWS4-HMAC-SHA256'),
('X-Amz-Credential', f'{os.environ["S3_ACCESS_KEY"]}/{scope}'),
('X-Amz-Date', amz_date),
('X-Amz-Expires', '60'),
('X-Amz-SignedHeaders', signed_headers),
])
# Sort encoded pairs and send exactly the query that is signed, including
# extension parameters and credentials containing characters such as '@'.
canonical_query = '&'.join(f'{key}={value}' for key, value in sorted(
(quote(key, safe='~'), quote(value, safe='~')) for key, value in query
))
canonical_request = '\n'.join([
args.method, path, canonical_query, canonical_headers, signed_headers, 'UNSIGNED-PAYLOAD',
])
string_to_sign = '\n'.join([
'AWS4-HMAC-SHA256', amz_date, scope, hashlib.sha256(canonical_request.encode()).hexdigest(),
])
key = ('AWS4' + os.environ['S3_SECRET_KEY']).encode()
for value in (date_stamp, args.region, 's3', 'aws4_request'):
key = hmac.new(key, value.encode(), hashlib.sha256).digest()
signature = hmac.new(key, string_to_sign.encode(), hashlib.sha256).hexdigest()
if args.presign:
canonical_query += '&X-Amz-Signature=' + signature
else:
headers['authorization'] = (
f'AWS4-HMAC-SHA256 Credential={os.environ["S3_ACCESS_KEY"]}/{scope}, '
f'SignedHeaders={signed_headers}, Signature={signature}'
)
url = args.endpoint + path + ('?' + canonical_query if canonical_query else '')
command = ['curl', '-sS', '--max-time', '30', '-o', args.output, '-w', '%{http_code}']
for name, value in headers.items():
command.extend(['-H', f'{name}: {value}'])
if args.data:
command.extend(['--data-binary', '@' + args.data])
command.extend(['-X', args.method, url])
raise SystemExit(subprocess.call(command))
PY_SIGN
}
md5_of_file() { md5sum "$1" 2>/dev/null | awk '{print $1}'; }
new_bucket() {
local b="$1"
aws_run s3api create-bucket --bucket "${b}"
assert_aws_ok || return 1
}
rm_bucket() {
local b="$1"
aws_run s3api delete-bucket --bucket "${b}" 2>/dev/null || true
}
make_test_file() {
local path="$1" size="$2"
if [ "${size}" -eq 0 ]; then : > "${path}"; else head -c "${size}" /dev/urandom > "${path}"; fi
}
results_summary() {
printf '\n========================================\n'
printf 'RESULTS: PASS=%d FAIL=%d UNSUPPORTED=%d\n' "${PASS}" "${FAIL}" "${UNSUPPORTED}"
if [ "${#FAILED_TESTS[@]}" -gt 0 ]; then
printf '\nFailed tests:\n'
for t in "${FAILED_TESTS[@]}"; do printf ' - %s\n' "${t}"; done
fi
}
TOPO_RESULTS=()
record_topology_result() {
local topo="$1"
TOPO_RESULTS+=("${topo}: PASS=${PASS} FAIL=${FAIL} UNSUPPORTED=${UNSUPPORTED}")
if [ "${#FAILED_TESTS[@]}" -gt 0 ]; then
local t
for t in "${FAILED_TESTS[@]}"; do TOPO_RESULTS+=(" - ${t}"); done
fi
}
final_summary() {
printf '\n========================================\n'
printf 'ALL TOPOLOGIES SUMMARY\n'
local line
for line in "${TOPO_RESULTS[@]}"; do printf '%s\n' "${line}"; done
printf '========================================\n'
}
# ==================== Test cases ====================
test_s3c1401() { # COPY-directive CopyObject keeps source metadata, ignores request-only fields (regression #5511)
local code
new_bucket "s3c1401-src" || return 1
new_bucket "s3c1401-dst" || return 1
make_test_file "${TEST_TMP}/s3c1401" 65536
aws_run s3api put-object --bucket "s3c1401-src" --key f --body "${TEST_TMP}/s3c1401" \
--content-type "application/x-rustfs-src" --cache-control "max-age=60" --metadata src=1
assert_aws_ok || { echo "put src failed"; return 1; }
code="$(s3_signed_curl PUT "/s3c1401-dst/f" \
-H "x-amz-copy-source: /s3c1401-src/f" \
-H "content-type: application/x-request-only" \
-H "x-amz-meta-request-only: ignored")"
[ "${code}" = "200" ] || { echo "COPY with metadata-like headers returned ${code}: $(head -c 200 "${TEST_TMP}/curl.out")"; return 1; }
aws_run s3api head-object --bucket "s3c1401-dst" --key f
assert_aws_ok || return 1
printf '%s' "${AWS_OUT}" | jq -e \
'.ContentType == "application/x-rustfs-src" and .Metadata.src == "1" and .Metadata.requestonly == null' >/dev/null \
|| { echo "COPY did not preserve source metadata / drop request-only metadata: ${AWS_OUT}"; return 1; }
rm_bucket "s3c1401-src"; rm_bucket "s3c1401-dst"
}
test_s3c1402() { # Content-Encoding: aws-chunked without decoded-content-length is a normal signed upload (regression #4962)
local code
new_bucket "s3c1402-b" || return 1
make_test_file "${TEST_TMP}/s3c1402" 65536
code="$(s3_signed_curl PUT "/s3c1402-b/f" -H "content-encoding: aws-chunked" --data "${TEST_TMP}/s3c1402")"
[ "${code}" = "200" ] || { echo "aws-chunked PUT returned ${code}: $(head -c 200 "${TEST_TMP}/curl.out")"; return 1; }
aws_run s3api head-object --bucket "s3c1402-b" --key f
assert_aws_ok || return 1
printf '%s' "${AWS_OUT}" | jq -e '.ContentLength == 65536' >/dev/null \
|| { echo "wrong stored size: ${AWS_OUT}"; return 1; }
aws_run s3api get-object --bucket "s3c1402-b" --key f "${TEST_TMP}/s3c1402-dl"
assert_aws_ok || return 1
[ "$(md5_of_file "${TEST_TMP}/s3c1402-dl")" = "$(md5_of_file "${TEST_TMP}/s3c1402")" ] \
|| { echo "content mismatch"; return 1; }
rm_bucket "s3c1402-b"
}
test_s3c1403() { # concurrent UploadPart must not fail while write quorum is met (regressions #6133 #6350)
local bucket="s3c1403-b" parts=32 psize=5242880 up_id i rc=0
local pids expected_md5 actual_md5
new_bucket "${bucket}" || return 1
aws_run s3api create-multipart-upload --bucket "${bucket}" --key big
assert_aws_ok || return 1
up_id="$(printf '%s' "${AWS_OUT}" | jq -r '.UploadId // empty')"
[ -n "${up_id}" ] || { echo "no UploadId"; return 1; }
for ((i = 1; i <= parts; i++)); do make_test_file "${TEST_TMP}/s3c1403-p${i}" "${psize}"; done
for ((i = 1; i <= parts; i++)); do
aws --endpoint-url "${ENDPOINT}" --region "${REGION}" s3api upload-part \
--bucket "${bucket}" --key big --upload-id "${up_id}" --part-number "${i}" \
--body "${TEST_TMP}/s3c1403-p${i}" >"${TEST_TMP}/s3c1403-up${i}.json" 2>&1 &
pids[${i}]=$!
done
for ((i = 1; i <= parts; i++)); do
wait "${pids[${i}]}" || { echo "part ${i} failed:"; head -c 300 "${TEST_TMP}/s3c1403-up${i}.json"; rc=1; }
done
if [ "${rc}" -ne 0 ]; then
aws_run s3api abort-multipart-upload --bucket "${bucket}" --key big --upload-id "${up_id}"
rm_bucket "${bucket}"
return 1
fi
{
printf '{"Parts":['
for ((i = 1; i <= parts; i++)); do
if [ "${i}" -gt 1 ]; then printf ','; fi
jq -c --argjson n "${i}" '{PartNumber: $n, ETag: .ETag}' "${TEST_TMP}/s3c1403-up${i}.json"
done
printf ']}'
} > "${TEST_TMP}/s3c1403-complete.json"
aws_run s3api complete-multipart-upload --bucket "${bucket}" --key big --upload-id "${up_id}" \
--multipart-upload "file://${TEST_TMP}/s3c1403-complete.json"
assert_aws_ok || { echo "complete failed: ${AWS_OUT}"; return 1; }
aws_run s3api head-object --bucket "${bucket}" --key big
assert_aws_ok || return 1
printf '%s' "${AWS_OUT}" | jq -e --argjson n "$((parts * psize))" '.ContentLength == $n' >/dev/null \
|| { echo "wrong object size: ${AWS_OUT}"; return 1; }
aws_run s3api get-object --bucket "${bucket}" --key big "${TEST_TMP}/s3c1403-dl"
assert_aws_ok || return 1
expected_md5="$({ for ((i = 1; i <= parts; i++)); do cat "${TEST_TMP}/s3c1403-p${i}"; done; } | md5sum | awk '{print $1}')"
actual_md5="$(md5_of_file "${TEST_TMP}/s3c1403-dl")"
[ "${actual_md5}" = "${expected_md5}" ] || { echo "assembled content mismatch"; return 1; }
rm_bucket "${bucket}"
}
test_s3c1404() { # re-deleting an object whose latest version is a delete marker must succeed (rustfs#8742)
local bucket="s3c1404-b"
new_bucket "${bucket}" || return 1
aws_run s3api put-bucket-versioning --bucket "${bucket}" --versioning-configuration Status=Enabled
assert_aws_ok "enable versioning" || { rm_bucket "${bucket}"; return 1; }
make_test_file "${TEST_TMP}/s3c1404-v" 1024
aws_run s3api put-object --bucket "${bucket}" --key f --body "${TEST_TMP}/s3c1404-v"
assert_aws_ok "put-object f" || { rm_bucket "${bucket}"; return 1; }
aws_run s3api delete-object --bucket "${bucket}" --key f
assert_aws_ok "first delete (creates the marker)" || { rm_bucket "${bucket}"; return 1; }
# The latest version is now a delete marker. AWS S3 treats deleting an
# already-deleted (or nonexistent) object as success; the regression
# answered the second delete with 503 SlowDown instead.
aws_run s3api delete-object --bucket "${bucket}" --key f
assert_aws_ok "second delete over the delete marker (rustfs#8742)" || { rm_bucket "${bucket}"; return 1; }
aws_run s3api delete-object --bucket "${bucket}" --key never-existed
assert_aws_ok "delete of a key that never existed" || { rm_bucket "${bucket}"; return 1; }
rm_bucket "${bucket}"
}
test_s3c1405() { # CreateBucket on an existing bucket must not 503 under write load (rustfs#8741)
local bucket="s3c1405-b" i rc=0 ok_puts=0
new_bucket "${bucket}" || return 1
make_test_file "${TEST_TMP}/s3c1405-v" 1048576
# Steady PutObject traffic holds the bucket lifecycle read lock; the
# existence check used to run only after the exclusive locks were taken,
# so an overlapping CreateBucket waited out the 5s lock timeout and came
# back 503 SlowDown. Load must overlap every create attempt below.
(
local_end=$((SECONDS + 24))
while [ "${SECONDS}" -lt "${local_end}" ]; do
aws --endpoint-url "${ENDPOINT}" --region "${REGION}" s3api put-object \
--bucket "${bucket}" --key "load-${RANDOM}" --body "${TEST_TMP}/s3c1405-v" >/dev/null 2>&1 || true
done
) &
local loader_pid=$!
for i in 1 2 3 4; do
if aws --endpoint-url "${ENDPOINT}" --region "${REGION}" s3api create-bucket --bucket "${bucket}" \
>"${TEST_TMP}/s3c1405-cb-${i}.json" 2>&1; then
: # owner/already-exists response is fine
elif grep -q 'SlowDown' "${TEST_TMP}/s3c1405-cb-${i}.json"; then
echo "create-bucket attempt ${i} returned SlowDown under write load (rustfs#8741):"
head -c 300 "${TEST_TMP}/s3c1405-cb-${i}.json"
rc=1
fi
sleep 3
done
wait "${loader_pid}"
aws_run s3api list-objects-v2 --bucket "${bucket}" --query 'length(Contents || `[]`)'
[ "${AWS_CODE}" -eq 0 ] || { echo "list after load failed: ${AWS_OUT}"; return 1; }
ok_puts="${AWS_OUT}"
[ "${ok_puts}" -ge 3 ] || { echo "write load did not materialize (${ok_puts} objects); run is vacuous"; return 1; }
return "${rc}"
}
test_s3c1406() { # a bucket emptied of all objects must be deletable (rustfs#8499)
local bucket="s3c1406-b" i
new_bucket "${bucket}" || return 1
make_test_file "${TEST_TMP}/s3c1406-v" 4096
for i in $(seq 1 20); do
aws_run s3api put-object --bucket "${bucket}" --key "obj-${i}" --body "${TEST_TMP}/s3c1406-v"
assert_aws_ok "put-object obj-${i}" || { rm_bucket "${bucket}"; return 1; }
done
for i in $(seq 1 20); do
aws_run s3api delete-object --bucket "${bucket}" --key "obj-${i}"
assert_aws_ok "delete-object obj-${i}" || { rm_bucket "${bucket}"; return 1; }
done
# Usage accounting may converge asynchronously; a persistently stale
# object count keeps DeleteBucket answering BucketNotEmpty forever
# (rustfs#8499). Tolerate a bounded convergence window, nothing more.
local deadline=$(( $(date +%s) + 90 )) deleted=0
while [ "$(date +%s)" -lt "${deadline}" ]; do
aws_run s3api delete-bucket --bucket "${bucket}"
if [ "${AWS_CODE}" -eq 0 ]; then
deleted=1
break
fi
printf '%s' "${AWS_OUT}" | grep -q 'BucketNotEmpty' \
|| { echo "unexpected delete-bucket failure: ${AWS_OUT}"; return 1; }
sleep 5
done
[ "${deleted}" -eq 1 ] || { echo "bucket still BucketNotEmpty 90s after emptying (rustfs#8499)"; return 1; }
}
# Deep Object Lock: default retention, GOVERNANCE, COMPLIANCE, and legal hold.
# Campaigns with an existing endpoint should call this via
# scripts/campaign/run-worm-object-lock.sh instead of a retention-metadata check.
worm_object_lock_tests() {
run_test S3C-602 "DefaultRetention" test_s3c602
run_test S3C-603 "GovernanceProtection" test_s3c603
run_test S3C-604 "ComplianceProtection" test_s3c604
run_test S3C-605 "LegalHold" test_s3c605
}
bulk_delete_regression() {
local id="$1" index=1 node
local args=(--case "${id}" --endpoint "${ENDPOINT}")
case "${id}" in
S3C-213|S3C-1306)
args+=(--profile "${S3_BULK_PROFILE}" --key-shape "${S3_BULK_KEY_SHAPE}")
if [ -n "${S3_BULK_KEY_BYTES}" ]; then args+=(--key-bytes "${S3_BULK_KEY_BYTES}"); fi
;;
esac
if [ -z "${S3_BULK_RESULTS_DIR}" ]; then
S3_BULK_RESULTS_DIR="$(mktemp -d "${LOG_FILE:+$(dirname "${LOG_FILE}")/}rustfs-s3-bulk.XXXXXX")"
fi
mkdir -p "${S3_BULK_RESULTS_DIR}/${CURRENT_TOPOLOGY:-existing}"
args+=(--result-dir "${S3_BULK_RESULTS_DIR}/${CURRENT_TOPOLOGY:-existing}/${id}")
for node in $(topology_nodes "${CURRENT_TOPOLOGY}"); do
if [ "${index}" -gt 1 ]; then args+=(--endpoint "http://${node}:9000"); fi
index=$((index+1))
done
RUSTFS_ACCESS_KEY="${ACCESS_KEY}" RUSTFS_SECRET_KEY="${SECRET_KEY}" AWS_DEFAULT_REGION="${REGION}" \
"${S3_BULK_PYTHON}" "${SCRIPT_DIR}/scripts/s3_bulk_delete_regressions.py" "${args[@]}"
}
# Strict SSE contract: exact SSE response headers, exact refusal codes, and no
# object left behind by a refused write. The helper talks to the endpoint only;
# this suite's server has RUSTFS_SSE_S3_MASTER_KEY and no KMS, which ENC-204
# relies on.
sse_contract_case() {
RUSTFS_ACCESS_KEY="${ACCESS_KEY}" RUSTFS_SECRET_KEY="${SECRET_KEY}" \
python3 "${SCRIPT_DIR}/scripts/sse_contract_cases.py" --endpoint "${ENDPOINT}" --case "$1"
}
test_enc201() { sse_contract_case ENC-201; }
test_enc202() { sse_contract_case ENC-202; }
test_enc203() { sse_contract_case ENC-203; }
test_enc204() { sse_contract_case ENC-204; }
test_enc205() { sse_contract_case ENC-205; }
test_enc206() { sse_contract_case ENC-206; }
test_enc207() { sse_contract_case ENC-207; }
test_enc208() { sse_contract_case ENC-208; }
test_enc209() { sse_contract_case ENC-209; }
test_enc210() { sse_contract_case ENC-210; }
test_s3c213() { bulk_delete_regression S3C-213; }
test_s3c214() { bulk_delete_regression S3C-214; }
test_s3c1306() { bulk_delete_regression S3C-1306; }
test_s3c1307() { bulk_delete_regression S3C-1307; }
run_all_tests() {
run_test S3C-101 "CreateBucket" test_s3c101
run_test S3C-102 "HeadBucket" test_s3c102
run_test S3C-103 "ListBuckets" test_s3c103
run_test S3C-104 "DeleteBucket" test_s3c104
run_test S3C-105 "GetBucketLocation" test_s3c105
run_test S3C-106 "BucketNameValidity" test_s3c106
run_test S3C-201 "PutObject(1KB/1MB/100MB)" test_s3c201
run_test S3C-202 "PutObjectEmpty" test_s3c202
run_test S3C-203 "GetObject" test_s3c203
run_test S3C-204 "RangeGet" test_s3c204
run_test S3C-205 "HeadObject" test_s3c205
run_test S3C-206 "CustomMetadata" test_s3c206
run_test S3C-207 "DeleteObject" test_s3c207
run_test S3C-208 "DeleteObjectsBatch" test_s3c208
run_test S3C-209 "CopyObject" test_s3c209
run_test S3C-210 "SpecialCharKey" test_s3c210
run_test S3C-211 "ServerSideMove" test_s3c211
run_test S3C-212 "ReservedStorageNames" test_s3c212
run_test S3C-213 "BulkDeleteBatchMatrix" test_s3c213
run_test S3C-214 "BulkDeleteDuplicateKeys" test_s3c214
run_test S3C-301 "MultipartFullFlow" test_s3c301
run_test S3C-302 "UploadPartCopy" test_s3c302
run_test S3C-303 "ListPartsAndUploads" test_s3c303
run_test S3C-304 "AbortMultipartUpload" test_s3c304
run_test S3C-305 "MultipartBadComplete" test_s3c305
run_test S3C-401 "ListObjectsV2" test_s3c401
run_test S3C-402 "PrefixDelimiter" test_s3c402
run_test S3C-403 "Pagination" test_s3c403
run_test S3C-404 "ListObjectsV1" test_s3c404
run_test S3C-405 "TreeAndDu" test_s3c405
run_test S3C-501 "VersioningToggle" test_s3c501
run_test S3C-502 "MultiVersionWrites" test_s3c502
run_test S3C-503 "GetByVersion" test_s3c503
run_test S3C-504 "DeleteMarker" test_s3c504
run_test S3C-505 "DeleteVersion" test_s3c505
run_test S3C-506 "RestoreByMarkerRemove" test_s3c506
run_test S3C-507 "SuspendedSemantics" test_s3c507
run_test S3C-601 "LockBucketCreate" test_s3c601
worm_object_lock_tests
run_test S3C-606 "NonLockBucketReject" test_s3c606
run_test S3C-701 "ObjectTagCrud" test_s3c701
run_test S3C-702 "BucketTagCrud" test_s3c702
run_test S3C-703 "UploadWithTags" test_s3c703
run_test S3C-704 "LifecycleCrud" test_s3c704
run_test S3C-801 "BucketPolicyCrud" test_s3c801
run_test S3C-802 "AnonymousAccess" test_s3c802
run_test S3C-803 "PolicyStatus" test_s3c803
run_test S3C-804 "PublicAccessBlock" test_s3c804
run_test S3C-805 "CannedAcl" test_s3c805
run_test S3C-901 "SseS3" test_s3c901
run_test S3C-902 "SseC" test_s3c902
run_test S3C-903 "BucketEncryption" test_s3c903
run_test S3C-904 "EncryptedCopyMultipart" test_s3c904
run_test ENC-101 "SseS3SizeBoundaries" test_enc101
run_test ENC-106 "SseCNegatives" test_enc106
run_test ENC-107 "SseCRangeGet" test_enc107
run_test ENC-108 "SseCMultipart" test_enc108
run_test ENC-111 "SseChecksum" test_enc111