Skip to content

Commit

Permalink
fix worflow deployment verification and add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vinumaddumage committed Jun 13, 2023
1 parent d5dd3ff commit 338824b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,27 +201,35 @@ protected void addAssociationForMatch() throws Exception {
protected void waitForWorkflowToDeploy() throws Exception {

// We have to check whether the service is up and running by calling the generated endpoint.
String url = super.getBackendURL() + addUserWorkflowName + "Service";
HttpClient client = new HttpClientFactory().getHttpClient();
HttpGet request = new HttpGet(url);

String url;
boolean runLoop;
boolean isBpelDeployed = false;
int count = 1;

log.info("Verifying deployment of BPEL Workflow.");
do {
runLoop = false;

if (!isBpelDeployed) {
url = super.getBackendURL() + addUserWorkflowName + "Service?wsdl";
} else {
url = super.getBackendURL() + addUserWorkflowName + "TaskService?wsdl";
}
HttpGet request = new HttpGet(url);
HttpResponse httpResponse = client.execute(request);

// If the server response is 500 or it contains "service not available" text or "Operation not found" text,
// If the server response is 500, or it contains "service not available" text or "Operation not found" text,
// then we have to assume that the service is still not available. So we have to recheck after
// brief time period.
if (httpResponse.getStatusLine().getStatusCode() == 500) {
log.info("Response code: " + httpResponse.getStatusLine().getStatusCode());
runLoop = true;
} else {
BufferedReader bufferedReader =
new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
String line;
while ((line = bufferedReader.readLine()) != null) {
log.info("Response: " + line);
if (line.contains("The service cannot be found for the endpoint reference") ||
line.contains("The endpoint reference (EPR) for the Operation not found")) {
runLoop = true;
Expand All @@ -230,6 +238,24 @@ protected void waitForWorkflowToDeploy() throws Exception {
}
}

if (httpResponse.getStatusLine().getStatusCode() == 200) {
if (!isBpelDeployed) {
log.info("BPEL Workflow deployed successfully in " + count + " attempt(s).");
isBpelDeployed = true;
log.info("Verifying deployment of HumanTask Workflow.");
runLoop = true;
continue;
} else {
log.info("HumanTask deployed successfully in " + count + " attempt(s).");
log.info("Waiting for 5 seconds before proceeding.");
Thread.sleep(5000);
break;
}
} else {
log.info("Workflow not deployed yet. Continuing the loop.");
runLoop = true;
}

// Wait 20 times for 5 seconds intervals until the workflow is properly deployed. This is for server based
// test runners like Jenkins.
if (count < 20) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ public void testListTasksWhenAvailable() throws Exception {
.path("findAll{ it.presentationName == '"
+ TEST_WORKFLOW_ADD_USER_FOR_REST_TASK + "' }.size()");
if (numOfTasks == 3) {
log.info("All approval tasks are created successfully");
break;
}

// Wait till workflow is applied.
log.info("Waiting 5 seconds till the workflow is applied for association, iteration " + i + " of 3");
log.info("Waiting 5 seconds till the workflow is applied for association, iteration " + i + " of " +
MAX_WAIT_ITERATIONS_TILL_WORKFLOW_DEPLOYMENT);
log.info("Number of tasks created for now : " + numOfTasks);
Thread.sleep(5000);
}

Expand Down

0 comments on commit 338824b

Please sign in to comment.