Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

FLPATH-394 - Speedup integration test execution #339

Merged
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
27 changes: 17 additions & 10 deletions sdk-utils/src/main/java/com/redhat/parodos/sdkutils/SdkUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void onFailure(ApiException e, int statusCode, Map<String, List<String>>

@Override
public void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders) {
if (f.check(result)) {
if (f.check(result, statusCode)) {
try {
f.execute(this);
}
Expand Down Expand Up @@ -192,8 +192,18 @@ private void signal() {
* @throws InterruptedException If the async call reaches the waiting timeout
* @throws ApiException If the API method invocation fails
*/
public static void waitProjectStart(ProjectApi projectApi) throws InterruptedException, ApiException {
waitAsyncResponse((FuncExecutor<List<ProjectResponseDTO>>) callback -> projectApi.getProjectsAsync(callback));
public static void waitProjectStart(ProjectApi projectApi) throws ApiException, InterruptedException {
waitAsyncResponse(new FuncExecutor<List<ProjectResponseDTO>>() {
@Override
public boolean check(List<ProjectResponseDTO> result, int statusCode) {
return statusCode != 200;
}

@Override
public void execute(@NonNull ApiCallback<List<ProjectResponseDTO>> callback) throws ApiException {
projectApi.getProjectsAsync(callback);
}
});
}

/**
Expand All @@ -208,9 +218,10 @@ public static void waitProjectStart(ProjectApi projectApi) throws InterruptedExc
*/
public static WorkFlowStatusResponseDTO waitWorkflowStatusAsync(WorkflowApi workflowApi, UUID workFlowExecutionId)
throws InterruptedException, ApiException {

WorkFlowStatusResponseDTO workFlowStatusResponseDTO = waitAsyncResponse(new FuncExecutor<>() {
@Override
public boolean check(WorkFlowStatusResponseDTO result) {
public boolean check(WorkFlowStatusResponseDTO result, int statusCode) {
return !result.getStatus().equals(WorkFlowStatusResponseDTO.StatusEnum.COMPLETED);
}

Expand Down Expand Up @@ -264,7 +275,7 @@ public interface FuncExecutor<T> {
* @return {true} if it is necessary to continue monitoring the result, {false}
* when it's possible to stop the monitoring.
*/
default boolean check(T result) {
default boolean check(T result, int statusCode) {
return true;
}

Expand All @@ -284,11 +295,8 @@ default boolean check(T result) {
* @throws ApiException If the API methods invocations fail
*/
public static ProjectResponseDTO getProjectAsync(ApiClient apiClient, String projectName, String projectDescription)
throws InterruptedException, ApiException {
throws ApiException {
ProjectApi projectApi = new ProjectApi(apiClient);
log.info("Wait project to be ready on {}", apiClient.getBasePath());
waitProjectStart(projectApi);
log.info("Project is ✔️ on {}", apiClient.getBasePath());

ProjectResponseDTO testProject;

Expand Down Expand Up @@ -324,7 +332,6 @@ public static ProjectResponseDTO getProjectAsync(ApiClient apiClient, String pro

// ASSERT PROJECT "testProject" IS PRESENT
projects = projectApi.getProjects();
log.debug("PROJECTS: {}", projects);

if (projects.isEmpty()) {
throw new ApiException("Project has not been created.");
Expand Down