@@ -111,6 +111,14 @@ public MultiClusterSpecIT(
111111 super (fileName , groupName , testName , lineNumber , convertToRemoteIndices (testCase ), instructions , mode );
112112 }
113113
114+ // TODO: think how to handle this better
115+ public static final Set <String > LOOKUP_JOIN_AFTER_STATS_TESTS = Set .of (
116+ "StatsAndLookupIPAndMessageFromIndex" ,
117+ "JoinMaskingRegex" ,
118+ "StatsAndLookupIPFromIndex" ,
119+ "StatsAndLookupMessageFromIndex"
120+ );
121+
114122 @ Override
115123 protected void shouldSkipTest (String testName ) throws IOException {
116124 boolean remoteMetadata = testCase .requiredCapabilities .contains (METADATA_FIELDS_REMOTE_TEST .capabilityName ());
@@ -138,6 +146,8 @@ protected void shouldSkipTest(String testName) throws IOException {
138146 // Unmapped fields require a coorect capability response from every cluster, which isn't currently implemented.
139147 assumeFalse ("UNMAPPED FIELDS not yet supported in CCS" , testCase .requiredCapabilities .contains (UNMAPPED_FIELDS .capabilityName ()));
140148 assumeFalse ("FORK not yet supported in CCS" , testCase .requiredCapabilities .contains (FORK_V7 .capabilityName ()));
149+ // Tests that use capabilities not supported in CCS
150+ assumeFalse ("LOOKUP JOIN after stats not yet supported in CCS" , LOOKUP_JOIN_AFTER_STATS_TESTS .contains (testName ));
141151 }
142152
143153 @ Override
@@ -186,8 +196,9 @@ protected RestClient buildClient(Settings settings, HttpHost[] localHosts) throw
186196 // These indices are used in metadata tests so we want them on remote only for consistency
187197 public static final List <String > METADATA_INDICES = List .of ("employees" , "apps" , "ul_logs" );
188198
189- // These are loopkup indices, we want them on remotes and locals
190- public static final Set <String > LOOKUP_INDICES = Stream .of (
199+ // These are lookup indices, we want them on both remotes and locals
200+ // TODO: can we somehow find it from the data loader?
201+ public static final Set <String > LOOKUP_INDICES = Set .of (
191202 "languages_nested_fields" ,
192203 "languages_lookup" ,
193204 "clientips_lookup" ,
@@ -199,7 +210,9 @@ protected RestClient buildClient(Settings settings, HttpHost[] localHosts) throw
199210 "languages_lookup_non_unique_key" ,
200211 "lookup_sample_data_ts_nanos" ,
201212 "service_owners"
202- ).map (i -> "/" + i + "/_bulk" ).collect (Collectors .toSet ());
213+ );
214+
215+ public static final Set <String > LOOKUP_ENDPOINTS = LOOKUP_INDICES .stream ().map (i -> "/" + i + "/_bulk" ).collect (Collectors .toSet ());
203216
204217 public static final Set <String > ENRICH_ENDPOINTS = ENRICH_SOURCE_INDICES .stream ()
205218 .map (i -> "/" + i + "/_bulk" )
@@ -225,7 +238,7 @@ static RestClient twoClients(RestClient localClient, RestClient remoteClient) th
225238 return remoteClient .performRequest (request );
226239 } else if (endpoint .endsWith ("/_bulk" )
227240 && ENRICH_ENDPOINTS .contains (endpoint ) == false
228- && LOOKUP_INDICES .contains (endpoint ) == false ) {
241+ && LOOKUP_ENDPOINTS .contains (endpoint ) == false ) {
229242 return bulkClient .performRequest (request );
230243 } else {
231244 Request [] clones = cloneRequests (request , 2 );
@@ -277,13 +290,19 @@ static CsvSpecReader.CsvTestCase convertToRemoteIndices(CsvSpecReader.CsvTestCas
277290 String query = testCase .query ;
278291 String [] commands = query .split ("\\ |" );
279292 String first = commands [0 ].trim ();
293+ // If true, we're using *:index, otherwise we're using *:index,index
294+ boolean onlyRemotes = canUseRemoteIndicesOnly () && randomBoolean ();
280295 if (commands [0 ].toLowerCase (Locale .ROOT ).startsWith ("from" )) {
281296 String [] parts = commands [0 ].split ("(?i)metadata" );
282297 assert parts .length >= 1 : parts ;
283298 String fromStatement = parts [0 ];
284299 String [] localIndices = fromStatement .substring ("FROM " .length ()).split ("," );
300+ if (Arrays .stream (localIndices ).anyMatch (i -> LOOKUP_INDICES .contains (i .trim ().toLowerCase ()))) {
301+ // If the query contains lookup indices, use only remotes to avoid duplication
302+ onlyRemotes = true ;
303+ }
285304 final String remoteIndices ;
286- if (canUseRemoteIndicesOnly () && randomBoolean () ) {
305+ if (onlyRemotes ) {
287306 remoteIndices = Arrays .stream (localIndices ).map (index -> "*:" + index .trim ()).collect (Collectors .joining ("," ));
288307 } else {
289308 remoteIndices = Arrays .stream (localIndices )
@@ -297,7 +316,7 @@ static CsvSpecReader.CsvTestCase convertToRemoteIndices(CsvSpecReader.CsvTestCas
297316 String [] parts = commands [0 ].split ("\\ s+" );
298317 assert parts .length >= 2 : commands [0 ];
299318 String [] indices = parts [1 ].split ("," );
300- if (canUseRemoteIndicesOnly () && randomBoolean () ) {
319+ if (onlyRemotes ) {
301320 parts [1 ] = Arrays .stream (indices ).map (index -> "*:" + index .trim ()).collect (Collectors .joining ("," ));
302321 } else {
303322 parts [1 ] = Arrays .stream (indices ).map (index -> "*:" + index .trim () + "," + index .trim ()).collect (Collectors .joining ("," ));
0 commit comments