Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-1433] No TDR temporary snapshots in tests #595

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions api/test/wfl/integration/datarepo_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,18 @@
(is (== 1 (count row-ids))
"Single input row should have been written to the dataset")
(testing "creating snapshot after completed ingest"
(fixtures/with-temporary-snapshot
(snapshots/unique-snapshot-request tdr-profile
dataset
table-name
row-ids)
#(let [snapshot (datarepo/snapshot %)
expected-prefix (str (:name dataset) "_" table-name)]
(is (= % (:id snapshot)))
(is (str/starts-with? (:name snapshot) expected-prefix)
(str "Snapshot name should start with "
"dataset name and table name"))))))))))))
(let [request (snapshots/unique-snapshot-request
tdr-profile
dataset
table-name
row-ids)
snapshot-id (datarepo/create-snapshot request)
snapshot (datarepo/snapshot snapshot-id)
expected-prefix (str (:name dataset) "_" table-name)]
(is (= snapshot-id (:id snapshot)))
(is (str/starts-with? (:name snapshot) expected-prefix)
(str "Snapshot name should start with "
"dataset name and table name")))))))))))

(deftest test-flattened-query-result
(let [samplesheets (-> (datarepo/snapshot (:id testing-snapshot))
Expand Down
12 changes: 0 additions & 12 deletions api/test/wfl/tools/fixtures.clj
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,6 @@
datarepo/delete-snapshots-then-dataset
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's where we clean up any snapshots as part of cleaning up a temporary dataset.

f))

;; Recommendation: only call this within a temporary dataset.
;; If calling within a fixed dataset, running the same test concurrently
;; may fail due to exclusive dataset locking on snapshot deletion.
;;
(defn with-temporary-snapshot
"Create a temporary Terra Data Repository Snapshot with `snapshot-request`"
[snapshot-request f]
(util/bracket
#(datarepo/create-snapshot snapshot-request)
datarepo/delete-snapshot
f))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again.


(defn with-temporary-workspace
"Create and use a temporary Terra Workspace."
([workspace-prefix group f]
Expand Down