SIENTIAPDE-1478

Enhance end-to-end tests for PredictionsBatch workflow scenarios

- Introduced mock repositories for PI Web API and OPC operations to improve test coverage.
- Updated test scenarios to handle partial write errors for PI Web API and OPC.
- Refactored existing tests to assert correct behavior under various error conditions.
- Enhanced logging and error handling in API and OPC activities to provide clearer feedback on failures.
- Removed outdated integration test file to streamline test suite.
This commit is contained in:
vitor-aignosi
2026-01-16 16:41:36 -03:00
parent 6b9bb38968
commit 241f283724
9 changed files with 1546 additions and 547 deletions

View File

@@ -445,27 +445,7 @@ The `predictions_batch` workflow:
### 3.2 Error Scenarios
#### Scenario 3.2.1: PostgreSQL Export Error - Predictions Table
**Description**: Failed to write predictions to database
**Input**:
- Valid formatted prediction
- PostgreSQL connection fails or table doesn't exist
**Expected Behavior**:
- `export_data_to_postgres` raises exception
- Notification sent with database error
- Workflow fails after retries
**Assertions**:
- Exception raised from export activity
- Error notification sent
- Workflow fails
- Metrics NOT written (activity doesn't execute)
---
#### Scenario 3.2.2: PI Web API Write Error
#### Scenario 3.2.1: PI Web API Write Error
**Description**: PI Web API export fails
**Input**:
@@ -485,7 +465,7 @@ The `predictions_batch` workflow:
---
#### Scenario 3.2.3: OPC Write Error
#### Scenario 3.2.2: OPC Write Error
**Description**: OPC server write fails
**Input**:
@@ -504,64 +484,26 @@ The `predictions_batch` workflow:
---
## 4. End-to-End Integration Scenarios
### 4.1 Complete Success Path
#### Scenario 4.1.1: Full Pipeline Success with All Features
**Description**: Complete workflow execution with all optional features enabled
#### Scenario 3.2.3: PI Web API Partial Write Error
**Description**: Two prediction tags attempt to be written to PI Web API, but only one succeeds
**Input**:
- Valid SQL query returning data
- All configurations provided (OPC, PI Web API, filters, policies)
- MLFlow services available
- All databases available
- Valid prediction
- Two prediction tags configured
- PI Web API returns partial success (one tag succeeds, one fails)
**Expected Behavior**:
- SQL query loads data
- Input gate passes
- MLFlow transform succeeds
- MLFlow predict succeeds
- All validations pass
- Prediction formatted
- Transformed data formatted
- Both exported to PostgreSQL
- PI Web API write succeeds
- OPC write succeeds
- Metrics written
- `write_pi_web_api_data` processes response
- `process_pi_web_api_response` detects partial failure
- Error confidence set (13)
- Notification sent for failed tag
- Workflow completes with error confidence
**Assertions**:
- All activities executed in correct order
- All three workflows execute (batch, process, export)
- All exports succeed
- All tables have data
- All external systems updated
- Metrics recorded
---
### 4.2 Error Recovery Integration
#### Scenario 4.2.1: Transform Error with Repeat Fallback
**Description**: Transform fails, workflow repeats last prediction
**Input**:
- Valid input
- MLFlow transform fails
- REPEAT policy configured
- Previous prediction exists
**Expected Behavior**:
- Transform fails
- Filter detects error
- Path handler triggers REPEAT
- Last prediction retrieved and re-exported
- Workflow completes successfully
**Assertions**:
- Transform attempted
- Error handled gracefully
- Last prediction copied
- Workflow completes without exception
- One tag written successfully
- One tag failed
- Error confidence set in prediction
- Error notification sent
- Workflow completes
---