Skip to content

Commit

Permalink
Removing old datasources model test
Browse files Browse the repository at this point in the history
Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
  • Loading branch information
vamsi-amazon committed Mar 26, 2024
1 parent bfcaedf commit 7ec6bf8
Showing 1 changed file with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import static org.opensearch.sql.datasources.utils.XContentParserUtils.DESCRIPTION_FIELD;
import static org.opensearch.sql.datasources.utils.XContentParserUtils.NAME_FIELD;
import static org.opensearch.sql.datasources.utils.XContentParserUtils.STATUS_FIELD;
import static org.opensearch.sql.legacy.TestUtils.createIndexByRestClient;
import static org.opensearch.sql.legacy.TestUtils.getResponseBody;
import static org.opensearch.sql.legacy.TestUtils.isIndexExist;
import static org.opensearch.sql.legacy.TestUtils.loadDataByRestClient;

import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
Expand Down Expand Up @@ -70,10 +67,6 @@ protected static void deleteDataSourcesCreated() throws IOException {
deleteRequest = getDeleteDataSourceRequest("patch_prometheus");
deleteResponse = client().performRequest(deleteRequest);
Assert.assertEquals(204, deleteResponse.getStatusLine().getStatusCode());

deleteRequest = getDeleteDataSourceRequest("old_prometheus");
deleteResponse = client().performRequest(deleteRequest);
Assert.assertEquals(204, deleteResponse.getStatusLine().getStatusCode());
}

@SneakyThrows
Expand Down Expand Up @@ -392,35 +385,6 @@ public void patchDataSourceAPITest() {
Assert.assertEquals("test", dataSourceMetadata.getDescription());
}

@SneakyThrows
@Test
public void testOldDataSourceModelLoadingThroughGetDataSourcesAPI() {
Index index = Index.DATASOURCES;
String indexName = index.getName();
String mapping = index.getMapping();
String dataSet = index.getDataSet();
if (!isIndexExist(client(), indexName)) {
createIndexByRestClient(client(), indexName, mapping);
}
loadDataByRestClient(client(), indexName, dataSet);
// waiting for loaded indices.
Thread.sleep(1000);
// get datasource to validate the creation.
Request getRequest = getFetchDataSourceRequest(null);
Response getResponse = client().performRequest(getRequest);
Assert.assertEquals(200, getResponse.getStatusLine().getStatusCode());
String getResponseString = getResponseBody(getResponse);
Type listType = new TypeToken<List<DataSourceMetadata>>() {}.getType();
List<DataSourceMetadata> dataSourceMetadataList =
new Gson().fromJson(getResponseString, listType);
Assert.assertTrue(
dataSourceMetadataList.stream()
.anyMatch(
dataSourceMetadata ->
dataSourceMetadata.getName().equals("old_prometheus")
&& dataSourceMetadata.getStatus().equals(ACTIVE)));
}

public DataSourceMetadata mockDataSourceMetadata(String name) {
return new DataSourceMetadata.Builder()
.setName(name)
Expand Down

0 comments on commit 7ec6bf8

Please sign in to comment.