From c7d79850adecd5a2c557d8f0e15b18cee9f911f0 Mon Sep 17 00:00:00 2001 From: Matt Richardson Date: Thu, 5 Oct 2023 13:23:24 +1100 Subject: [PATCH 1/4] Add support for the launch update endpoint --- .../com/epam/reportportal/service/ReportPortalClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/epam/reportportal/service/ReportPortalClient.java b/src/main/java/com/epam/reportportal/service/ReportPortalClient.java index 7b867573..90d8aa91 100644 --- a/src/main/java/com/epam/reportportal/service/ReportPortalClient.java +++ b/src/main/java/com/epam/reportportal/service/ReportPortalClient.java @@ -17,10 +17,7 @@ import com.epam.ta.reportportal.ws.model.*; import com.epam.ta.reportportal.ws.model.item.ItemCreatedRS; -import com.epam.ta.reportportal.ws.model.launch.LaunchResource; -import com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ; -import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; -import com.epam.ta.reportportal.ws.model.launch.StartLaunchRS; +import com.epam.ta.reportportal.ws.model.launch.*; import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; import io.reactivex.Maybe; import okhttp3.MultipartBody; @@ -36,6 +33,9 @@ public interface ReportPortalClient { @POST("v1/{projectName}/launch/merge") Maybe mergeLaunches(@Body MergeLaunchesRQ rq); + @PUT("v1/{projectName}/launch/{launchId}/update") + Maybe updateLaunch(@Path("launchId") String launchId, @Body UpdateLaunchRQ rq); + @PUT("v1/{projectName}/launch/{launchId}/finish") Maybe finishLaunch(@Path("launchId") String launch, @Body FinishExecutionRQ rq); From 213bbc7d6181c45a0d59bdf6ceaa312b3c55fc9c Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Sat, 11 Nov 2023 17:13:50 +0300 Subject: [PATCH 2/4] Separate `SecondaryLaunchFinishCondition` class --- CHANGELOG.md | 2 + .../service/launch/PrimaryLaunch.java | 38 +++--------- .../SecondaryLaunchFinishCondition.java | 59 +++++++++++++++++++ 3 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 src/main/java/com/epam/reportportal/service/launch/SecondaryLaunchFinishCondition.java diff --git a/CHANGELOG.md b/CHANGELOG.md index c18648e5..441b694c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Changed +- `SecondaryLaunchFinishCondition` class was separated to resolve fat jar issues, by @HardNorth ## [5.1.23] ### Changed diff --git a/src/main/java/com/epam/reportportal/service/launch/PrimaryLaunch.java b/src/main/java/com/epam/reportportal/service/launch/PrimaryLaunch.java index 4e7fa171..b6f535b1 100644 --- a/src/main/java/com/epam/reportportal/service/launch/PrimaryLaunch.java +++ b/src/main/java/com/epam/reportportal/service/launch/PrimaryLaunch.java @@ -25,13 +25,11 @@ import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; import java.util.Calendar; -import java.util.Collection; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import static com.epam.reportportal.utils.ObjectUtils.clonePojo; -import static java.util.Optional.ofNullable; /** * An implementation of a {@link Launch} object which managed to obtain main lock with {@link LaunchIdLock} object. @@ -44,37 +42,19 @@ public PrimaryLaunch(ReportPortalClient rpClient, ListenerParameters parameters, super(rpClient, parameters, launch, executorService, launchIdLock, instanceUuid); } + /** + * Wait for all secondary launches finish and then close the Primary Launch. If there was running secondary launch + * number change then the timeout will reset. + * + * @param request Finish Launch Request to use (end time will be updated after wait). + */ @Override public void finish(final FinishExecutionRQ request) { stopRunning(); - - // Secondary launch wait finish condition - Callable finishCondition = new Callable() { - private volatile Collection launches; - - @Override - public Boolean call() { - // Get current live secondary launches, locks `.sync` file - Collection current = lock.getLiveInstanceUuids(); - - // If there is no live launches, or the only live launch is the primary launch we are done - if (current.isEmpty() || (current.size() == 1 && uuid.equals(current.iterator().next()))) { - return true; - } - - // Determine whether there were any updates in secondary launches: new launches started or old one finished - Boolean changed = ofNullable(launches).map(l -> !l.equals(current)).orElse(Boolean.TRUE); - launches = current; - if (changed) { - // If there were changes in secondary launches than the execution is live, and we are going wait more - return false; - } - // No changes from last time - return null; - } - }; - + Callable finishCondition = new SecondaryLaunchFinishCondition(lock, uuid); Boolean finished = Boolean.FALSE; + // If there was launch number change (finished == false) we will wait more. + // Only if while (finished != Boolean.TRUE && finished != null) { Waiter waiter = new Waiter("Wait for all launches end").duration( getParameters().getClientJoinTimeout(), diff --git a/src/main/java/com/epam/reportportal/service/launch/SecondaryLaunchFinishCondition.java b/src/main/java/com/epam/reportportal/service/launch/SecondaryLaunchFinishCondition.java new file mode 100644 index 00000000..15301e49 --- /dev/null +++ b/src/main/java/com/epam/reportportal/service/launch/SecondaryLaunchFinishCondition.java @@ -0,0 +1,59 @@ +/* + * Copyright 2023 EPAM Systems + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.epam.reportportal.service.launch; + +import com.epam.reportportal.service.LaunchIdLock; + +import java.util.Collection; +import java.util.concurrent.Callable; + +import static java.util.Optional.ofNullable; + +/** + * Condition which designed to wait for all secondary launches finished (true), or at least one launch finished (false). + */ +public class SecondaryLaunchFinishCondition implements Callable { + private volatile Collection launches; + private final LaunchIdLock lock; + private final String uuid; + + public SecondaryLaunchFinishCondition(LaunchIdLock launchIdLock, String selfUuid) { + lock = launchIdLock; + uuid = selfUuid; + } + + @Override + public Boolean call() { + // Get current live secondary launches, locks `.sync` file + Collection current = lock.getLiveInstanceUuids(); + + // If there is no live launches, or the only live launch is the primary launch we are done + if (current.isEmpty() || (current.size() == 1 && uuid.equals(current.iterator().next()))) { + return true; + } + + // Determine whether there were any updates in secondary launches: new launches started or old one finished + Boolean changed = ofNullable(launches).map(l -> !l.equals(current)).orElse(Boolean.TRUE); + launches = current; + if (changed) { + // If there were changes in secondary launches than the execution is live, and we are going wait more + return false; + } + // No changes from last time + return null; + } +} From 31cbd91b3e37443b3d708f7f832a9b056f0a46cf Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 15 Nov 2023 16:42:10 +0300 Subject: [PATCH 3/4] `rxjava` was forcibly excluded from `retrofit2:adapter-rxjava2` transitive dependencies to resolve fat jar issues --- CHANGELOG.md | 1 + build.gradle | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 441b694c..f0af94c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] ### Changed - `SecondaryLaunchFinishCondition` class was separated to resolve fat jar issues, by @HardNorth +- `rxjava` was forcibly excluded from `retrofit2:adapter-rxjava2` transitive dependencies to resolve fat jar issues, by @HardNorth ## [5.1.23] ### Changed diff --git a/build.gradle b/build.gradle index d6281fb0..9c423dd5 100644 --- a/build.gradle +++ b/build.gradle @@ -52,7 +52,9 @@ dependencies { implementation ("com.squareup.retrofit2:converter-jackson:${project.retrofit_version}") { exclude module: 'jackson-databind' } - implementation "com.squareup.retrofit2:adapter-rxjava2:${project.retrofit_version}" + implementation ("com.squareup.retrofit2:adapter-rxjava2:${project.retrofit_version}") { + exclude module: 'rxjava' + } implementation 'com.squareup.okhttp3:logging-interceptor:3.14.9' api "org.aspectj:aspectjrt:${project.aspectj_version}" From b7071890d72b43468a372a49781aab773ed5d57e Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 15 Nov 2023 16:45:08 +0300 Subject: [PATCH 4/4] CHANGELOG.md update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0af94c6..d62a8420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Added +- `ReportPortalClient.updateLaunch` method, by @matt-richardson ### Changed - `SecondaryLaunchFinishCondition` class was separated to resolve fat jar issues, by @HardNorth - `rxjava` was forcibly excluded from `retrofit2:adapter-rxjava2` transitive dependencies to resolve fat jar issues, by @HardNorth