-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMR-9519 Fixing KMS replacement of cache when KMS API is down. (#1983)
- Loading branch information
Showing
3 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
common-app-lib/test/cmr/common_app/services/kms_fetcher_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(ns cmr.common-app.services.kms-fetcher-test | ||
(:require | ||
[clojure.test :refer :all] | ||
[cmr.common.cache :as cache] | ||
[cmr.common-app.services.kms-fetcher :as fetcher] | ||
[cmr.indexer.system :as idx-sys] | ||
[cmr.transmit.kms :as trans-kms])) | ||
|
||
(deftest validate-getting-kms-keywords-test | ||
(let [context {:system (idx-sys/create-system)} | ||
kms-cache (cache/context->cache context fetcher/kms-cache-key) | ||
_ (#'fetcher/refresh-kms-cache context) | ||
kms-map (cache/get-value kms-cache fetcher/kms-cache-key)] | ||
|
||
(testing "Testing that KMS keywords such as projects exist after normal loading." | ||
(is (some? (:projects kms-map)))) | ||
|
||
(testing "Test KMS keywords API returning nil for testing purposes." | ||
(let [context (assoc context :testing-for-nil-keyword-scheme-value true)] | ||
(is (nil? (trans-kms/get-keywords-for-keyword-scheme context :projects))))) | ||
|
||
;; Test to make sure that if KMS keywords API returns nil for a keyword after | ||
;; parsing, (KMS API is down) that previous cache value is used, so that we don't | ||
;; wipe out the KMS keyword values in the cache. | ||
(testing "Makes sure that KMS keywords are not wiped out." | ||
(let [context (assoc context :testing-for-nil-keyword-scheme-value true)] | ||
(#'fetcher/refresh-kms-cache context) | ||
(is (some? (:projects (cache/get-value kms-cache fetcher/kms-cache-key)))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters