Skip to content

Commit

Permalink
Merge branch 'main' of github.com:jepsen-io/jepsen
Browse files Browse the repository at this point in the history
  • Loading branch information
aphyr committed Jul 25, 2023
2 parents 56293fe + a8d4ac5 commit 2310c73
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 41 deletions.
19 changes: 10 additions & 9 deletions doc/tutorial/03-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,26 +276,27 @@ INFO [2017-03-30 22:14:25,633] jepsen worker 0 - jepsen.util 0 :ok :read "0"
Ah, we've got a bit of a snag here. etcd thinks in terms of strings, but we'd
like to work with numbers. We could pull in a serialization library (jepsen
includes a simple one in `jepsen.codec`), but since we're only dealing with
integers and nil, we can get away with using Java's built-in
`Long.parseLong(String str)` method.
integers and nil, we can get away with using Clojure's built-in `parse-long`
function. It doesn't like being passed `nil`, though, so we'll write a small
wrapper:

```clj
(defn parse-long
(defn parse-long-nil
"Parses a string to a Long. Passes through `nil`."
[s]
(when s (Long/parseLong s)))
(when s (parse-long s)))
...
(invoke! [_ test op]
(case (:f op)
:read (assoc op :type :ok, :value (parse-long (v/get conn "foo")))
:read (assoc op :type :ok, :value (parse-long-nil (v/get conn "foo")))
:write (do (v/reset! conn "foo" (:value op))
(assoc op :type :ok))))
```

Note that we only call parseLong when our string is truthy--using `(when s
...)`. If `when` doesn't match, it'll return `nil`, which lets us pass through
Note that we only call `parse-long` when our string is truthy--using `(when s
)`. If `when` doesn't match, it'll return `nil`, which lets us pass through
`nil` values transparently.

```bash
Expand Down Expand Up @@ -326,7 +327,7 @@ We can use that to determine the `:type` of the CaS operation.
```clj
(invoke! [_ test op]
(case (:f op)
:read (assoc op :type :ok, :value (parse-long (v/get conn "foo")))
:read (assoc op :type :ok, :value (parse-long-nil (v/get conn "foo")))
:write (do (v/reset! conn "foo" (:value op))
(assoc op :type :ok))
:cas (let [[old new] (:value op)]
Expand Down Expand Up @@ -374,7 +375,7 @@ error code.
```clj
(invoke! [this test op]
(case (:f op)
:read (assoc op :type :ok, :value (parse-long (v/get conn "foo")))
:read (assoc op :type :ok, :value (parse-long-nil (v/get conn "foo")))
:write (do (v/reset! conn "foo" (:value op))
(assoc op :type :ok))
:cas (try+
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/05-nemesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ that:
(case (:f op)
:read (let [value (-> conn
(v/get "foo" {:quorum? true})
parse-long)]
parse-long-nil)]
(assoc op :type :ok, :value value))
...
```
Expand Down
6 changes: 3 additions & 3 deletions doc/tutorial/06-refining.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ safely convert crashed reads to failed reads, and improve checker performance.
(case (:f op)
:read (try (let [value (-> conn
(v/get "foo" {:quorum? true})
parse-long)]
parse-long-nil)]
(assoc op :type :ok, :value value))
(catch java.net.SocketTimeoutException ex
(assoc op :type :fail, :error :timeout)))
Expand All @@ -70,7 +70,7 @@ a little cleaner.
(case (:f op)
:read (let [value (-> conn
(v/get "foo" {:quorum? true})
parse-long)]
parse-long-nil)]
(assoc op :type :ok, :value value))
:write (do (v/reset! conn "foo" (:value op))
(assoc op :type :ok))
Expand Down Expand Up @@ -163,7 +163,7 @@ keys.
(case (:f op)
:read (let [value (-> conn
(v/get k {:quorum? true})
parse-long)]
parse-long-nil)]
(assoc op :type :ok, :value (independent/tuple k value)))

