Add end-to-end test for production (with manual verification)
This commit is contained in:
parent
53bbaff30c
commit
7513ed471e
2 changed files with 21 additions and 13 deletions
|
@ -41,8 +41,9 @@
|
||||||
"development" (server/start (merge server/dev-system options))
|
"development" (server/start (merge server/dev-system options))
|
||||||
"dev" (server/start (merge server/dev-system options))
|
"dev" (server/start (merge server/dev-system options))
|
||||||
"e2e" (let [system (server/start (merge server/dev-system options))]
|
"e2e" (let [system (server/start (merge server/dev-system options))]
|
||||||
(e2e/run-e2e-tests system)
|
(e2e/run-e2e-tests (:database-uri system) (str "http://localhost:" (:port system)))
|
||||||
(server/stop system))
|
(server/stop system))
|
||||||
|
"e2e-prod" (e2e/run-manual-e2e-tests (System/getenv "GRUB_PRODUCTION_URL"))
|
||||||
"production" (server/start (merge server/prod-system options))
|
"production" (server/start (merge server/prod-system options))
|
||||||
"prod" (server/start (merge server/prod-system options))
|
"prod" (server/start (merge server/prod-system options))
|
||||||
(exit 1 (usage summary)))))
|
(exit 1 (usage summary)))))
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
(defn set-chromedriver-path! []
|
(defn set-chromedriver-path! []
|
||||||
(System/setProperty "webdriver.chrome.driver" "bin/chromedriver"))
|
(System/setProperty "webdriver.chrome.driver" "bin/chromedriver"))
|
||||||
|
|
||||||
(defn start-client []
|
(defn start-client [server-url]
|
||||||
(let [driver (new-driver {:browser :chrome})]
|
(let [driver (new-driver {:browser :chrome})]
|
||||||
(taxi/to driver "http://localhost:3000")
|
(taxi/to driver server-url)
|
||||||
driver))
|
driver))
|
||||||
|
|
||||||
(defn grub-text [driver elem]
|
(defn grub-text [driver elem]
|
||||||
|
@ -79,20 +79,27 @@
|
||||||
(let [client (nth clients (rand-int (count clients)))]
|
(let [client (nth clients (rand-int (count clients)))]
|
||||||
(make-random-change-on-client client))))
|
(make-random-change-on-client client))))
|
||||||
|
|
||||||
(defn eventual-sync-test [db-uri]
|
(defn eventual-sync-test [db-uri server-url]
|
||||||
(let [num-clients 4
|
(let [num-clients 4
|
||||||
num-changes 100]
|
num-changes 100]
|
||||||
(println "Starting" num-clients "clients")
|
(println "Starting" num-clients "clients")
|
||||||
(let [clients (repeatedly 4 start-client)]
|
(let [clients (repeatedly 4 #(start-client server-url))]
|
||||||
(println "Making" num-changes "random changes")
|
(println "Making" num-changes "random changes")
|
||||||
(make-random-changes-on-clients clients)
|
(make-random-changes-on-clients clients)
|
||||||
|
(if db-uri
|
||||||
|
(do
|
||||||
(println "Sleeping for a moment")
|
(println "Sleeping for a moment")
|
||||||
(Thread/sleep 2000)
|
(Thread/sleep 2000)
|
||||||
(println "Verifying clients are in sync")
|
(println "Verifying clients are in sync")
|
||||||
(assert-all-clients-in-sync clients (get-db-grubs db-uri))
|
(assert-all-clients-in-sync clients (get-db-grubs db-uri))
|
||||||
(println "Closing clients")
|
(println "Closing clients")
|
||||||
(doseq [client clients] (stop-client client)))))
|
(doseq [client clients] (stop-client client)))
|
||||||
|
(println "Verify clients are in sync")))))
|
||||||
|
|
||||||
(defn run-e2e-tests [system]
|
(defn run-e2e-tests [db-uri server-url]
|
||||||
(set-chromedriver-path!)
|
(set-chromedriver-path!)
|
||||||
(eventual-sync-test (:database-uri system)))
|
(eventual-sync-test db-uri server-url))
|
||||||
|
|
||||||
|
(defn run-manual-e2e-tests [server-url]
|
||||||
|
(set-chromedriver-path!)
|
||||||
|
(eventual-sync-test nil server-url))
|
||||||
|
|
Loading…
Reference in a new issue