Skip to content

Commit

Permalink
Checkpoint back to endpoints/userinfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
tbl3rd committed Feb 18, 2021
1 parent ee79aa1 commit f11d496
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 22 deletions.
3 changes: 2 additions & 1 deletion api/test/wfl/integration/modules/aou_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[wfl.api.spec]
[wfl.util :as util]
[wfl.module.aou :as aou]
[wfl.tools.endpoints :as endpoints]
[wfl.tools.fixtures :as fixtures]
[wfl.tools.workloads :as workloads]
[wfl.service.postgres :as postgres]
Expand All @@ -18,7 +19,7 @@

(defn ^:private make-aou-workload-request []
(-> (workloads/aou-workload-request (UUID/randomUUID))
(assoc :creator (:email @workloads/userinfo))))
(assoc :creator (:email @endpoints/userinfo))))

(defn ^:private inc-version [sample]
(update sample :analysis_version_number inc))
Expand Down
3 changes: 2 additions & 1 deletion api/test/wfl/integration/modules/arrays_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require [clojure.test :refer [testing is deftest use-fixtures]]
[wfl.api.spec]
[wfl.service.terra :as terra]
[wfl.tools.endpoints :as endpoints]
[wfl.tools.fixtures :as fixtures]
[wfl.tools.workloads :as workloads])
(:import (java.util UUID)))
Expand All @@ -16,7 +17,7 @@

(defn ^:private make-arrays-workload-request []
(-> (workloads/arrays-workload-request (UUID/randomUUID))
(assoc :creator (:email @workloads/userinfo))))
(assoc :creator (:email @endpoints/userinfo))))

(defn ^:private check-inputs
[workflow]
Expand Down
3 changes: 2 additions & 1 deletion api/test/wfl/integration/modules/copyfile_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[wfl.module.all :as all]
[wfl.module.copyfile :as copyfile]
[wfl.service.cromwell :refer [wait-for-workflow-complete submit-workflow]]
[wfl.tools.endpoints :as endpoints]
[wfl.tools.fixtures :as fixtures]
[wfl.tools.workloads :as workloads]
[wfl.util :as util])
Expand All @@ -15,7 +16,7 @@
(defn ^:private make-copyfile-workload-request
[src dst]
(-> (workloads/copyfile-workload-request src dst)
(assoc :creator (:email @workloads/userinfo))))
(assoc :creator (:email @endpoints/userinfo))))

(defn ^:private old-create-copyfile-workload! []
(let [request (make-copyfile-workload-request "gs://fake/input" "gs://fake/output")]
Expand Down
5 changes: 3 additions & 2 deletions api/test/wfl/integration/modules/sg_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[wfl.module.sg :as sg]
[wfl.service.clio :as clio]
[wfl.service.cromwell :as cromwell]
[wfl.tools.endpoints :as endpoints]
[wfl.tools.fixtures :as fixtures]
[wfl.tools.workloads :as workloads]
[wfl.util :as util :refer [absent?]])
Expand Down Expand Up @@ -38,7 +39,7 @@
"gs://broad-gotc-dev-storage/temp_references/gdc/dbsnp_144.hg38.vcf.gz.tbi"
:input_cram
"gs://broad-gotc-dev-wfl-sg-test-inputs/pipeline/G96830/NA12878/v23/NA12878.cram"}}]
:creator (:email @workloads/userinfo)})
:creator (:email @endpoints/userinfo)})

(defn mock-submit-workload
[{:keys [workflows]} _ _ _ _ _]
Expand Down Expand Up @@ -109,7 +110,7 @@
:output "gs://broad-gotc-dev-wfl-ptc-test-outputs/sg-test-output/"
:pipeline sg/pipeline
:project @workloads/project
:creator (:email @workloads/userinfo)}
:creator (:email @endpoints/userinfo)}
workloads/execute-workload!
workloads/update-workload!)]
(is (:finished workload))))
Expand Down
18 changes: 9 additions & 9 deletions api/test/wfl/integration/modules/wgs_test.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(ns wfl.integration.modules.wgs-test
(:require [clojure.set :refer [rename-keys]]
[clojure.test :refer [deftest testing is] :as clj-test]
[wfl.service.cromwell :refer [wait-for-workflow-complete
submit-workflows]]
[wfl.service.cromwell :as cromwell]
[wfl.tools.endpoints :as endpoints]
[wfl.tools.fixtures :as fixtures]
[wfl.tools.workloads :as workloads]
[wfl.module.wgs :as wgs]
Expand All @@ -21,7 +21,7 @@
(defn ^:private make-wgs-workload-request []
(-> (UUID/randomUUID)
workloads/wgs-workload-request
(assoc :creator (:email @workloads/userinfo))))
(assoc :creator (:email @endpoints/userinfo))))

(defn ^:private strip-prefix [[k v]]
[(keyword (util/unprefix (str k) ":ExternalWholeGenomeReprocessing.")) v])
Expand Down Expand Up @@ -58,7 +58,7 @@
:workflows)))))

(deftest test-start-wgs-workload!
(with-redefs-fn {#'submit-workflows mock-submit-workflows}
(with-redefs-fn {#'cromwell/submit-workflows mock-submit-workflows}
#(let [workload (-> (make-wgs-workload-request)
workloads/create-workload!
workloads/start-workload!)]
Expand Down Expand Up @@ -115,13 +115,13 @@
(UUID/randomUUID))
inputs))]
(with-redefs-fn
{#'submit-workflows verify-inputs}
{#'cromwell/submit-workflows verify-inputs}
#(-> (make-wgs-workload-request)
(update :items use-input_bam)
(workloads/execute-workload!)
(as-> workload
(is (:started workload))
(run! go! (:workflows workload)))))))
(run! go! (:workflows workload)))))))

