forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] Add CCS tests for index filtering (elastic#119619) (elastic#119716
) * Add CCS tests for index filtering (elastic#119619) * Add CCS tests for index filtering See also: elastic#116755 * Don't run the test on pre-8.18
- Loading branch information
Showing
2 changed files
with
129 additions
and
26 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
...sters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/RequestIndexFilteringIT.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,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.ccq; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; | ||
|
||
import org.apache.http.HttpHost; | ||
import org.elasticsearch.Version; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.client.RestClient; | ||
import org.elasticsearch.core.IOUtils; | ||
import org.elasticsearch.test.TestClustersThreadFilter; | ||
import org.elasticsearch.test.cluster.ElasticsearchCluster; | ||
import org.elasticsearch.xpack.esql.qa.rest.RequestIndexFilteringTestCase; | ||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.rules.RuleChain; | ||
import org.junit.rules.TestRule; | ||
|
||
import java.io.IOException; | ||
|
||
@ThreadLeakFilters(filters = TestClustersThreadFilter.class) | ||
public class RequestIndexFilteringIT extends RequestIndexFilteringTestCase { | ||
|
||
static ElasticsearchCluster remoteCluster = Clusters.remoteCluster(); | ||
static ElasticsearchCluster localCluster = Clusters.localCluster(remoteCluster); | ||
|
||
@ClassRule | ||
public static TestRule clusterRule = RuleChain.outerRule(remoteCluster).around(localCluster); | ||
private static RestClient remoteClient; | ||
|
||
@Override | ||
protected String getTestRestCluster() { | ||
return localCluster.getHttpAddresses(); | ||
} | ||
|
||
@Before | ||
public void setRemoteClient() throws IOException { | ||
if (remoteClient == null) { | ||
var clusterHosts = parseClusterHosts(remoteCluster.getHttpAddresses()); | ||
remoteClient = buildClient(restClientSettings(), clusterHosts.toArray(new HttpHost[0])); | ||
} | ||
} | ||
|
||
@BeforeClass | ||
public static void checkVersion() { | ||
assumeTrue("skip if version before 8.18", Clusters.localClusterVersion().onOrAfter(Version.V_8_18_0)); | ||
} | ||
|
||
@AfterClass | ||
public static void closeRemoteClients() throws IOException { | ||
try { | ||
IOUtils.close(remoteClient); | ||
} finally { | ||
remoteClient = null; | ||
} | ||
} | ||
|
||
@Override | ||
protected void indexTimestampData(int docs, String indexName, String date, String differentiatorFieldName) throws IOException { | ||
indexTimestampDataForClient(client(), docs, indexName, date, differentiatorFieldName); | ||
indexTimestampDataForClient(remoteClient, docs, indexName, date, differentiatorFieldName); | ||
} | ||
|
||
@Override | ||
protected String from(String... indexName) { | ||
if (randomBoolean()) { | ||
return "FROM *:" + String.join(",*:", indexName); | ||
} else { | ||
return "FROM " + String.join(",", indexName); | ||
} | ||
} | ||
|
||
@After | ||
public void wipeRemoteTestData() throws IOException { | ||
try { | ||
var response = remoteClient.performRequest(new Request("DELETE", "/test*")); | ||
assertEquals(200, response.getStatusLine().getStatusCode()); | ||
} catch (ResponseException re) { | ||
assertEquals(404, re.getResponse().getStatusLine().getStatusCode()); | ||
} | ||
} | ||
} |
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