Skip to content

Commit

Permalink
[WIP] Jepsen fix (#138)
Browse files Browse the repository at this point in the history
* Do like redis

* Add workflow to test jepsen tests...

* Remove jepson tests on pull/push

* Let's check a scenario with time-limit 7200

* Change gen/time-limit

* Okay... Let's set it to 3600s

* Take up timeouts!..

* Let's check it with 60000 read timeout

* Rename errors

* Add keys to the mysql hosts

* Fix ssh connection

* fix timeout

* Remove on_push and on_pull_request triggers
  • Loading branch information
noname0443 authored Oct 8, 2024
1 parent 4a012aa commit 193ef65
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jepsen_test:
timeout 600 docker exec mysync_mysql2_1 sh -c "/var/lib/dist/base/generate_certs.sh mysync_mysql2_1.mysync_mysql_net && supervisorctl restart mysync && supervisorctl start mysqld"
timeout 600 docker exec mysync_mysql3_1 sh -c "/var/lib/dist/base/generate_certs.sh mysync_mysql3_1.mysync_mysql_net && supervisorctl restart mysync && supervisorctl start mysqld"
timeout 600 docker exec mysync_mysql1_1 setup.sh
timeout 600 bash ./tests/images/copy_keys.sh
mkdir -p ./tests/logs
(docker exec mysync_jepsen_1 /root/jepsen/run.sh > ./tests/logs/jepsen.log 2>&1 && tail -n 4 ./tests/logs/jepsen.log) || ./tests/images/jepsen_main/save_logs.sh
docker compose -p mysync -f ./tests/images/jepsen-compose.yml down --rmi all
Expand Down
13 changes: 13 additions & 0 deletions tests/images/copy_keys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
for i in mysql1 mysql2 mysql3; do
docker exec mysync_${i}_1 rm /root/.ssh/id_rsa
docker exec mysync_${i}_1 ssh-keygen -m PEM -t rsa -b 2048 -N '' -C root@mysync_${i}_1 -f /root/.ssh/id_rsa
done

for i in mysql1 mysql2 mysql3; do
docker cp mysync_${i}_1:/root/.ssh/id_rsa.pub id_rsa.pub
for j in mysql1 mysql2 mysql3; do
docker exec mysync_${j}_1 /bin/bash -c "echo '$(cat id_rsa.pub)' >>/root/.ssh/authorized_keys"
done
done

rm id_rsa.pub
2 changes: 1 addition & 1 deletion tests/images/jepsen_common/sshd_config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
PubkeyAcceptedAlgorithms ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
PermitRootLogin yes
MaxAuthTries 1000000
11 changes: 6 additions & 5 deletions tests/images/jepsen_main/jepsen/src/jepsen/mysync.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@
(try
(with-conn [c conn]
(case (:f op)
:read (cond (= (count (j/query c ["show slave status for channel ''"])) 0)
:read (timeout 60000 (assoc op :type :info, :error "read-timeout")
(cond (= (count (j/query c ["show slave status for channel ''"])) 0)
(assoc op :type :ok,
:value (->> (j/query c ["select value from test1.test_set"]
{:row-fn :value})
(vec)
(set)))
true
(assoc op :type :info, :error "read-only"))
:add (timeout 5000 (assoc op :type :info, :error "timeout")
(assoc op :type :info, :error "read-only")))
:add (timeout 5000 (assoc op :type :info, :error "add-timeout")
(do
(info (str "Adding: " (get op :value) " to " (get c :subname)))
(j/execute! c [(str "insert into test1.test_set values ('" (get op :value) "')")])
Expand Down Expand Up @@ -266,9 +267,9 @@
(fn [] (map gen/once
[{:type :info, :f (rand-nth nemesis-starts)}
{:type :info, :f (rand-nth nemesis-starts)}
{:type :sleep, :value 120}
{:type :sleep, :value 60}
{:type :info, :f :stop}
{:type :sleep, :value 120}])))
{:type :sleep, :value 60}])))
(gen/time-limit 7200))
(->> r
(gen/stagger 1)
Expand Down

0 comments on commit 193ef65

Please sign in to comment.