Package com.epam.reportportal.service
Class LaunchImpl
- java.lang.Object
-
- com.epam.reportportal.service.Launch
-
- com.epam.reportportal.service.LaunchImpl
-
- Direct Known Subclasses:
AbstractJoinedLaunch
public class LaunchImpl extends Launch
Asynchronous Launch object implementation, which uses reactive framework to handle launch events. It accepts and returns promises of items' IDs and launch ID, and handle actual requests to ReportPortal under the hood.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classLaunchImpl.ComputationConcurrentHashMapprotected static classLaunchImpl.TreeItemWrapper around TestItem entity to be able to track parent and children items
-
Field Summary
Fields Modifier and Type Field Description protected io.reactivex.Maybe<ApiInfo>apiInfostatic java.lang.StringCUSTOM_AGENTDefault Agent name for cases where real name is not known.static java.lang.StringDISABLE_PROPERTYEnvironment variable name to disable analyticsprotected java.util.Queue<io.reactivex.Completable>logCompletablesstatic java.lang.StringMICROSECONDS_MIN_VERSIONprotected io.reactivex.Maybe<ProjectSettingsResource>projectSettingsprotected LaunchImpl.ComputationConcurrentHashMapqueueMessages queue to track items execution orderprotected StartLaunchRQstartRqprotected java.util.Queue<io.reactivex.disposables.Disposable>virtualItemDisposablesCollection of disposables from virtual item subscriptionsprotected java.util.Map<io.reactivex.Maybe<java.lang.String>,io.reactivex.subjects.PublishSubject<java.lang.String>>virtualItemsMapping between virtual item Maybes and their emitters-
Fields inherited from class com.epam.reportportal.service.Launch
client, NOOP_LAUNCH, NOT_ISSUE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLaunchImpl(ReportPortalClient reportPortalClient, ListenerParameters parameters, StartLaunchRQ rq, java.util.concurrent.ExecutorService executorService)Convenience constructor which uses a defaultLoggingSubscriberfor batched log uploads.protectedLaunchImpl(ReportPortalClient reportPortalClient, ListenerParameters parameters, StartLaunchRQ rq, java.util.concurrent.ExecutorService executorService, LoggingSubscriber loggingSubscriber)Constructs aLaunchImplthat starts a new launch on first use and configures a batched log emitter.protectedLaunchImpl(ReportPortalClient reportPortalClient, ListenerParameters parameters, io.reactivex.Maybe<java.lang.String> launchMaybe, java.util.concurrent.ExecutorService executorService)Constructs aLaunchImplusing an already created launch ID promise.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcompleteIssues(Issue issue)Lookup for the Issue Type locator in project settings and fill missed external issue fields based on properties.protected voidcompleteLogEmitter()Finalizes the batched log emitter ensuring the last batch is sent before completing.protected io.reactivex.SchedulercreateScheduler(java.util.concurrent.ExecutorService executorService)Creates or reuses an RxJavaSchedulerbacked by the provided executor.io.reactivex.Maybe<java.lang.String>createVirtualItem()Creates a virtual test item in ReportPortal.protected io.reactivex.CompletablecreateVirtualItemCompletable()Creates a Completable that polls for completion of all virtual items.voidfinish(FinishExecutionRQ request)Finishes launch in ReportPortal.io.reactivex.Maybe<OperationCompletionRS>finishTestItem(io.reactivex.Maybe<java.lang.String> item, FinishTestItemRQ request)Finishes Test Item in ReportPortal asynchronously (non-blocking).java.util.concurrent.ExecutorServicegetExecutor()Returns a current executor which is used to process launch events such as requests and responses.io.reactivex.Maybe<java.lang.String>getLaunch()Returns current launch UUID promise asMaybe, empty if the launch is not started.io.reactivex.SchedulergetScheduler()Returns a currentSchedulerwhich is used to process launch events such as requests and responses.voidlog(SaveLogRQ rq)Logs message to the ReportPortal Launch.voidlog(io.reactivex.Maybe<java.lang.String> logItemUuid, java.util.function.Function<java.lang.String,SaveLogRQ> logSupplier)Logs message to the ReportPortal Launch.voidlog(java.util.function.Function<java.lang.String,SaveLogRQ> logSupplier)Logs message to the ReportPortal Launch.io.reactivex.Maybe<java.lang.String>start()Starts new launch in ReportPortal asynchronously (non-blocking).protected io.reactivex.Maybe<java.lang.String>start(boolean statistics)Starts the launch asynchronously on first subscription.io.reactivex.Maybe<java.lang.String>startTestItem(StartTestItemRQ request)Starts new root test item in ReportPortal asynchronously (non-blocking).io.reactivex.Maybe<java.lang.String>startTestItem(io.reactivex.Maybe<java.lang.String> parentId, StartTestItemRQ request)Starts new test item in ReportPortal asynchronously (non-blocking).io.reactivex.Maybe<java.lang.String>startTestItem(io.reactivex.Maybe<java.lang.String> parentId, io.reactivex.Maybe<java.lang.String> retryOf, StartTestItemRQ rq)Starts new test item in ReportPortal asynchronously (non-blocking), ensure provided retry item ID starts first.io.reactivex.Maybe<java.lang.String>startVirtualTestItem(io.reactivex.Maybe<java.lang.String> virtualItem, StartTestItemRQ rq)Starts new test item in ReportPortal asynchronously (non-blocking) and populates the provided virtual item with the real item ID.io.reactivex.Maybe<java.lang.String>startVirtualTestItem(io.reactivex.Maybe<java.lang.String> parentId, io.reactivex.Maybe<java.lang.String> virtualItem, StartTestItemRQ rq)Starts new test item in ReportPortal asynchronously (non-blocking) and populates the provided virtual item with the real item ID.booleanuseMicroseconds()Determines whether timestamps should use microsecond precision based on the ReportPortal server version.protected voidwaitForCompletable(io.reactivex.Completable... completableTasks)Executes completion tasks with a timeout.protected voidwaitForItemsCompletion(io.reactivex.Completable itemCompletable)Waits for completion of all test items including virtual ones and log emitters.-
Methods inherited from class com.epam.reportportal.service.Launch
currentLaunch, getClient, getParameters, getStepReporter
-
-
-
-
Field Detail
-
DISABLE_PROPERTY
public static final java.lang.String DISABLE_PROPERTY
Environment variable name to disable analytics- See Also:
- Constant Field Values
-
MICROSECONDS_MIN_VERSION
public static final java.lang.String MICROSECONDS_MIN_VERSION
- See Also:
- Constant Field Values
-
CUSTOM_AGENT
public static final java.lang.String CUSTOM_AGENT
Default Agent name for cases where real name is not known.- See Also:
- Constant Field Values
-
queue
protected final LaunchImpl.ComputationConcurrentHashMap queue
Messages queue to track items execution order
-
virtualItems
protected final java.util.Map<io.reactivex.Maybe<java.lang.String>,io.reactivex.subjects.PublishSubject<java.lang.String>> virtualItems
Mapping between virtual item Maybes and their emitters
-
virtualItemDisposables
protected final java.util.Queue<io.reactivex.disposables.Disposable> virtualItemDisposables
Collection of disposables from virtual item subscriptions
-
logCompletables
protected final java.util.Queue<io.reactivex.Completable> logCompletables
-
startRq
protected final StartLaunchRQ startRq
-
projectSettings
protected final io.reactivex.Maybe<ProjectSettingsResource> projectSettings
-
apiInfo
protected final io.reactivex.Maybe<ApiInfo> apiInfo
-
-
Constructor Detail
-
LaunchImpl
protected LaunchImpl(@Nonnull ReportPortalClient reportPortalClient, @Nonnull ListenerParameters parameters, @Nonnull StartLaunchRQ rq, @Nonnull java.util.concurrent.ExecutorService executorService, @Nonnull LoggingSubscriber loggingSubscriber)Constructs aLaunchImplthat starts a new launch on first use and configures a batched log emitter.- Parameters:
reportPortalClient- the client used to communicate with ReportPortalparameters- the agent listener parametersrq- launch start request used to initialize the launchexecutorService- executor used to schedule reactive operationsloggingSubscriber- subscriber which receives batched log upload results- Throws:
InternalReportPortalClientException- if the provided executor is already shut down
-
LaunchImpl
protected LaunchImpl(@Nonnull ReportPortalClient reportPortalClient, @Nonnull ListenerParameters parameters, @Nonnull StartLaunchRQ rq, @Nonnull java.util.concurrent.ExecutorService executorService)Convenience constructor which uses a defaultLoggingSubscriberfor batched log uploads.- Parameters:
reportPortalClient- the client used to communicate with ReportPortalparameters- the agent listener parametersrq- launch start request used to initialize the launchexecutorService- executor used to schedule reactive operations
-
LaunchImpl
protected LaunchImpl(@Nonnull ReportPortalClient reportPortalClient, @Nonnull ListenerParameters parameters, @Nonnull io.reactivex.Maybe<java.lang.String> launchMaybe, @Nonnull java.util.concurrent.ExecutorService executorService)Constructs aLaunchImplusing an already created launch ID promise. No new launch will be started by this instance.- Parameters:
reportPortalClient- the client used to communicate with ReportPortalparameters- the agent listener parameterslaunchMaybe- an existing launch ID promise to be used by this instanceexecutorService- executor used to schedule reactive operations- Throws:
InternalReportPortalClientException- if the provided executor is already shut down
-
-
Method Detail
-
createScheduler
protected io.reactivex.Scheduler createScheduler(java.util.concurrent.ExecutorService executorService)
Creates or reuses an RxJavaSchedulerbacked by the provided executor. Ensures a single scheduler per executor instance.- Parameters:
executorService- the executor to back the scheduler- Returns:
- a scheduler mapped to the provided executor
-
useMicroseconds
public boolean useMicroseconds()
Determines whether timestamps should use microsecond precision based on the ReportPortal server version. Versions greater than or equal to 5.13.2 support microseconds.The value is computed once and cached for subsequent calls.
- Specified by:
useMicrosecondsin classLaunch- Returns:
trueif server version greater or equal 5.13.2, otherwisefalse
-
getExecutor
public java.util.concurrent.ExecutorService getExecutor()
Returns a current executor which is used to process launch events such as requests and responses.- Returns:
- an
ExecutorService
-
getScheduler
public io.reactivex.Scheduler getScheduler()
Returns a currentSchedulerwhich is used to process launch events such as requests and responses.- Returns:
- an
Scheduler
-
getLaunch
@Nonnull public io.reactivex.Maybe<java.lang.String> getLaunch()
Returns current launch UUID promise asMaybe, empty if the launch is not started.
-
start
@Nonnull protected io.reactivex.Maybe<java.lang.String> start(boolean statistics)
Starts the launch asynchronously on first subscription. Subsequent calls do not start the launch again due to internal caching.- Parameters:
statistics- whether to send analytics events for the launch- Returns:
- a
Maybethat emits the launch UUID once available
-
start
@Nonnull public io.reactivex.Maybe<java.lang.String> start()
Starts new launch in ReportPortal asynchronously (non-blocking). Does NOT start the same launch twice.
-
createVirtualItemCompletable
protected io.reactivex.Completable createVirtualItemCompletable()
Creates a Completable that polls for completion of all virtual items. This method recursively checks if all virtual items have been populated with real IDs. If there are still virtual items pending, it schedules another check after a 100ms delay. When all virtual items are processed (the virtualItems map is empty), it completes.- Returns:
- A Completable that completes when all virtual items are processed
-
waitForCompletable
protected void waitForCompletable(io.reactivex.Completable... completableTasks)
Executes completion tasks with a timeout.- Parameters:
completableTasks- Completable tasks to execute
-
waitForItemsCompletion
protected void waitForItemsCompletion(@Nullable io.reactivex.Completable itemCompletable)Waits for completion of all test items including virtual ones and log emitters. This method ensures all test results are properly reported to ReportPortal before the launch completes. It uses the timeout defined in the parameters to prevent indefinite waiting.- Parameters:
itemCompletable- A completable representing the test items to be completed before finishing the launch
-
completeLogEmitter
protected void completeLogEmitter()
Finalizes the batched log emitter ensuring the last batch is sent before completing. Blocks within the configured reporting timeout while waiting for the final batch to be processed.
-
finish
public void finish(@Nonnull FinishExecutionRQ request)Finishes launch in ReportPortal. Blocks until all items are reported correctly.
-
startTestItem
@Nonnull public io.reactivex.Maybe<java.lang.String> startTestItem(StartTestItemRQ request)
Starts new root test item in ReportPortal asynchronously (non-blocking).- Specified by:
startTestItemin classLaunch- Parameters:
request- Item start request.- Returns:
- Test Item ID promise.
-
startTestItem
@Nonnull public io.reactivex.Maybe<java.lang.String> startTestItem(io.reactivex.Maybe<java.lang.String> parentId, StartTestItemRQ request)Starts new test item in ReportPortal asynchronously (non-blocking).- Specified by:
startTestItemin classLaunch- Parameters:
parentId- Promise of parent item ID.request- Item start request.- Returns:
- Test Item ID promise
-
startTestItem
@Nonnull public io.reactivex.Maybe<java.lang.String> startTestItem(io.reactivex.Maybe<java.lang.String> parentId, io.reactivex.Maybe<java.lang.String> retryOf, StartTestItemRQ rq)Starts new test item in ReportPortal asynchronously (non-blocking), ensure provided retry item ID starts first. Also sets flagsretry: trueandretryOf: {retryOf argument value}.- Specified by:
startTestItemin classLaunch- Parameters:
parentId- Promise of parent item ID.retryOf- Previous item ID promise, which is retried.rq- Item start request.- Returns:
- Promise of Test Item ID.
-
createVirtualItem
@Nonnull public io.reactivex.Maybe<java.lang.String> createVirtualItem()
Creates a virtual test item in ReportPortal. Virtual items are used as temporary placeholders until they are populated with real item IDs. This is useful for scenarios where item creation order needs to be decoupled from test execution order.- Specified by:
createVirtualItemin classLaunch- Returns:
- Virtual test item ID promise that will be populated with a real ID later
-
startVirtualTestItem
@Nonnull public io.reactivex.Maybe<java.lang.String> startVirtualTestItem(io.reactivex.Maybe<java.lang.String> virtualItem, StartTestItemRQ rq)Starts new test item in ReportPortal asynchronously (non-blocking) and populates the provided virtual item with the real item ID.- Specified by:
startVirtualTestItemin classLaunch- Parameters:
virtualItem- Virtual item ID promise to populate with real ID.rq- Item start rq.- Returns:
- Real Test Item ID promise.
-
startVirtualTestItem
@Nonnull public io.reactivex.Maybe<java.lang.String> startVirtualTestItem(io.reactivex.Maybe<java.lang.String> parentId, io.reactivex.Maybe<java.lang.String> virtualItem, StartTestItemRQ rq)Starts new test item in ReportPortal asynchronously (non-blocking) and populates the provided virtual item with the real item ID.- Specified by:
startVirtualTestItemin classLaunch- Parameters:
parentId- Promise of parent item ID.virtualItem- Virtual item ID promise to populate with real ID.rq- Item start request.- Returns:
- Real Test Item ID promise.
-
completeIssues
protected void completeIssues(@Nonnull Issue issue)Lookup for the Issue Type locator in project settings and fill missed external issue fields based on properties.- Parameters:
issue- Issue to complete
-
finishTestItem
@Nonnull public io.reactivex.Maybe<OperationCompletionRS> finishTestItem(io.reactivex.Maybe<java.lang.String> item, FinishTestItemRQ request)
Finishes Test Item in ReportPortal asynchronously (non-blocking). Schedules finish after success of all child items.- Specified by:
finishTestItemin classLaunch- Parameters:
item- Item ID promise.request- Item finish request.- Returns:
- Promise of Test Item finish response.
-
log
public void log(@Nonnull SaveLogRQ rq)Logs message to the ReportPortal Launch.
-
log
public void log(@Nonnull java.util.function.Function<java.lang.String,SaveLogRQ> logSupplier)Logs message to the ReportPortal Launch.
-
log
public void log(@Nonnull io.reactivex.Maybe<java.lang.String> logItemUuid, @Nonnull java.util.function.Function<java.lang.String,SaveLogRQ> logSupplier)Logs message to the ReportPortal Launch.
-
-