@@ -27,6 +27,11 @@ General:
2727 --skip-build Reuse the existing tests/../openrun binary instead
2828 of rebuilding it (faster edit/run loops)
2929 --verbose Pass --verbose to commander
30+ --dr Also run the disaster recovery scenarios in a full
31+ run (they are skipped by default: slow, hard-kill a
32+ server). The docker scenario needs --seaweedfs and a
33+ container command; the kubernetes scenario needs
34+ --seaweedfs and --kube-registry
3035 -h, --help Show this help
3136
3237Containers:
@@ -69,6 +74,7 @@ HOME_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6974COVERDIR=" "
7075SKIP_BUILD=" "
7176VERBOSE=" "
77+ ENABLE_DR=" "
7278CONTAINER_COMMANDS=" docker"
7379CONTAINER_TOOL=" docker"
7480ENABLE_POSTGRES=" "
@@ -103,6 +109,7 @@ while [[ $# -gt 0 ]]; do
103109 --coverdir) COVERDIR=" $2 " ; shift 2 ;;
104110 --skip-build) SKIP_BUILD=1; shift ;;
105111 --verbose) VERBOSE=" --verbose" ; shift ;;
112+ --dr) ENABLE_DR=1; shift ;;
106113 --container-commands) CONTAINER_COMMANDS=" $2 " ; shift 2 ;;
107114 --container-tool) CONTAINER_TOOL=" $2 " ; shift 2 ;;
108115 --postgres) ENABLE_POSTGRES=1; shift ;;
@@ -151,6 +158,16 @@ is_explicitly_selected() {
151158 return 1
152159}
153160
161+ # dr_selected NAME: the disaster recovery suites are skipped in default full
162+ # runs (slow, hard-kill a server). They run when requested by name, or as part
163+ # of a full run with --dr (e.g. the weekly verify job).
164+ dr_selected () {
165+ if [[ -n " $ENABLE_DR " && ${# TESTS[@]} -eq 0 ]]; then
166+ return 0
167+ fi
168+ is_explicitly_selected " $1 "
169+ }
170+
154171# contains_any "a b c": true if no test-file args were given or one of them
155172# matches a name in the given space separated list.
156173contains_any () {
@@ -1154,9 +1171,10 @@ fi
11541171# OPENRUN_HOME with the backed-up config must restore the metadata (app list,
11551172# audit history) and the app's sqlite data from the replica alone.
11561173#
1157- # Disabled by default (it is slow and hard-kills a server): runs only when
1158- # explicitly requested, e.g. ./tests/run_cli_tests.sh --seaweedfs test_dr_sqlite.yaml
1159- if [[ -n " $ENABLE_SEAWEEDFS " && -n " $LITESTREAM_CONTAINER_CMD " ]] && is_explicitly_selected test_dr_sqlite.yaml; then
1174+ # Disabled by default (it is slow and hard-kills a server): runs when
1175+ # explicitly requested, e.g. ./tests/run_cli_tests.sh --seaweedfs test_dr_sqlite.yaml,
1176+ # or in a full run with --dr
1177+ if [[ -n " $ENABLE_SEAWEEDFS " && -n " $LITESTREAM_CONTAINER_CMD " ]] && dr_selected test_dr_sqlite.yaml; then
11601178 start_seaweedfs_testcontainer
11611179
11621180 # Unique replica prefix per run so a rerun never restores a previous run's data
@@ -1257,10 +1275,13 @@ fi
12571275# a SECOND namespace, restoring the metadata from S3 and the app data into a
12581276# fresh PVC via the restore init containers.
12591277#
1260- # Disabled by default: needs --seaweedfs and --kube-registry, and runs only
1261- # when explicitly requested, e.g.
1278+ # Disabled by default: needs --seaweedfs and --kube-registry, and runs when
1279+ # explicitly requested, e.g.
12621280# ./tests/run_cli_tests.sh --seaweedfs --kube-registry registry.orb.local:5000 test_dr_kubernetes.yaml
1263- if [[ -n " $ENABLE_SEAWEEDFS " && -n " $KUBE_REGISTRY_URL " ]] && is_explicitly_selected test_dr_kubernetes.yaml; then
1281+ # or in a full run with --dr. This block must stay ahead of the
1282+ # test_kubernetes.yaml block below: the DR scenario runs before the full
1283+ # kubernetes suite.
1284+ if [[ -n " $ENABLE_SEAWEEDFS " && -n " $KUBE_REGISTRY_URL " ]] && dr_selected test_dr_kubernetes.yaml; then
12641285 start_seaweedfs_testcontainer
12651286
12661287 # Pods cannot reach the host's 127.0.0.1 SeaweedFS endpoint. Default the
@@ -1281,6 +1302,13 @@ if [[ -n "$ENABLE_SEAWEEDFS" && -n "$KUBE_REGISTRY_URL" ]] && is_explicitly_sele
12811302 registry_host=" ${registry_host# https:// } "
12821303 registry_host=" ${registry_host%%/* } "
12831304 registry_host=" ${registry_host%%:* } "
1305+ if [[ " $registry_host " == * .svc.cluster.local ]]; then
1306+ # The registry is a cluster-internal service (e.g. the k3s CI runner):
1307+ # its DNS name resolves to a ClusterIP that only serves the registry
1308+ # port. SeaweedFS publishes on all host interfaces, so pods reach it
1309+ # through the node IP instead.
1310+ registry_host=$( kubectl get nodes -o jsonpath=' {.items[0].status.addresses[?(@.type=="InternalIP")].address}' )
1311+ fi
12841312 KUBE_S3_ENDPOINT=" http://${registry_host} :${TEST_S3_ENDPOINT##*: } "
12851313 fi
12861314 fi
0 commit comments