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

[4.x] - Fix Intermittent TestJBatchEndpoint.runJob #5542

Merged
merged 2 commits into from
Nov 28, 2022
Merged
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 @@ -23,8 +23,8 @@
import jakarta.ws.rs.core.MediaType;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;


@HelidonTest
Expand All @@ -45,18 +45,23 @@ public void runJob() throws InterruptedException {
Integer responseJobId = jsonObject.getInt("Started a job with Execution ID: ");
assertNotNull(responseJobId, "Response Job Id");

//Wait a bit for it to complete
Thread.sleep(3000);
boolean result = false;
for (int i = 1; i < 10; i++) {
//Wait a bit for it to complete
Thread.sleep(i*1000);

//Examine the results
jsonObject = webTarget
.path("batch/status/" + responseJobId)
.request(MediaType.APPLICATION_JSON_TYPE)
.get(JsonObject.class);
//Examine the results
jsonObject = webTarget
.path("batch/status/" + responseJobId)
.request(MediaType.APPLICATION_JSON_TYPE)
.get(JsonObject.class);

String responseString = jsonObject.toString();
result = responseString.equals("{\"Steps executed\":\"[step1, step2]\",\"Status\":\"COMPLETED\"}");

String responseString = jsonObject.toString();
if (result) break;
}

assertEquals("{\"Steps executed\":\"[step1, step2]\",\"Status\":\"COMPLETED\"}",
responseString, "Job Result string");
assertTrue(result, "Job Result string");
}
}