Skip to content

Commit 403f29c

Browse files
committed
update int tests
1 parent 4c5ed5f commit 403f29c

13 files changed

Lines changed: 72 additions & 61 deletions

File tree

dev-system/src/cmr/dev_system/control.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@
119119
:when (get-in system [:apps service-name])]
120120
(reset-fn (app-context system service-name)))
121121
;; After reset some elasticsearch indexes may not be initialized yet. We will check the status here
122-
(elastic-conn/wait-for-healthy-elastic (get-in system [:apps :indexer :db]))
122+
(elastic-conn/wait-for-healthy-elastic (get-in system [:apps :indexer :gran-elastic]))
123+
(elastic-conn/wait-for-healthy-elastic (get-in system [:apps :indexer :non-gran-elastic]))
123124
(debug "dev system /reset complete")
124125
{:status 200})
125126

indexer-app/src/cmr/indexer/api/routes.clj

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,25 @@
7777
(index-set-svc/delete-index-set request-context id cmr.elastic-utils.config/non-gran-elastic-name)
7878
{:status 204})
7979

80-
;; TODO 10636 We need to update all these endpoints to work with the new clusters
80+
;; TODO 10636 Updated. Need to test that it worked.
8181
(context "/rebalancing-collections/:concept-id" [concept-id]
8282

8383
;; Marks the collection as re-balancing in the index set.
8484
(POST "/start" {request-context :request-context params :params}
85-
;(acl/verify-ingest-management-permission request-context :update)
86-
;(index-set-svc/mark-collection-as-rebalancing request-context id concept-id (:target params))
87-
;{:status 200}
85+
(acl/verify-ingest-management-permission request-context :update)
86+
(index-set-svc/mark-collection-as-rebalancing request-context id concept-id (:target params))
8887
{:status 200})
8988

9089
;; Update the status of collection being rebalanced
9190
(POST "/update-status" {request-context :request-context params :params}
92-
;(acl/verify-ingest-management-permission request-context :update)
93-
;(index-set-svc/update-collection-rebalancing-status request-context id concept-id (:status params))
91+
(acl/verify-ingest-management-permission request-context :update)
92+
(index-set-svc/update-collection-rebalancing-status request-context id concept-id (:status params))
9493
{:status 200})
9594

9695
;; Marks the collection as completed rebalancing
9796
(POST "/finalize" {request-context :request-context}
98-
;(acl/verify-ingest-management-permission request-context :update)
99-
;(index-set-svc/finalize-collection-rebalancing request-context id concept-id)
97+
(acl/verify-ingest-management-permission request-context :update)
98+
(index-set-svc/finalize-collection-rebalancing request-context id concept-id)
10099
{:status 200})))))
101100

102101
;; Note for future. We should cleanup this API. It's not very well layed out.

indexer-app/src/cmr/indexer/services/index_service.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@
888888

889889
(defn reindex-all-collections
890890
"Reindexes all collections in all providers. This is only called in the indexer when humanizers
891-
are updated and we only index the latest collection revision."
891+
are updated, and we only index the latest collection revision."
892892
[context]
893893
(let [providers (map :provider-id (meta-db2/get-providers context))]
894894
(info "Sending events to reindex collections in all providers:" (pr-str providers))

system-int-test/src/cmr/system_int_test/utils/dev_system_util.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
(qb-side-api/wait-for-terminal-states)
2626
(try
2727
(client/post (url/dev-system-reset-url) (admin-connect-options))
28-
(index/refresh-elastic-index)
28+
(index/refresh-all-elastic-indexes)
2929
(load-kms-redis-cache) ;; This will cause the redis cache to reload
3030
(catch Exception e
3131
(error "Failed to send reset to dev-system\n" e)

system-int-test/src/cmr/system_int_test/utils/index_util.clj

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
[cmr.system-int-test.utils.url-helper :as url]
1212
[cmr.transmit.config :as transmit-config]))
1313

14-
(defn refresh-elastic-index
14+
(defn refresh-all-elastic-indexes
1515
[]
16-
(client/post (url/elastic-refresh-url) {:connection-manager (s/conn-mgr)}))
16+
(client/post (url/elastic-refresh-url cmr.elastic-utils.config/gran-elastic-name) {:connection-manager (s/conn-mgr)})
17+
(client/post (url/elastic-refresh-url cmr.elastic-utils.config/non-gran-elastic-name) {:connection-manager (s/conn-mgr)}))
1718

1819
(defn wait-until-indexed
1920
"Wait until ingested concepts have been indexed"
2021
[]
2122
(qb-side-api/wait-for-terminal-states)
22-
(refresh-elastic-index))
23+
(refresh-all-elastic-indexes))
2324

2425
(defn full-refresh-collection-granule-aggregate-cache
2526
"Triggers a full refresh of the collection granule aggregate cache in the indexer."
@@ -99,11 +100,12 @@
99100
:query-params query-params})]
100101
response)))
101102

