From 2be482af89dea963c75273d42ebed38f6f027ad6 Mon Sep 17 00:00:00 2001 From: Sachin Dev Tomar Date: Wed, 1 Nov 2023 11:20:56 +0530 Subject: [PATCH 1/7] Increased Read/Request timeout to 180 seconds (#53) Co-authored-by: Sachin Tomar --- pom.xml | 2 +- .../Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7943bba..8238616 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ ${revision}${changelist} hpi - 4.0.7 + 4.0.8 -SNAPSHOT jenkinsci/leapwork-plugin -SNAPSHOT diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java index a20177c..33b266a 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java @@ -19,6 +19,7 @@ import com.Leapwork.Leapwork_plugin.model.RunCollection; import com.Leapwork.Leapwork_plugin.model.RunItem; import com.ning.http.client.AsyncHttpClient; +import com.ning.http.client.AsyncHttpClientConfig; import hudson.AbortException; import hudson.EnvVars; @@ -50,6 +51,7 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild private boolean leapworkWritePassedFlowKeyFrames; private boolean leapworkEnableHttps; private String leapworkScheduleVariables; + private static final int TIMEOUT_IN_SECONDS = 180; private static PluginHandler pluginHandler = PluginHandler.getInstance(); @@ -170,8 +172,13 @@ public void perform(final Run build, FilePath workspace, Launcher launcher String scheduleVariablesRequestPart = pluginHandler .getScheduleVariablesRequestPart(getLeapworkScheduleVariables(), listener); - - try (AsyncHttpClient mainClient = new AsyncHttpClient()) { + + AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() + .setReadTimeout(TIMEOUT_IN_SECONDS * 1000) + .setRequestTimeout(TIMEOUT_IN_SECONDS * 1000) + .build(); + + try (AsyncHttpClient mainClient = new AsyncHttpClient(config)) { // Get schedule titles (or/and ids in case of pipeline) LinkedHashMap schedulesIdTitleHashMap = pluginHandler.getSchedulesIdTitleHashMap(mainClient, From 540aef19a704e2db7ac04daa2d2ac464afef63e0 Mon Sep 17 00:00:00 2001 From: Sachin Dev Tomar Date: Thu, 2 Nov 2023 18:07:05 +0530 Subject: [PATCH 2/7] Revert "Increased Read/Request timeout to 180 seconds (#53)" (#54) This reverts commit 2be482af89dea963c75273d42ebed38f6f027ad6. Co-authored-by: Sachin Tomar --- pom.xml | 2 +- .../Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 8238616..7943bba 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ ${revision}${changelist} hpi - 4.0.8 + 4.0.7 -SNAPSHOT jenkinsci/leapwork-plugin -SNAPSHOT diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java index 33b266a..a20177c 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java @@ -19,7 +19,6 @@ import com.Leapwork.Leapwork_plugin.model.RunCollection; import com.Leapwork.Leapwork_plugin.model.RunItem; import com.ning.http.client.AsyncHttpClient; -import com.ning.http.client.AsyncHttpClientConfig; import hudson.AbortException; import hudson.EnvVars; @@ -51,7 +50,6 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild private boolean leapworkWritePassedFlowKeyFrames; private boolean leapworkEnableHttps; private String leapworkScheduleVariables; - private static final int TIMEOUT_IN_SECONDS = 180; private static PluginHandler pluginHandler = PluginHandler.getInstance(); @@ -172,13 +170,8 @@ public void perform(final Run build, FilePath workspace, Launcher launcher String scheduleVariablesRequestPart = pluginHandler .getScheduleVariablesRequestPart(getLeapworkScheduleVariables(), listener); - - AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() - .setReadTimeout(TIMEOUT_IN_SECONDS * 1000) - .setRequestTimeout(TIMEOUT_IN_SECONDS * 1000) - .build(); - - try (AsyncHttpClient mainClient = new AsyncHttpClient(config)) { + + try (AsyncHttpClient mainClient = new AsyncHttpClient()) { // Get schedule titles (or/and ids in case of pipeline) LinkedHashMap schedulesIdTitleHashMap = pluginHandler.getSchedulesIdTitleHashMap(mainClient, From b245949b25b10a8f6f44313f84644fa883d1fa9c Mon Sep 17 00:00:00 2001 From: Sachin Dev Tomar Date: Thu, 2 Nov 2023 19:36:09 +0530 Subject: [PATCH 3/7] enhancement : Increased Read/Request timeout to 180 seconds (#55) Co-authored-by: Sachin Tomar --- pom.xml | 2 +- .../Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7943bba..8238616 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ ${revision}${changelist} hpi - 4.0.7 + 4.0.8 -SNAPSHOT jenkinsci/leapwork-plugin -SNAPSHOT diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java index a20177c..e803d0e 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java @@ -19,6 +19,7 @@ import com.Leapwork.Leapwork_plugin.model.RunCollection; import com.Leapwork.Leapwork_plugin.model.RunItem; import com.ning.http.client.AsyncHttpClient; +import com.ning.http.client.AsyncHttpClientConfig; import hudson.AbortException; import hudson.EnvVars; @@ -50,6 +51,7 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild private boolean leapworkWritePassedFlowKeyFrames; private boolean leapworkEnableHttps; private String leapworkScheduleVariables; + private static final int TIMEOUT_IN_SECONDS = 180; private static PluginHandler pluginHandler = PluginHandler.getInstance(); @@ -170,8 +172,13 @@ public void perform(final Run build, FilePath workspace, Launcher launcher String scheduleVariablesRequestPart = pluginHandler .getScheduleVariablesRequestPart(getLeapworkScheduleVariables(), listener); + + AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() + .setReadTimeout(TIMEOUT_IN_SECONDS * 1000) + .setRequestTimeout(TIMEOUT_IN_SECONDS * 1000) + .build(); - try (AsyncHttpClient mainClient = new AsyncHttpClient()) { + try (AsyncHttpClient mainClient = new AsyncHttpClient(config)) { // Get schedule titles (or/and ids in case of pipeline) LinkedHashMap schedulesIdTitleHashMap = pluginHandler.getSchedulesIdTitleHashMap(mainClient, From d69096e3bb2de902e6c44096b98e8a7d901df736 Mon Sep 17 00:00:00 2001 From: Sachin Dev Tomar Date: Thu, 23 Nov 2023 15:57:07 +0530 Subject: [PATCH 4/7] enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (#56) * enhancement : Increased http timeout to 5 min * Made http timeout configurable in all API Requests --------- Co-authored-by: Sachin Tomar --- .../LeapworkJenkinsBridgeBuilder.java | 53 ++++++++++++++++--- .../Leapwork/Leapwork_plugin/Messages.java | 2 + .../Leapwork_plugin/PluginHandler.java | 28 +++++++++- .../LeapworkJenkinsBridgeBuilder/config.jelly | 3 ++ .../help-leapworkTimeout.html | 4 ++ 5 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/help-leapworkTimeout.html diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java index e803d0e..8eb1efc 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java @@ -44,6 +44,7 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild private final String leapworkPort; private final Secret leapworkAccessKey; private String leapworkDelay; + private String leapworkTimeout; private String leapworkDoneStatusAs; private String leapworkReport; private final String leapworkSchIds; @@ -51,7 +52,6 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild private boolean leapworkWritePassedFlowKeyFrames; private boolean leapworkEnableHttps; private String leapworkScheduleVariables; - private static final int TIMEOUT_IN_SECONDS = 180; private static PluginHandler pluginHandler = PluginHandler.getInstance(); @@ -59,13 +59,14 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild // "DataBoundConstructor" @DataBoundConstructor public LeapworkJenkinsBridgeBuilder(String leapworkHostname, String leapworkPort, String leapworkAccessKey, - String leapworkDelay, String leapworkDoneStatusAs, String leapworkReport, String leapworkSchNames, + String leapworkDelay, String leapworkTimeout, String leapworkDoneStatusAs, String leapworkReport, String leapworkSchNames, String leapworkSchIds, boolean leapworkWritePassedFlowKeyFrames, boolean leapworkEnableHttps) { this.leapworkHostname = leapworkHostname; this.leapworkPort = leapworkPort; this.leapworkAccessKey = Secret.fromString(leapworkAccessKey); this.leapworkDelay = leapworkDelay; + this.leapworkTimeout = leapworkTimeout; this.leapworkDoneStatusAs = leapworkDoneStatusAs; this.leapworkReport = leapworkReport; this.leapworkSchIds = leapworkSchIds; @@ -89,6 +90,11 @@ public void setLeapworkDelay(String leapworkDelay) { this.leapworkDelay = leapworkDelay; } + @DataBoundSetter + public void setLeapworkTimeout(String leapworkTimeout) { + this.leapworkTimeout = leapworkTimeout; + } + @DataBoundSetter public void setLeapworkWritePassedFlowKeyFrames(boolean leapworkWritePassedFlowKeyFrames) { this.leapworkWritePassedFlowKeyFrames = leapworkWritePassedFlowKeyFrames; @@ -120,6 +126,10 @@ public String getLeapworkDelay() { return leapworkDelay; } + public String getLeapworkTimeout() { + return leapworkTimeout; + } + public String getLeapworkSchNames() { return leapworkSchNames; } @@ -155,6 +165,8 @@ public void perform(final Run build, FilePath workspace, Launcher launcher EnvVars env = build.getEnvironment(listener); ArrayList invalidSchedules = new ArrayList<>(); + int timeout = pluginHandler.getTimeout(leapworkTimeout, listener); + String workspacePath = pluginHandler.getWorkSpaceSafe(workspace, env); this.leapworkReport = pluginHandler.getReportFileName(this.getLeapworkReport(), DescriptorImpl.DEFAULT_REPORT_NAME); @@ -174,8 +186,8 @@ public void perform(final Run build, FilePath workspace, Launcher launcher .getScheduleVariablesRequestPart(getLeapworkScheduleVariables(), listener); AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() - .setReadTimeout(TIMEOUT_IN_SECONDS * 1000) - .setRequestTimeout(TIMEOUT_IN_SECONDS * 1000) + .setReadTimeout(timeout * 1000) + .setRequestTimeout(timeout * 1000) .build(); try (AsyncHttpClient mainClient = new AsyncHttpClient(config)) { @@ -206,7 +218,7 @@ public void perform(final Run build, FilePath workspace, Launcher launcher if (runId != null) { resultsMap.put(runId, run); CollectScheduleRunResults(controllerApiHttpAddress, Secret.toString(leapworkAccessKey), runId, - schTitle, timeDelay, isDoneStatusAsSuccess, writePassedKeyframes, run, listener); + schTitle, timeDelay, timeout, isDoneStatusAsSuccess, writePassedKeyframes, run, listener); } else resultsMap.put(UUID.randomUUID(), run); @@ -288,12 +300,17 @@ public void perform(final Run build, FilePath workspace, Launcher launcher } private static void CollectScheduleRunResults(String controllerApiHttpAddress, String accessKey, UUID runId, - String scheduleName, int timeDelay, boolean isDoneStatusAsSuccess, boolean writePassedKeyframes, + String scheduleName, int timeDelay, int timeout, boolean isDoneStatusAsSuccess, boolean writePassedKeyframes, LeapworkRun resultRun, final TaskListener listener) throws AbortException, InterruptedException { List runItemsId = new ArrayList<>(); Object waiter = new Object(); + + AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() + .setReadTimeout(timeout * 1000) + .setRequestTimeout(timeout * 1000) + .build(); // get statuses - try (AsyncHttpClient client = new AsyncHttpClient()) { + try (AsyncHttpClient client = new AsyncHttpClient(config)) { boolean isStillRunning = true; do { @@ -380,7 +397,7 @@ private static void CollectScheduleRunResults(String controllerApiHttpAddress, S String interruptedExceptionMessage = String.format(Messages.INTERRUPTED_EXCEPTION, e.getMessage()); listener.error(interruptedExceptionMessage); RunItem invalidItem = new RunItem("Aborted run", "Cancelled", 0, e.getMessage(), scheduleName); - pluginHandler.stopRun(controllerApiHttpAddress, runId, scheduleName, accessKey, listener); + pluginHandler.stopRun(controllerApiHttpAddress, runId, scheduleName, accessKey, timeout, listener); resultRun.incErrors(); resultRun.runItems.add(invalidItem); } finally { @@ -405,6 +422,7 @@ private void printPluginInputs(final TaskListener listener, String workspace) { listener.getLogger().println(String.format(Messages.INPUT_SCHEDULE_NAMES_VALUE, getLeapworkSchNames())); listener.getLogger().println(String.format(Messages.INPUT_SCHEDULE_IDS_VALUE, getLeapworkSchIds())); listener.getLogger().println(String.format(Messages.INPUT_DELAY_VALUE, getLeapworkDelay())); + listener.getLogger().println(String.format(Messages.INPUT_TIMEOUT_VALUE, getLeapworkTimeout())); listener.getLogger().println(String.format(Messages.INPUT_DONE_VALUE, getLeapworkDoneStatusAs())); listener.getLogger().println(String.format(Messages.INPUT_WRITE_PASSED, isLeapworkWritePassedFlowKeyFrames())); listener.getLogger().println(String.format(Messages.INPUT_VARIABLES, getLeapworkScheduleVariables())); @@ -435,6 +453,7 @@ public boolean isApplicable(Class aClass) { } public static final String DEFAULT_DELAY = "5"; + public static final String DEFAULT_TIMEOUT = "300"; public static final String DEFAULT_REPORT_NAME = "report.xml"; public static final boolean DEFAULT_WRITE_PASSED_FLOW_KEYFRAMES = false; public static final boolean DEFAULT_ENABLE_lEAPWORK_HTTPS = false; @@ -453,10 +472,28 @@ public FormValidation doCheckLeapworkDelay(@QueryParameter("leapworkDelay") Stri return FormValidation.ok(); } + public FormValidation doCheckLeapworkTimeout(@QueryParameter("leapworkTimeout") String timeout) { + int temp; + try { + temp = Integer.parseInt(timeout); + + if (temp < 1) { + return FormValidation.error("Entered number must be higher than 0"); + } + } catch (NumberFormatException ex) { + return FormValidation.error("Invalid number"); + } + return FormValidation.ok(); + } + public String getDefaultLeapworkDelay() { return DEFAULT_DELAY; } + public String getDefaultLeapworkTimeout() { + return DEFAULT_TIMEOUT; + } + public String getDefaultLeapworkReport() { return DEFAULT_REPORT_NAME; } diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/Messages.java b/src/main/java/com/Leapwork/Leapwork_plugin/Messages.java index 0c2e16e..551f4d1 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/Messages.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/Messages.java @@ -75,6 +75,7 @@ public class Messages { public static final String NO_DISK_SPACE = "No enough disk space to start schedule"; public static final String PORT_NUMBER_IS_INVALID = "Port number is invalid, setting to default %1$d"; public static final String TIME_DELAY_NUMBER_IS_INVALID = "Time delay number is invalid: %1$s, setting to default %2$s"; + public static final String TIMEOUT_NUMBER_IS_INVALID = "Timeout number is invalid: %1$s, setting to default %2$s"; public static final String FULL_REPORT_FILE_PATH = "Creating report file by path: %1$s"; public static final String SCHEDULE_DISABLED = "Schedule %1$s[%2$s] is disabled"; public static final String INVALID_SCHEDULE_VARIABLE = "Failed to parse variable: %1$s"; @@ -90,6 +91,7 @@ public class Messages { public static final String INPUT_SCHEDULE_NAMES_VALUE = "Schedule names: %1$s"; public static final String INPUT_SCHEDULE_IDS_VALUE = "Schedule ids: %1$s"; public static final String INPUT_DELAY_VALUE = "Delay between status checks: %1$s"; + public static final String INPUT_TIMEOUT_VALUE = "Leapwork API Request/Response Timeout: %1$s"; public static final String INPUT_DONE_VALUE = "Done Status As: %1$s"; public static final String INPUT_WRITE_PASSED = "Write keyframes of passed flows: %1$b"; public static final String INPUT_VARIABLES = "Passed schedule variables: %1$s"; diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java b/src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java index b46362c..2338193 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java @@ -28,6 +28,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.ning.http.client.AsyncHttpClient; +import com.ning.http.client.AsyncHttpClientConfig; import com.ning.http.client.Response; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -125,6 +126,23 @@ public int getTimeDelay(String rawTimeDelay, TaskListener listener) { } } + public int getTimeout(String rawTimeout, TaskListener listener) { + int defaultTimeout = 300; + try { + if (!rawTimeout.isEmpty() || !"".equals(rawTimeout)) + return Integer.parseInt(rawTimeout); + else { + listener.getLogger() + .println(String.format(Messages.TIMEOUT_NUMBER_IS_INVALID, rawTimeout, defaultTimeout)); + return defaultTimeout; + } + } catch (Exception e) { + listener.getLogger() + .println(String.format(Messages.TIMEOUT_NUMBER_IS_INVALID, rawTimeout, defaultTimeout)); + return defaultTimeout; + } + } + public boolean isDoneStatusAsSuccess(String doneStatusAs) { return doneStatusAs.contentEquals("Success"); } @@ -388,13 +406,19 @@ private static UUID OnScheduleRunConnectionFailure(Exception e, TaskListener lis } @SuppressFBWarnings(value = "REC_CATCH_EXCEPTION") - public boolean stopRun(String controllerApiHttpAddress, UUID runId, String scheduleTitle, String accessKey, + public boolean stopRun(String controllerApiHttpAddress, UUID runId, String scheduleTitle, String accessKey, int timeout, final TaskListener listener) { boolean isSuccessfullyStopped = false; listener.error(String.format(Messages.STOPPING_RUN, scheduleTitle, runId)); String uri = String.format(Messages.STOP_RUN_URI, controllerApiHttpAddress, runId.toString()); - try (AsyncHttpClient client = new AsyncHttpClient()) { + + AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() + .setReadTimeout(timeout * 1000) + .setRequestTimeout(timeout * 1000) + .build(); + + try (AsyncHttpClient client = new AsyncHttpClient(config)) { Response response = client.preparePut(uri).setBody("").setHeader("AccessKey", accessKey).execute().get(); client.close(); diff --git a/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/config.jelly b/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/config.jelly index 7e22a4f..ed32b88 100644 --- a/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/config.jelly +++ b/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/config.jelly @@ -49,6 +49,9 @@ + + + diff --git a/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/help-leapworkTimeout.html b/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/help-leapworkTimeout.html new file mode 100644 index 0000000..944bd1c --- /dev/null +++ b/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/help-leapworkTimeout.html @@ -0,0 +1,4 @@ +
+The 'timeout' property represents the duration within which an operation or request expects to receive a response before considering it unsuccessful or timing out.
+It's measured in seconds, and the default value for this property is set to 300 seconds. +
From 77c3605f601ea51e36449f100e55e09788ed7da6 Mon Sep 17 00:00:00 2001 From: Sachin Dev Tomar Date: Tue, 28 Nov 2023 12:03:57 +0530 Subject: [PATCH 5/7] Upgraded plugin version to 4.0.9 (#57) Co-authored-by: Sachin Tomar --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8238616..41adbef 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ ${revision}${changelist} hpi - 4.0.8 + 4.0.9 -SNAPSHOT jenkinsci/leapwork-plugin -SNAPSHOT From 91cc21efdbf32cca1765fa140f4f5c78200e8663 Mon Sep 17 00:00:00 2001 From: Sachin Dev Tomar Date: Tue, 28 Nov 2023 15:51:19 +0530 Subject: [PATCH 6/7] Revert configurable timeout (#58) * Revert "Upgraded plugin version to 4.0.9 (#57)" This reverts commit 77c3605f601ea51e36449f100e55e09788ed7da6. * Revert "enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (#56)" This reverts commit d69096e3bb2de902e6c44096b98e8a7d901df736. --------- Co-authored-by: Sachin Tomar --- pom.xml | 2 +- .../LeapworkJenkinsBridgeBuilder.java | 53 +++---------------- .../Leapwork/Leapwork_plugin/Messages.java | 2 - .../Leapwork_plugin/PluginHandler.java | 28 +--------- .../LeapworkJenkinsBridgeBuilder/config.jelly | 3 -- .../help-leapworkTimeout.html | 4 -- 6 files changed, 11 insertions(+), 81 deletions(-) delete mode 100644 src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/help-leapworkTimeout.html diff --git a/pom.xml b/pom.xml index 41adbef..8238616 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ ${revision}${changelist} hpi - 4.0.9 + 4.0.8 -SNAPSHOT jenkinsci/leapwork-plugin -SNAPSHOT diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java index 8eb1efc..e803d0e 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder.java @@ -44,7 +44,6 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild private final String leapworkPort; private final Secret leapworkAccessKey; private String leapworkDelay; - private String leapworkTimeout; private String leapworkDoneStatusAs; private String leapworkReport; private final String leapworkSchIds; @@ -52,6 +51,7 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild private boolean leapworkWritePassedFlowKeyFrames; private boolean leapworkEnableHttps; private String leapworkScheduleVariables; + private static final int TIMEOUT_IN_SECONDS = 180; private static PluginHandler pluginHandler = PluginHandler.getInstance(); @@ -59,14 +59,13 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild // "DataBoundConstructor" @DataBoundConstructor public LeapworkJenkinsBridgeBuilder(String leapworkHostname, String leapworkPort, String leapworkAccessKey, - String leapworkDelay, String leapworkTimeout, String leapworkDoneStatusAs, String leapworkReport, String leapworkSchNames, + String leapworkDelay, String leapworkDoneStatusAs, String leapworkReport, String leapworkSchNames, String leapworkSchIds, boolean leapworkWritePassedFlowKeyFrames, boolean leapworkEnableHttps) { this.leapworkHostname = leapworkHostname; this.leapworkPort = leapworkPort; this.leapworkAccessKey = Secret.fromString(leapworkAccessKey); this.leapworkDelay = leapworkDelay; - this.leapworkTimeout = leapworkTimeout; this.leapworkDoneStatusAs = leapworkDoneStatusAs; this.leapworkReport = leapworkReport; this.leapworkSchIds = leapworkSchIds; @@ -90,11 +89,6 @@ public void setLeapworkDelay(String leapworkDelay) { this.leapworkDelay = leapworkDelay; } - @DataBoundSetter - public void setLeapworkTimeout(String leapworkTimeout) { - this.leapworkTimeout = leapworkTimeout; - } - @DataBoundSetter public void setLeapworkWritePassedFlowKeyFrames(boolean leapworkWritePassedFlowKeyFrames) { this.leapworkWritePassedFlowKeyFrames = leapworkWritePassedFlowKeyFrames; @@ -126,10 +120,6 @@ public String getLeapworkDelay() { return leapworkDelay; } - public String getLeapworkTimeout() { - return leapworkTimeout; - } - public String getLeapworkSchNames() { return leapworkSchNames; } @@ -165,8 +155,6 @@ public void perform(final Run build, FilePath workspace, Launcher launcher EnvVars env = build.getEnvironment(listener); ArrayList invalidSchedules = new ArrayList<>(); - int timeout = pluginHandler.getTimeout(leapworkTimeout, listener); - String workspacePath = pluginHandler.getWorkSpaceSafe(workspace, env); this.leapworkReport = pluginHandler.getReportFileName(this.getLeapworkReport(), DescriptorImpl.DEFAULT_REPORT_NAME); @@ -186,8 +174,8 @@ public void perform(final Run build, FilePath workspace, Launcher launcher .getScheduleVariablesRequestPart(getLeapworkScheduleVariables(), listener); AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() - .setReadTimeout(timeout * 1000) - .setRequestTimeout(timeout * 1000) + .setReadTimeout(TIMEOUT_IN_SECONDS * 1000) + .setRequestTimeout(TIMEOUT_IN_SECONDS * 1000) .build(); try (AsyncHttpClient mainClient = new AsyncHttpClient(config)) { @@ -218,7 +206,7 @@ public void perform(final Run build, FilePath workspace, Launcher launcher if (runId != null) { resultsMap.put(runId, run); CollectScheduleRunResults(controllerApiHttpAddress, Secret.toString(leapworkAccessKey), runId, - schTitle, timeDelay, timeout, isDoneStatusAsSuccess, writePassedKeyframes, run, listener); + schTitle, timeDelay, isDoneStatusAsSuccess, writePassedKeyframes, run, listener); } else resultsMap.put(UUID.randomUUID(), run); @@ -300,17 +288,12 @@ public void perform(final Run build, FilePath workspace, Launcher launcher } private static void CollectScheduleRunResults(String controllerApiHttpAddress, String accessKey, UUID runId, - String scheduleName, int timeDelay, int timeout, boolean isDoneStatusAsSuccess, boolean writePassedKeyframes, + String scheduleName, int timeDelay, boolean isDoneStatusAsSuccess, boolean writePassedKeyframes, LeapworkRun resultRun, final TaskListener listener) throws AbortException, InterruptedException { List runItemsId = new ArrayList<>(); Object waiter = new Object(); - - AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() - .setReadTimeout(timeout * 1000) - .setRequestTimeout(timeout * 1000) - .build(); // get statuses - try (AsyncHttpClient client = new AsyncHttpClient(config)) { + try (AsyncHttpClient client = new AsyncHttpClient()) { boolean isStillRunning = true; do { @@ -397,7 +380,7 @@ private static void CollectScheduleRunResults(String controllerApiHttpAddress, S String interruptedExceptionMessage = String.format(Messages.INTERRUPTED_EXCEPTION, e.getMessage()); listener.error(interruptedExceptionMessage); RunItem invalidItem = new RunItem("Aborted run", "Cancelled", 0, e.getMessage(), scheduleName); - pluginHandler.stopRun(controllerApiHttpAddress, runId, scheduleName, accessKey, timeout, listener); + pluginHandler.stopRun(controllerApiHttpAddress, runId, scheduleName, accessKey, listener); resultRun.incErrors(); resultRun.runItems.add(invalidItem); } finally { @@ -422,7 +405,6 @@ private void printPluginInputs(final TaskListener listener, String workspace) { listener.getLogger().println(String.format(Messages.INPUT_SCHEDULE_NAMES_VALUE, getLeapworkSchNames())); listener.getLogger().println(String.format(Messages.INPUT_SCHEDULE_IDS_VALUE, getLeapworkSchIds())); listener.getLogger().println(String.format(Messages.INPUT_DELAY_VALUE, getLeapworkDelay())); - listener.getLogger().println(String.format(Messages.INPUT_TIMEOUT_VALUE, getLeapworkTimeout())); listener.getLogger().println(String.format(Messages.INPUT_DONE_VALUE, getLeapworkDoneStatusAs())); listener.getLogger().println(String.format(Messages.INPUT_WRITE_PASSED, isLeapworkWritePassedFlowKeyFrames())); listener.getLogger().println(String.format(Messages.INPUT_VARIABLES, getLeapworkScheduleVariables())); @@ -453,7 +435,6 @@ public boolean isApplicable(Class aClass) { } public static final String DEFAULT_DELAY = "5"; - public static final String DEFAULT_TIMEOUT = "300"; public static final String DEFAULT_REPORT_NAME = "report.xml"; public static final boolean DEFAULT_WRITE_PASSED_FLOW_KEYFRAMES = false; public static final boolean DEFAULT_ENABLE_lEAPWORK_HTTPS = false; @@ -472,28 +453,10 @@ public FormValidation doCheckLeapworkDelay(@QueryParameter("leapworkDelay") Stri return FormValidation.ok(); } - public FormValidation doCheckLeapworkTimeout(@QueryParameter("leapworkTimeout") String timeout) { - int temp; - try { - temp = Integer.parseInt(timeout); - - if (temp < 1) { - return FormValidation.error("Entered number must be higher than 0"); - } - } catch (NumberFormatException ex) { - return FormValidation.error("Invalid number"); - } - return FormValidation.ok(); - } - public String getDefaultLeapworkDelay() { return DEFAULT_DELAY; } - public String getDefaultLeapworkTimeout() { - return DEFAULT_TIMEOUT; - } - public String getDefaultLeapworkReport() { return DEFAULT_REPORT_NAME; } diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/Messages.java b/src/main/java/com/Leapwork/Leapwork_plugin/Messages.java index 551f4d1..0c2e16e 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/Messages.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/Messages.java @@ -75,7 +75,6 @@ public class Messages { public static final String NO_DISK_SPACE = "No enough disk space to start schedule"; public static final String PORT_NUMBER_IS_INVALID = "Port number is invalid, setting to default %1$d"; public static final String TIME_DELAY_NUMBER_IS_INVALID = "Time delay number is invalid: %1$s, setting to default %2$s"; - public static final String TIMEOUT_NUMBER_IS_INVALID = "Timeout number is invalid: %1$s, setting to default %2$s"; public static final String FULL_REPORT_FILE_PATH = "Creating report file by path: %1$s"; public static final String SCHEDULE_DISABLED = "Schedule %1$s[%2$s] is disabled"; public static final String INVALID_SCHEDULE_VARIABLE = "Failed to parse variable: %1$s"; @@ -91,7 +90,6 @@ public class Messages { public static final String INPUT_SCHEDULE_NAMES_VALUE = "Schedule names: %1$s"; public static final String INPUT_SCHEDULE_IDS_VALUE = "Schedule ids: %1$s"; public static final String INPUT_DELAY_VALUE = "Delay between status checks: %1$s"; - public static final String INPUT_TIMEOUT_VALUE = "Leapwork API Request/Response Timeout: %1$s"; public static final String INPUT_DONE_VALUE = "Done Status As: %1$s"; public static final String INPUT_WRITE_PASSED = "Write keyframes of passed flows: %1$b"; public static final String INPUT_VARIABLES = "Passed schedule variables: %1$s"; diff --git a/src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java b/src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java index 2338193..b46362c 100644 --- a/src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java +++ b/src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java @@ -28,7 +28,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.ning.http.client.AsyncHttpClient; -import com.ning.http.client.AsyncHttpClientConfig; import com.ning.http.client.Response; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -126,23 +125,6 @@ public int getTimeDelay(String rawTimeDelay, TaskListener listener) { } } - public int getTimeout(String rawTimeout, TaskListener listener) { - int defaultTimeout = 300; - try { - if (!rawTimeout.isEmpty() || !"".equals(rawTimeout)) - return Integer.parseInt(rawTimeout); - else { - listener.getLogger() - .println(String.format(Messages.TIMEOUT_NUMBER_IS_INVALID, rawTimeout, defaultTimeout)); - return defaultTimeout; - } - } catch (Exception e) { - listener.getLogger() - .println(String.format(Messages.TIMEOUT_NUMBER_IS_INVALID, rawTimeout, defaultTimeout)); - return defaultTimeout; - } - } - public boolean isDoneStatusAsSuccess(String doneStatusAs) { return doneStatusAs.contentEquals("Success"); } @@ -406,19 +388,13 @@ private static UUID OnScheduleRunConnectionFailure(Exception e, TaskListener lis } @SuppressFBWarnings(value = "REC_CATCH_EXCEPTION") - public boolean stopRun(String controllerApiHttpAddress, UUID runId, String scheduleTitle, String accessKey, int timeout, + public boolean stopRun(String controllerApiHttpAddress, UUID runId, String scheduleTitle, String accessKey, final TaskListener listener) { boolean isSuccessfullyStopped = false; listener.error(String.format(Messages.STOPPING_RUN, scheduleTitle, runId)); String uri = String.format(Messages.STOP_RUN_URI, controllerApiHttpAddress, runId.toString()); - - AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() - .setReadTimeout(timeout * 1000) - .setRequestTimeout(timeout * 1000) - .build(); - - try (AsyncHttpClient client = new AsyncHttpClient(config)) { + try (AsyncHttpClient client = new AsyncHttpClient()) { Response response = client.preparePut(uri).setBody("").setHeader("AccessKey", accessKey).execute().get(); client.close(); diff --git a/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/config.jelly b/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/config.jelly index ed32b88..7e22a4f 100644 --- a/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/config.jelly +++ b/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/config.jelly @@ -49,9 +49,6 @@ - - - diff --git a/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/help-leapworkTimeout.html b/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/help-leapworkTimeout.html deleted file mode 100644 index 944bd1c..0000000 --- a/src/main/resources/com/Leapwork/Leapwork_plugin/LeapworkJenkinsBridgeBuilder/help-leapworkTimeout.html +++ /dev/null @@ -1,4 +0,0 @@ -
-The 'timeout' property represents the duration within which an operation or request expects to receive a response before considering it unsuccessful or timing out.
-It's measured in seconds, and the default value for this property is set to 300 seconds. -
From 85b3a7701e865ef2fe83241f72c70a1cc860779a Mon Sep 17 00:00:00 2001 From: Sachin Dev Tomar Date: Fri, 8 Dec 2023 17:23:43 +0530 Subject: [PATCH 7/7] Sync Leapwork from JenkinsCI (#59) * Automatic plugin release (#1) * Automatic release prerequisites * Updating for CD, automatic release (#6) - Updating cd.yml file (from the master branch, not yet on the main branch) - adding yaml file (from the master branch, not yet on the main branch) - Do not ignore .mvn dir contents (already in another pull request) - Use parent pom 4.24 (would be best if dependabot were enabled on this repo) - Use changelist property for version (incrementals) (already in another pull request) - Use scmTag symbol, not explicit tag (already in another pull request) - Use most recent plugin bom release (would be best if dependabot were enabled on this repo) - Use most recent JQuery plugin release (see the comment that explains why you should use a different JQuery library) - Remove unused dependency, do not include jsr305 jar in hpi (remove jsr305 jar from the hpi because it is not needed) * chore: use jenkins infra maven cd reusable workflow (#23) Signed-off-by: Joseph Petersen Signed-off-by: Joseph Petersen * Update Jenkinsfile syntax (#24) * Increased Read/Request timeout to 180 seconds (#25) Co-authored-by: Sachin Tomar * Revert "Increased Read/Request timeout to 180 seconds (#25)" (#26) This reverts commit 3937e68567a6f4af80b0576bf44a284455e35b03. Co-authored-by: Sachin Tomar * enhancement : Increased Read/Request timeout to 180 seconds (#27) * Increased Read/Request timeout to 180 seconds (#53) Co-authored-by: Sachin Tomar * Revert "Increased Read/Request timeout to 180 seconds (#53)" (#54) This reverts commit 2be482af89dea963c75273d42ebed38f6f027ad6. Co-authored-by: Sachin Tomar * enhancement : Increased Read/Request timeout to 180 seconds (#55) Co-authored-by: Sachin Tomar --------- Co-authored-by: Sachin Tomar * enhancement : Increased Read/Request timeout to 180 seconds - 2 (#28) * Increased Read/Request timeout to 180 seconds (#53) Co-authored-by: Sachin Tomar * Revert "Increased Read/Request timeout to 180 seconds (#53)" (#54) This reverts commit 2be482af89dea963c75273d42ebed38f6f027ad6. Co-authored-by: Sachin Tomar * enhancement : Increased Read/Request timeout to 180 seconds (#55) Co-authored-by: Sachin Tomar * enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (#56) * enhancement : Increased http timeout to 5 min * Made http timeout configurable in all API Requests --------- Co-authored-by: Sachin Tomar * Upgraded plugin version to 4.0.9 (#57) Co-authored-by: Sachin Tomar * Revert configurable timeout (#58) * Revert "Upgraded plugin version to 4.0.9 (#57)" This reverts commit 77c3605f601ea51e36449f100e55e09788ed7da6. * Revert "enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (#56)" This reverts commit d69096e3bb2de902e6c44096b98e8a7d901df736. --------- Co-authored-by: Sachin Tomar --------- Co-authored-by: Sachin Tomar --------- Signed-off-by: Joseph Petersen Co-authored-by: BirSikanderMahajan <83980204+BirSikanderMahajan@users.noreply.github.com> Co-authored-by: Anton Liakhovich <72276668+AntonLiakhovich@users.noreply.github.com> Co-authored-by: Joseph Petersen Co-authored-by: Alexander Brandes Co-authored-by: Sachin Tomar --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fa39036..18218b7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,4 +2,4 @@ See the documentation for more options: https://github.com/jenkins-infra/pipeline-library/ */ -buildPlugin(useAci: true) +buildPlugin(useContainerAgent: true)