(deftest test-submitted-workflow-inputs
(letfn [(prefixed? [prefix key] (str/starts-with? (str key) (str prefix)))
Expand All @@ -137,7 +137,7 @@
(verify-workflow-inputs (into {} (map strip-prefix in)))
(UUID/randomUUID))
inputs))]
(with-redefs-fn {#'submit-workflows verify-submitted-inputs}
(with-redefs-fn {#'cromwell/submit-workflows verify-submitted-inputs}
(fn []
(->
(make-wgs-workload-request)
Expand Down Expand Up @@ -167,7 +167,7 @@
(let [request (-> (make-wgs-workload-request)
(assoc :items [{:inputs {key value}}]))]
(testing (str "default inputs when given only " key)
(with-redefs-fn {#'submit-workflows verify-submitted-inputs}
(with-redefs-fn {#'cromwell/submit-workflows verify-submitted-inputs}
#(workloads/execute-workload! request)))))]
(test-with-input :input_bam (:input_cram workloads/wgs-inputs))
(test-with-input :input_cram (:input_cram workloads/wgs-inputs))))
Expand All @@ -182,7 +182,7 @@
(verify-workflow-options options)
(is (= defaults (select-keys options (keys defaults))))
(map (fn [_] (UUID/randomUUID)) inputs)))]
(with-redefs-fn {#'submit-workflows verify-submitted-options}
(with-redefs-fn {#'cromwell/submit-workflows verify-submitted-options}
(fn []
(->
(make-wgs-workload-request)
Expand Down
6 changes: 4 additions & 2 deletions api/test/wfl/integration/modules/xx_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
[wfl.module.xx :as xx]
[wfl.module.batch :as batch]
[wfl.service.cromwell :as cromwell]
[wfl.tools.endpoints :as endpoints]
[wfl.tools.fixtures :as fixtures]
[wfl.tools.endpoints :as endpoints]
[wfl.tools.workloads :as workloads]
[wfl.util :as util :refer [absent?]])
(:import (java.time OffsetDateTime)
Expand All @@ -16,7 +18,7 @@
(defn ^:private make-xx-workload-request []
(-> (UUID/randomUUID)
workloads/xx-workload-request
(assoc :creator (:email @workloads/userinfo))))
(assoc :creator (:email @endpoints/userinfo))))

(defn mock-submit-workload [{:keys [workflows]} _ _ _ _ _]
(let [now (OffsetDateTime/now)
Expand Down Expand Up @@ -78,7 +80,7 @@
:output "gs://broad-gotc-dev-wfl-ptc-test-outputs/xx-test-output/"
:pipeline xx/pipeline
:project @workloads/project
:creator (:email @workloads/userinfo)}
:creator (:email @endpoints/userinfo)}
workloads/execute-workload!
workloads/update-workload!)]
(is (:finished workload))))
Expand Down
3 changes: 2 additions & 1 deletion api/test/wfl/integration/workloads_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require [clojure.test :refer [deftest testing is] :as clj-test]
[clojure.test :refer :all]
[wfl.module.copyfile :as copyfile]
[wfl.tools.endpoints :as endpoints]
[wfl.tools.fixtures :as fixtures]
[wfl.tools.workloads :as workloads]))

Expand All @@ -10,7 +11,7 @@
(defn ^:private make-copyfile-workload-request-with-project
[src dst project]
(-> (workloads/copyfile-workload-request src dst)
(assoc :creator (:email @workloads/userinfo) :project project)))
(assoc :creator (:email @endpoints/userinfo) :project project)))

(deftest test-loading-copyfile-workloads-with-project
(let [upper-project "TEST-PROJECT"
Expand Down
4 changes: 2 additions & 2 deletions api/test/wfl/system/v1_endpoint_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
(endpoints/create-workload request)]
(is uuid "workloads should be been assigned a uuid")
(is created "should have a created timestamp")
(is (= (:email @workloads/userinfo) creator)
(is (= (:email @endpoints/userinfo) creator)
"creator inferred from auth token")
(is (not started) "hasn't been started in cromwell")
(letfn [(included [m] (select-keys m [:pipeline :project]))]
Expand Down Expand Up @@ -125,7 +125,7 @@
(is uuid "workloads should have a uuid")
(is created "should have a created timestamp")
(is started "should have a started timestamp")
(is (= (:email @workloads/userinfo) creator)
(is (= (:email @endpoints/userinfo) creator)
"creator inferred from auth token")
(letfn [(included [m] (select-keys m [:pipeline :project]))]
(is (= (included request) (included workload))))
Expand Down
4 changes: 4 additions & 0 deletions api/test/wfl/tools/endpoints.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
[clojure.data.json :as json]
[wfl.auth :as auth]
[wfl.environment :as env]
[wfl.service.google.storage :as gcs]
[wfl.util :as util]))

(def userinfo
(delay (gcs/userinfo {:headers (auth/get-auth-header)})))

(def ^:private wfl-url
"The WFL server URL to test."
(delay (env/getenv "WFL_WFL_URL")))
Expand Down
3 changes: 0 additions & 3 deletions api/test/wfl/tools/workloads.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

(def clio-url (delay (env/getenv "WFL_CLIO_URL")))

(def userinfo
(delay (gcs/userinfo {:headers (auth/get-auth-header)})))

(def ^:private git-branch
(delay (util/shell! "git" "branch" "--show-current")))

Expand Down

0 comments on commit f11d496

Please sign in to comment.