better match exceptions

This commit is contained in:
Alex 2023-04-18 16:19:35 +02:00
parent bc11701999
commit 70c1d3db46

View file

@ -9,6 +9,7 @@
[tests :as tests]] [tests :as tests]]
[jepsen.control.util :as cu] [jepsen.control.util :as cu]
[jepsen.os.debian :as debian] [jepsen.os.debian :as debian]
[slingshot.slingshot :refer [try+]]
[amazonica.aws.s3 :as s3] [amazonica.aws.s3 :as s3]
[amazonica.aws.s3transfer :as s3transfer])) [amazonica.aws.s3transfer :as s3transfer]))
@ -101,13 +102,14 @@
(setup! [this test]) (setup! [this test])
(invoke! [this test op] (invoke! [this test op]
(case (:f op) (case (:f op)
:get-object :get-object (try+
(let [value-bytes (try (let [value
(-> (s3/get-object (:creds this) grg-bucket grg-object) (-> (s3/get-object (:creds this) grg-bucket grg-object)
:input-stream :input-stream
slurp) slurp)]
(catch Exception e nil))] (assoc op :type :ok, :value value))
(assoc op :type :ok, :value value-bytes)) (catch (re-find #"Key not found" (.getMessage %)) ex
(assoc op :type :ok, :value nil)))
:put-object :put-object
(let [some-bytes (.getBytes (:value op) "UTF-8") (let [some-bytes (.getBytes (:value op) "UTF-8")
bytes-stream (java.io.ByteArrayInputStream. some-bytes)] bytes-stream (java.io.ByteArrayInputStream. some-bytes)]
@ -137,10 +139,10 @@
:os debian/os :os debian/os
:db (db "v0.8.2") :db (db "v0.8.2")
:client (Client. nil) :client (Client. nil)
:generator (->> (gen/mix [op-get op-put]) :generator (->> (gen/mix [op-get op-put op-del])
(gen/stagger 1) (gen/stagger 1)
(gen/nemesis nil) (gen/nemesis nil)
(gen/time-limit 15))})) (gen/time-limit 20))}))
(defn -main (defn -main
"Handles command line arguments. Can either run a test, or a web server for "Handles command line arguments. Can either run a test, or a web server for