-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Peter Nied <[email protected]>
- Loading branch information
Showing
6 changed files
with
163 additions
and
68 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
74 changes: 74 additions & 0 deletions
74
...r/src/internalClusterTest/java/org/opensearch/action/admin/indices/view/ViewTestBase.java
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,74 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.indices.view; | ||
|
||
import org.opensearch.action.search.SearchRequest; | ||
import org.opensearch.action.search.SearchResponse; | ||
import org.opensearch.test.BackgroundIndexer; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import java.util.List; | ||
|
||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; | ||
|
||
public abstract class ViewTestBase extends OpenSearchIntegTestCase { | ||
|
||
protected int createIndexWithDocs(final String indexName) throws Exception { | ||
createIndex(indexName); | ||
ensureGreen(indexName); | ||
|
||
final int numOfDocs = scaledRandomIntBetween(0, 200); | ||
try (final BackgroundIndexer indexer = new BackgroundIndexer(indexName, "_doc", client(), numOfDocs)) { | ||
waitForDocs(numOfDocs, indexer); | ||
} | ||
|
||
refresh(indexName); | ||
assertHitCount(client().prepareSearch(indexName).setSize(0).get(), numOfDocs); | ||
return numOfDocs; | ||
} | ||
|
||
protected GetViewAction.Response createView(final String name, final String indexPattern) throws Exception { | ||
final CreateViewAction.Request request = new CreateViewAction.Request( | ||
name, | ||
null, | ||
List.of(new CreateViewAction.Request.Target(indexPattern)) | ||
); | ||
return client().admin().indices().createView(request).actionGet(); | ||
} | ||
|
||
protected GetViewAction.Response getView(final String name) { | ||
return client().admin().indices().getView(new GetViewAction.Request(name)).actionGet(); | ||
|
||
} | ||
|
||
protected void deleteView(final String name) { | ||
client().admin().indices().deleteView(new DeleteViewAction.Request(name)).actionGet(); | ||
performRemoteStoreTestAction(); | ||
} | ||
|
||
protected List<String> listViewNames() { | ||
return client().listViewNames(new ListViewNamesAction.Request()).actionGet().getViewNames(); | ||
} | ||
|
||
protected SearchResponse searchView(final String viewName) throws Exception { | ||
final SearchViewAction.Request request = SearchViewAction.createRequestWith(viewName, new SearchRequest()); | ||
final SearchResponse response = client().searchView(request).actionGet(); | ||
return response; | ||
} | ||
|
||
protected GetViewAction.Response updateView(final String name, final String description, final String indexPattern) { | ||
final CreateViewAction.Request request = new CreateViewAction.Request( | ||
name, | ||
description, | ||
List.of(new CreateViewAction.Request.Target(indexPattern)) | ||
); | ||
final GetViewAction.Response response = client().admin().indices().updateView(request).actionGet(); | ||
return response; | ||
} | ||
} |
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
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
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
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