Skip to content

Commit 435b883

Browse files
committed
[ML] Fix and unmute Transform upgrade test (elastic#132995)
(cherry picked from commit 208ae57) # Conflicts: # x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpgradeTransformsAction.java
1 parent a9d778d commit 435b883

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,19 @@ public void deleteOldIndices(ActionListener<Boolean> listener) {
295295

296296
// use the transform context as we access system indexes
297297
try (ThreadContext.StoredContext ctx = client.threadPool().getThreadContext().stashWithOrigin(TRANSFORM_ORIGIN)) {
298-
indicesToDelete.addAll(
299-
Arrays.asList(
300-
indexNameExpressionResolver.concreteIndexNames(
301-
state,
302-
IndicesOptions.lenientExpandHidden(),
303-
TransformInternalIndexConstants.INDEX_NAME_PATTERN
304-
)
305-
)
298+
var matchingIndexes = indexNameExpressionResolver.concreteIndices(
299+
state,
300+
IndicesOptions.lenientExpandHidden(),
301+
TransformInternalIndexConstants.INDEX_NAME_PATTERN
306302
);
307303

304+
for (var index : matchingIndexes) {
305+
var meta = state.getMetadata().indexMetadata(index);
306+
if (meta.isSystem() == false) { // ignore system indices as these are automatically managed
307+
indicesToDelete.add(meta.getIndex().getName());
308+
}
309+
}
310+
308311
indicesToDelete.addAll(
309312
Arrays.asList(
310313
indexNameExpressionResolver.concreteIndexNames(

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MLModelDeploymentsUpgradeIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public void setUpLogging() throws IOException {
7373
request.setJsonEntity("""
7474
{
7575
"persistent": {
76-
"logger.org.elasticsearch.xpack.ml.inference": "TRACE",
76+
"logger.org.elasticsearch.xpack.ml.inference": "DEBUG",
7777
"logger.org.elasticsearch.xpack.ml.inference.assignments": "DEBUG",
7878
"logger.org.elasticsearch.xpack.ml.process": "DEBUG",
79-
"logger.org.elasticsearch.xpack.ml.action": "TRACE"
79+
"logger.org.elasticsearch.xpack.ml.action": "DEBUG"
8080
}
8181
}
8282
""");

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TransformSurvivesUpgradeIT.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.apache.http.HttpHost;
1010
import org.apache.http.entity.ContentType;
1111
import org.apache.http.entity.StringEntity;
12+
import org.elasticsearch.Version;
1213
import org.elasticsearch.client.Request;
1314
import org.elasticsearch.client.Response;
1415
import org.elasticsearch.client.RestClient;
@@ -96,7 +97,6 @@ public void testTransformRollingUpgrade() throws Exception {
9697
lastCheckpoint = 2;
9798
}
9899
verifyContinuousTransformHandlesData(lastCheckpoint);
99-
verifyUpgradeFailsIfMixedCluster();
100100
}
101101
case UPGRADED -> {
102102
client().performRequest(waitForYellow);
@@ -131,11 +131,11 @@ private void createAndStartContinuousTransform() throws Exception {
131131

132132
assertBusy(() -> {
133133
var stateAndStats = getTransformStats(CONTINUOUS_TRANSFORM_ID);
134+
assertThat((Integer) XContentMapValues.extractValue("stats.documents_indexed", stateAndStats), equalTo(ENTITIES.size()));
134135
assertThat(
135-
((Integer) XContentMapValues.extractValue("stats.documents_indexed", stateAndStats)).longValue(),
136-
equalTo(ENTITIES.size())
136+
((Integer) XContentMapValues.extractValue("stats.documents_processed", stateAndStats)).longValue(),
137+
equalTo(totalDocsWritten)
137138
);
138-
assertThat((Integer) XContentMapValues.extractValue("stats.documents_processed", stateAndStats), equalTo(totalDocsWritten));
139139
// Even if we get back to started, we may periodically get set back to `indexing` when triggered.
140140
// Though short lived due to no changes on the source indices, it could result in flaky test behavior
141141
assertThat(stateAndStats.get("state"), oneOf("started", "indexing"));
@@ -232,17 +232,6 @@ private void verifyContinuousTransformHandlesData(long expectedLastCheckpoint) t
232232
});
233233
}
234234

235-
private void verifyUpgradeFailsIfMixedCluster() {
236-
// upgrade tests by design are also executed with the same version, this check must be skipped in this case, see gh#39102.
237-
if (isOriginalClusterCurrent()) {
238-
return;
239-
}
240-
final Request upgradeTransformRequest = new Request("POST", getTransformEndpoint() + "_upgrade");
241-
242-
Exception ex = expectThrows(Exception.class, () -> client().performRequest(upgradeTransformRequest));
243-
assertThat(ex.getMessage(), containsString("All nodes must be the same version"));
244-
}
245-
246235
private void verifyUpgrade() throws IOException {
247236
final Request upgradeTransformRequest = new Request("POST", getTransformEndpoint() + "_upgrade");
248237
Response response = client().performRequest(upgradeTransformRequest);

0 commit comments

Comments
 (0)