Skip to content

Commit 9c58768

Browse files
committed
Added DR test to weekly run
1 parent d242a1e commit 9c58768

4 files changed

Lines changed: 48 additions & 6 deletions

File tree

.github/workflows/test.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ on:
1717
required: false
1818
default: false
1919
type: boolean
20+
enable_dr_tests:
21+
description: "Also run the docker and kubernetes disaster recovery scenarios"
22+
required: false
23+
default: false
24+
type: boolean
2025
secrets:
2126
CL_INFOCLACE_SSH:
2227
required: false
@@ -83,6 +88,12 @@ jobs:
8388
# Using a self-hosted runner, use Docker for container tests
8489
MAKE_TEST_ARGS=(CONTAINER_COMMANDS=docker POSTGRES=1 MYSQL=1 SEAWEEDFS=1)
8590
91+
if [[ "${{ inputs.enable_dr_tests }}" == "true" ]]; then
92+
# Run the docker and kubernetes disaster recovery scenarios too
93+
# (the kubernetes one needs enable_kubernetes_tests as well)
94+
MAKE_TEST_ARGS+=(DR=1)
95+
fi
96+
8697
RUN_KUBERNETES_TESTS=false
8798
if [[ "${{ inputs.enable_kubernetes_tests }}" == "true" ]]; then
8899
RUN_KUBERNETES_TESTS=true

.github/workflows/weekly-verify.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
uses: ./.github/workflows/test.yml
2626
with:
2727
enable_kubernetes_tests: true
28+
enable_dr_tests: true
2829
secrets:
2930
CL_INFOCLACE_SSH: ${{ secrets.CL_INFOCLACE_SSH }}
3031
CL_GITHUB_SECRET: ${{ secrets.CL_GITHUB_SECRET }}

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ SEAWEEDFS ?=
3131
S3_URL ?=
3232
KUBE_REGISTRY ?=
3333
KUBE_NAMESPACE ?=
34+
DR ?=
3435
SKIP_BUILD ?=
3536
RUN_CLI_TEST_ARGS ?=
3637
RUN_CLI_TESTS_FLAGS = --home $(OPENRUN_HOME) \
@@ -44,6 +45,7 @@ RUN_CLI_TESTS_FLAGS = --home $(OPENRUN_HOME) \
4445
$(if $(S3_URL),--s3-url $(S3_URL)) \
4546
$(if $(KUBE_REGISTRY),--kube-registry $(KUBE_REGISTRY)) \
4647
$(if $(KUBE_NAMESPACE),--kube-namespace $(KUBE_NAMESPACE)) \
48+
$(if $(DR),--dr) \
4749
$(if $(SKIP_BUILD),--skip-build) \
4850
$(RUN_CLI_TEST_ARGS)
4951

tests/run_cli_tests.sh

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
3237
Containers:
@@ -69,6 +74,7 @@ HOME_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6974
COVERDIR=""
7075
SKIP_BUILD=""
7176
VERBOSE=""
77+
ENABLE_DR=""
7278
CONTAINER_COMMANDS="docker"
7379
CONTAINER_TOOL="docker"
7480
ENABLE_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.
156173
contains_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

Comments
 (0)