103+
;; TODO 10636 - just a note that type-name is not used in this func...
102104
(defn doc-present?
103105
"If doc is present return true, otherwise return false"
104-
[index-name type-name doc-id]
106+
[index-name type-name doc-id elastic-name]
105107
(let [response (client/get
106-
(format "%s/%s/_doc/_search?q=_id:%s" (url/elastic-root) index-name doc-id)
108+
(format "%s/%s/_doc/_search?q=_id:%s" (url/elastic-root elastic-name) index-name doc-id)
107109
{:throw-exceptions false
108110
:connection-manager (s/conn-mgr)})
109111
body (json/decode (:body response) true)]
@@ -143,13 +145,13 @@
143145
(qb-side-api/set-message-queue-retry-behavior 0)
144146
(qb-side-api/set-message-queue-publish-timeout 10000))))))
145147

146-
(defn delete-elasticsearch-index
147-
"Helper to delete an elasticsearch index associated with a collection."
148+
(defn delete-gran-elastic-index
149+
"Helper will delete the elasticsearch granule index associated with a collection."
148150
[coll]
149151
(let [index-name (string/replace (format "1_%s" (string/lower-case (:concept-id coll)))
150152
#"-" "_")]
151153
(warn "Deleting index " index-name)
152-
(client/delete (format "%s/%s" (url/elastic-root) index-name)
154+
(client/delete (format "%s/%s" (url/elastic-root cmr.elastic-utils.config/gran-elastic-name) index-name)
153155
{:connection-manager (s/conn-mgr)})))
154156

155157
(defn- query-for-granules-by-collection
@@ -162,19 +164,19 @@
162164
{:match_all {}}
163165
:filter {:term {:collection-concept-id-doc-values (:concept-id coll)}}}}}))
164166

