|
@@ -473,10 +473,17 @@ public abstract class TransformRestTestCase extends ESRestTestCase {
|
|
|
// start the transform
|
|
|
startTransform(transformId, authHeader, secondaryAuthHeader, null, warnings);
|
|
|
assertTrue(indexExists(transformIndex));
|
|
|
- // wait until the transform has been created and all data is available
|
|
|
- waitForTransformCheckpoint(transformId);
|
|
|
-
|
|
|
- waitForTransformStopped(transformId);
|
|
|
+ assertBusy(() -> {
|
|
|
+ Map<?, ?> transformStatsAsMap = getTransformStateAndStats(transformId);
|
|
|
+ // wait until the transform has been created and all data is available
|
|
|
+ assertEquals(
|
|
|
+ "Stats were: " + transformStatsAsMap,
|
|
|
+ 1,
|
|
|
+ XContentMapValues.extractValue("checkpointing.last.checkpoint", transformStatsAsMap)
|
|
|
+ );
|
|
|
+ // wait until the transform is stopped
|
|
|
+ assertEquals("Stats were: " + transformStatsAsMap, "stopped", XContentMapValues.extractValue("state", transformStatsAsMap));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
refreshIndex(transformIndex);
|
|
|
}
|
|
|
|
|
@@ -539,16 +546,16 @@ public abstract class TransformRestTestCase extends ESRestTestCase {
|
|
|
return createRequestWithSecondaryAuth(method, endpoint, authHeader, null);
|
|
|
}
|
|
|
|
|
|
- void waitForTransformStopped(String transformId) throws Exception {
|
|
|
- assertBusy(() -> { assertEquals("stopped", getTransformState(transformId)); }, 15, TimeUnit.SECONDS);
|
|
|
- }
|
|
|
-
|
|
|
- void waitForTransformCheckpoint(String transformId) throws Exception {
|
|
|
- waitForTransformCheckpoint(transformId, 1L);
|
|
|
- }
|
|
|
-
|
|
|
void waitForTransformCheckpoint(String transformId, long checkpoint) throws Exception {
|
|
|
- assertBusy(() -> assertEquals(checkpoint, getTransformCheckpoint(transformId)), 30, TimeUnit.SECONDS);
|
|
|
+ assertBusy(() -> {
|
|
|
+ Map<?, ?> transformStatsAsMap = getTransformStateAndStats(transformId);
|
|
|
+ assertNotEquals("Stats were: " + transformStatsAsMap, "failed", XContentMapValues.extractValue("state", transformStatsAsMap));
|
|
|
+ assertEquals(
|
|
|
+ "Stats were: " + transformStatsAsMap,
|
|
|
+ (int) checkpoint,
|
|
|
+ XContentMapValues.extractValue("checkpointing.last.checkpoint", transformStatsAsMap)
|
|
|
+ );
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
void refreshIndex(String index) throws IOException {
|
|
@@ -632,16 +639,6 @@ public abstract class TransformRestTestCase extends ESRestTestCase {
|
|
|
wipeAllIndices();
|
|
|
}
|
|
|
|
|
|
- static int getTransformCheckpoint(String transformId) throws IOException {
|
|
|
- Response statsResponse = client().performRequest(new Request("GET", getTransformEndpoint() + transformId + "/_stats"));
|
|
|
-
|
|
|
- Map<?, ?> transformStatsAsMap = (Map<?, ?>) ((List<?>) entityAsMap(statsResponse).get("transforms")).get(0);
|
|
|
-
|
|
|
- // assert that the transform did not fail
|
|
|
- assertNotEquals("Stats were: " + transformStatsAsMap, "failed", XContentMapValues.extractValue("state", transformStatsAsMap));
|
|
|
- return (int) XContentMapValues.extractValue("checkpointing.last.checkpoint", transformStatsAsMap);
|
|
|
- }
|
|
|
-
|
|
|
protected void setupDataAccessRole(String role, String... indices) throws IOException {
|
|
|
String indicesStr = Arrays.stream(indices).collect(Collectors.joining("\",\"", "\"", "\""));
|
|
|
Request request = new Request("PUT", "/_security/role/" + role);
|