   (:require [jepsen [core       :as jepsen]
                     [db         :as db]
                     [control    :as c :refer [|]]
+                    [checker    :as checker]
                     [client     :as client]
+                    [generator  :as gen]
+                    [nemesis    :as nemesis]
                     [tests      :as tests]]
             [jepsen.os.debian     :as debian]
             [jepsen.control.util  :as cu]
+            [knossos.model :as model]
             [clojure.string :as str]
             [clojure.data.xml :as xml]
             [clojure.tools.logging :refer [info warn]])
-  (:import (org.voltdb.client Client
+  (:import (org.voltdb VoltTable
+                       VoltTableRow)
+           (org.voltdb.client Client
                               ClientConfig
-                              ClientFactory)))
+                              ClientFactory
+                              ClientResponse)))
 
 (def username "voltdb")
 (def base-dir "/opt/voltdb")

         :name    "voltdb"
         :os      debian/os
         :client  (client)
         :db      (db url)))

   (let [initialized? (promise)]
     (reify client/Client
       (setup! [_ test node]
         (let [conn (connect node)]
           (c/on node
                 (when (deliver initialized? true)
                   ; Create table
                   (sql-cmd! "CREATE TABLE registers (
                             id          INTEGER UNIQUE NOT NULL,
                             value       INTEGER NOT NULL,
                             PRIMARY KEY (id)
                             );
                             PARTITION TABLE registers ON COLUMN id;")
                   (info node "table created")

                   ; Install stored procedures
                   (c/upload "procedures/jepsen-procedures.jar"
                             (str base-dir "/jepsen-procedures.jar"))
                   (sql-cmd! "load classes jepsen-procedures.jar")
                   (sql-cmd! "CREATE PROCEDURE FROM CLASS jepsen.procedures.ReadAll")
                   (call! conn "REGISTERS.upsert" 0 0)))

           (client conn)))

       (invoke! [this test op]
         (case (:f op)
           :read   (assoc op
                          :type :ok
                          :value (-> conn
                                     (call! "REGISTERS.select" 0)
                                     first
                                     :rows
                                     first
                                     :VALUE))
           :write (do (call! conn "REGISTERS.upsert" 0 (:value op))
                      (assoc op :type :ok))
           :cas   (let [[v v'] (:value op)
                        res (-> conn
                                (ad-hoc! "UPDATE registers SET value = ?
                                         WHERE id = ? AND value = ?"
                                         v' 0 v)
                                first
                                :rows
                                first
                                :modified_tuples)]
                    (assert (#{0 1} res))
                    (assoc op :type (if (zero? res) :fail :ok)))))

       (teardown! [_ test]
         (.close conn))))))

(defn r   [_ _] {:type :invoke, :f :read, :value nil})
(defn w   [_ _] {:type :invoke, :f :write, :value (rand-int 5)})
(defn cas [_ _] {:type :invoke, :f :cas, :value [(rand-int 5) (rand-int 5)]})

(defn voltdb-test
  "Takes a tarball URL"