165-
(defn delete-granules-from-small-collections
167+
(defn delete-granules-from-small-collections-elastic-index
166168
"Helper to delete granules from the small collections index for the given collection."
167169
[coll]
168-
(client/post (format "%s/1_small_collections/_delete_by_query" (url/elastic-root))
170+
(client/post (format "%s/1_small_collections/_delete_by_query" (url/elastic-root cmr.elastic-utils.config/gran-elastic-name))
169171
{:connection-manager (s/conn-mgr)
170172
:body (query-for-granules-by-collection coll)
171173
:content-type "application/json"}))
172174

173-
(defn check-index-exists
174-
"Helpper to check if elasticsearch index exists."
175+
(defn gran-elastic-index-exists?
176+
"Helper to check if elasticsearch granule index exists."
175177
[coll]
176178
(let [index-name (string/replace (format "1_%s" (string/lower-case (:concept-id coll)))
177179
#"-" "_")]
178-
(client/head (format "%s/%s" (url/elastic-root) index-name)
180+
(client/head (format "%s/%s" (url/elastic-root cmr.elastic-utils.config/gran-elastic-name) index-name)
179181
{:connection-manager (s/conn-mgr)
180182
:throw-exceptions false})))

system-int-test/src/cmr/system_int_test/utils/url_helper.clj

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,24 @@
5656
;; Elasticsearch URLs
5757

5858
(defn elastic-root
59-
[]
60-
(format "http://localhost:%s" (es-config/elastic-port)))
59+
[elastic-name]
60+
(cond
61+
(= elastic-name cmr.elastic-utils.config/gran-elastic-name)
62+
(format "http://localhost:%s" (es-config/elastic-port))
63+
64+
(= elastic-name cmr.elastic-utils.config/non-gran-elastic-name)
65+
(format "http://localhost:%s" (es-config/elastic-port-non-gran))
66+
67+
:else
68+
(throw (Exception. (str "Given wrong elastic-name: " elastic-name " to create elastic root url.")))))
6169

6270
(defn elastic-refresh-url
63-
[]
64-
(str (elastic-root) "/_refresh"))
71+
[elastic-name]
72+
(str (elastic-root elastic-name) "/_refresh"))
6573

6674
(defn elastic-delete-tag-url
6775
[id]
68-
(format "%s/1_tags/_doc/%s" (elastic-root) id))
76+
(format "%s/1_tags/_doc/%s" (elastic-root cmr.elastic-utils.config/non-gran-elastic-name) id))
6977

7078
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7179
;; Metadata DB URLs

system-int-test/test/cmr/system_int_test/bootstrap/rebalance_collections_test.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@
435435
(search/clear-caches)
436436
;; Delete the granules from small collections to show that search is still using the separate
437437
;; index
438-
(index/delete-granules-from-small-collections coll2)
438+
(index/delete-granules-from-small-collections-elastic-index coll2)
439439
(index/wait-until-indexed)
440440
(assert-rebalance-status {:small-collections 0 :separate-index 2 :rebalancing-status "COMPLETE"} coll2)
441441
(is (= 2 (count (:refs (search/find-refs :granule {:concept-id (:concept-id coll1)})))))
@@ -462,8 +462,8 @@
462462
(is (= 4 (count (:refs (search/find-refs :granule {:concept-id (:concept-id coll1)})))))
463463
(is (= 2 (count (:refs (search/find-refs :granule {:concept-id (:concept-id coll2)})))))
464464
;; Delete the collection specific indexes to show it has no impact on search after finalize
465-
(index/delete-elasticsearch-index coll1)
466-
(index/delete-elasticsearch-index coll2)
465+
(index/delete-gran-elastic-index coll1)
466+
(index/delete-gran-elastic-index coll2)
467467
(index/wait-until-indexed)
468468
(assert-rebalance-status {:small-collections 4 :rebalancing-status "NOT_REBALANCING"} coll1)
469469
(assert-rebalance-status {:small-collections 2 :rebalancing-status "NOT_REBALANCING"} coll2)

system-int-test/test/cmr/system_int_test/ingest/granule_bulk_update/granule_bulk_update_volume_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
(is (= "COMPLETE" (:task-status (ingest/granule-bulk-update-task-status task-id)))))
9090

9191
(testing "The data is reflected in the updated values in search"
92-
(index/refresh-elastic-index)
92+
(index/refresh-all-elastic-indexes)
9393
(let [next-granules (-> (search/find-concepts-umm-json :granule {:granule-ur urs})
9494
:body
9595
(json/parse-string true)

system-int-test/test/cmr/system_int_test/ingest/misc/deleted_granule_index_test.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
(index/wait-until-indexed)
2222
(bootstrap/finalize-rebalance-collection (:concept-id collection))
2323
(index/wait-until-indexed)
24-
(let [index-exists-before-delete-response (index/check-index-exists collection)
24+
(let [index-exists-before-delete-response (index/gran-elastic-index-exists? collection)
2525
_ (ingest/delete-concept (data-core/umm-c-collection->concept collection :echo10) {})
2626
_ (index/wait-until-indexed)
27-
index-exists-after-delete-response (index/check-index-exists collection)]
27+
index-exists-after-delete-response (index/gran-elastic-index-exists? collection)]
2828
(is (= 200 (:status index-exists-before-delete-response)))
2929
(is (= 404 (:status index-exists-after-delete-response))))))
3030
(testing "Ingest collection, rebalance collection, delete collection, ingest collection, ingest granule, check index exists again"
@@ -37,7 +37,7 @@
3737
(index/wait-until-indexed)
3838
(ingest/delete-concept (data-core/umm-c-collection->concept collection :echo10) {})
3939
(index/wait-until-indexed)
40-
(let [index-not-exists-before-reingest-response (index/check-index-exists collection)
40+
(let [index-not-exists-before-reingest-response (index/gran-elastic-index-exists? collection)
4141
new-collection (data-core/ingest-umm-spec-collection "PROV1"
4242
(data-umm-c/collection {})
4343
{:validate-keywords false})
@@ -46,6 +46,6 @@
4646
dissoc :ShortName :Version))
4747
_ (index/wait-until-indexed)
4848

49-
index-not-exists-after-reingest-response (index/check-index-exists collection)]
49+
index-not-exists-after-reingest-response (index/gran-elastic-index-exists? collection)]
5050
(is (= 404 (:status index-not-exists-before-reingest-response)))
5151
(is (= 200 (:status index-not-exists-after-reingest-response)))))))

system-int-test/test/cmr/system_int_test/ingest/misc/deleted_granules_index_test.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
[concept-id]
2626
(index/doc-present? deleted-granule/deleted-granule-index-name
2727
deleted-granule/deleted-granule-type-name
28-
concept-id))
28+
concept-id
29+
cmr.elastic-utils.config/gran-elastic-name))
2930

3031
(defn- find-deleted-granules
3132
"Calls get-deleted-granules endpoint and returns parsed items from response"

0 commit comments

Comments
 (0)