                           :x-waiter-scale-down-factor 0.9
                           :x-waiter-name (rand-name)}]
       (scaling-for-service-test "Scaling healthy app" waiter-url 3 concurrency-level
-                                #(make-kitchen-request waiter-url custom-headers)))))
+                                #(make-kitchen-request waiter-url custom-headers :cookies %)))))
 
 (deftest ^:parallel ^:integration-fast ^:resource-heavy test-scaling-unhealthy-app
   (testing-using-waiter-url

            [waiter.util.client-tools :refer :all]
            [waiter.util.utils :as utils]))

(defn- scaling-for-service-test [testing-str waiter-url target-instances concurrency-level request-fn]
  (testing testing-str
    (let [continue-running (atom true)
          first-request (request-fn)
          service-id (retrieve-service-id waiter-url (:request-headers first-request))
          count-instances (fn [] (num-instances waiter-url service-id))]
      (with-service-cleanup
        service-id
        (is (wait-for #(= 1 (count-instances))) "First instance never started")
        (future (dorun (pmap (fn [_] (while @continue-running (request-fn)))
                             (range (* target-instances concurrency-level)))))
        (is (wait-for #(= target-instances (count-instances))) (str "Never scaled up to " target-instances " instances"))
        (reset! continue-running false)
        ; When scaling down in Marathon, we have to wait for forced kills,
        ; which by default occur after 60 seconds of failed kills.
        ; So give the scale down extra time
        (is (wait-for #(= 1 (count-instances)) :timeout 300) "Never scaled back down to 1 instance")))))

(deftest ^:parallel ^:integration-slow ^:resource-heavy test-scaling-healthy-app
  (testing-using-waiter-url

                          :x-waiter-cmd "sleep 600"
                          :x-waiter-queue-timeout 5000}]
      (scaling-for-service-test "Scaling unhealthy app" waiter-url 3 concurrency-level
                                #(make-shell-request waiter-url custom-headers :cookies %)))))

(defn- run-scale-service-requests
  [waiter-url cookies request-fn requests-per-thread delay-secs service-id
