Browse Source

[ML-DataFrame] fix test failure in checkpoint retrieval (#45297)

gracefully handle if index response returns null, increase and assert timeout

closes #45238
Hendrik Muhs 6 years ago
parent
commit
151724fa64

+ 3 - 1
x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/checkpoint/DefaultCheckpointProvider.java

@@ -148,7 +148,9 @@ public class DefaultCheckpointProvider implements CheckpointProvider {
 
         ClientHelper.executeWithHeadersAsync(transformConfig.getHeaders(), ClientHelper.DATA_FRAME_ORIGIN, client, GetIndexAction.INSTANCE,
                 getIndexRequest, ActionListener.wrap(getIndexResponse -> {
-                    Set<String> userIndices = new HashSet<>(Arrays.asList(getIndexResponse.getIndices()));
+                    Set<String> userIndices = getIndexResponse.getIndices() != null
+                            ? new HashSet<>(Arrays.asList(getIndexResponse.getIndices()))
+                            : Collections.emptySet();
                     // 2nd get stats request
                     ClientHelper.executeAsyncWithOrigin(client,
                         ClientHelper.DATA_FRAME_ORIGIN,

+ 1 - 1
x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/DataFrameSingleNodeTestCase.java

@@ -70,7 +70,7 @@ public abstract class DataFrameSingleNodeTestCase extends ESSingleNodeTestCase {
         }), latch);
 
         function.accept(listener);
-        latch.await(10, TimeUnit.SECONDS);
+        assertTrue("timed out after 20s", latch.await(20, TimeUnit.SECONDS));
     }
 
 }

+ 3 - 3
x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/checkpoint/DataFrameTransformCheckpointServiceNodeTests.java

@@ -73,8 +73,8 @@ public class DataFrameTransformCheckpointServiceNodeTests extends DataFrameSingl
 
     private class MockClientForCheckpointing extends NoOpClient {
 
-        private ShardStats[] shardStats;
-        private String[] indices;
+        private volatile ShardStats[] shardStats;
+        private volatile String[] indices;
 
         MockClientForCheckpointing(String testName) {
             super(testName);
@@ -98,6 +98,7 @@ public class DataFrameTransformCheckpointServiceNodeTests extends DataFrameSingl
 
             if (request instanceof GetIndexRequest) {
                 // for this test we only need the indices
+                assert(indices != null);
                 final GetIndexResponse indexResponse = new GetIndexResponse(indices, null, null, null, null);
 
                 listener.onResponse((Response) indexResponse);
@@ -177,7 +178,6 @@ public class DataFrameTransformCheckpointServiceNodeTests extends DataFrameSingl
                 DataFrameTransformCheckpoint.EMPTY, null, null);
     }
 
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/45238")
     public void testGetCheckpointStats() throws InterruptedException {
         String transformId = randomAlphaOfLengthBetween(3, 10);
         long timestamp = 1000;