From 24e24e33c97e7a23d1b4508dcdd6ccd9e409722c Mon Sep 17 00:00:00 2001 From: Vinu Maddumage Date: Tue, 13 Jun 2023 10:28:21 +0530 Subject: [PATCH] fix worflow deployment verification and add logs --- .../approval/common/UserApprovalTestBase.java | 36 ++++++++++++++++--- .../user/approval/v1/UserMeApprovalTest.java | 5 ++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/common/UserApprovalTestBase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/common/UserApprovalTestBase.java index 527c1deee38..cd88c9a20cb 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/common/UserApprovalTestBase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/common/UserApprovalTestBase.java @@ -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; @@ -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 10 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) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/v1/UserMeApprovalTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/v1/UserMeApprovalTest.java index 0bddbdb023b..e9d4e9d350a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/v1/UserMeApprovalTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/v1/UserMeApprovalTest.java @@ -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); }