You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ResultAndErrorHandlingApiOfTheInstrumentedProcess.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -4,25 +4,25 @@
4
4
5
5
- The _instrumented process_ is an external process used for the isolated invocation.
6
6
- The `ConcreteExecutor` is a class which provides smooth and concise interaction with the _instrumented process_. It works in the _main process_.
7
-
- A client is an object which directly uses `ConcreteExecutor`, so it works in the _main process_ as well.
8
-
- An _Instrumentation_ is an object which should be passed to `ConcreteExecutor`. It defines the logic of invocation and bytecode instrumentation in the _instrumented process_.
7
+
- A client is an object which directly uses the `ConcreteExecutor`, so it works in the _main process_ as well.
8
+
- An _Instrumentation_ is an object which has to be passed to the`ConcreteExecutor`. It defines the logic of invocation and bytecode instrumentation in the _instrumented process_.
9
9
10
10
## Common
11
11
12
12
Basically, if any exception happens inside the _instrumented process_, it is rethrown to the client process via RD.
13
-
- Some of the errors lead to the instant death of the _instrumented process_. Such errors are wrapped in `InstrumentedProcessDeathException`. Before processing the next request, the _instrumented process_ will be restarted automatically, but it can take some time.
14
-
- Errors which do not cause the termination of the _instrumented process_are wrapped in `InstrumentedProcessError`. Process won't be restarted, so client's requests will be handled by the same process. We believe, that the state of the _instrumented process_is consistent, but in some tricky situations it may be not.
13
+
- Errors which do not cause the termination of the _instrumented process_are wrapped in `InstrumentedProcessError`. Process won't be restarted, so client's requests will be handled by the same process. We believe, that the state of the _instrumented process_ is consistent, but in some tricky situations it **may be not**. Such situations should be reported as bugs.
14
+
- Some of the errors lead to the instant death of the _instrumented process_. Such errors are wrapped in `InstrumentedProcessDeathException`. Before processing the next request, the _instrumented process_will be restarted automatically, but it can take some time.
15
15
16
16
The extra logic of error and result handling depends on the provided instrumentation.
17
17
18
-
## UtConcreteExecutionInstrumentation
18
+
## UtExecutionInstrumentation
19
19
20
20
The next sections are related only to the `UtExecutionInstrumentation` passed to the _instrumented process_.
21
21
22
22
The calling of `ConcreteExecutor::executeAsync` instantiated by the `UtExecutionInstrumentation` can lead to the three possible situations:
23
23
-`InstrumentedProcessDeathException` occurs. Usually, this situation means there is an internal issue in the _instrumented process_, but, nevertheless, this exception should be handled by the client.
24
24
-`InstrumentedProcessError` occurs. It also means an internal issue and should be handled by the client. Sometimes it happens because the client provided the wrong configuration or parameters, but the _instrumented process_**can't determine exactly** what's wrong with the client's data. The cause contains the description of the phase which threw the exception.
25
-
- No exception occurs, so the `UtConcreteExecutionResult` is returned. It means that everything went well during the invocation or something broke down because of the wrong input, and the _instrumented process_**knows exactly** what's wrong with the client's input. The _instrumented process_guarantee that the state **is consistent**. The exact reason of failure is a `UtConcreteExecutionResult::result` field. It includes:
25
+
- No exception occurs, so the `UtConcreteExecutionResult` is returned. It means that everything went well during the invocation or something broke down because of the wrong input, and the _instrumented process_**knows exactly** what's wrong with the client's input. The _instrumented process_guarantees that the state **is consistent**. The exact reason of failure is a `UtConcreteExecutionResult::result` field. It includes:
26
26
- `UtSandboxFailure` --- violation of permissions.
27
27
- `UtTimeoutException` --- the test execution time exceeds the provided time limit (`UtConcreteExecutionData::timeout`).
28
28
- `UtExecutionSuccess` --- the test executed successfully.
@@ -32,24 +32,24 @@ The calling of `ConcreteExecutor::executeAsync` instantiated by the `UtExecution
32
32
33
33
### How the error handling works
34
34
35
-
The flow of the `UtExecutionInstrumentation::invoke` consists of 6 phases:
35
+
The pipeline of the `UtExecutionInstrumentation::invoke` consists of 6 phases:
36
36
-`ValueConstructionPhase` --- constructs values from the models.
37
37
-`PreparationPhase` --- prepares statics, etc.
38
38
-`InvocationPhase` --- invokes the target method.
39
39
-`StatisticsCollectionPhase` --- collects the coverage and execution-related data.
40
-
-`ModelConstructionPhase` --- constructs the result models from.
40
+
-`ModelConstructionPhase` --- constructs the result models from the heap objects (`Any?`).
41
41
-`PostprocessingPhase` --- restores statics, clear mocks, etc.
42
42
43
43
Each phase can throw two kinds of exceptions:
44
-
-`ExecutionPhaseStop` --- indicates that the phase want to stop the invocation pipeline completely, because it's already has a result. The returned result is the `ExecutionPhaseStop::result` field.
44
+
-`ExecutionPhaseStop` --- indicates that the phase want to stop the invocation of the pipeline completely, because it's already has a result. The returned result is the `ExecutionPhaseStop::result` field.
45
45
-`ExecutionPhaseError` --- indicates that an unexpected error happened inside the phase execution, so it's rethrown to the main process.
46
46
47
47
The `PhasesController::computeConcreteExecutionResult` then matches on the exception type and rethrows the exception if it's an `ExecutionPhaseError`, and returns the result if it's an `ExecutionPhaseStop`.
48
48
49
49
### Timeout
50
50
51
-
There is a time limit on the concrete execution, so the `UtExecutionInstrumentation::invoke` method must respect. We wrap phases which can take a long time with the `executePhaseInTimeout` block, which internally keeps and updates the elapsed time. If any wrapped phase exceeds the timeout, we return the `TimeoutException` as the result of that phase.
51
+
There is a time limit on the concrete execution, so the `UtExecutionInstrumentation::invoke` method must respect it. We wrap phases which can take a long time with the `executePhaseInTimeout` block, which internally keeps and updates the elapsed time. If any wrapped phase exceeds the timeout, we return the `TimeoutException` as the result of that phase.
52
52
53
-
The clients cannot depend that cancellation request immediately breaks the invocation inside the _instrumented process_. The invocation is guaranteed to finish in the time of passed timeout, but notearlier.
53
+
The clients cannot depend that cancellation request immediately breaks the invocation inside the _instrumented process_. The invocation is guaranteed to finish in the time of passed timeout. It may or **may not** finish earlier. Already started query in instrumented process is **uncancellable** - this is by design.
54
54
55
-
Even if the `TimeoutException` occurs, the _instrumented process_ is ready to receive new requests.
55
+
Even if the `TimeoutException` occurs, the _instrumented process_ is ready to process new requests.
0 commit comments