Skip to content

Commit

Permalink
Adjustments to get tests running in EAP.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Jul 30, 2015
1 parent dbbf5b5 commit d8b4288
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 27 deletions.
8 changes: 7 additions & 1 deletion core/src/immutant/util.clj
Expand Up @@ -32,10 +32,16 @@
[]
(WunderBoss/inContainer))

(defn in-eap?
"Returns true if running inside an EAP container."
[]
(when-let [f (try-resolve 'immutant.wildfly/in-eap?)]
(f)))

(defn in-cluster?
"Returns true if running inside a WildFly/EAP container that's part of a cluster"
[]
(if-let [f (try-resolve 'immutant.wildfly/in-cluster?)]
(when-let [f (try-resolve 'immutant.wildfly/in-cluster?)]
(f)))

(defn reset-fixture
Expand Down
4 changes: 2 additions & 2 deletions etc/bin/ci-prep-wildfly.sh
Expand Up @@ -24,6 +24,6 @@ if [ $(grep -c NIO ${conf}) -eq 0 ]; then
perl -p -i -e "s:(<hornetq-server>)$:\1<journal-type>NIO</journal-type>:" $(ls ${jboss_home}/*/configuration/*)
#echo "Enabling TRACE logging"
#sed -i.bak '/<root-logger>/{N; s/<root-logger>.*<level name="INFO"/<root-logger><level name="TRACE"/g}' ${conf}
echo "Adding application user testuser:testuser"
${jboss_home}/bin/add-user.sh --silent -a -u 'testuser' -p 'testuser' -g 'guest'
echo "Adding application user testuser:testuser1!"
${jboss_home}/bin/add-user.sh --silent -a -u 'testuser' -p 'testuser1!' -g 'guest'
fi
8 changes: 6 additions & 2 deletions integration-tests/project.clj
Expand Up @@ -19,7 +19,7 @@
[org.immutant/wildfly _]]
:aliases {"all" ^:replace ["do" "clean," "test"]}
:modules {:parent nil}
:profiles {:integ-base {:plugins [[lein-immutant "2.0.1-SNAPSHOT"]]
:profiles {:integ-base {:plugins [[lein-immutant "2.0.0"]]
:aliases {"test" ^:displace ["immutant" "test"]}
:modules {:parent ".."}}
:integ-messaging {:test-paths ["../messaging/test"]}
Expand Down Expand Up @@ -56,4 +56,8 @@
:dependencies [[org.immutant/fntest _]
[clj-http _]]
:test-paths ^:replace ["test-clustering"]}
:eap {:immutant {:war {:resource-paths ["eap-resources"]}}}})
:eap-base {:immutant {:war {:resource-paths ["eap-resources"]}}
:exclusions [org.hornetq/hornetq-jms-server org.hornetq/hornetq-server]
:dependencies [[org.hornetq/hornetq-jms-server "2.3.25.Final"]
[org.hornetq/hornetq-server "2.3.25.Final"]]}
:eap [:web :scheduling :messaging :eap-base]})
2 changes: 1 addition & 1 deletion integration-tests/test-clustering/integs/cluster_test.clj
Expand Up @@ -22,7 +22,7 @@
[immutant.messaging :as msg]))

(def opts {:host "localhost", :remote-type :hornetq-wildfly,
:username "testuser", :password "testuser"})
:username "testuser", :password "testuser1!"})

(use-fixtures :once
(compose-fixtures
Expand Down
33 changes: 21 additions & 12 deletions messaging/test/immutant/messaging_test.clj
Expand Up @@ -20,6 +20,9 @@

(u/set-log-level! (or (System/getenv "LOG_LEVEL") :OFF))

(def test-user "testuser")
(def test-password "testuser1!")

(use-fixtures :once u/reset-fixture)

(defn random-queue []
Expand Down Expand Up @@ -183,8 +186,9 @@
(deftest remote-request-respond-should-work
(queue "remote-req-resp" :durable? false)
(let [extra-connect-opts
(when (u/in-container?)
[:username "testuser" :password "testuser" :remote-type :hornetq-wildfly])]
(cond-> []
(u/in-container?) (conj :username test-user :password test-password)
(and (u/in-container?) (not (u/in-eap?))) (conj :remote-type :hornetq-wildfly))]
(with-open [c (apply context :host "localhost" :port (u/messaging-remoting-port)
extra-connect-opts)]
(let [q (queue "remote-req-resp" :context c)]
Expand All @@ -194,8 +198,9 @@
(deftest remote-listen-should-work
(queue "remote-listen" :durable? false)
(let [extra-connect-opts
(when (u/in-container?)
[:username "testuser" :password "testuser" :remote-type :hornetq-wildfly])]
(cond-> []
(u/in-container?) (conj :username test-user :password test-password)
(and (u/in-container?) (not (u/in-eap?))) (conj :remote-type :hornetq-wildfly))]
(with-open [c (apply context :host "localhost" :port (u/messaging-remoting-port)
extra-connect-opts)]
(let [q (queue "remote-listen" :context c)
Expand All @@ -217,8 +222,9 @@
(deftest remote-context-should-work
(queue "remote" :durable? false)
(let [extra-connect-opts
(when (u/in-container?)
[:username "testuser" :password "testuser" :remote-type :hornetq-wildfly])]
(cond-> []
(u/in-container?) (conj :username test-user :password test-password)
(and (u/in-container?) (not (u/in-eap?))) (conj :remote-type :hornetq-wildfly))]
(with-open [c (apply context :host "localhost" :port (u/messaging-remoting-port)
extra-connect-opts)]
(let [q (queue "remote" :context c)]
Expand All @@ -232,8 +238,9 @@
#_(deftest remote-receive-should-properly-timeout
(let [q-name (.name (random-queue))
extra-connect-opts
(when (u/in-container?)
[:username "testuser" :password "testuser" :remote-type :hornetq-wildfly])]
(cond-> []
(u/in-container?) (conj :username test-user :password test-password)
(and (u/in-container?) (not (u/in-eap?))) (conj :remote-type :hornetq-wildfly))]
(with-open [c (apply context :host "localhost" :port (u/messaging-remoting-port)
extra-connect-opts)]
(let [q (queue q-name :context c)
Expand Down Expand Up @@ -280,10 +287,12 @@

(deftest publish-to-a-remote-queue-from-a-listener-should-work
(queue "remote" :durable? false)
(let [conn (if (u/in-container?)
(context :host "localhost" :port (u/messaging-remoting-port)
:username "testuser" :password "testuser" :remote-type :hornetq-wildfly)
(context :host "localhost"))
(let [extra-connect-opts
(cond-> []
(u/in-container?) (conj :username test-user :password test-password)
(and (u/in-container?) (not (u/in-eap?))) (conj :remote-type :hornetq-wildfly))
conn (apply context :host "localhost" :port (u/messaging-remoting-port)
extra-connect-opts)
q (random-queue)
remote-q (queue "remote" :context conn)
l (listen q #(publish remote-q %))]
Expand Down
6 changes: 3 additions & 3 deletions project.clj
Expand Up @@ -91,11 +91,11 @@
clj-http "1.0.1"

;; org.projectodd.wunderboss "0.8.1"
;; org.projectodd.wunderboss "1.x.incremental.247"
org.projectodd.wunderboss "0.8.2-SNAPSHOT"
org.projectodd.wunderboss "1.x.incremental.263"
;; org.projectodd.wunderboss "0.8.2-SNAPSHOT"

org.immutant :version
fntest "2.0.6-SNAPSHOT"}}
fntest "2.0.5"}}

:release-tasks [["vcs" "assert-committed"]

Expand Down
2 changes: 1 addition & 1 deletion transactions/test/immutant/transactions_test.clj
Expand Up @@ -28,7 +28,7 @@
(def local-remote-queue (msg/queue "remote" :durable? false))
(def conn (if (in-container?)
(msg/context :host "localhost" :port (messaging-remoting-port)
:username "testuser" :password "testuser" :remote-type :hornetq-wildfly
:username "testuser" :password "testuser1!" :remote-type :hornetq-wildfly
:xa? true)
(msg/context :host "localhost" :xa? true)))
(def remote-queue (msg/queue "remote" :context conn))
Expand Down
9 changes: 8 additions & 1 deletion web/src/immutant/web/internal/servlet.clj
Expand Up @@ -15,7 +15,9 @@
(ns ^{:no-doc true} immutant.web.internal.servlet
(:require [immutant.web.internal.ring :as ring]
[immutant.web.internal.headers :as hdr]
[immutant.internal.util :refer [try-resolve]]
[immutant.web.async :as async])

(:import [org.projectodd.wunderboss.web.async Channel
Channel$OnOpen Channel$OnClose Channel$OnError
ServletHttpChannel WebsocketUtil]
Expand Down Expand Up @@ -152,6 +154,10 @@
(add-endpoint context
{:path path :handshake (handshake-ring-invoker handler)}))))))

(defn async-streaming-supported? []
(when-let [f (try-resolve 'immutant.wildfly/async-streaming-supported?)]
(f)))

(defmethod async/initialize-stream :servlet
[request {:keys [on-open on-error on-close]}]
(ServletHttpChannel.
Expand All @@ -170,7 +176,8 @@
(reify Channel$OnClose
(handle [_ ch code reason]
(on-close ch {:code code
:reason reason}))))))
:reason reason}))))
(async-streaming-supported?)))

(defmethod async/initialize-websocket :servlet
[request {:keys [on-open on-error on-close on-message on-error]}]
Expand Down
2 changes: 1 addition & 1 deletion wildfly/project.clj
Expand Up @@ -19,6 +19,6 @@

:dependencies [[org.immutant/core _]
[org.clojure/tools.nrepl "_"]
[org.projectodd.wunderboss/wunderboss-as-support _]]
[org.projectodd.wunderboss/wunderboss-wildfly _]]

:profiles {:base {:dependencies []}})
22 changes: 19 additions & 3 deletions wildfly/src/immutant/wildfly.clj
Expand Up @@ -25,7 +25,6 @@
(def ^:no-doc in-cluster (delay (-> ^Class (u/try-import 'org.projectodd.wunderboss.as.ClusterUtils)
(.getMethod "inCluster" nil)
(.invoke nil nil))))

(defn- get-resource-loaders
[cl]
(if (module-class-loader-class)
Expand Down Expand Up @@ -110,9 +109,26 @@
"Returns the HTTP port for the embedded web server"
(partial port :http))

(def messaging-remoting-port
(let [container-type (delay (-> ^Class (u/try-import 'org.projectodd.wunderboss.as.ASUtils)
(.getMethod "containerTypeAsString" nil)
(.invoke nil nil)))]
(defn in-eap?
"Returns true if we're in an EAP container."
[]
(= "EAP" @container-type)))

(let [streaming-supported? (delay (-> ^Class (u/try-import 'org.projectodd.wunderboss.as.ASUtils)
(.getMethod "isAsyncStreamingSupported" nil)
(.invoke nil nil)))]
(defn async-streaming-supported?
"Returns true if the container supports async HTTP stream sends."
[]
@streaming-supported?))

(defn messaging-remoting-port
"Returns the port that HornetQ is listening on for remote connections"
http-port)
[]
(port (if (in-eap?) :messaging :http)))

(defn context-path
"Returns the HTTP context path for the deployed app"
Expand Down

0 comments on commit d8b4288

Please sign in to comment.