Skip to content

Commit 76ec29f

Browse files
committed
Addressed review feedback:
- changed doc url to link github issue - added return after continuation send -- oops! - use junit methods for testing message/exception matching - moved the test to the xpack ml/qa folder - added a gradle build file that appears to work - removed excess override settings from RestTest
1 parent 7766546 commit 76ec29f

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
2+
3+
apply plugin: 'elasticsearch.internal-java-rest-test'
4+
apply plugin: 'elasticsearch.internal-testclusters'
5+
apply plugin: 'elasticsearch.rest-resources'
6+
7+
dependencies {
8+
testImplementation project(':x-pack:qa')
9+
testImplementation project(path: ':test:test-clusters')
10+
javaRestTestImplementation project(path: xpackModule('core'))
11+
}
12+
13+
tasks.named('javaRestTest') {
14+
usesDefaultDistribution("Test internally configures the clusters")
15+
}

modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/DatafeedRemoteClusterClientIT.java renamed to x-pack/plugin/ml/qa/datafeed-multicluster-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/datafeed/DatafeedRemoteClusterClientIT.java

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
package org.elasticsearch.datastreams;
10+
package org.elasticsearch.xpack.ml.datafeed;
1111

1212
import org.apache.http.HttpHost;
1313
import org.elasticsearch.client.Request;
@@ -26,13 +26,15 @@
2626
import java.io.IOException;
2727
import java.util.regex.Pattern;
2828

29+
import static org.hamcrest.Matchers.containsString;
30+
2931
/**
3032
* A test to check that remote_cluster_client errors are correctly reported when a datafeed job is started.
3133
* The local datafeed job references a remote index in a local anomaly detection job. When the
3234
* remote_cluster_client role is missing in the local cluster. This prevents remote indices from being
3335
* resolved to their cluster names.
3436
*
35-
* Written to address github issue 121149.
37+
* @see <a href="https://github.com/elastic/elasticsearch/issues/121149">GitHub issue 121149</a>
3638
*/
3739
public class DatafeedRemoteClusterClientIT extends ESRestTestCase {
3840
public static ElasticsearchCluster remoteCluster = ElasticsearchCluster.local()
@@ -160,37 +162,17 @@ public void testSource() throws IOException {
160162
"start": "2019-04-07T18:22:16Z"
161163
}
162164
""");
163-
try {
164-
localClient.performRequest(startRequest);
165-
assertTrue("This request should fail", false);
166-
} catch (ResponseException e) {
167-
String[] messages = e.getMessage().split("\n");
168-
assertTrue(Pattern.matches("""
169-
.*Datafeed \\[test_datafeed\\] is configured with a remote index pattern\\(s\\) \
170-
\\[remote_cluster:remote_index\\] but the current node \\[local_cluster-0\\] \
171-
is not allowed to connect to remote clusters. Please enable node.remote_cluster_client \
172-
for all machine learning nodes and master-eligible nodes.*""", messages[1]));
173-
}
165+
ResponseException e = assertThrows(ResponseException.class, () -> localClient.performRequest(startRequest));
166+
assertThat(e.getMessage(), containsString("""
167+
Datafeed [test_datafeed] is configured with a remote index pattern(s) \
168+
[remote_cluster:remote_index] but the current node [local_cluster-0] \
169+
is not allowed to connect to remote clusters. Please enable node.remote_cluster_client \
170+
for all machine learning nodes and master-eligible nodes"""));
174171
}
175172
}
176173

177174
@Override
178175
protected String getTestRestCluster() {
179176
return localCluster.getHttpAddresses();
180177
}
181-
182-
@Override
183-
protected boolean preserveIndicesUponCompletion() {
184-
return true;
185-
}
186-
187-
@Override
188-
protected boolean preserveClusterUponCompletion() {
189-
return true;
190-
}
191-
192-
@Override
193-
protected boolean preserveDataStreamsUponCompletion() {
194-
return true;
195-
}
196178
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public void onFailure(Exception e) {
234234
)
235235
)
236236
);
237+
return;
237238
}
238239

239240
final RemoteClusterLicenseChecker remoteClusterLicenseChecker = new RemoteClusterLicenseChecker(

0 commit comments

Comments
 (0)