:write (do (v/reset! conn k v)
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/07-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ reads, in the Client `invoke` function:
(case (:f op)
:read (let [value (-> conn
(v/get k {:quorum? (:quorum test)})
parse-long)]
parse-long-nil)]
(assoc op :type :ok, :value (independent/tuple k value)))
```

Expand Down
4 changes: 0 additions & 4 deletions docker/bin/up
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ INFO "Running \`docker compose build\`"
# shellcheck disable=SC2086
docker compose --compatibility -p jepsen -f docker-compose.yml ${COMPOSE} ${DEV} build

# We need a fresh share volume each time we start, so we have a correct set of
# DB hosts. Why does Docker make sharing state SO hard
docker run --rm -v jepsen_jepsen-shared:/data/ debian:buster rm /data/nodes || true

INFO "Running \`docker compose up\`"
if [ "${RUN_AS_DAEMON}" -eq 1 ]; then
# shellcheck disable=SC2086
Expand Down
19 changes: 4 additions & 15 deletions docker/control/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bullseye
FROM jgoerzen/debian-base-standard:bullseye

ENV container=docker
STOPSIGNAL SIGRTMIN+3
Expand All @@ -8,20 +8,9 @@ ENV LEIN_ROOT true
#
# Jepsen dependencies
#
RUN apt-get -y -q update && \
apt-get install -qy openjdk-17-jdk-headless \
libjna-java \
vim \
emacs \
git \
htop \
screen \
pssh \
curl \
wget \
gnuplot \
graphviz \
dos2unix
RUN apt-get -qy update && \
apt-get -qy install \
curl dos2unix emacs git gnuplot graphviz htop iputils-ping libjna-java openjdk-17-jdk-headless pssh screen vim wget

RUN wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein && \
mv lein /usr/bin && \
Expand Down
13 changes: 7 additions & 6 deletions docker/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ ENV container=docker
STOPSIGNAL SIGRTMIN+3

# Basic system stuff
RUN apt-get update
RUN apt-get install -y apt-transport-https
RUN apt-get -qy update && \
apt-get -qy install \
apt-transport-https

# Install packages
RUN apt-get -qy update && \
apt-get -qy install \
dos2unix \
openssh-server \
pwgen
dos2unix openssh-server pwgen

# When run, boot-debian-base will call this script, which does final
# per-db-node setup stuff.
Expand All @@ -28,7 +27,9 @@ RUN sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh
ENV DEBBASE_SSH enabled

# Install Jepsen deps
RUN apt-get install -qy build-essential bzip2 curl dnsutils faketime iproute2 iptables iputils-ping libzip4 logrotate man man-db net-tools ntpdate psmisc python rsyslog sudo tar unzip vim wget ca-certificates
RUN apt-get -qy update && \
apt-get -qy install \
build-essential bzip2 ca-certificates curl dirmngr dnsutils faketime iproute2 iptables iputils-ping libzip4 logrotate man man-db netcat net-tools ntpdate psmisc python rsyslog sudo tar tcpdump unzip vim wget

EXPOSE 22
CMD ["/usr/local/bin/boot-debian-base"]
3 changes: 2 additions & 1 deletion docker/template/depends.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- n%%N%%
n%%N%%:
condition: service_healthy
18 changes: 18 additions & 0 deletions docker/template/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ x-node:
- ALL
ports:
- ${JEPSEN_PORT:-22}
stop_signal: SIGRTMIN+3
healthcheck:
test: [ 'CMD-SHELL', 'systemctl status sshd | grep "Active: active (running)"' ]
interval: 1s
timeout: 1s
retries: 3
start_period: 3s
depends_on:
setup:
condition: service_completed_successfully

volumes:
jepsen-shared:
Expand All @@ -30,6 +40,13 @@ networks:
jepsen:

services:
setup:
image: jgoerzen/debian-base-standard:bullseye
container_name: jepsen-setup
hostname: setup
volumes:
- "jepsen-shared:/var/jepsen/shared"
entrypoint: [ 'rm', '-rf', '/var/jepsen/shared/nodes' ]
control:
container_name: jepsen-control
hostname: control
Expand All @@ -44,4 +61,5 @@ services:
- jepsen
volumes:
- "jepsen-shared:/var/jepsen/shared"
stop_signal: SIGRTMIN+3
%%DBS%%
2 changes: 1 addition & 1 deletion stolon/src/jepsen/stolon/nemesis.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[time :as nt]]))

(defn nemesis-package
"Constructs a nemesis and generators for MongoDB."
"Constructs a nemesis and generators for Stolon."
[opts]
(let [opts (update opts :faults set)]
(nc/nemesis-package opts)))

0 comments on commit 2310c73

Please sign in to comment.