Permalink
Browse files

Squashed commit of the following:

    Fix to stop Hunchentoot threads after clack:stop.
    Fix v1-compat tests.
    Use a random port for testing.
  • Loading branch information...
fukamachi committed Mar 29, 2017
1 parent db4617b commit e28dd64a7f0df15da49d329a2096af866cada976
@@ -112,14 +112,14 @@
:persistent-connections-p persistent-connections-p
(and taskmaster
(list :taskmaster taskmaster))))))
(setf (hunchentoot::acceptor-shutdown-p acceptor) nil)
(start-listening acceptor)
(let ((taskmaster (acceptor-taskmaster acceptor)))
(let* ((taskmaster (acceptor-taskmaster acceptor))
(threadedp (typep taskmaster 'multi-threaded-taskmaster)))
(setf (taskmaster-acceptor taskmaster) acceptor)
#+thread-support
(setf (acceptor-process taskmaster) (bt:current-thread))
(unwind-protect
(accept-connections acceptor)
(progn
(hunchentoot:start acceptor)
(when threadedp
(bt:join-thread (hunchentoot::acceptor-process taskmaster))))
(hunchentoot:stop acceptor)))))
(defun handle-response (res)
View
@@ -4,6 +4,8 @@
(:import-from :clack
:clackup
:stop)
(:import-from :dexador
:*use-connection-pool*)
(:import-from :prove
:subtest)
(:import-from :usocket
@@ -36,7 +38,7 @@ Use if you want to set another port. The default is `*clack-test-port*`.")
(defvar *enable-debug* t)
(defvar *random-port* nil)
(defvar *random-port* t)
(defun port-available-p (port)
(let (socket)
@@ -100,7 +102,8 @@ Use if you want to set another port. The default is `*clack-test-port*`.")
(loop until (server-running-p *clack-test-port*)
do (sleep 0.1))
(unwind-protect
(funcall client)
(let ((dex:*use-connection-pool* nil))
(funcall client))
(stop acceptor))))))
(defmacro subtest-app (desc app &body client)
View
@@ -5,6 +5,7 @@
:clack.test.suite))
(in-package :clack-test.handler.fcgi)
(let ((clack.test:*clack-test-port* 14949)
(let ((clack.test:*random-port* nil)
(clack.test:*clack-test-port* 14949)
(clack.test:*clack-test-access-port* 4949))
(clack.test.suite:run-server-tests :fcgi))
@@ -5,5 +5,4 @@
:clack.test.suite))
(in-package :t.clack.handler.hunchentoot)
(let ((clack.test:*random-port* t))
(clack.test.suite:run-server-tests :hunchentoot))
(clack.test.suite:run-server-tests :hunchentoot)
@@ -20,12 +20,12 @@
(make-instance '<clack-app-file>
:root (merge-pathnames #p"tmp/" *clack-pathname*)))
(multiple-value-bind (body status headers)
(http-request "http://localhost:4242/jellyfish.jpg")
(http-request (localhost "/jellyfish.jpg"))
(is status 200)
(is (cdr (assoc :content-type headers)) "image/jpeg")
(is (length body) 139616))
(multiple-value-bind (body status headers)
(http-request "http://localhost:4242/redhat.png")
(http-request (localhost "/redhat.png"))
(is status 200)
(is (cdr (assoc :content-type headers)) "image/png")
(is (length body) 12155)))
@@ -37,12 +37,12 @@
:file "jellyfish.jpg"
:root (merge-pathnames #p"tmp/" *clack-pathname*)))
(multiple-value-bind (body status headers)
(http-request "http://localhost:4242/jellyfish.jpg")
(http-request (localhost "/jellyfish.jpg"))
(is status 200)
(is (cdr (assoc :content-type headers)) "image/jpeg")
(is (length body) 139616))
(multiple-value-bind (body status headers)
(http-request "http://localhost:4242/redhat.png")
(http-request (localhost "/redhat.png"))
(is status 200)
(is (cdr (assoc :content-type headers)) "image/jpeg")
(is (length body) 139616)))
@@ -26,13 +26,13 @@
(incf (gethash :counter (getf env :clack.session))))))))
(let ((cookie-jar (make-instance 'cookie-jar)))
(multiple-value-bind (body status)
(http-request "http://localhost:4242/"
(http-request (localhost)
:cookie-jar cookie-jar)
(diag "1st request")
(is status 200)
(is body "Hello, you've been here for 1th times!"))
(multiple-value-bind (body status)
(http-request "http://localhost:4242/"
(http-request (localhost)
:cookie-jar cookie-jar)
(diag "2nd request")
(is status 200)
@@ -54,13 +54,13 @@
(incf (gethash :counter (getf env :clack.session))))))))
(let ((cookie-jar (make-instance 'cookie-jar)))
(multiple-value-bind (body status)
(http-request "http://localhost:4242/"
(http-request (localhost)
:cookie-jar cookie-jar)
(diag "1st request")
(is status 200)
(is body "Hello, you've been here for 1th times!"))
(multiple-value-bind (body status)
(http-request "http://localhost:4242/"
(http-request (localhost)
:cookie-jar cookie-jar)
(diag "2nd request")
(is status 200)
@@ -24,16 +24,16 @@
(declare (ignore env))
`(200 (:content-type "text/plain; charset=utf-8") ("Happy Valentine!"))))
(multiple-value-bind (body status headers)
(http-request "http://localhost:4242/public/jellyfish.jpg")
(http-request (localhost "/public/jellyfish.jpg"))
(is status 200)
(is (cdr (assoc :content-type headers)) "image/jpeg")
(is (length body) 139616))
(multiple-value-bind (body status)
(http-request "http://localhost:4242/public/hoge.png")
(http-request (localhost "/public/hoge.png"))
(is status 404)
(is body "not found"))
(multiple-value-bind (body status headers)
(http-request "http://localhost:4242/")
(http-request (localhost))
(is status 200)
(is (cdr (assoc :content-type headers)) "text/plain; charset=utf-8")
(is body "Happy Valentine!")))
@@ -100,7 +100,7 @@
(make-request env)
`(200 nil (,(gethash "filename" (cadr (body-parameter (make-request env) :|file|))))))
(multiple-value-bind (body status)
(http-request "http://localhost:4242/"
(http-request (localhost)
:method :post
:parameters
`(("file" ,(merge-pathnames #p"tmp/jellyfish.jpg" *clack-pathname*)
@@ -110,7 +110,7 @@
(is body "jellyfish.jpg"))
(multiple-value-bind (body status)
(http-request "http://localhost:4242/"
(http-request (localhost)
:method :post
:parameters
`(("file" ,(merge-pathnames #p"tmp/jellyfish.jpg" *clack-pathname*)

0 comments on commit e28dd64

Please sign in to comment.