mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-30 20:57:35 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7b5b29abf | |||
| 4fee593499 | |||
| 7a9024ab8b |
@@ -1097,6 +1097,27 @@
|
||||
"policy_reason": "Preserve operator-disabled state; enabling requires a separate policy decision.",
|
||||
"origin": "baseline"
|
||||
},
|
||||
{
|
||||
"workflow": ".github/workflows/jepsen-unit.yml",
|
||||
"name": "Jepsen unit",
|
||||
"roles": [
|
||||
"pr"
|
||||
],
|
||||
"events": [
|
||||
"pull_request",
|
||||
"push"
|
||||
],
|
||||
"cadence": "event",
|
||||
"timezone": "UTC",
|
||||
"schedule": [],
|
||||
"owner": "@overtrue",
|
||||
"policy": "active",
|
||||
"monitor": "none",
|
||||
"result_owner": "jepsen-unit.yml",
|
||||
"disposition": "Runs the Jepsen checker unit tests. It does not start a RustFS cluster.",
|
||||
"monitor_reason": "Runs when the Jepsen project changes and has no periodic freshness obligation.",
|
||||
"origin": "added"
|
||||
},
|
||||
{
|
||||
"workflow": ".github/workflows/manual-main-packages.yml",
|
||||
"name": "Manual Linux packages",
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
# Copyright 2024 RustFS Team
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
name: Jepsen unit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "jepsen/**"
|
||||
- ".github/workflows/jepsen-unit.yml"
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "jepsen/**"
|
||||
- ".github/workflows/jepsen-unit.yml"
|
||||
|
||||
jobs:
|
||||
lein-test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
- name: Install Leiningen
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p "$HOME/bin"
|
||||
curl -fsSL -o "$HOME/bin/lein" https://raw.githubusercontent.com/technomancy/leiningen/2.11.2/bin/lein
|
||||
chmod +x "$HOME/bin/lein"
|
||||
echo "$HOME/bin" >> "$GITHUB_PATH"
|
||||
"$HOME/bin/lein" version
|
||||
- name: Run Jepsen checker tests
|
||||
working-directory: jepsen
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Clojars occasionally drops the jepsen and generator jars mid-download.
|
||||
for attempt in 1 2 3; do
|
||||
if lein test; then
|
||||
exit 0
|
||||
fi
|
||||
echo "lein test attempt ${attempt} failed"
|
||||
if [ "$attempt" -eq 3 ]; then
|
||||
exit 1
|
||||
fi
|
||||
sleep $((attempt * 15))
|
||||
done
|
||||
@@ -53,6 +53,8 @@ RTO = "RTO"
|
||||
rto = "rto"
|
||||
# rustix OFlags variant (POSIX O_WRONLY equivalent).
|
||||
WRONLY = "WRONLY"
|
||||
# Jepsen writes Extensible Data Notation result files named results.edn.
|
||||
edn = "edn"
|
||||
|
||||
[files]
|
||||
extend-exclude = []
|
||||
|
||||
@@ -15,6 +15,7 @@ Pick the lowest layer that can prove the change; add a higher-layer test only wh
|
||||
| s3s-e2e conformance | External S3 conformance tool against a live server | `./scripts/e2e-run.sh ./target/debug/rustfs <data-dir>` | Non-documentation PRs, required through `Test and Lint` (second half of the `End-to-End Tests` job) |
|
||||
| S3 compatibility | `ceph/s3-tests` (boto3; allow-list `scripts/s3-tests/implemented_tests.txt`) and MinIO `mint` | `scripts/s3-tests/run.sh`; mint via `.github/workflows/mint.yml` | Non-documentation PRs: implemented and lifecycle S3 lanes required through `Test and Lint`; the separate s3-tests workflow provides additional PR reporting and a weekly full sweep; mint: weekly, report-only |
|
||||
| Chaos / fault-injection | Single-node disk fault injection (`crates/e2e_test/src/chaos.rs`, `crates/e2e_test/src/fault_proxy.rs`) plus the 4-node kill/fresh-drive/blackhole cases in `crates/e2e_test/src/distributed/chaos_test.rs` | Part of the e2e crate (`e2e-reliability` and `e2e-distributed`) | Reliability cases with `e2e-full`; 4-node chaos nightly via `e2e-distributed` |
|
||||
| Jepsen | Elle and Knossos histories of 1.0.7 under Jepsen Nemesis, on a 4×4 set and a 3×2 set, run one topology at a time | `cd jepsen && lein test` for the checkers; a cluster run is `jepsen/README.md` | `jepsen-unit.yml` runs `lein test` only. The multi-node run is manual on the Mac mini. |
|
||||
| Fuzz | `cargo-fuzz` targets over untrusted parsing surfaces; isolated sub-workspace under `fuzz/` | `./scripts/fuzz/run.sh` (see [`fuzz/README.md`](../../fuzz/README.md)) | PR smoke on the paths listed in `.github/workflows/fuzz.yml`, plus nightly corpus |
|
||||
| Benchmarks | Criterion benches under each crate's `benches/` | `cargo bench -p <crate>` | On demand; never a gate |
|
||||
| Conditional reads | Paired ordinary/hit/miss GET latency, throughput and read-lock measurements | `scripts/run_conditional_read_abba.py` | Local conditional-read acceptance; [guide and scope](conditional-read-benchmark.md) |
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
target/
|
||||
store/
|
||||
.lein-*
|
||||
.nrepl-port
|
||||
*.iml
|
||||
docker/state/
|
||||
@@ -0,0 +1,187 @@
|
||||
# Jepsen tests for RustFS 1.0.7
|
||||
|
||||
This directory is a [Jepsen](https://github.com/jepsen-io/jepsen) 0.3.16 project. It does not reimplement Nemesis, Elle, or Knossos. Network partitions, process kill, process pause, clock skew, and packet delay or loss come from `jepsen.nemesis.combined`. The register histories are checked with Elle's `rw-register` (strict serializability of single-key transactions) and Knossos (`jepsen.checker/linearizable` on `knossos.model/cas-register`). Jepsen 0.3.16 has no disk-full or slow-disk nemesis. Packet delay is the latency fault that library does provide. Bit-flip file corruption is opt-in and off by default.
|
||||
|
||||
The Mac mini (24 GB, OrbStack Docker capped near 14 GB) runs **one topology at a time**. Shut the first cluster down, including its volumes, before starting the second.
|
||||
|
||||
## What is checked
|
||||
|
||||
RustFS 1.0.7 acknowledges object writes at erasure write quorum and serves the current object from read quorum. Listings are not linearizable reads. The in-tree notes for that are `rustfs/src/app/bucket_list_through.rs` and `crates/ecstore/src/data_usage/mod.rs`. Elle and Knossos therefore see puts, gets, deletes, conditional puts, and multipart completion. A list is a separate checker that only rejects an ETag no acknowledged or indeterminate write can explain. A stale list is not a failure.
|
||||
|
||||
`If-Match` and `If-None-Match: *` are supported on `PutObject` in 1.0.7 (`scripts/s3-tests/implemented_tests.txt` covers `test_put_object_ifmatch_*` and `test_put_object_ifnonmatch_*`). Versioning is supported. Multipart upload of a single small part is a blind write, not a conditional write. There is no multi-key transaction, so the Elle workload defaults to one micro-op per transaction. That workload runs Elle's strict-serializability search and, on each single-micro-op key, Knossos. Elle does not infer a per-key version order from real time unless `:linearizable-keys?` is set, and Elle's notes say that flag can report a cycle that is not there, so this suite leaves it off and uses Knossos for that order. `--max-txn-length` greater than 1 asks for a guarantee the server does not claim. A strict-serializability failure there is expected, and Knossos ignores those multi-micro-op transactions.
|
||||
|
||||
A lost response is `:info` (indeterminate). A precondition failure is `:fail`. Knossos or Elle returning `:valid? :unknown` means the history was inconclusive. `:valid? false` is a failed check.
|
||||
|
||||
## Topologies
|
||||
|
||||
Both layouts are one pool and one erasure set. `RUSTFS_VOLUMES` uses RustFS ellipsis expansion: each `{start...end}` is a dimension, and the dimensions multiply. The path is a directory on that node. The same string is passed to every node. `rustfs server` reads it from the environment. This matches `DisksLayout` in `crates/ecstore/src/layout/disks_layout.rs`, including `http://rustfs{0...15}.mydomain.net/data{0...1}`.
|
||||
|
||||
Default parity follows `default_parity_count` (8 or more drives → 4, 6 or 7 → 3). Read quorum is `drives - parity`. Write quorum is the data-shard count, plus one when that count equals parity (`default_write_quorum`).
|
||||
|
||||
| Topology | Nodes | Drives each | Endpoints | Set | Parity | Read quorum | Write quorum | Volume argument |
|
||||
|---|---|---|---|---|---|---|---|---|
|
||||
| `4x4` | 4 | 4 | 16 | 16 | 4 | 12 | 12 | `http://n{1...4}.orb.local:9000/var/lib/rustfs/data{1...4}` |
|
||||
| `3x2` | 3 | 2 | 6 | 6 | 3 | 3 | 4 | `http://n{1...3}.orb.local:9000/var/lib/rustfs/data{1...2}` |
|
||||
|
||||
On `4x4`, losing one node leaves 12 drives, which still meets quorum. A kill of a minority is two nodes and leaves 8 drives, so the cluster cannot read or write until the nemesis heals. A 2-2 partition also leaves neither side at quorum 12. On `3x2`, one node down leaves 4 drives, which still meets write quorum 4. A 2-1 partition lets the two-node side write. The single node has two drives and must not acknowledge a write.
|
||||
|
||||
Named volumes in the compose files are directories on the OrbStack disk. They are not sixteen or six independent physical disks. UTM can attach a virtual disk per mount when that distinction matters. File corruption, off by default, targets `/var/lib/rustfs/data1` on one node.
|
||||
|
||||
## Mac mini: software
|
||||
|
||||
Install Temurin 21, Leiningen, and gnuplot on macOS. Jepsen 0.3.16 is built for Java 21. The perf checker shells out to gnuplot and fails the run if the binary is missing. The Jepsen process runs on the Mac, not inside the 14 GB Docker budget. The project JVM cap is 3 GB.
|
||||
|
||||
```bash
|
||||
brew install --cask temurin@21
|
||||
brew install leiningen gnuplot
|
||||
export JAVA_HOME="$(/usr/libexec/java_home -v 21)"
|
||||
java -version
|
||||
cd jepsen && lein test
|
||||
```
|
||||
|
||||
`lein test` does not start RustFS. It checks quorum numbers, the volume string, Elle on a legal and an illegal history, Knossos on a legal and an illegal history, and the listing and version-id checkers.
|
||||
|
||||
OrbStack Docker 29 is the container path below. UTM is the path that can give each node its own clock.
|
||||
|
||||
## Docker nodes (OrbStack)
|
||||
|
||||
These containers are Debian SSH machines. Jepsen installs the official 1.0.7 musl zip, verifies its sha256, and starts `rustfs server` with `start-stop-daemon`. The packaged systemd unit is not used: it sets `ProtectClock=true` and `Restart=always`, which would hide clock changes and undo a kill. The image does not grant `SYS_TIME`. A clock change inside a container would move the shared OrbStack clock, so the default fault list is `partition,kill,pause,packet` and does not include `clock`.
|
||||
|
||||
From the repository root on the Mac:
|
||||
|
||||
```bash
|
||||
export JEPSEN_SSH_PUBKEY="$(cat ~/.ssh/id_ed25519.pub)"
|
||||
export JEPSEN_SSH_KEY="$HOME/.ssh/id_ed25519"
|
||||
./jepsen/scripts/switch-topology.sh 4x4
|
||||
./jepsen/scripts/preflight.sh --drives 4 \
|
||||
n1.orb.local n2.orb.local n3.orb.local n4.orb.local
|
||||
```
|
||||
|
||||
`switch-topology.sh` runs `down -v` on the 3x2 project and both smoke stacks, then builds and starts only the 4x4 nodes. Container names are `n1` through `n4`, which OrbStack publishes as `n1.orb.local` and so on. Each container is limited to 2 GiB and 1 CPU (8 GiB for this topology). Drives are `/var/lib/rustfs/data1` through `data4`. The entrypoint writes `/etc/hosts` so `n1.orb.local` inside the network is that container's bridge address. RustFS marks an endpoint local only when that name resolves to a local IP and port 9000.
|
||||
|
||||
Preflight must show passwordless `sudo`, the data directories, `iptables -L`, and a local address for each `nX.orb.local`. If it prints `tc netem: NOT available`, rerun with `--faults partition,kill,pause`.
|
||||
|
||||
Then, still one topology:
|
||||
|
||||
```bash
|
||||
export JEPSEN_SSH_KEY="$HOME/.ssh/id_ed25519"
|
||||
./jepsen/scripts/run-topology.sh 4x4
|
||||
```
|
||||
|
||||
That runs `elle`, `register`, `versioned`, and `list` in order, 90 seconds of client traffic each, concurrency 8, rate about 10 ops/s. It stops at the first non-zero Jepsen exit. A single workload:
|
||||
|
||||
```bash
|
||||
cd jepsen
|
||||
lein run test --topology 4x4 --workload elle --time-limit 90 --concurrency 8 \
|
||||
--username jepsen --ssh-private-key "$HOME/.ssh/id_ed25519" \
|
||||
--faults partition,kill,pause,packet --rate 10
|
||||
```
|
||||
|
||||
Credentials are the test pair `rustfsadmin` / `rustfsadmin` (access key at least 3 bytes, secret at least 8). Override with `--access-key` and `--secret-key`. The bucket is `jepsen`. Region is `us-east-1`. The client uses path-style URLs on port 9000.
|
||||
|
||||
### Switch to 3x2
|
||||
|
||||
Do this only after the 4x4 run is finished. The script removes the 4x4 volumes so a 16-drive `format.json` cannot be opened as a 6-drive pool.
|
||||
|
||||
```bash
|
||||
export JEPSEN_SSH_PUBKEY="$(cat ~/.ssh/id_ed25519.pub)"
|
||||
./jepsen/scripts/switch-topology.sh 3x2
|
||||
./jepsen/scripts/preflight.sh --drives 2 \
|
||||
n1.orb.local n2.orb.local n3.orb.local
|
||||
./jepsen/scripts/run-topology.sh 3x2
|
||||
```
|
||||
|
||||
3x2 is three containers at 2 GiB (6 GiB), drives `data1` and `data2`, concurrency 6. Container name `n4` is gone. Do not start `compose-4x4.yaml` again until this project has been removed with `down -v`.
|
||||
|
||||
Results are under `jepsen/store/rustfs-4x4-<workload>/latest/` and `jepsen/store/rustfs-3x2-<workload>/latest/`. `results.edn` holds `:valid?`. Elle writes a plot directory next to it. `rustfs.log` is copied from each node. `latest` is the symlink Jepsen maintains.
|
||||
|
||||
## Optional image smoke
|
||||
|
||||
`jepsen/docker/smoke-4x4.yaml` and `smoke-3x2.yaml` start `rustfs/rustfs:1.0.7` directly, with the same ellipsis shape and container names `smoke-n1` and so on, so they do not occupy `n1`. This does not install the zip, does not run Nemesis, and is not a Jepsen result. Stop it before the SSH topology. From the repo root:
|
||||
|
||||
```bash
|
||||
docker compose -f jepsen/docker/smoke-4x4.yaml up -d
|
||||
docker compose -f jepsen/docker/smoke-4x4.yaml logs -f n1
|
||||
curl -fsS http://smoke-n1.orb.local:9000/health/live
|
||||
docker compose -f jepsen/docker/smoke-4x4.yaml down -v
|
||||
```
|
||||
|
||||
The smoke volume string is `http://n{1...4}:9000/data/disk{1...4}` because the official image can write under `/data`. The Jepsen nodes use `/var/lib/rustfs/data{1...4}` and the `.orb.local` names. If `rustfs/rustfs:1.0.7` is not published for arm64, the smoke file fails on pull. The Jepsen install path does not use that image. It downloads `rustfs-linux-aarch64-musl-v1.0.7.zip` (sha256 `e2c6d45105dd05df2f35547fbebfacf40dfba6ec4f8c31b86e30934faea79e76`) onto each node. The gnu zip is `--libc gnu`. An x86_64 node, including a Rosetta OrbStack machine, selects the matching pinned zip.
|
||||
|
||||
## UTM, or OrbStack Linux machines, when the clock must move
|
||||
|
||||
Use this instead of the compose files, not in addition to them. Four 2 GiB VMs plus macOS plus a 3 GB JVM is about 8 GB of guests and fits in 24 GB only when Docker is not also holding the 8 GB 4x4 set. Shut OrbStack Docker down before starting the VMs. Do not boot a fourth VM during the 3x2 run.
|
||||
|
||||
For UTM, create Debian 12 or 13 arm64 guests, 2 GiB RAM, 2 CPUs, and a 16 GB system disk. Attach four 1 GB virtio disks on each of the four guests for the first run and mount them at `/var/lib/rustfs/data1` through `data4`. Install `openssh-server`, `sudo`, `wget`, `unzip`, `iptables`, `iproute2`, and `netcat-openbsd`. Give the SSH user passwordless sudo. Put the same `/etc/hosts` on the Mac and on every guest, with stable addresses, for example `192.168.64.11 n1` through `192.168.64.14 n4`. The guest names must be `n1` through `n4` with no gaps.
|
||||
|
||||
```bash
|
||||
cd jepsen
|
||||
lein run test --topology 4x4 --nodes n1,n2,n3,n4 --workload elle \
|
||||
--time-limit 90 --concurrency 8 --username debian \
|
||||
--ssh-private-key "$HOME/.ssh/id_ed25519" \
|
||||
--faults partition,kill,pause,packet,clock --rate 10
|
||||
```
|
||||
|
||||
`-n` / `--node` adds a single host each time. A comma-separated list belongs on `--nodes`. The volume string becomes `http://n{1...4}:9000/var/lib/rustfs/data{1...4}`.
|
||||
|
||||
Before calling that a clock result, confirm the clocks are independent: on n1, `sudo date -s '+30 seconds'`, and on n2, `date`. If n2 jumps as well, OrbStack or UTM is sharing one clock and `--faults` must omit `clock`. The DB setup stops `systemd-timesyncd` and `chronyd` when those units exist. Reset the n1 clock with `sudo chronyc makestep` or a reboot after the probe.
|
||||
|
||||
For 3x2, power off n4. On n1, n2, and n3, unmount and ignore `data3` and `data4`, and delete the contents of `data1` and `data2` so the 16-drive format is not reused. Then repeat the command with `--topology 3x2 --nodes n1,n2,n3 --concurrency 6` and two mounted disks per guest.
|
||||
|
||||
OrbStack Linux machines are the same contract if `date -s` stays local to the machine. Create them only while the Docker Jepsen stack is down, at 2 GiB each:
|
||||
|
||||
```bash
|
||||
orb create --memory 2G --cpus 1 --disk 20G debian n1
|
||||
```
|
||||
|
||||
Repeat for n2, n3, and n4. If `debian` is not a distro name, the `orb create` help lists images. Use Debian 12 or 13 arm64. Install sshd inside the machine, add the Mac pubkey, and pass the machine names to `--nodes` if those names resolve from the Mac and from the other machines. The names still have to be numbered `n1` through `n4`.
|
||||
|
||||
## Faults and how to read a failure
|
||||
|
||||
| Fault | Library | On these topologies |
|
||||
|---|---|---|
|
||||
| `partition` | `jepsen.nemesis.combined` partition package (`:one`, `:majority`, `:majorities-ring`) | 4x4 majority is a 2-2 split and neither side has quorum. 3x2 majority is 2-1 and the larger side can write. |
|
||||
| `kill`, `pause` | DB `Kill` and `Pause` (`SIGKILL` / `SIGSTOP` on the `rustfs` process) | Targets are one node, or a minority. On 4x4 a minority is two nodes and drops below quorum. On 3x2 a minority is one node and quorum remains. |
|
||||
| `packet` | combined packet package, `tc netem` delay and 20% loss | One node. This is the stand-in for a slow disk. |
|
||||
| `clock` | `jepsen.nemesis.time` via the combined clock package | One node. Only on VMs whose clocks move independently. Off for Docker. |
|
||||
| `file-corruption` | combined bitflip of `/var/lib/rustfs/data1` | Off unless added to `--faults`. It can destroy a shard. |
|
||||
|
||||
Nemesis ops use `:info`. Client crashes and timeouts use `:info`. After the fault interval Jepsen heals, waits 10 seconds, and runs the workload's final reads.
|
||||
|
||||
Open `store/<test>/latest/results.edn`.
|
||||
|
||||
- `:valid? true` means that checker accepted the history.
|
||||
- `:valid? false` under `:workload` is the consistency failure. Elle's `:anomaly-types` names the cycle (`G1a`, `G1b`, internal, stale read, and so on). Knossos reports the operation it could not linearize. `:listing` false means a list returned an ETag that was never written, a duplicate key in one page, or a size that does not match the write of that ETag. `:versions` false means a successful versioned put or CAS returned no version id, or two successes shared one.
|
||||
- `:valid? :unknown` means Elle or Knossos could not decide, usually because too many operations were indeterminate. Extend the quiet period or rerun. It is not a passing result and it is not, by itself, a bug report.
|
||||
- A process that never comes back, or `results.edn` missing, is a harness or environment failure. Read `jepsen.log` and `rustfs.log` before treating it as a storage bug.
|
||||
|
||||
The perf plot shows partition, kill, pause, packet, and clock intervals from the Nemesis package. A spike of errors during a 4x4 two-node kill is the quorum going away. The check fails when a value that was acknowledged cannot be ordered with a later read, or when a side that should not have quorum acknowledges a write that disagrees with the other side.
|
||||
|
||||
## Blockers on Apple Silicon
|
||||
|
||||
Docker containers share the OrbStack VM clock. Do not add `SYS_TIME`, and do not put `clock` in `--faults` for the compose path.
|
||||
|
||||
`tc qdisc netem` needs the sch_netem module in the OrbStack kernel. Preflight says so when it is missing. Drop `packet` in that case. Partitions use `iptables` in the container namespace and need `NET_ADMIN`, which the compose file adds. If preflight's `iptables -L` fails, partitions will not isolate nodes and the run is not a fault test.
|
||||
|
||||
`n1.orb.local` is an OrbStack name. Docker Desktop alone does not publish it. Use the UTM `/etc/hosts` path there, or OrbStack.
|
||||
|
||||
Port 9000 is shared by design: each node is reached by its own DNS name, not by `localhost:9000`. Four containers cannot all publish host port 9000.
|
||||
|
||||
The musl zip is the default because a gnu binary built on a newer glibc may not start on Debian 12. `--libc gnu` selects the gnu zip and its pinned sha256.
|
||||
|
||||
A 4x4 format on disk will not boot as 3x2. `switch-topology.sh` deletes volumes. A hand-run `down` without `-v` leaves the old format in place and the next start fails closed.
|
||||
|
||||
Running both compose projects, or the Docker stack plus four UTM guests, exceeds the 14 GB Docker cap or the 24 GB machine. The scripts refuse to leave the other Jepsen project up.
|
||||
|
||||
## Artifacts
|
||||
|
||||
Release page: <https://github.com/rustfs/rustfs/releases/tag/1.0.7>.
|
||||
|
||||
| Zip | sha256 |
|
||||
|---|---|
|
||||
| `rustfs-linux-aarch64-musl-v1.0.7.zip` | `e2c6d45105dd05df2f35547fbebfacf40dfba6ec4f8c31b86e30934faea79e76` |
|
||||
| `rustfs-linux-aarch64-gnu-v1.0.7.zip` | `147ef56079be712a242c4db43866ab269a6441a14214d66bac7ed22ef5db419e` |
|
||||
| `rustfs-linux-x86_64-musl-v1.0.7.zip` | `c90a40ba8cdc1468c71029a4d65fdd13449720183d3a8e00bc61ab09fcd448a5` |
|
||||
| `rustfs-linux-x86_64-gnu-v1.0.7.zip` | `4cd2ee55b75f7cb7c935eeb20f8c22f17e1453009cf1af1ff8b42f7986cba201` |
|
||||
|
||||
`--rustfs-url` requires `--rustfs-sha256`. The installer deletes a zip that does not match and will not start it.
|
||||
@@ -0,0 +1,32 @@
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
openssh-server \
|
||||
sudo \
|
||||
ca-certificates \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
iptables \
|
||||
iproute2 \
|
||||
procps \
|
||||
netcat-openbsd \
|
||||
coreutils \
|
||||
findutils \
|
||||
iputils-ping \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& useradd --create-home --shell /bin/bash jepsen \
|
||||
&& printf 'jepsen ALL=(ALL) NOPASSWD:ALL\nDefaults:jepsen !requiretty\n' > /etc/sudoers.d/jepsen \
|
||||
&& chmod 440 /etc/sudoers.d/jepsen \
|
||||
&& mkdir -p /run/sshd /home/jepsen/.ssh \
|
||||
&& chown -R jepsen:jepsen /home/jepsen/.ssh \
|
||||
&& chmod 700 /home/jepsen/.ssh
|
||||
|
||||
COPY entrypoint.sh /usr/local/bin/jepsen-entrypoint
|
||||
RUN chmod 755 /usr/local/bin/jepsen-entrypoint
|
||||
|
||||
EXPOSE 22 9000
|
||||
ENTRYPOINT ["/usr/local/bin/jepsen-entrypoint"]
|
||||
@@ -0,0 +1,52 @@
|
||||
# Three Debian SSH nodes, two drives each. Start this only after the 4x4
|
||||
# project has been removed with `down -v`. Three containers at 2 GB is 6 GB.
|
||||
name: rustfs-jepsen-3x2
|
||||
|
||||
x-node: &node
|
||||
build: .
|
||||
init: true
|
||||
restart: "no"
|
||||
mem_limit: 2g
|
||||
memswap_limit: 2g
|
||||
cpus: 1.0
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
environment:
|
||||
JEPSEN_SSH_PUBKEY: ${JEPSEN_SSH_PUBKEY:?export JEPSEN_SSH_PUBKEY to a public key line}
|
||||
CLUSTER_NODES: n1,n2,n3
|
||||
DRIVES: "2"
|
||||
networks: [jepsen]
|
||||
|
||||
services:
|
||||
n1:
|
||||
<<: *node
|
||||
container_name: n1
|
||||
hostname: rustfs-n1
|
||||
volumes:
|
||||
- n1d1:/var/lib/rustfs/data1
|
||||
- n1d2:/var/lib/rustfs/data2
|
||||
n2:
|
||||
<<: *node
|
||||
container_name: n2
|
||||
hostname: rustfs-n2
|
||||
volumes:
|
||||
- n2d1:/var/lib/rustfs/data1
|
||||
- n2d2:/var/lib/rustfs/data2
|
||||
n3:
|
||||
<<: *node
|
||||
container_name: n3
|
||||
hostname: rustfs-n3
|
||||
volumes:
|
||||
- n3d1:/var/lib/rustfs/data1
|
||||
- n3d2:/var/lib/rustfs/data2
|
||||
|
||||
networks:
|
||||
jepsen:
|
||||
|
||||
volumes:
|
||||
n1d1: {}
|
||||
n1d2: {}
|
||||
n2d1: {}
|
||||
n2d2: {}
|
||||
n3d1: {}
|
||||
n3d2: {}
|
||||
@@ -0,0 +1,79 @@
|
||||
# Four Debian SSH nodes, four drives each. Jepsen installs RustFS 1.0.7.
|
||||
# Do not start this while compose-3x2.yaml or a smoke stack is running.
|
||||
# OrbStack Docker budget on the Mac mini is about 14 GB. Four containers at 2 GB
|
||||
# is 8 GB. The Jepsen JVM runs on macOS, outside that budget.
|
||||
name: rustfs-jepsen-4x4
|
||||
|
||||
x-node: &node
|
||||
build: .
|
||||
init: true
|
||||
restart: "no"
|
||||
mem_limit: 2g
|
||||
memswap_limit: 2g
|
||||
cpus: 1.0
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
environment: &env
|
||||
JEPSEN_SSH_PUBKEY: ${JEPSEN_SSH_PUBKEY:?export JEPSEN_SSH_PUBKEY to a public key line}
|
||||
CLUSTER_NODES: n1,n2,n3,n4
|
||||
DRIVES: "4"
|
||||
networks: [jepsen]
|
||||
|
||||
services:
|
||||
n1:
|
||||
<<: *node
|
||||
container_name: n1
|
||||
hostname: rustfs-n1
|
||||
volumes: &n1
|
||||
- n1d1:/var/lib/rustfs/data1
|
||||
- n1d2:/var/lib/rustfs/data2
|
||||
- n1d3:/var/lib/rustfs/data3
|
||||
- n1d4:/var/lib/rustfs/data4
|
||||
n2:
|
||||
<<: *node
|
||||
container_name: n2
|
||||
hostname: rustfs-n2
|
||||
volumes:
|
||||
- n2d1:/var/lib/rustfs/data1
|
||||
- n2d2:/var/lib/rustfs/data2
|
||||
- n2d3:/var/lib/rustfs/data3
|
||||
- n2d4:/var/lib/rustfs/data4
|
||||
n3:
|
||||
<<: *node
|
||||
container_name: n3
|
||||
hostname: rustfs-n3
|
||||
volumes:
|
||||
- n3d1:/var/lib/rustfs/data1
|
||||
- n3d2:/var/lib/rustfs/data2
|
||||
- n3d3:/var/lib/rustfs/data3
|
||||
- n3d4:/var/lib/rustfs/data4
|
||||
n4:
|
||||
<<: *node
|
||||
container_name: n4
|
||||
hostname: rustfs-n4
|
||||
volumes:
|
||||
- n4d1:/var/lib/rustfs/data1
|
||||
- n4d2:/var/lib/rustfs/data2
|
||||
- n4d3:/var/lib/rustfs/data3
|
||||
- n4d4:/var/lib/rustfs/data4
|
||||
|
||||
networks:
|
||||
jepsen:
|
||||
|
||||
volumes:
|
||||
n1d1: {}
|
||||
n1d2: {}
|
||||
n1d3: {}
|
||||
n1d4: {}
|
||||
n2d1: {}
|
||||
n2d2: {}
|
||||
n2d3: {}
|
||||
n2d4: {}
|
||||
n3d1: {}
|
||||
n3d2: {}
|
||||
n3d3: {}
|
||||
n3d4: {}
|
||||
n4d1: {}
|
||||
n4d2: {}
|
||||
n4d3: {}
|
||||
n4d4: {}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# Prepare a Debian node for Jepsen. RustFS itself is started later over SSH.
|
||||
set -eu
|
||||
|
||||
if [ -z "${JEPSEN_SSH_PUBKEY:-}" ]; then
|
||||
echo "JEPSEN_SSH_PUBKEY is required (the Mac user's public key)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${CLUSTER_NODES:-}" ] || [ -z "${DRIVES:-}" ]; then
|
||||
echo "CLUSTER_NODES and DRIVES are required." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p /run/sshd /home/jepsen/.ssh
|
||||
printf '%s\n' "$JEPSEN_SSH_PUBKEY" > /home/jepsen/.ssh/authorized_keys
|
||||
chown -R jepsen:jepsen /home/jepsen/.ssh
|
||||
chmod 700 /home/jepsen/.ssh
|
||||
chmod 600 /home/jepsen/.ssh/authorized_keys
|
||||
ssh-keygen -A
|
||||
|
||||
i=1
|
||||
while [ "$i" -le "$DRIVES" ]; do
|
||||
mkdir -p "/var/lib/rustfs/data${i}"
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
# Resolve service names through Docker DNS before any /etc/hosts alias is added.
|
||||
# A later alias of n1.orb.local to that address lets RustFS treat the URL host
|
||||
# as local without making every node resolve n1 to 127.0.0.1.
|
||||
tmp=$(mktemp)
|
||||
if [ -f /etc/hosts ]; then
|
||||
grep -v 'orb.local' /etc/hosts > "$tmp" || true
|
||||
else
|
||||
: > "$tmp"
|
||||
fi
|
||||
|
||||
old_ifs=$IFS
|
||||
IFS=,
|
||||
for name in $CLUSTER_NODES; do
|
||||
ip=$(getent ahostsv4 "$name" | awk 'NR==1 { print $1 }')
|
||||
if [ -z "$ip" ]; then
|
||||
echo "Docker DNS did not resolve ${name}." >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s %s.orb.local\n' "$ip" "$name" >> "$tmp"
|
||||
done
|
||||
IFS=$old_ifs
|
||||
cat "$tmp" > /etc/hosts
|
||||
rm -f "$tmp"
|
||||
|
||||
exec /usr/sbin/sshd -D -e
|
||||
@@ -0,0 +1,60 @@
|
||||
# Optional 3x2 health check of rustfs/rustfs:1.0.7. Not a Jepsen node.
|
||||
# `down -v` before compose-3x2.yaml. Do not run beside the 4x4 smoke stack.
|
||||
name: rustfs-smoke-3x2
|
||||
|
||||
x-rustfs: &rustfs
|
||||
image: rustfs/rustfs:1.0.7
|
||||
init: true
|
||||
restart: "no"
|
||||
mem_limit: 2g
|
||||
memswap_limit: 2g
|
||||
cpus: 1.0
|
||||
environment:
|
||||
RUSTFS_VOLUMES: http://n{1...3}:9000/data/disk{1...2}
|
||||
RUSTFS_ACCESS_KEY: rustfsadmin
|
||||
RUSTFS_SECRET_KEY: rustfsadmin
|
||||
RUSTFS_ADDRESS: 0.0.0.0:9000
|
||||
RUSTFS_CONSOLE_ENABLE: "false"
|
||||
RUSTFS_REGION: us-east-1
|
||||
networks:
|
||||
cluster: {}
|
||||
|
||||
services:
|
||||
n1:
|
||||
<<: *rustfs
|
||||
container_name: smoke-n1
|
||||
networks:
|
||||
cluster:
|
||||
aliases: [n1]
|
||||
volumes:
|
||||
- s1d1:/data/disk1
|
||||
- s1d2:/data/disk2
|
||||
n2:
|
||||
<<: *rustfs
|
||||
container_name: smoke-n2
|
||||
networks:
|
||||
cluster:
|
||||
aliases: [n2]
|
||||
volumes:
|
||||
- s2d1:/data/disk1
|
||||
- s2d2:/data/disk2
|
||||
n3:
|
||||
<<: *rustfs
|
||||
container_name: smoke-n3
|
||||
networks:
|
||||
cluster:
|
||||
aliases: [n3]
|
||||
volumes:
|
||||
- s3d1:/data/disk1
|
||||
- s3d2:/data/disk2
|
||||
|
||||
networks:
|
||||
cluster:
|
||||
|
||||
volumes:
|
||||
s1d1: {}
|
||||
s1d2: {}
|
||||
s2d1: {}
|
||||
s2d2: {}
|
||||
s3d1: {}
|
||||
s3d2: {}
|
||||
@@ -0,0 +1,89 @@
|
||||
# Optional health check of the official 1.0.7 image. This is not the Jepsen
|
||||
# node image: it has no SSH daemon, and its clock is the OrbStack VM clock.
|
||||
# Stop it with `down -v` before compose-4x4.yaml. Container names are
|
||||
# smoke-n*, so they do not take the n1.orb.local names Jepsen uses.
|
||||
name: rustfs-smoke-4x4
|
||||
|
||||
x-rustfs: &rustfs
|
||||
image: rustfs/rustfs:1.0.7
|
||||
init: true
|
||||
restart: "no"
|
||||
mem_limit: 2g
|
||||
memswap_limit: 2g
|
||||
cpus: 1.0
|
||||
environment: &env
|
||||
RUSTFS_VOLUMES: http://n{1...4}:9000/data/disk{1...4}
|
||||
RUSTFS_ACCESS_KEY: rustfsadmin
|
||||
RUSTFS_SECRET_KEY: rustfsadmin
|
||||
RUSTFS_ADDRESS: 0.0.0.0:9000
|
||||
RUSTFS_CONSOLE_ENABLE: "false"
|
||||
RUSTFS_REGION: us-east-1
|
||||
networks:
|
||||
cluster: {}
|
||||
|
||||
services:
|
||||
n1:
|
||||
<<: *rustfs
|
||||
container_name: smoke-n1
|
||||
networks:
|
||||
cluster:
|
||||
aliases: [n1]
|
||||
volumes:
|
||||
- s1d1:/data/disk1
|
||||
- s1d2:/data/disk2
|
||||
- s1d3:/data/disk3
|
||||
- s1d4:/data/disk4
|
||||
n2:
|
||||
<<: *rustfs
|
||||
container_name: smoke-n2
|
||||
networks:
|
||||
cluster:
|
||||
aliases: [n2]
|
||||
volumes:
|
||||
- s2d1:/data/disk1
|
||||
- s2d2:/data/disk2
|
||||
- s2d3:/data/disk3
|
||||
- s2d4:/data/disk4
|
||||
n3:
|
||||
<<: *rustfs
|
||||
container_name: smoke-n3
|
||||
networks:
|
||||
cluster:
|
||||
aliases: [n3]
|
||||
volumes:
|
||||
- s3d1:/data/disk1
|
||||
- s3d2:/data/disk2
|
||||
- s3d3:/data/disk3
|
||||
- s3d4:/data/disk4
|
||||
n4:
|
||||
<<: *rustfs
|
||||
container_name: smoke-n4
|
||||
networks:
|
||||
cluster:
|
||||
aliases: [n4]
|
||||
volumes:
|
||||
- s4d1:/data/disk1
|
||||
- s4d2:/data/disk2
|
||||
- s4d3:/data/disk3
|
||||
- s4d4:/data/disk4
|
||||
|
||||
networks:
|
||||
cluster:
|
||||
|
||||
volumes:
|
||||
s1d1: {}
|
||||
s1d2: {}
|
||||
s1d3: {}
|
||||
s1d4: {}
|
||||
s2d1: {}
|
||||
s2d2: {}
|
||||
s2d3: {}
|
||||
s2d4: {}
|
||||
s3d1: {}
|
||||
s3d2: {}
|
||||
s3d3: {}
|
||||
s3d4: {}
|
||||
s4d1: {}
|
||||
s4d2: {}
|
||||
s4d3: {}
|
||||
s4d4: {}
|
||||
@@ -0,0 +1,18 @@
|
||||
(defproject rustfs-jepsen "0.1.0"
|
||||
:description "Jepsen tests for RustFS 1.0.7. Reuses jepsen-io/jepsen Nemesis, Elle, and Knossos."
|
||||
:url "https://github.com/rustfs/rustfs"
|
||||
:license {:name "Apache License 2.0"
|
||||
:url "https://www.apache.org/licenses/LICENSE-2.0"}
|
||||
;; The AWS SDK pulls SLF4J 1.7, which cannot load Jepsen's Logback 1.5
|
||||
;; (org.slf4j.spi.LoggingEventAware). Keep the API version Jepsen uses.
|
||||
:dependencies [[org.clojure/clojure "1.12.7"]
|
||||
[org.slf4j/slf4j-api "2.0.16"]
|
||||
[jepsen "0.3.16"]
|
||||
[software.amazon.awssdk/s3 "2.29.45" :exclusions [org.slf4j/slf4j-api]]
|
||||
[software.amazon.awssdk/url-connection-client "2.29.45" :exclusions [org.slf4j/slf4j-api]]]
|
||||
:main rustfs.core
|
||||
:jvm-opts ["-Xmx3g"
|
||||
"-Djava.awt.headless=true"
|
||||
"-server"
|
||||
"-Djava.net.preferIPv4Stack=true"]
|
||||
:profiles {:dev {:jvm-opts ["-Xmx3g" "-Djava.awt.headless=true"]}})
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
# Check SSH nodes before a Jepsen run.
|
||||
# Usage: jepsen/scripts/preflight.sh --drives 4 n1.orb.local n2.orb.local n3.orb.local n4.orb.local
|
||||
set -euo pipefail
|
||||
|
||||
drives=4
|
||||
if [ "${1:-}" = "--drives" ]; then
|
||||
drives=$2
|
||||
shift 2
|
||||
fi
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "usage: preflight.sh --drives N host..." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
user=${JEPSEN_SSH_USER:-jepsen}
|
||||
key=${JEPSEN_SSH_KEY:-$HOME/.ssh/id_ed25519}
|
||||
ssh_opts=(-i "$key" -o StrictHostKeyChecking=accept-new -o BatchMode=yes)
|
||||
|
||||
fail=0
|
||||
for host in "$@"; do
|
||||
short=${host%%.orb.local}
|
||||
echo "== ${host} (drives ${drives})"
|
||||
if ! ssh "${ssh_opts[@]}" "${user}@${host}" "sudo -n true"; then
|
||||
echo "FAIL ${host}: sudo -n true" >&2
|
||||
fail=1
|
||||
continue
|
||||
fi
|
||||
if ! ssh "${ssh_opts[@]}" "${user}@${host}" "bash -s" -- "$short" "$drives" <<'REMOTE'
|
||||
set -eu
|
||||
short=$1
|
||||
drives=$2
|
||||
i=1
|
||||
while [ "$i" -le "$drives" ]; do
|
||||
test -d "/var/lib/rustfs/data${i}"
|
||||
i=$((i + 1))
|
||||
done
|
||||
sudo -n iptables -L -n >/dev/null
|
||||
if sudo -n tc qdisc add dev lo root netem delay 1ms; then
|
||||
sudo -n tc qdisc del dev lo root
|
||||
echo "tc netem: available"
|
||||
else
|
||||
echo "tc netem: NOT available (drop packet from --faults)"
|
||||
fi
|
||||
ip=$(getent ahostsv4 "${short}.orb.local" | awk 'NR==1 { print $1 }')
|
||||
echo "resolved ${short}.orb.local -> ${ip}"
|
||||
if ! ip -4 addr show | grep -q "inet ${ip}/"; then
|
||||
echo "FAIL: ${short}.orb.local does not resolve to a local address" >&2
|
||||
exit 1
|
||||
fi
|
||||
uname -m
|
||||
awk '/MemAvailable/ { print }' /proc/meminfo
|
||||
REMOTE
|
||||
then
|
||||
echo "FAIL ${host}" >&2
|
||||
fail=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit "$fail"
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Run the four workloads one after another against an already started topology.
|
||||
# Usage: jepsen/scripts/run-topology.sh 4x4
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
topology=${1:?usage: run-topology.sh 4x4|3x2}
|
||||
case "$topology" in
|
||||
4x4) concurrency=8 ;;
|
||||
3x2) concurrency=6 ;;
|
||||
*) echo "topology must be 4x4 or 3x2" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
key=${JEPSEN_SSH_KEY:-$HOME/.ssh/id_ed25519}
|
||||
time_limit=${JEPSEN_TIME_LIMIT:-90}
|
||||
faults=${JEPSEN_FAULTS:-partition,kill,pause,packet}
|
||||
|
||||
cd "$root"
|
||||
for workload in elle register versioned list; do
|
||||
echo "=== ${topology} ${workload} ==="
|
||||
lein run test \
|
||||
--topology "$topology" \
|
||||
--workload "$workload" \
|
||||
--time-limit "$time_limit" \
|
||||
--concurrency "$concurrency" \
|
||||
--username "${JEPSEN_SSH_USER:-jepsen}" \
|
||||
--ssh-private-key "$key" \
|
||||
--faults "$faults" \
|
||||
--rate 10
|
||||
done
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# Bring up one topology and make sure the other is gone.
|
||||
# Usage, from anywhere: jepsen/scripts/switch-topology.sh 4x4
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
requested=${1:?usage: switch-topology.sh 4x4|3x2}
|
||||
case "$requested" in
|
||||
4x4)
|
||||
this="$root/docker/compose-4x4.yaml"
|
||||
other="$root/docker/compose-3x2.yaml"
|
||||
;;
|
||||
3x2)
|
||||
this="$root/docker/compose-3x2.yaml"
|
||||
other="$root/docker/compose-4x4.yaml"
|
||||
;;
|
||||
*)
|
||||
echo "topology must be 4x4 or 3x2" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "${JEPSEN_SSH_PUBKEY:-}" ]; then
|
||||
echo "export JEPSEN_SSH_PUBKEY to one public-key line before starting nodes." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "Stopping the other Jepsen topology and both smoke stacks."
|
||||
docker compose -f "$other" down -v --remove-orphans
|
||||
docker compose -f "$root/docker/smoke-4x4.yaml" down -v --remove-orphans
|
||||
docker compose -f "$root/docker/smoke-3x2.yaml" down -v --remove-orphans
|
||||
|
||||
echo "Starting ${requested}. Memory cap is 2 GiB per container. Do not start the other topology until this one is down."
|
||||
docker compose -f "$this" up -d --build
|
||||
docker compose -f "$this" ps
|
||||
@@ -0,0 +1,202 @@
|
||||
(ns rustfs.checker
|
||||
"Elle and Knossos wrappers, plus the listing and version-id invariants those
|
||||
libraries cannot state.
|
||||
|
||||
Listings are not fed to Elle or Knossos. In-tree comments record that a
|
||||
listing is not a linearizable read (`rustfs/src/app/bucket_list_through.rs`,
|
||||
`crates/ecstore/src/data_usage/mod.rs`). The listing checker only rejects an
|
||||
observation that invents an ETag no acknowledged or indeterminate write can
|
||||
explain. A stale list is allowed."
|
||||
(:require [clojure.string :as str]
|
||||
[elle.rw-register :as elle-rw]
|
||||
[jepsen.checker :as checker]
|
||||
[knossos.model :as model]
|
||||
[rustfs.s3 :as s3]))
|
||||
|
||||
(defn txn->register-ops
|
||||
"Project single-micro-op transactions into Knossos register operations.
|
||||
A transaction with several micro-ops is left to Elle; splitting it would
|
||||
invent an order the client did not record."
|
||||
[history]
|
||||
(keep (fn [op]
|
||||
(when (and (= :txn (:f op))
|
||||
(#{:invoke :ok :info :fail} (:type op))
|
||||
(= 1 (count (:value op))))
|
||||
(let [[f k v] (first (:value op))]
|
||||
(assoc op
|
||||
:f (case f :r :read :w :write f)
|
||||
:value v
|
||||
:key k))))
|
||||
history))
|
||||
|
||||
(defn register-projection-checker
|
||||
"Knossos linearizability for each key in a single-micro-op Elle history."
|
||||
[]
|
||||
(reify checker/Checker
|
||||
(check [_ test history _opts]
|
||||
(let [projected (group-by :key (txn->register-ops history))
|
||||
results (mapv (fn [[k ops]]
|
||||
(let [ops (mapv #(dissoc % :key) ops)
|
||||
result (checker/check
|
||||
(checker/linearizable {:model (model/cas-register)})
|
||||
test
|
||||
ops
|
||||
{})]
|
||||
(assoc result :key k)))
|
||||
projected)
|
||||
valids (map :valid? results)]
|
||||
{:valid? (cond
|
||||
(some false? valids) false
|
||||
(every? true? valids) true
|
||||
:else :unknown)
|
||||
:key-count (count results)
|
||||
:results (vec (take 20 results))}))))
|
||||
|
||||
(defn elle-checker
|
||||
"Strict serializability from Elle, plus Knossos on each single-micro-op key.
|
||||
|
||||
Elle's register cycle search does not order versions of one key from real
|
||||
time unless `:linearizable-keys?` is set, and Elle's own notes say that flag
|
||||
can report a cycle that is not there. Knossos checks each key exactly.
|
||||
Multi-micro-op transactions stay with Elle only."
|
||||
[]
|
||||
(checker/compose
|
||||
{:elle (reify checker/Checker
|
||||
(check [_ _test history opts]
|
||||
(elle-rw/check {:consistency-models [:strict-serializable]
|
||||
:directory (:directory opts)
|
||||
:plot-timeout 10000}
|
||||
history)))
|
||||
:linearizable (register-projection-checker)}))
|
||||
|
||||
(defn knossos-checker
|
||||
"Linearizability of one register. Callers that use `jepsen.independent`
|
||||
should wrap this so each key is its own register."
|
||||
[]
|
||||
(checker/linearizable {:model (model/cas-register)}))
|
||||
|
||||
(defn- op-ok? [op] (= :ok (:type op)))
|
||||
(defn- op-info? [op] (= :info (:type op)))
|
||||
|
||||
(defn- register-key
|
||||
"Key from an independent `[k v]` value, or from a list entry's object key."
|
||||
[value]
|
||||
(when (sequential? value)
|
||||
(first value)))
|
||||
|
||||
(defn- writes-by-key
|
||||
[history]
|
||||
(reduce (fn [acc op]
|
||||
(if-not (#{:write :cas} (:f op))
|
||||
acc
|
||||
(let [k (register-key (:value op))
|
||||
etag (s3/etag-identity (:etag op))]
|
||||
(cond
|
||||
(and (op-ok? op) etag)
|
||||
(update-in acc [k :ok] (fnil conj []) {:etag etag :size (:size op)})
|
||||
|
||||
(op-info? op)
|
||||
(assoc-in acc [k :indeterminate?] true)
|
||||
|
||||
:else acc))))
|
||||
{}
|
||||
history))
|
||||
|
||||
(defn- logical-list-key
|
||||
"S3 keys are `k-<register>`. Listing rows are compared on the register key."
|
||||
[object-key]
|
||||
(when (and (string? object-key) (str/starts-with? object-key "k-"))
|
||||
(let [suffix (subs object-key 2)]
|
||||
(or (parse-long suffix) suffix))))
|
||||
|
||||
(defn listing-errors
|
||||
"Fabricated listing entries. Returns a vector of error maps."
|
||||
[history]
|
||||
(let [writes (writes-by-key history)]
|
||||
(vec
|
||||
(for [op history
|
||||
:when (and (op-ok? op) (= :list (:f op)))
|
||||
:let [rows (or (:value op) [])
|
||||
seen (volatile! #{})]
|
||||
row rows
|
||||
:let [identity (s3/etag-identity (:etag row))
|
||||
key (logical-list-key (:key row))
|
||||
dup? (contains? @seen key)
|
||||
_ (vswap! seen conj key)
|
||||
known (get writes key)
|
||||
matched (some #(and (= identity (:etag %))
|
||||
(= (:size row) (:size %)))
|
||||
(:ok known))]]
|
||||
(cond
|
||||
dup?
|
||||
{:type :duplicate-key :key key :op-index (:index op)}
|
||||
|
||||
(str/blank? identity)
|
||||
{:type :blank-etag :key key :op-index (:index op)}
|
||||
|
||||
matched
|
||||
nil
|
||||
|
||||
(:indeterminate? known)
|
||||
nil
|
||||
|
||||
:else
|
||||
{:type :fabricated
|
||||
:key key
|
||||
:etag identity
|
||||
:size (:size row)
|
||||
:op-index (:index op)})))))
|
||||
|
||||
(defn listing-checker
|
||||
[]
|
||||
(reify checker/Checker
|
||||
(check [_ _test history _opts]
|
||||
(let [errors (remove nil? (listing-errors history))]
|
||||
{:valid? (empty? errors)
|
||||
:error-count (count errors)
|
||||
:errors (vec (take 20 errors))}))))
|
||||
|
||||
(defn version-id-errors
|
||||
"Every acknowledged create or overwrite in a versioned bucket must return a
|
||||
version id, and those ids are unique."
|
||||
[history]
|
||||
(let [present? (fn [op] (not (str/blank? (:version-id op))))
|
||||
required (filter (fn [op]
|
||||
(and (op-ok? op)
|
||||
(or (and (= :write (:f op))
|
||||
(some? (second (:value op))))
|
||||
(= :cas (:f op)))))
|
||||
history)
|
||||
missing (remove present? required)
|
||||
ids (->> history
|
||||
(filter #(and (op-ok? %) (#{:write :cas} (:f %)) (present? %)))
|
||||
(map :version-id))
|
||||
dupes (->> ids frequencies (filter #(> (val %) 1)) (map key))]
|
||||
(concat
|
||||
(map (fn [op] {:type :missing-version-id :op-index (:index op) :f (:f op)}) missing)
|
||||
(map (fn [id] {:type :duplicate-version-id :version-id id}) dupes))))
|
||||
|
||||
(defn version-checker
|
||||
[]
|
||||
(reify checker/Checker
|
||||
(check [_ _test history _opts]
|
||||
(let [errors (vec (version-id-errors history))]
|
||||
{:valid? (empty? errors)
|
||||
:error-count (count errors)
|
||||
:errors (vec (take 20 errors))}))))
|
||||
|
||||
(defn filter-checker
|
||||
"Run `inner` on the history restricted by `pred`."
|
||||
[pred inner]
|
||||
(reify checker/Checker
|
||||
(check [_ test history opts]
|
||||
(checker/check inner test (filter pred history) opts))))
|
||||
|
||||
(defn workload-checker
|
||||
"Compose perf, stats, and the workload's own Elle or Knossos checker.
|
||||
Nemesis intervals are drawn when the test map has `:plot {:nemeses ...}`."
|
||||
[workload-checker]
|
||||
(checker/compose
|
||||
{:stats (checker/stats)
|
||||
:perf (checker/perf)
|
||||
:workload workload-checker}))
|
||||
@@ -0,0 +1,148 @@
|
||||
(ns rustfs.client
|
||||
"Jepsen client. Each process talks to one node over path-style S3.
|
||||
|
||||
A lost response is `:info`. A precondition rejection is `:fail` only when no
|
||||
earlier operation in the transaction has already committed. Reads of a
|
||||
missing key are successful reads of nil."
|
||||
(:require [clojure.tools.logging :refer [info warn]]
|
||||
[jepsen.client :as client]
|
||||
[rustfs.s3 :as s3]))
|
||||
|
||||
(def bucket "jepsen")
|
||||
|
||||
(defn- endpoint [test node]
|
||||
(str "http://" node ":" (:port test)))
|
||||
|
||||
(defn- definite? [ex] (:definite? (ex-data ex)))
|
||||
|
||||
(defn- fail [op error]
|
||||
(assoc op :type :fail :error error))
|
||||
|
||||
(defn- info-op [op error]
|
||||
(assoc op :type :info :error error))
|
||||
|
||||
(defn- with-meta-fields
|
||||
[op meta]
|
||||
(assoc op
|
||||
:etag (:etag meta)
|
||||
:version-id (:version-id meta)
|
||||
:size (:size meta)))
|
||||
|
||||
(defn- invoke-register
|
||||
[conn test op]
|
||||
(let [[k v] (:value op)]
|
||||
(case (:f op)
|
||||
:read
|
||||
(let [got (s3/read-value conn bucket k)]
|
||||
(-> op
|
||||
(assoc :type :ok :value [k (:value got)])
|
||||
(with-meta-fields got)))
|
||||
|
||||
:write
|
||||
(let [multipart? (< (rand) (:multipart-fraction test 0))
|
||||
wrote (s3/write-value! conn bucket k v {:multipart? multipart?})]
|
||||
(-> op
|
||||
(assoc :type :ok)
|
||||
(with-meta-fields wrote)))
|
||||
|
||||
:cas
|
||||
(let [[expected desired] v
|
||||
current (s3/read-value conn bucket k)]
|
||||
(cond
|
||||
(not= (:value current) expected)
|
||||
(fail op :precondition)
|
||||
|
||||
(and (nil? expected) (some? desired))
|
||||
(let [wrote (s3/write-value! conn bucket k desired {:if-none-match "*"})]
|
||||
(-> op (assoc :type :ok) (with-meta-fields wrote)))
|
||||
|
||||
(some? expected)
|
||||
(let [wrote (s3/write-value! conn bucket k desired {:if-match (:etag current)})]
|
||||
(-> op (assoc :type :ok) (with-meta-fields wrote)))
|
||||
|
||||
:else
|
||||
(let [wrote (s3/write-value! conn bucket k nil {})]
|
||||
(-> op (assoc :type :ok) (with-meta-fields wrote))))))))
|
||||
|
||||
(defn- apply-mop
|
||||
[conn test [f k v]]
|
||||
(case f
|
||||
:r (let [got (s3/read-value conn bucket k)]
|
||||
[:r k (:value got)])
|
||||
:w (do
|
||||
(s3/write-value! conn bucket k v
|
||||
{:multipart? (< (rand) (:multipart-fraction test 0))})
|
||||
[:w k v])))
|
||||
|
||||
(defn- invoke-txn
|
||||
[conn test op]
|
||||
(loop [done [] mops (:value op)]
|
||||
(if-not (seq mops)
|
||||
(assoc op :type :ok :value done)
|
||||
(let [mop (first mops)
|
||||
result (try
|
||||
[:ok (apply-mop conn test mop)]
|
||||
(catch clojure.lang.ExceptionInfo e
|
||||
[:err e]))]
|
||||
(if (= :ok (first result))
|
||||
(recur (conj done (second result)) (next mops))
|
||||
(let [e (second result)
|
||||
error (:error (ex-data e) :unknown)]
|
||||
(if (and (definite? e) (empty? done))
|
||||
(assoc op :type :fail :error error)
|
||||
(assoc op :type :info :error error :value (vec (conj done mop))))))))))
|
||||
|
||||
(defn- handle
|
||||
[op f]
|
||||
(try
|
||||
(f)
|
||||
(catch clojure.lang.ExceptionInfo e
|
||||
(if (definite? e)
|
||||
(fail op (:error (ex-data e) :rejected))
|
||||
(info-op op (:error (ex-data e) :indeterminate))))))
|
||||
|
||||
(defrecord S3Client [conn node]
|
||||
client/Client
|
||||
(open! [this test node]
|
||||
(assoc this
|
||||
:node node
|
||||
:conn (s3/connect {:endpoint (endpoint test node)
|
||||
:access-key (:access-key test)
|
||||
:secret-key (:secret-key test)})))
|
||||
|
||||
(setup! [_ test]
|
||||
(let [deadline (+ (System/currentTimeMillis) 180000)]
|
||||
(loop []
|
||||
(let [outcome (try
|
||||
(s3/ensure-bucket! conn bucket)
|
||||
(when (= :versioned (:workload test))
|
||||
(s3/enable-versioning! conn bucket))
|
||||
:ready
|
||||
(catch Exception e
|
||||
e))]
|
||||
(cond
|
||||
(= :ready outcome)
|
||||
(info "S3 client ready on" node "bucket" bucket)
|
||||
|
||||
(< (System/currentTimeMillis) deadline)
|
||||
(do
|
||||
(warn "Waiting for RustFS on" node ":" (.getMessage ^Exception outcome))
|
||||
(Thread/sleep 1000)
|
||||
(recur))
|
||||
|
||||
:else
|
||||
(throw outcome))))))
|
||||
|
||||
(invoke! [_ test op]
|
||||
(case (:f op)
|
||||
:txn (invoke-txn conn test op)
|
||||
:list (handle op #(assoc op :type :ok :value (s3/list-prefix conn bucket)))
|
||||
(:read :write :cas) (handle op #(invoke-register conn test op))
|
||||
(info-op op :unsupported)))
|
||||
|
||||
(teardown! [_ _test])
|
||||
|
||||
(close! [_ _test]
|
||||
(s3/close! conn)))
|
||||
|
||||
(defn client [] (S3Client. nil nil))
|
||||
@@ -0,0 +1,136 @@
|
||||
(ns rustfs.core
|
||||
"Entry point. Two official topologies, run one at a time:
|
||||
|
||||
4x4 four nodes, four drives each, one 16-drive set
|
||||
3x2 three nodes, two drives each, one 6-drive set"
|
||||
(:refer-clojure :exclude [test])
|
||||
(:require [clojure.string :as str]
|
||||
[jepsen.cli :as cli]
|
||||
[jepsen.generator :as gen]
|
||||
[jepsen.tests :as tests]
|
||||
[rustfs.checker :as rustfs-checker]
|
||||
[rustfs.client :as rustfs-client]
|
||||
[rustfs.db :as rustfs-db]
|
||||
[rustfs.nemesis :as rustfs-nemesis]
|
||||
[rustfs.topology :as topo]
|
||||
[rustfs.workload :as workload])
|
||||
(:import [org.slf4j LoggerFactory]))
|
||||
|
||||
(def ^:private log (LoggerFactory/getLogger "rustfs.core"))
|
||||
|
||||
(def cli-opts
|
||||
[[nil "--topology NAME" "4x4 or 3x2"
|
||||
:default :4x4
|
||||
:parse-fn keyword
|
||||
:validate [#{:4x4 :3x2} "must be 4x4 or 3x2"]]
|
||||
|
||||
[nil "--node-template TEMPLATE" "Format for the topology's default node names. %d is 1..N."
|
||||
:default "n%d.orb.local"]
|
||||
|
||||
[nil "--rustfs-version VERSION" "Release tag whose official zip is installed."
|
||||
:default "1.0.7"]
|
||||
|
||||
[nil "--libc LIBC" "musl (default, static) or gnu."
|
||||
:default "musl"
|
||||
:validate [#{"musl" "gnu"} "musl or gnu"]]
|
||||
|
||||
[nil "--rustfs-url URL" "Override the release zip URL. Requires --rustfs-sha256."]
|
||||
|
||||
[nil "--rustfs-sha256 HEX" "sha256 of --rustfs-url."]
|
||||
|
||||
[nil "--port PORT" "RustFS S3 and internode port."
|
||||
:default 9000
|
||||
:parse-fn parse-long]
|
||||
|
||||
[nil "--access-key KEY" "Root access key. Test default only."
|
||||
:default "rustfsadmin"]
|
||||
|
||||
[nil "--secret-key KEY" "Root secret key. Test default only; at least 8 bytes."
|
||||
:default "rustfsadmin"]
|
||||
|
||||
[nil "--faults FAULTS" "Comma-separated: partition,kill,pause,packet,clock,file-corruption. Clock is for separate VMs, not Docker containers."
|
||||
:default [:partition :kill :pause :packet]
|
||||
:parse-fn #(mapv keyword (remove str/blank? (str/split % #",")))]
|
||||
|
||||
[nil "--nemesis-interval SECONDS"
|
||||
:default 15
|
||||
:parse-fn parse-long]
|
||||
|
||||
[nil "--rate HZ" "Approximate client op rate passed to gen/stagger as 1/HZ."
|
||||
:default 10
|
||||
:parse-fn parse-double]
|
||||
|
||||
[nil "--key-count N"
|
||||
:default 8
|
||||
:parse-fn parse-long]
|
||||
|
||||
[nil "--max-txn-length N" "Elle only. 1 matches the single-key S3 claim. Larger values ask for a transaction RustFS does not provide."
|
||||
:default 1
|
||||
:parse-fn parse-long]
|
||||
|
||||
[nil "--per-key-limit N" "Knossos bound on operations per key."
|
||||
:default 20
|
||||
:parse-fn parse-long]
|
||||
|
||||
[nil "--multipart-fraction P" "Fraction of blind writes performed as a one-part multipart upload."
|
||||
:default 0.25
|
||||
:parse-fn parse-double
|
||||
:validate [#(<= 0 % 1) "must be between 0 and 1"]]
|
||||
|
||||
[nil "--workload NAME" "elle, register, versioned, or list."
|
||||
:default :elle
|
||||
:parse-fn keyword
|
||||
:validate [#{:elle :register :versioned :list} "unknown workload"]]])
|
||||
|
||||
(defn generator
|
||||
[test nemesis-pkg work]
|
||||
(let [nemesis-gen (:generator nemesis-pkg)
|
||||
final-nemesis (:final-generator nemesis-pkg)
|
||||
client (->> (:generator work)
|
||||
(gen/stagger (/ 1.0 (:rate test))))
|
||||
during (if nemesis-gen
|
||||
(gen/nemesis nemesis-gen client)
|
||||
client)
|
||||
during (gen/time-limit (:time-limit test) during)
|
||||
during (if-let [wrap (:wrap-generator work)]
|
||||
(wrap during)
|
||||
during)]
|
||||
(gen/phases
|
||||
during
|
||||
(gen/nemesis final-nemesis)
|
||||
(gen/log "Nemesis stopped; quiet period before final reads")
|
||||
(gen/sleep 10)
|
||||
(:final-generator work))))
|
||||
|
||||
(defn test
|
||||
[opts]
|
||||
(let [topology (:topology opts)
|
||||
nodes (topo/resolve-nodes (:nodes opts) topology (:node-template opts))
|
||||
opts (assoc opts
|
||||
:nodes nodes
|
||||
:topology topology
|
||||
:port (or (:port opts) 9000))
|
||||
db (rustfs-db/db)
|
||||
nemesis-pkg (rustfs-nemesis/package (assoc opts :db db))
|
||||
work (workload/workload opts)
|
||||
test (merge tests/noop-test
|
||||
opts
|
||||
{:name (str "rustfs-" (name topology) "-" (name (:workload opts)))
|
||||
:os :noop
|
||||
:db db
|
||||
:client (rustfs-client/client)
|
||||
:nemesis (:nemesis nemesis-pkg)
|
||||
:pure-generators true
|
||||
:plot {:nemeses (:perf nemesis-pkg)}
|
||||
:checker (rustfs-checker/workload-checker (:checker work))
|
||||
:generator (generator opts nemesis-pkg work)})]
|
||||
(doseq [line (topo/info-lines test)]
|
||||
(.info log line))
|
||||
(update test :ssh #(merge {:strict-host-key-checking :no} %))))
|
||||
|
||||
(defn -main
|
||||
[& args]
|
||||
(cli/run! (merge (cli/single-test-cmd {:test-fn test
|
||||
:opt-spec cli-opts})
|
||||
(cli/serve-cmd))
|
||||
args))
|
||||
@@ -0,0 +1,166 @@
|
||||
(ns rustfs.db
|
||||
"Install and supervise the official RustFS 1.0.7 binary on Debian nodes.
|
||||
|
||||
The process is started with start-stop-daemon, not the packaged systemd unit.
|
||||
That unit sets ProtectClock=true and Restart=always, which would hide clock
|
||||
skew and restart a process the kill nemesis had stopped."
|
||||
(:require [clojure.string :as str]
|
||||
[clj-commons.slingshot :refer [try+]]
|
||||
[jepsen.control :as c]
|
||||
[jepsen.control.util :as cu]
|
||||
[jepsen.db :as db]
|
||||
[jepsen.os.debian :as debian]
|
||||
[rustfs.topology :as topo])
|
||||
(:import [org.slf4j LoggerFactory]))
|
||||
|
||||
(def ^:private log (LoggerFactory/getLogger "rustfs.db"))
|
||||
|
||||
(def binary "/usr/local/bin/rustfs")
|
||||
(def pidfile "/var/run/rustfs.pid")
|
||||
(def logfile "/var/log/rustfs/rustfs.log")
|
||||
|
||||
(def artifact-sha256
|
||||
"sha256 of the GitHub release zip, keyed by [version arch libc]."
|
||||
{["1.0.7" "aarch64" "musl"] "e2c6d45105dd05df2f35547fbebfacf40dfba6ec4f8c31b86e30934faea79e76"
|
||||
["1.0.7" "aarch64" "gnu"] "147ef56079be712a242c4db43866ab269a6441a14214d66bac7ed22ef5db419e"
|
||||
["1.0.7" "x86_64" "musl"] "c90a40ba8cdc1468c71029a4d65fdd13449720183d3a8e00bc61ab09fcd448a5"
|
||||
["1.0.7" "x86_64" "gnu"] "4cd2ee55b75f7cb7c935eeb20f8c22f17e1453009cf1af1ff8b42f7986cba201"})
|
||||
|
||||
(defn node-arch
|
||||
[]
|
||||
(let [machine (str/trim (c/exec :uname :-m))]
|
||||
(case machine
|
||||
"aarch64" "aarch64"
|
||||
"arm64" "aarch64"
|
||||
"x86_64" "x86_64"
|
||||
(throw (ex-info "Unsupported node architecture for the 1.0.7 release zips."
|
||||
{:uname machine})))))
|
||||
|
||||
(defn artifact
|
||||
[{:keys [version libc arch url sha256]}]
|
||||
(if url
|
||||
(do
|
||||
(when-not sha256
|
||||
(throw (ex-info "An overridden RustFS URL requires --rustfs-sha256."
|
||||
{:url url})))
|
||||
{:url url :sha256 sha256})
|
||||
(let [arch (or arch "unresolved")
|
||||
pin (get artifact-sha256 [version arch libc])]
|
||||
(when-not pin
|
||||
(throw (ex-info "No pinned RustFS 1.0.7 zip for this architecture. Pass --rustfs-url and --rustfs-sha256."
|
||||
{:version version :arch arch :libc libc})))
|
||||
{:url (format "https://github.com/rustfs/rustfs/releases/download/%s/rustfs-linux-%s-%s-v%s.zip"
|
||||
version arch libc version)
|
||||
:sha256 pin})))
|
||||
|
||||
(defn install-packages!
|
||||
[]
|
||||
(debian/install [:wget :unzip :curl :ca-certificates :iptables :iproute2
|
||||
:procps :netcat-openbsd :coreutils :findutils]))
|
||||
|
||||
(defn install-binary!
|
||||
[test]
|
||||
(let [arch (node-arch)
|
||||
{:keys [url sha256]} (artifact (assoc test :arch arch))
|
||||
zip (cu/cached-wget! url)
|
||||
got (-> (c/exec :sha256sum zip) (str/split #"\s+") first)]
|
||||
(when-not (= sha256 got)
|
||||
(c/exec :rm :-f zip)
|
||||
(throw (ex-info "RustFS release zip checksum mismatch."
|
||||
{:url url :expected sha256 :actual got})))
|
||||
(let [dir (cu/tmp-dir!)]
|
||||
(try
|
||||
(c/exec :unzip :-qo zip :-d dir)
|
||||
(let [paths (cu/ls dir {:recursive? true :full-path? true})
|
||||
bin (or (first (filter #(= "rustfs" (last (str/split % #"/"))) paths))
|
||||
(throw (ex-info "The release zip does not contain a rustfs binary."
|
||||
{:url url :paths paths})))]
|
||||
(c/exec :install :-m "0755" bin binary))
|
||||
(finally
|
||||
(c/exec :rm :-rf dir))))
|
||||
(.info log "Installed {} from {}" binary url)))
|
||||
|
||||
(defn prepare-dirs!
|
||||
[test]
|
||||
(let [drives (:drives-per-node (topo/topologies (:topology test)))]
|
||||
(c/exec :mkdir :-p "/var/log/rustfs" "/var/lib/rustfs")
|
||||
(doseq [i (range 1 (inc drives))]
|
||||
(let [dir (topo/data-dir i)]
|
||||
(c/exec :mkdir :-p dir)
|
||||
(c/exec :find dir :-mindepth 1 :-delete)))))
|
||||
|
||||
(defn stop-timesync!
|
||||
[]
|
||||
(try+ (c/exec :systemctl :stop :systemd-timesyncd) (catch Object _))
|
||||
(try+ (c/exec :systemctl :stop :chronyd) (catch Object _))
|
||||
(try+ (c/exec :timedatectl :set-ntp :false) (catch Object _)))
|
||||
|
||||
(defn write-credentials!
|
||||
[test]
|
||||
(c/exec :mkdir :-p "/etc/rustfs")
|
||||
(cu/write-file! (:access-key test) "/etc/rustfs/access-key")
|
||||
(cu/write-file! (:secret-key test) "/etc/rustfs/secret-key")
|
||||
(c/exec :chmod "0600" "/etc/rustfs/access-key" "/etc/rustfs/secret-key"))
|
||||
|
||||
(defn start-process!
|
||||
[test]
|
||||
(let [volumes (topo/volume-arg test)]
|
||||
(.info log "Starting RustFS with {}" volumes)
|
||||
(write-credentials! test)
|
||||
(cu/start-daemon!
|
||||
{:env {:RUSTFS_ACCESS_KEY_FILE "/etc/rustfs/access-key"
|
||||
:RUSTFS_SECRET_KEY_FILE "/etc/rustfs/secret-key"
|
||||
:RUSTFS_ADDRESS (str "0.0.0.0:" (:port test))
|
||||
:RUSTFS_VOLUMES volumes
|
||||
:RUSTFS_CONSOLE_ENABLE "false"
|
||||
:RUSTFS_REGION "us-east-1"}
|
||||
:logfile logfile
|
||||
:pidfile pidfile
|
||||
:chdir "/var/lib/rustfs"
|
||||
:make-pidfile? true}
|
||||
binary
|
||||
"server")
|
||||
(cu/await-tcp-port (:port test) {:timeout 180000 :retry-interval 1000})))
|
||||
|
||||
(defn signal!
|
||||
[signal]
|
||||
(c/su
|
||||
(try+
|
||||
(c/exec :killall :-s (name signal) :rustfs)
|
||||
(catch [:type :jepsen.control/nonzero-exit :exit 1] _ :no-process))))
|
||||
|
||||
(defrecord RustFS []
|
||||
db/DB
|
||||
(setup! [_ test _node]
|
||||
(c/su
|
||||
(install-packages!)
|
||||
(install-binary! test)
|
||||
(stop-timesync!)
|
||||
(prepare-dirs! test)
|
||||
(start-process! test)))
|
||||
|
||||
(teardown! [_ _test _node]
|
||||
(c/su
|
||||
(cu/stop-daemon! "rustfs" pidfile)
|
||||
(try+ (c/exec :find "/var/lib/rustfs" :-mindepth 2 :-delete) (catch Object _))
|
||||
(try+ (c/exec :rm :-f logfile) (catch Object _))))
|
||||
|
||||
db/LogFiles
|
||||
(log-files [_ _test _node]
|
||||
{logfile "rustfs.log"})
|
||||
|
||||
db/Kill
|
||||
(kill! [_ _test _node]
|
||||
(c/su (cu/stop-daemon! "rustfs" pidfile)))
|
||||
|
||||
(start! [_ test _node]
|
||||
(c/su (start-process! test)))
|
||||
|
||||
db/Pause
|
||||
(pause! [_ _test _node]
|
||||
(signal! :STOP))
|
||||
|
||||
(resume! [_ _test _node]
|
||||
(signal! :CONT)))
|
||||
|
||||
(defn db [] (RustFS.))
|
||||
@@ -0,0 +1,33 @@
|
||||
(ns rustfs.nemesis
|
||||
"Faults from jepsen.nemesis.combined. Disk-full and slow-disk are not in
|
||||
Jepsen 0.3.16; packet delay is the latency fault the library does provide."
|
||||
(:require [jepsen.nemesis.combined :as combined]))
|
||||
|
||||
(def supported
|
||||
#{:partition :kill :pause :clock :packet :file-corruption})
|
||||
|
||||
(defn package
|
||||
[opts]
|
||||
(let [faults (set (:faults opts))
|
||||
unknown (remove supported faults)]
|
||||
(when (seq unknown)
|
||||
(throw (ex-info "Unknown nemesis fault."
|
||||
{:unknown (vec unknown)
|
||||
:supported (sort supported)})))
|
||||
(combined/nemesis-package
|
||||
(cond-> {:db (:db opts)
|
||||
:interval (:nemesis-interval opts 15)
|
||||
:faults faults
|
||||
:partition {:targets [:one :majority :majorities-ring]}
|
||||
:packet {:targets [:one]
|
||||
:behaviors [{:delay {}}
|
||||
{:loss {:percent :20%}}]}
|
||||
:kill {:targets [:one :minority]}
|
||||
:pause {:targets [:one :minority]}
|
||||
:clock {:targets [:one]}}
|
||||
(contains? faults :file-corruption)
|
||||
(assoc :file-corruption
|
||||
{:targets [:one]
|
||||
:corruptions [{:type :bitflip
|
||||
:file "/var/lib/rustfs/data1"
|
||||
:probability 1.0e-4}]})))))
|
||||
@@ -0,0 +1,306 @@
|
||||
(ns rustfs.s3
|
||||
"Path-style S3 client for RustFS 1.0.7.
|
||||
|
||||
Signing, retries, and XML are the AWS SDK. This namespace only decides which
|
||||
calls are definite and which are indeterminate, and maps object bodies onto
|
||||
the register values Elle and Knossos see. Listings are not register reads."
|
||||
(:require [clojure.string :as str])
|
||||
(:import [java.net URI]
|
||||
[java.time Duration]
|
||||
[software.amazon.awssdk.auth.credentials AwsBasicCredentials StaticCredentialsProvider]
|
||||
[software.amazon.awssdk.core.exception SdkClientException]
|
||||
[software.amazon.awssdk.core.client.config ClientOverrideConfiguration]
|
||||
[software.amazon.awssdk.core.retry RetryPolicy]
|
||||
[software.amazon.awssdk.core.sync RequestBody]
|
||||
[software.amazon.awssdk.http.urlconnection UrlConnectionHttpClient]
|
||||
[software.amazon.awssdk.regions Region]
|
||||
[software.amazon.awssdk.services.s3 S3Client]
|
||||
[software.amazon.awssdk.services.s3.model
|
||||
AbortMultipartUploadRequest
|
||||
BucketAlreadyExistsException
|
||||
BucketAlreadyOwnedByYouException
|
||||
BucketVersioningStatus
|
||||
CompleteMultipartUploadRequest
|
||||
CompletedMultipartUpload
|
||||
CompletedPart
|
||||
CreateBucketRequest
|
||||
CreateMultipartUploadRequest
|
||||
DeleteObjectRequest
|
||||
GetObjectRequest
|
||||
ListObjectsV2Request
|
||||
NoSuchKeyException
|
||||
PutBucketVersioningRequest
|
||||
PutObjectRequest
|
||||
S3Exception
|
||||
UploadPartRequest
|
||||
VersioningConfiguration]))
|
||||
|
||||
(def ^:private call-timeout (Duration/ofSeconds 15))
|
||||
|
||||
(defn quoted-etag
|
||||
"If-Match wants the quoted S3 ETag. Multipart ETags keep their `-N` suffix."
|
||||
[etag]
|
||||
(let [etag (some-> etag str str/trim)]
|
||||
(cond
|
||||
(str/blank? etag) nil
|
||||
(str/starts-with? etag "\"") etag
|
||||
:else (str "\"" etag "\""))))
|
||||
|
||||
(defn etag-identity
|
||||
"Compare ETags without quotes or a weak-validator prefix."
|
||||
[etag]
|
||||
(some-> etag
|
||||
str
|
||||
str/trim
|
||||
(str/replace #"^W/" "")
|
||||
(str/replace #"^\"|\"$" "")
|
||||
not-empty))
|
||||
|
||||
(defn classify
|
||||
"Turn a thrown S3 or transport failure into `{:definite? bool :absent? bool :rejected? bool :error keyword}`."
|
||||
[^Throwable t]
|
||||
(cond
|
||||
(instance? NoSuchKeyException t)
|
||||
{:definite? true :absent? true :error :not-found}
|
||||
|
||||
(instance? S3Exception t)
|
||||
(let [^S3Exception ex t
|
||||
status (.statusCode ex)
|
||||
code (some-> ex .awsErrorDetails .errorCode)]
|
||||
(cond
|
||||
(= 404 status)
|
||||
{:definite? true :absent? true :error (keyword (or code "not-found"))}
|
||||
|
||||
(#{400 403 405 409 412 416} status)
|
||||
{:definite? true :rejected? true :error (keyword (or code "rejected")) :status status}
|
||||
|
||||
:else
|
||||
{:definite? false :error (keyword (or code "server-error")) :status status}))
|
||||
|
||||
(instance? SdkClientException t)
|
||||
{:definite? false :error :transport}
|
||||
|
||||
:else
|
||||
{:definite? false :error :unknown}))
|
||||
|
||||
(defn- throw-classified!
|
||||
[^Throwable t]
|
||||
(throw (ex-info (.getMessage t) (classify t) t)))
|
||||
|
||||
(defn connect
|
||||
[{:keys [endpoint access-key secret-key]}]
|
||||
(let [http (.. (UrlConnectionHttpClient/builder)
|
||||
(connectionTimeout (Duration/ofSeconds 3))
|
||||
(socketTimeout call-timeout))
|
||||
retry (.. (RetryPolicy/builder)
|
||||
(numRetries 0))
|
||||
override (.. (ClientOverrideConfiguration/builder)
|
||||
(apiCallTimeout call-timeout)
|
||||
(apiCallAttemptTimeout call-timeout)
|
||||
(retryPolicy (.build retry)))]
|
||||
(.. (S3Client/builder)
|
||||
(httpClientBuilder http)
|
||||
(overrideConfiguration (.build override))
|
||||
(endpointOverride (URI/create endpoint))
|
||||
(region Region/US_EAST_1)
|
||||
(credentialsProvider
|
||||
(StaticCredentialsProvider/create
|
||||
(AwsBasicCredentials/create access-key secret-key)))
|
||||
(forcePathStyle true)
|
||||
(build))))
|
||||
|
||||
(defn- key-str
|
||||
[k]
|
||||
(str "k-" k))
|
||||
|
||||
(defn- body-str
|
||||
[value]
|
||||
(str value))
|
||||
|
||||
(defn- parse-body
|
||||
[body]
|
||||
(or (parse-long (str/trim body))
|
||||
[::unreadable body]))
|
||||
|
||||
(defn- result-meta
|
||||
[response size]
|
||||
{:etag (.eTag response)
|
||||
:version-id (.versionId response)
|
||||
:size size})
|
||||
|
||||
(defn ensure-bucket!
|
||||
[^S3Client client bucket]
|
||||
(try
|
||||
(.createBucket client (.. (CreateBucketRequest/builder) (bucket bucket) (build)))
|
||||
:created
|
||||
(catch BucketAlreadyOwnedByYouException _
|
||||
:exists)
|
||||
(catch BucketAlreadyExistsException _
|
||||
:exists)
|
||||
(catch S3Exception e
|
||||
(let [info (classify e)]
|
||||
(if (and (:definite? info) (:rejected? info)
|
||||
(#{"BucketAlreadyOwnedByYou" "BucketAlreadyExists"}
|
||||
(some-> e .awsErrorDetails .errorCode)))
|
||||
:exists
|
||||
(throw-classified! e))))
|
||||
(catch SdkClientException e
|
||||
(throw-classified! e))))
|
||||
|
||||
(defn enable-versioning!
|
||||
[^S3Client client bucket]
|
||||
(try
|
||||
(.putBucketVersioning
|
||||
client
|
||||
(.. (PutBucketVersioningRequest/builder)
|
||||
(bucket bucket)
|
||||
(versioningConfiguration
|
||||
(.. (VersioningConfiguration/builder)
|
||||
(status BucketVersioningStatus/ENABLED)
|
||||
(build)))
|
||||
(build)))
|
||||
:enabled
|
||||
(catch Throwable t
|
||||
(throw-classified! t))))
|
||||
|
||||
(defn- put-object!
|
||||
[^S3Client client bucket key body {:keys [if-match if-none-match]}]
|
||||
(let [req (-> (PutObjectRequest/builder)
|
||||
(.bucket bucket)
|
||||
(.key key)
|
||||
(cond->
|
||||
if-match (.ifMatch (quoted-etag if-match))
|
||||
if-none-match (.ifNoneMatch if-none-match))
|
||||
(.build))]
|
||||
(.putObject client req (RequestBody/fromString body))))
|
||||
|
||||
(defn- abort-upload!
|
||||
[^S3Client client bucket key upload-id]
|
||||
(try
|
||||
(.abortMultipartUpload
|
||||
client
|
||||
(-> (AbortMultipartUploadRequest/builder)
|
||||
(.bucket bucket)
|
||||
(.key key)
|
||||
(.uploadId upload-id)
|
||||
(.build)))
|
||||
(catch Throwable _)))
|
||||
|
||||
(defn- put-multipart!
|
||||
"One small part, then Complete. A lost Complete response is indeterminate, so
|
||||
this does not abort after Complete has been attempted."
|
||||
[^S3Client client bucket key body]
|
||||
(let [created (.createMultipartUpload
|
||||
client
|
||||
(-> (CreateMultipartUploadRequest/builder)
|
||||
(.bucket bucket)
|
||||
(.key key)
|
||||
(.build)))
|
||||
upload-id (.uploadId created)
|
||||
part (try
|
||||
(.uploadPart
|
||||
client
|
||||
(-> (UploadPartRequest/builder)
|
||||
(.bucket bucket)
|
||||
(.key key)
|
||||
(.uploadId upload-id)
|
||||
(.partNumber (int 1))
|
||||
(.build))
|
||||
(RequestBody/fromString body))
|
||||
(catch Throwable t
|
||||
(abort-upload! client bucket key upload-id)
|
||||
(throw-classified! t)))
|
||||
completed-part (-> (CompletedPart/builder)
|
||||
(.partNumber (int 1))
|
||||
(.eTag (.eTag part))
|
||||
(.build))
|
||||
upload (-> (CompletedMultipartUpload/builder)
|
||||
(.parts ^java.util.Collection [completed-part])
|
||||
(.build))]
|
||||
(try
|
||||
(.completeMultipartUpload
|
||||
client
|
||||
(-> (CompleteMultipartUploadRequest/builder)
|
||||
(.bucket bucket)
|
||||
(.key key)
|
||||
(.uploadId upload-id)
|
||||
(.multipartUpload upload)
|
||||
(.build)))
|
||||
(catch Throwable t
|
||||
(throw-classified! t)))))
|
||||
|
||||
(defn write-value!
|
||||
"Write `value`. A nil value deletes the current object. `opts` may contain
|
||||
`:multipart?`, `:if-match`, or `:if-none-match`."
|
||||
[^S3Client client bucket k value opts]
|
||||
(let [key (key-str k)]
|
||||
(try
|
||||
(if (nil? value)
|
||||
(let [resp (.deleteObject
|
||||
client
|
||||
(.. (DeleteObjectRequest/builder) (bucket bucket) (key key) (build)))]
|
||||
{:etag nil :version-id (.versionId resp) :size 0 :deleted? true})
|
||||
(let [body (body-str value)
|
||||
resp (if (:multipart? opts)
|
||||
(put-multipart! client bucket key body)
|
||||
(put-object! client bucket key body opts))]
|
||||
(result-meta resp (count (.getBytes body "UTF-8")))))
|
||||
(catch clojure.lang.ExceptionInfo e
|
||||
(throw e))
|
||||
(catch Throwable t
|
||||
(throw-classified! t)))))
|
||||
|
||||
(defn read-value
|
||||
"Return `{:value v :etag ... :version-id ... :size ...}`. A missing key is
|
||||
`{:value nil}` and is a successful read, not a failure."
|
||||
[^S3Client client bucket k]
|
||||
(try
|
||||
(with-open [in (.getObject
|
||||
client
|
||||
(.. (GetObjectRequest/builder)
|
||||
(bucket bucket)
|
||||
(key (key-str k))
|
||||
(build)))]
|
||||
(let [resp (.response in)
|
||||
body (slurp in)]
|
||||
{:value (parse-body body)
|
||||
:etag (.eTag resp)
|
||||
:version-id (.versionId resp)
|
||||
:size (count (.getBytes body "UTF-8"))}))
|
||||
(catch NoSuchKeyException _
|
||||
{:value nil :etag nil :version-id nil :size 0 :absent? true})
|
||||
(catch Throwable t
|
||||
(let [info (classify t)]
|
||||
(if (:absent? info)
|
||||
{:value nil :etag nil :version-id nil :size 0 :absent? true}
|
||||
(throw-classified! t))))))
|
||||
|
||||
(defn list-prefix
|
||||
"List current objects under `k-`. This is not a linearizable read."
|
||||
[^S3Client client bucket]
|
||||
(try
|
||||
(loop [token nil acc []]
|
||||
(let [resp (.listObjectsV2
|
||||
client
|
||||
(-> (ListObjectsV2Request/builder)
|
||||
(.bucket bucket)
|
||||
(.prefix "k-")
|
||||
(.maxKeys (int 1000))
|
||||
(cond-> token (.continuationToken token))
|
||||
(.build)))
|
||||
page (mapv (fn [obj]
|
||||
{:key (.key obj)
|
||||
:etag (.eTag obj)
|
||||
:size (some-> (.size obj) long)})
|
||||
(.contents resp))
|
||||
acc (into acc page)]
|
||||
(if (.isTruncated resp)
|
||||
(recur (.nextContinuationToken resp) acc)
|
||||
acc)))
|
||||
(catch Throwable t
|
||||
(throw-classified! t))))
|
||||
|
||||
(defn close!
|
||||
[^S3Client client]
|
||||
(when client
|
||||
(.close client)))
|
||||
@@ -0,0 +1,170 @@
|
||||
(ns rustfs.topology
|
||||
"Official RustFS Jepsen topologies and the volume arguments they require.
|
||||
|
||||
RustFS expands `{start...end}` in `RUSTFS_VOLUMES` the way MinIO does: every
|
||||
brace is a dimension of one pool, and the dimensions multiply. That is the
|
||||
layout exercised by `DisksLayout` (for example
|
||||
`http://rustfs{0...15}.mydomain.net/data{0...1}` is 32 endpoints). A single
|
||||
argument with no second pool is one pool. Set width is then chosen from the
|
||||
divisors of the endpoint count, preferring the widest symmetric set of at
|
||||
most 16 drives.
|
||||
|
||||
`http://n{1...4}.orb.local:9000/var/lib/rustfs/data{1...4}` is therefore
|
||||
4×4 = 16 endpoints and one set of 16. `...data{1...2}` on three hosts is
|
||||
3×2 = 6 endpoints and one set of 6. The path after the host is a directory
|
||||
on that node, not an HTTP prefix.
|
||||
|
||||
Default parity comes from `default_parity_count`: 1→0, 2–3→1, 4–5→2, 6–7→3,
|
||||
8 or more→4. Read quorum is `drives - parity`. Write quorum is the data
|
||||
count, plus one when that count equals parity (`default_write_quorum`).")
|
||||
|
||||
(def default-jepsen-nodes
|
||||
"Node list Jepsen supplies when the command does not pass `-n`."
|
||||
["n1" "n2" "n3" "n4" "n5"])
|
||||
|
||||
(def topologies
|
||||
{:4x4 {:nodes 4
|
||||
:drives-per-node 4
|
||||
:drives 16
|
||||
:set-size 16
|
||||
:parity 4
|
||||
:read-quorum 12
|
||||
:write-quorum 12
|
||||
:survives-one-node-loss? true
|
||||
:majority-partition "2-2, eight drives on each side, neither side has quorum 12"}
|
||||
:3x2 {:nodes 3
|
||||
:drives-per-node 2
|
||||
:drives 6
|
||||
:set-size 6
|
||||
:parity 3
|
||||
:read-quorum 3
|
||||
:write-quorum 4
|
||||
:survives-one-node-loss? true
|
||||
:majority-partition "2-1. The two-node side has four drives and can write. The single node has two drives and cannot read or write."}})
|
||||
|
||||
(defn node-name
|
||||
[node]
|
||||
(cond
|
||||
(keyword? node) (name node)
|
||||
(symbol? node) (name node)
|
||||
:else (str node)))
|
||||
|
||||
(defn parse-numbered-host
|
||||
"Split `n12.orb.local` into prefix `n`, number 12, suffix `.orb.local`."
|
||||
[host]
|
||||
(let [host (node-name host)]
|
||||
(if-let [[_ prefix number suffix] (re-matches #"^(.*?)(\d+)([^\d]*)$" host)]
|
||||
{:host host
|
||||
:prefix prefix
|
||||
:number (Long/parseLong number)
|
||||
:suffix suffix}
|
||||
(throw (ex-info "Node name must end in a number so RUSTFS_VOLUMES can use {start...end}."
|
||||
{:node host})))))
|
||||
|
||||
(defn default-nodes
|
||||
[topology template]
|
||||
(let [{:keys [nodes]} (topologies topology)]
|
||||
(mapv #(format template %) (range 1 (inc nodes)))))
|
||||
|
||||
(defn resolve-nodes
|
||||
"Use an explicit `-n` list when it matches the topology. The untouched Jepsen
|
||||
default of five nodes is replaced by the topology's own names."
|
||||
[requested topology template]
|
||||
(let [names (mapv node-name requested)
|
||||
spec (topologies topology)
|
||||
official (default-nodes topology template)]
|
||||
(cond
|
||||
(nil? spec)
|
||||
(throw (ex-info "Unknown topology. Use 4x4 or 3x2."
|
||||
{:topology topology}))
|
||||
|
||||
(= names default-jepsen-nodes)
|
||||
official
|
||||
|
||||
(= (count names) (:nodes spec))
|
||||
names
|
||||
|
||||
:else
|
||||
(throw (ex-info "Node count does not match the topology."
|
||||
{:topology topology
|
||||
:expected (:nodes spec)
|
||||
:nodes names})))))
|
||||
|
||||
(defn ellipsis-host
|
||||
"Turn [n1.orb.local n2.orb.local ...] into `n{1...4}.orb.local`."
|
||||
[nodes]
|
||||
(let [parsed (mapv parse-numbered-host nodes)
|
||||
prefixes (map :prefix parsed)
|
||||
suffixes (map :suffix parsed)
|
||||
numbers (mapv :number parsed)
|
||||
expected (vec (range 1 (inc (count parsed))))]
|
||||
(when-not (and (= 1 (count (set prefixes)))
|
||||
(= 1 (count (set suffixes))))
|
||||
(throw (ex-info "Every node must share one prefix and one suffix."
|
||||
{:nodes (map :host parsed)})))
|
||||
(when (not= numbers expected)
|
||||
(throw (ex-info "Node numbers must be 1..N with no gaps, in order."
|
||||
{:nodes (map :host parsed)
|
||||
:numbers numbers})))
|
||||
(str (first prefixes) "{" (first numbers) "..." (peek numbers) "}" (first suffixes))))
|
||||
|
||||
(defn data-dir
|
||||
"On-disk directory for drive `i` (1-based). The same path is embedded in the volume URL."
|
||||
[i]
|
||||
(str "/var/lib/rustfs/data" i))
|
||||
|
||||
(defn volume-arg
|
||||
"The single `RUSTFS_VOLUMES` value, identical on every node."
|
||||
[{:keys [nodes port topology]}]
|
||||
(let [spec (topologies topology)
|
||||
host (ellipsis-host nodes)]
|
||||
(when-not spec
|
||||
(throw (ex-info "Unknown topology." {:topology topology})))
|
||||
(format "http://%s:%s/var/lib/rustfs/data{1...%d}"
|
||||
host
|
||||
(or port 9000)
|
||||
(:drives-per-node spec))))
|
||||
|
||||
(defn describe
|
||||
[topology]
|
||||
(let [spec (topologies topology)]
|
||||
(format "%s: %d nodes x %d drives = %d endpoints, one erasure set of %d, parity %d, read quorum %d, write quorum %d. %s"
|
||||
(name topology)
|
||||
(:nodes spec)
|
||||
(:drives-per-node spec)
|
||||
(:drives spec)
|
||||
(:set-size spec)
|
||||
(:parity spec)
|
||||
(:read-quorum spec)
|
||||
(:write-quorum spec)
|
||||
(:majority-partition spec))))
|
||||
|
||||
(defn quorum
|
||||
"Mirror `default_parity_count` and `default_write_quorum` for a set of `drives`."
|
||||
[drives]
|
||||
(let [parity (cond
|
||||
(<= drives 1) 0
|
||||
(<= drives 3) 1
|
||||
(<= drives 5) 2
|
||||
(<= drives 7) 3
|
||||
:else 4)
|
||||
data (- drives parity)
|
||||
write (if (= data parity) (inc data) data)]
|
||||
{:drives drives
|
||||
:parity parity
|
||||
:data data
|
||||
:read-quorum data
|
||||
:write-quorum write}))
|
||||
|
||||
(defn official-quorum-matches?
|
||||
[topology]
|
||||
(let [spec (topologies topology)
|
||||
got (quorum (:drives spec))]
|
||||
(and (= (:parity spec) (:parity got))
|
||||
(= (:read-quorum spec) (:read-quorum got))
|
||||
(= (:write-quorum spec) (:write-quorum got)))))
|
||||
|
||||
(defn info-lines
|
||||
[test]
|
||||
[(describe (:topology test))
|
||||
(str "RUSTFS_VOLUMES=" (volume-arg test))])
|
||||
@@ -0,0 +1,66 @@
|
||||
(ns rustfs.workload
|
||||
"Workloads. Elle sees single-key transactions because RustFS does not offer a
|
||||
multi-key transaction. Knossos sees an independent compare-and-set register
|
||||
per key, using If-Match and If-None-Match, which 1.0.7 implements."
|
||||
(:require [jepsen.checker :as checker]
|
||||
[jepsen.generator :as gen]
|
||||
[jepsen.independent :as independent]
|
||||
[jepsen.tests.cycle.wr :as wr]
|
||||
[jepsen.tests.linearizable-register :as linreg]
|
||||
[rustfs.checker :as rustfs-checker]))
|
||||
|
||||
(defn elle
|
||||
[test]
|
||||
(let [base (wr/test {:key-count (:key-count test)
|
||||
:min-txn-length 1
|
||||
:max-txn-length (:max-txn-length test)
|
||||
:consistency-models [:strict-serializable]})]
|
||||
(assoc base :checker (rustfs-checker/elle-checker))))
|
||||
|
||||
(defn register
|
||||
[test]
|
||||
(linreg/test {:nodes (:nodes test)
|
||||
:per-key-limit (:per-key-limit test)}))
|
||||
|
||||
(defn versioned
|
||||
[test]
|
||||
(let [base (register test)]
|
||||
(update base :checker
|
||||
(fn [inner]
|
||||
(checker/compose {:register inner
|
||||
:versions (rustfs-checker/version-checker)})))))
|
||||
|
||||
(defn list-gen
|
||||
[test]
|
||||
(let [n (count (:nodes test))]
|
||||
(gen/reserve
|
||||
1 (repeat {:type :invoke :f :list})
|
||||
(independent/concurrent-generator
|
||||
n
|
||||
(range (:key-count test))
|
||||
(fn [_k]
|
||||
(gen/mix
|
||||
[(fn [_ _] {:type :invoke :f :read})
|
||||
(fn [_ _] {:type :invoke :f :write :value (rand-int 1000000)})]))))))
|
||||
|
||||
(defn list-workload
|
||||
[test]
|
||||
(let [base (register (assoc test :per-key-limit (:per-key-limit test)))]
|
||||
{:generator (list-gen test)
|
||||
:final-generator nil
|
||||
:checker (checker/compose
|
||||
{:register (rustfs-checker/filter-checker
|
||||
#(#{:read :write :cas} (:f %))
|
||||
(:checker base))
|
||||
:listing (rustfs-checker/listing-checker)})}))
|
||||
|
||||
(defn workload
|
||||
[test]
|
||||
(case (:workload test)
|
||||
:elle (elle test)
|
||||
:register (register test)
|
||||
:versioned (versioned test)
|
||||
:list (list-workload test)
|
||||
(throw (ex-info "Unknown workload."
|
||||
{:workload (:workload test)
|
||||
:known [:elle :register :versioned :list]}))))
|
||||
@@ -0,0 +1,110 @@
|
||||
(ns rustfs.checker-test
|
||||
(:require [clojure.test :refer [deftest is]]
|
||||
[elle.rw-register :as elle-rw]
|
||||
[jepsen.checker :as checker]
|
||||
[jepsen.history :as history]
|
||||
[knossos.model :as model]
|
||||
[rustfs.checker :as c]
|
||||
[rustfs.db :as db]
|
||||
[rustfs.s3 :as s3]))
|
||||
|
||||
(def knossos-test
|
||||
{:name "knossos-unit"
|
||||
:start-time "unit"})
|
||||
|
||||
(defn- check-linearizable [ops]
|
||||
(checker/check (checker/linearizable {:model (model/cas-register)})
|
||||
knossos-test
|
||||
ops
|
||||
{}))
|
||||
|
||||
(deftest knossos-accepts-a-real-time-write-then-read
|
||||
(let [result (check-linearizable
|
||||
[{:index 0 :process 0 :type :invoke :f :write :value 1}
|
||||
{:index 1 :process 0 :type :ok :f :write :value 1}
|
||||
{:index 2 :process 1 :type :invoke :f :read :value nil}
|
||||
{:index 3 :process 1 :type :ok :f :read :value 1}])]
|
||||
(is (:valid? result))))
|
||||
|
||||
(deftest knossos-rejects-a-read-that-finishes-before-its-write
|
||||
(let [result (check-linearizable
|
||||
[{:index 0 :process 0 :type :invoke :f :read :value nil}
|
||||
{:index 1 :process 0 :type :ok :f :read :value 1}
|
||||
{:index 2 :process 1 :type :invoke :f :write :value 1}
|
||||
{:index 3 :process 1 :type :ok :f :write :value 1}])]
|
||||
(is (false? (:valid? result)))))
|
||||
|
||||
(defn- txn [index process type value time]
|
||||
{:index index :process process :type type :f :txn :value value :time time})
|
||||
|
||||
(deftest elle-accepts-a-single-key-write-then-read
|
||||
(let [history (history/history
|
||||
[(txn 0 0 :invoke [[:w :x 1]] 0)
|
||||
(txn 1 0 :ok [[:w :x 1]] 1)
|
||||
(txn 2 1 :invoke [[:r :x nil]] 2)
|
||||
(txn 3 1 :ok [[:r :x 1]] 3)])
|
||||
result (elle-rw/check {:consistency-models [:strict-serializable]} history)]
|
||||
(is (:valid? result) (pr-str (select-keys result [:valid? :anomaly-types])))))
|
||||
|
||||
(deftest elle-rejects-a-read-of-an-aborted-write
|
||||
(let [history (history/history
|
||||
[(txn 0 0 :invoke [[:w :x 1]] 0)
|
||||
(txn 1 0 :fail [[:w :x 1]] 1)
|
||||
(txn 2 1 :invoke [[:r :x nil]] 2)
|
||||
(txn 3 1 :ok [[:r :x 1]] 3)])
|
||||
result (elle-rw/check {:consistency-models [:strict-serializable]} history)]
|
||||
(is (false? (:valid? result)) (pr-str (:anomaly-types result)))))
|
||||
|
||||
(deftest knossos-rejects-a-stale-read-after-a-later-write
|
||||
(let [result (check-linearizable
|
||||
[{:index 0 :process 0 :type :invoke :f :write :value 1}
|
||||
{:index 1 :process 0 :type :ok :f :write :value 1}
|
||||
{:index 2 :process 1 :type :invoke :f :write :value 2}
|
||||
{:index 3 :process 1 :type :ok :f :write :value 2}
|
||||
{:index 4 :process 2 :type :invoke :f :read :value nil}
|
||||
{:index 5 :process 2 :type :ok :f :read :value 1}])]
|
||||
(is (false? (:valid? result)))))
|
||||
|
||||
(deftest listing-checker-allows-a-known-etag-and-rejects-a-fabricated-one
|
||||
(let [history [{:index 0 :type :ok :f :write :value [1 7] :etag "\"abc\"" :size 1}
|
||||
{:index 1 :type :ok :f :list
|
||||
:value [{:key "k-1" :etag "\"abc\"" :size 1}
|
||||
{:key "k-2" :etag "\"nope\"" :size 1}]}]
|
||||
result (checker/check (c/listing-checker) {} history {})]
|
||||
(is (false? (:valid? result)))
|
||||
(is (= [:fabricated] (map :type (:errors result))))))
|
||||
|
||||
(deftest listing-checker-accepts-the-etag-that-was-written
|
||||
(let [history [{:index 0 :type :ok :f :write :value [1 7] :etag "\"abc\"" :size 1}
|
||||
{:index 1 :type :ok :f :list
|
||||
:value [{:key "k-1" :etag "abc" :size 1}]}]
|
||||
result (checker/check (c/listing-checker) {} history {})]
|
||||
(is (:valid? result) (pr-str result))))
|
||||
|
||||
(deftest version-ids-must-exist-and-be-unique
|
||||
(is (:valid? (checker/check (c/version-checker) {}
|
||||
[{:type :ok :f :write :value [1 2] :version-id "v1"}
|
||||
{:type :ok :f :read :value [1 2] :version-id "v1"}
|
||||
{:type :ok :f :write :value [1 3] :version-id "v2"}]
|
||||
{})))
|
||||
(let [missing (checker/check (c/version-checker) {}
|
||||
[{:type :ok :f :write :value [1 2]}]
|
||||
{})]
|
||||
(is (false? (:valid? missing))))
|
||||
(let [dup (checker/check (c/version-checker) {}
|
||||
[{:type :ok :f :write :value [1 2] :version-id "v1"}
|
||||
{:type :ok :f :write :value [1 3] :version-id "v1"}]
|
||||
{})]
|
||||
(is (false? (:valid? dup)))))
|
||||
|
||||
(deftest etag-normalization
|
||||
(is (= "abc" (s3/etag-identity "\"abc\"")))
|
||||
(is (= "abc-1" (s3/etag-identity "W/\"abc-1\"")))
|
||||
(is (= "\"abc\"" (s3/quoted-etag "abc")))
|
||||
(is (= "\"abc\"" (s3/quoted-etag "\"abc\""))))
|
||||
|
||||
(deftest pinned-aarch64-musl-zip
|
||||
(let [got (db/artifact {:version "1.0.7" :arch "aarch64" :libc "musl"})]
|
||||
(is (= "e2c6d45105dd05df2f35547fbebfacf40dfba6ec4f8c31b86e30934faea79e76"
|
||||
(:sha256 got)))
|
||||
(is (re-find #"rustfs-linux-aarch64-musl-v1\.0\.7\.zip$" (:url got)))))
|
||||
@@ -0,0 +1,42 @@
|
||||
(ns rustfs.topology-test
|
||||
(:require [clojure.test :refer [deftest is testing]]
|
||||
[rustfs.topology :as topo]))
|
||||
|
||||
(deftest official-quorums-match-rustfs
|
||||
(doseq [topology [:4x4 :3x2]]
|
||||
(is (topo/official-quorum-matches? topology) (name topology)))
|
||||
(is (= {:drives 16 :parity 4 :data 12 :read-quorum 12 :write-quorum 12}
|
||||
(topo/quorum 16)))
|
||||
(is (= {:drives 6 :parity 3 :data 3 :read-quorum 3 :write-quorum 4}
|
||||
(topo/quorum 6))))
|
||||
|
||||
(deftest default-five-nodes-become-the-topology
|
||||
(is (= ["n1.orb.local" "n2.orb.local" "n3.orb.local" "n4.orb.local"]
|
||||
(topo/resolve-nodes [:n1 :n2 :n3 :n4 :n5] :4x4 "n%d.orb.local")))
|
||||
(is (= ["n1.orb.local" "n2.orb.local" "n3.orb.local"]
|
||||
(topo/resolve-nodes ["n1" "n2" "n3" "n4" "n5"] :3x2 "n%d.orb.local"))))
|
||||
|
||||
(deftest explicit-nodes-must-match-the-count
|
||||
(is (= ["n1" "n2" "n3" "n4"]
|
||||
(topo/resolve-nodes ["n1" "n2" "n3" "n4"] :4x4 "n%d.orb.local")))
|
||||
(is (thrown-with-msg? clojure.lang.ExceptionInfo #"Node count"
|
||||
(topo/resolve-nodes ["n1" "n2"] :4x4 "n%d.orb.local"))))
|
||||
|
||||
(deftest volume-argument-is-one-ellipsis-pool
|
||||
(testing "4x4 is the cartesian product of four hosts and four directories"
|
||||
(is (= "http://n{1...4}.orb.local:9000/var/lib/rustfs/data{1...4}"
|
||||
(topo/volume-arg {:topology :4x4
|
||||
:port 9000
|
||||
:nodes ["n1.orb.local" "n2.orb.local"
|
||||
"n3.orb.local" "n4.orb.local"]}))))
|
||||
(testing "3x2 is three hosts and two directories"
|
||||
(is (= "http://vm{1...3}:9000/var/lib/rustfs/data{1...2}"
|
||||
(topo/volume-arg {:topology :3x2
|
||||
:port 9000
|
||||
:nodes ["vm1" "vm2" "vm3"]})))))
|
||||
|
||||
(deftest nodes-must-be-numbered-without-gaps
|
||||
(is (thrown-with-msg? clojure.lang.ExceptionInfo #"no gaps"
|
||||
(topo/volume-arg {:topology :4x4
|
||||
:port 9000
|
||||
:nodes ["n1" "n2" "n4" "n3"]}))))
|
||||
Reference in New Issue
Block a user