diff --git a/.gitignore b/.gitignore index 3387254..b9df4c4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ pom.xml.asc *.class /lib/ /classes/ +/store/ /target/ /checkouts/ .lein-deps-sum diff --git a/doc/intro.md b/doc/intro.md new file mode 100644 index 0000000..237518d --- /dev/null +++ b/doc/intro.md @@ -0,0 +1,3 @@ +# Introduction to jable + +TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..03c7eeb --- /dev/null +++ b/project.clj @@ -0,0 +1,9 @@ +(defproject jable "0.1.0-SNAPSHOT" + :description "Jepsen tests for the Sable IRCd" + :url "https://git.tf/val/jable/" + :license {:name "AGPL-3.0-only" + :url "https://www.gnu.org/licenses/agpl-3.0.txt"} + :dependencies [[org.clojure/clojure "1.11.1"] + [jepsen "0.3.3"]] + :repl-options {:init-ns jable.core} + :main jable.cli) diff --git a/src/jable/cli.clj b/src/jable/cli.clj new file mode 100644 index 0000000..7f929e2 --- /dev/null +++ b/src/jable/cli.clj @@ -0,0 +1,42 @@ +; Copyright (C) 2023 Val Lorentz +; +; This program is free software: you can redistribute it and/or modify it under the +; terms of the GNU Affero General Public License version 3, as published by the Free +; Software Foundation. +; +; This program is distributed in the hope that it will be useful, but WITHOUT ANY +; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +; PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. +; +; You should have received a copy of the GNU Affero General Public License along with +; this program. If not, see . + +(ns jable.cli + (:require [jepsen.cli :as cli] + [jepsen.tests :as tests] + [jepsen.os.debian :as debian] + [jable.db :as db])) + +(defn sable-test + "Given an options map from the command line runner (e.g. :nodes, :ssh, + :concurrency, ...), constructs a test map." + [opts] + (merge tests/noop-test + opts + {:name "etcd" + :os debian/os + :db (db/sable (:sable-bin opts)) + :pure-generators true})) + +(def cli-opts + "Additional command line options." + [[nil "--sable-bin SABLE/BIN/" "Path to a directory containing Sable's binary (eg. ~/sable/target/debug/)"]]) + +(defn -main + "Handles command line arguments. Can either run a test, or a web server for + browsing results." + [& args] + (cli/run! (merge (cli/single-test-cmd {:test-fn sable-test + :opt-spec cli-opts}) + (cli/serve-cmd)) + args)) diff --git a/src/jable/core.clj b/src/jable/core.clj new file mode 100644 index 0000000..f0b4a21 --- /dev/null +++ b/src/jable/core.clj @@ -0,0 +1,6 @@ +(ns jable.core) + +(defn foo + "I don't do a whole lot." + [x] + (println x "Hello, World!")) diff --git a/src/jable/db.clj b/src/jable/db.clj new file mode 100644 index 0000000..038fcb2 --- /dev/null +++ b/src/jable/db.clj @@ -0,0 +1,39 @@ +; Copyright (C) 2023 Val Lorentz +; +; This program is free software: you can redistribute it and/or modify it under the +; terms of the GNU Affero General Public License version 3, as published by the Free +; Software Foundation. +; +; This program is distributed in the hope that it will be useful, but WITHOUT ANY +; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +; PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. +; +; You should have received a copy of the GNU Affero General Public License along with +; this program. If not, see . + +(ns jable.db + (:require [clojure.tools.logging :refer :all] + [clojure.string :as str] + [jepsen [control :as c] + [db :as db]] + [jepsen.control.util :as cu] + [jepsen.control.core :as cc] + [jepsen.control.scp :as scp] + [jepsen.os.debian :as debian])) + +(defn sable + "Sable IRCd install from binaries in a local directory." + [sable_bin_path] + (reify db/DB + (setup! [_ test node] + (info node "installing Sable from" sable_bin_path) + (c/exec "rm" "-rf" "/tmp/sable_upload") + (c/exec "mkdir" "/tmp/sable_upload") + (let [remote_bin_path (c/upload (map (fn [file] (str sable_bin_path file)) + ["auth_client" "listener_process" "sable_ircd"]) + "/tmp/sable_upload")] + (c/su + (c/exec* "cp" (str remote_bin_path "/*") "/usr/local/bin")))) + + (teardown! [_ test node] + (info node "tearing down Sable")))) diff --git a/test/jable/core_test.clj b/test/jable/core_test.clj new file mode 100644 index 0000000..bcc13b6 --- /dev/null +++ b/test/jable/core_test.clj @@ -0,0 +1,7 @@ +(ns jable.core-test + (:require [clojure.test :refer :all] + [jable.core :refer :all])) + +(deftest a-test + (testing "FIXME, I fail." + (is (= 0 1))))