Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Wait longer for DFA jobs in stop-and-restart tests to make progress #67657

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,8 @@ public void testStopAndRestart() throws Exception {
NodeAcknowledgedResponse response = startAnalytics(jobId);
assertThat(response.getNode(), not(emptyString()));

// Wait until progress for first phase is over 1
assertBusy(() -> {
List<PhaseProgress> progress = getAnalyticsStats(jobId).getProgress();
assertThat(progress.get(0).getProgressPercent(), greaterThan(1));
});
String phaseToWait = randomFrom("reindexing", "loading_data", "feature_selection", "fine_tuning_parameters");
waitUntilSomeProgressHasBeenMadeForPhase(jobId, phaseToWait);
stopAnalytics(jobId);
waitUntilAnalyticsIsStopped(jobId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
Expand All @@ -69,6 +70,7 @@
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
Expand Down Expand Up @@ -272,6 +274,14 @@ protected List<TaskInfo> analyticsAssignedTaskList() {
return client().admin().cluster().prepareListTasks().setActions(MlTasks.DATA_FRAME_ANALYTICS_TASK_NAME + "[c]").get().getTasks();
}

protected void waitUntilSomeProgressHasBeenMadeForPhase(String jobId, String phase) throws Exception {
assertBusy(() -> {
List<PhaseProgress> progress = getAnalyticsStats(jobId).getProgress();
Optional<PhaseProgress> phaseProgress = progress.stream().filter(p -> phase.equals(p.getPhase())).findFirst();
assertThat("unexpected phase [" + phase + "]; progress was " + progress, phaseProgress.isEmpty(), is(false));
assertThat(phaseProgress.get().getProgressPercent(), greaterThan(1));
}, 60, TimeUnit.SECONDS);
}
/**
* Asserts whether the audit messages fetched from index match provided prefixes.
* More specifically, in order to pass:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,8 @@ public void testStopAndRestart() throws Exception {
NodeAcknowledgedResponse response = startAnalytics(jobId);
assertThat(response.getNode(), not(emptyString()));

// Wait until progress for first phase is over 1
assertBusy(() -> {
List<PhaseProgress> progress = getAnalyticsStats(jobId).getProgress();
assertThat(progress.get(0).getProgressPercent(), greaterThan(1));
});
String phaseToWait = randomFrom("reindexing", "loading_data", "feature_selection", "fine_tuning_parameters");
waitUntilSomeProgressHasBeenMadeForPhase(jobId, phaseToWait);
stopAnalytics(jobId);
waitUntilAnalyticsIsStopped(jobId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,8 @@ public void testOutlierDetectionStopAndRestart() throws Exception {
NodeAcknowledgedResponse response = startAnalytics(id);
assertThat(response.getNode(), not(emptyString()));

// Wait until progress for first phase is over 1
assertBusy(() -> {
List<PhaseProgress> progress = getAnalyticsStats(id).getProgress();
assertThat(progress.get(0).getProgressPercent(), greaterThan(1));
});
String phaseToWait = randomFrom("reindexing", "loading_data", "computing_outliers");
waitUntilSomeProgressHasBeenMadeForPhase(id, phaseToWait);
stopAnalytics(id);
waitUntilAnalyticsIsStopped(id);

Expand Down