diff --git a/src/clj/grub/core.clj b/src/clj/grub/core.clj index bf72ef5..aa3a511 100644 --- a/src/clj/grub/core.clj +++ b/src/clj/grub/core.clj @@ -41,8 +41,9 @@ "development" (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/run-e2e-tests system) + (e2e/run-e2e-tests (:database-uri system) (str "http://localhost:" (:port system))) (server/stop system)) + "e2e-prod" (e2e/run-manual-e2e-tests (System/getenv "GRUB_PRODUCTION_URL")) "production" (server/start (merge server/prod-system options)) "prod" (server/start (merge server/prod-system options)) (exit 1 (usage summary))))) diff --git a/src/test/grub/test/e2e/sync.clj b/src/test/grub/test/e2e/sync.clj index d786589..a43f6a0 100644 --- a/src/test/grub/test/e2e/sync.clj +++ b/src/test/grub/test/e2e/sync.clj @@ -7,9 +7,9 @@ (defn set-chromedriver-path! [] (System/setProperty "webdriver.chrome.driver" "bin/chromedriver")) -(defn start-client [] +(defn start-client [server-url] (let [driver (new-driver {:browser :chrome})] - (taxi/to driver "http://localhost:3000") + (taxi/to driver server-url) driver)) (defn grub-text [driver elem] @@ -79,20 +79,27 @@ (let [client (nth clients (rand-int (count clients)))] (make-random-change-on-client client)))) -(defn eventual-sync-test [db-uri] +(defn eventual-sync-test [db-uri server-url] (let [num-clients 4 num-changes 100] (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") (make-random-changes-on-clients clients) - (println "Sleeping for a moment") - (Thread/sleep 2000) - (println "Verifying clients are in sync") - (assert-all-clients-in-sync clients (get-db-grubs db-uri)) - (println "Closing clients") - (doseq [client clients] (stop-client client))))) + (if db-uri + (do + (println "Sleeping for a moment") + (Thread/sleep 2000) + (println "Verifying clients are in sync") + (assert-all-clients-in-sync clients (get-db-grubs db-uri)) + (println "Closing clients") + (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!) - (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))