Skip to content

Instantly share code, notes, and snippets.

@shikhar
Created June 8, 2014 06:33
Show Gist options
  • Save shikhar/84945b975432bdf385ef to your computer and use it in GitHub Desktop.
Save shikhar/84945b975432bdf385ef to your computer and use it in GitHub Desktop.
commit 32e36d85a9f5654dcf5f306088c825d24fb0d770
Author: shikhar <shikhar@schmizz.net>
Date: Fri Jun 6 23:58:35 2014 +0530
eskka testing
diff --git a/elasticsearch/src/jepsen/system/elasticsearch.clj b/elasticsearch/src/jepsen/system/elasticsearch.clj
index 107ddc0..ecf1494 100644
--- a/elasticsearch/src/jepsen/system/elasticsearch.clj
+++ b/elasticsearch/src/jepsen/system/elasticsearch.clj
@@ -37,7 +37,7 @@
(setup! [_ test node]
(c/su
(c/cd "/tmp"
- (let [version "1.1.0"
+ (let [version "1.2.1"
debfile (str "elasticsearch-" version ".deb")
uri (str "https://download.elasticsearch.org/"
"elasticsearch/elasticsearch/"
@@ -61,24 +61,24 @@
(info node "configuring elasticsearch")
(c/exec :echo
- (-> "elasticsearch/elasticsearch.yml"
+ (-> "elasticsearch/elasticsearch-eskka.yml"
io/resource
slurp
- (str/replace "$HOSTS" (json/generate-string
- (vals (c/on-many (:nodes test)
- (net/local-ip))))))
+ (str/replace "$ESKKA_ME" (net/local-ip))
+ (str/replace "$ESKKA_SEED_NODES" (json/generate-string (vals (c/on-many (:nodes test) (net/local-ip))))))
:> "/etc/elasticsearch/elasticsearch.yml")
- (info node "starting elasticsearch")
- (c/exec :service :elasticsearch :restart))
+ (info node "installing eskka")
+ (c/exec "/usr/share/elasticsearch/bin/plugin" :--url "https://s3.amazonaws.com/eskka/eskka-0.3.0-SNAPSHOT.zip" :--install :eskka)
- (wait 60 :green)
- (info node "elasticsearch ready"))
+ (info node "starting elasticsearch")
+ (c/exec :service :elasticsearch :restart)))
(teardown! [_ test node]
(c/su
(meh (c/exec :service :elasticsearch :stop))
- (c/exec :rm :-rf "/var/lib/elasticsearch/elasticsearch"))
+ (c/exec :rm :-rf "/var/lib/elasticsearch/elasticsearch")
+ (c/exec :rm :-rf "/usr/share/elasticsearch/plugins"))
(info node "elasticsearch nuked"))))
(defn http-error
@@ -104,23 +104,25 @@
(defrecord CreateSetClient [client]
client/Client
(setup! [_ test node]
- (let [; client (es/connect [[(name node) 9300]])]
- client (es/connect (str "http://" (name node) ":9200"))]
- ; Create index
- (try
- (esi/create client index-name
- :mappings {"number" {:properties
- {:num {:type "integer"
- :store "yes"}}}}
- :settings {"index" {"refresh_interval" "1"}})
- (catch clojure.lang.ExceptionInfo e
- ; Is this seriously how you're supposed to do idempotent
- ; index creation? I've gotta be doing this wrong.
- (let [err (http-error e)]
- (when-not (re-find #"IndexAlreadyExistsException" err)
- (throw (RuntimeException. err))))))
+ (do
+ (c/on-many (:nodes test) (wait 200 :green))
+ (let [; client (es/connect [[(name node) 9300]])]
+ client (es/connect (str "http://" (name node) ":9200"))]
+ ; Create index
+ (try
+ (esi/create client index-name
+ :mappings {"number" {:properties
+ {:num {:type "integer"
+ :store "yes"}}}}
+ :settings {"index" {"refresh_interval" "1"}})
+ (catch clojure.lang.ExceptionInfo e
+ ; Is this seriously how you're supposed to do idempotent
+ ; index creation? I've gotta be doing this wrong.
+ (let [err (http-error e)]
+ (when-not (re-find #"IndexAlreadyExistsException" err)
+ (throw (RuntimeException. err))))))
- (CreateSetClient. client)))
+ (CreateSetClient. client))))
(invoke! [this test op]
(case (:f op)
diff --git a/elasticsearch/test/jepsen/system/elasticsearch_test.clj b/elasticsearch/test/jepsen/system/elasticsearch_test.clj
index 6b93644..699bd1c 100644
--- a/elasticsearch/test/jepsen/system/elasticsearch_test.clj
+++ b/elasticsearch/test/jepsen/system/elasticsearch_test.clj
@@ -54,6 +54,7 @@
(assoc
noop-test
:name "elasticsearch"
+ :ssh {:username "root" :private-key-path "~/.ssh/id_rsa"}
:os debian/os
:db db
:client (create-set-client)
diff --git a/resources/elasticsearch/elasticsearch-eskka.yml b/resources/elasticsearch/elasticsearch-eskka.yml
new file mode 100644
index 0000000..7eb75b3
--- /dev/null
+++ b/resources/elasticsearch/elasticsearch-eskka.yml
@@ -0,0 +1,9 @@
+index.number_of_replicas: 2
+
+plugin.mandatory: eskka
+
+discovery.type: eskka.EskkaDiscoveryModule
+
+discovery.eskka.host: $ESKKA_ME
+
+discovery.eskka.seed_nodes: $ESKKA_SEED_NODES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment