Repository navigation
Software testing
- Total Tests: 26 automated
- Success Rate: 100% (26/26 passed)
- Execution Time: ~0.81 seconds
- Framework: pytest 8.4.2
- Python: 3.12.3
-
Test Branch:
test/feature-tests -
Path:
/sentinel-softserve/tests/
Note:
This documentation describes the implemented tests.
All executable code is located in thetestbranch of the repository.
This feature provides a centralized view of all incidents in the system.
It returns a list of incidents ordered from newest to oldest and allows optional filtering by status.
This enables DevOps engineers to quickly identify and prioritize recent or relevant incidents.
- API integration tests using FastAPI TestClient
- Unit-level behavior with mocked Supabase
These tests ensure that the endpoint behaves correctly under normal conditions, including sorting and filtering logic.
They also verify that the system handles edge cases such as empty datasets without relying on a real database connection.
-
test_list_incidents_success_returns_rows
Verifies that the endpoint returns HTTP 200 and the expected list of incidents. -
test_list_incidents_orders_by_created_at_desc
Ensures that incidents are sorted by creation date in descending order. -
test_list_incidents_filters_by_status_query_param
Confirms that filtering by status works correctly using query parameters. -
test_list_incidents_empty_list
Checks that an empty list is returned when no incidents are found.
This feature allows retrieving detailed information about a specific incident by its ID.
It includes metadata, logs, classification, and analysis data, providing a complete view for investigation.
- API integration tests for
GET /api/incidents/{id} - Unit tests for internal logic and Loki integration (mocked)
The tests validate both the API response and the internal processing logic.
They ensure that the system behaves correctly when data is present, missing, or when external services (like Loki) fail.
-
test_get_incident_logic_returns_expected_fields
Confirms that all required fields are returned when the incident exists. -
test_get_incident_logic_returns_404_when_not_found
Ensures the system returns 404 when the incident does not exist. -
test_get_incident_api_success_returns_full_details
Verifies that the API returns complete incident details. -
test_get_incident_api_returns_404_when_incident_missing
Confirms correct behavior for invalid IDs. -
test_get_incident_api_simulates_realtime_update
Simulates updated data between requests to reflect real-time behavior. -
test_query_loki_logs_formats_output_lines
Ensures logs retrieved from Loki are properly formatted. -
test_query_loki_logs_returns_empty_when_loki_unavailable
Verifies graceful handling when Loki is unavailable.
The system automatically detects incidents by processing alerts received from Alertmanager.
When a failure alert is received, it creates a new incident with relevant metadata such as container and server information.
- API integration tests using FastAPI TestClient
- External systems (Supabase, Alertmanager) mocked
These tests confirm that alerts are correctly interpreted and converted into incidents.
They also ensure that non-critical or resolved alerts do not trigger incorrect behavior.
-
test_alerts_firing_creates_incident
Verifies that a valid failure alert creates a new incident. -
test_alerts_resolved_does_not_create_incident
Ensures resolved alerts do not create new incidents. -
test_alerts_invalid_payload_returns_unprocessable
Confirms that invalid alert payloads are rejected with HTTP 422.
This feature allows users to manually create incidents through the system.
Users provide basic information such as title, affected service, and severity.
- API tests using TestClient
- Supabase mocked
The tests ensure that valid data is accepted and stored correctly, while invalid or incomplete data is properly rejected.
-
test_create_manual_incident_success
Confirms that a valid request successfully creates an incident. -
test_create_manual_incident_missing_required_fields
Verifies validation errors when required fields are missing. -
test_create_manual_incident_invalid_severity
Ensures invalid severity values are rejected.
The system automatically classifies incidents using an AI-based service.
It assigns a category to the incident and updates its status during the classification process.
- Unit tests at the service level
- LLM and database interactions mocked
These tests verify that classification results are correctly applied and stored.
They also ensure the system remains stable even when the classification service fails.
-
test_auto_classification_success_persists_valid_label
Ensures valid classification results are stored correctly. -
test_auto_classification_sets_investigating_before_llm_runs
Confirms that the status changes before classification is completed. -
test_auto_classification_llm_error_persists_unknown
Verifies fallback behavior when classification fails.
This feature analyzes incident logs to identify the root cause, suggest actions, and determine urgency.
The results are stored and made available for further investigation.
- Unit tests at the service level
- Analyzer and database mocked
The tests ensure that analysis results are correctly generated and stored, and that failures do not interrupt the system.
-
test_root_cause_analysis_success_persists_reasoning_and_analyzed_status
Confirms successful analysis and status update. -
test_root_cause_analysis_failure_does_not_raise_and_skips_db
Ensures errors are handled gracefully. -
test_root_cause_analysis_insufficient_actions_skips_persist
Verifies that incomplete results are not stored.
The system sends notifications for high-priority incidents to ensure quick response.
Only critical and high severity incidents trigger notifications.
- Unit/service tests
- Notification system mocked
These tests verify that notifications are sent only when appropriate and that the payload contains the required information.
-
test_notification_sent_for_critical_or_high
Ensures notifications are sent for high severity incidents. -
test_notification_not_sent_for_medium_or_low
Confirms no notifications are sent for lower severity. -
test_notification_payload_has_required_fields
Verifies the structure and content of the notification.
- Install project and test dependencies
python -m pip install -r Backend/requirements.txt
python -m pip install -r requirements-test.txt- Run all tests
pytest tests/ -v --tb=no

Description: Partial test execution showing multiple services and unit tests passing successfully.

Description: Full test suite execution with 26 tests passing using pytest.
This section describes manual tests performed directly from the user interface to validate system behavior from the user's perspective.
The application is executed locally, and key user flows are tested through the dashboard interface.
- Incident list rendering
- Filters and sorting behavior
- Incident detail visualization
- Manual incident creation form
- Real-time updates (Supabase Realtime)
- Notification display
- Navigation between views
- Expected Result: The user should successfully log in and be redirected to the dashboard.
- Obtained Result: The user logged in successfully and was redirected to the dashboard without errors.
- Expected Result: There should be an error message and user may not log in.
- Obtained Result: There is an error message.
- Expected Result: The user should be logged out and redirected to the login page.
- Obtained Result: The user was logged out successfully and redirected to the login page.
- Expected Result: The system should display a list of incidents with relevant information (e.g., title, status, date).
- Obtained Result: The incident list was displayed correctly with all relevant information.
- Expected Result: The system should successfully create a new incident and display it in the incident list.
- Obtained Result: The incident was created successfully and appears in the incident list.
- Expected Result: The system should display all detailed information of the selected incident (e.g., description, status, date, related data).
- Obtained Result: The system displayed all the detailed information of the selected incident correctly.