Skip to content

Software testing

jacoEafit edited this page Mar 25, 2026 · 18 revisions

Table of Contents


Automated Tests

Executive Summary

  • Total Tests: 26 automated
  • Success Rate: 100% (26/26 passed)
  • Execution Time: ~0.81 seconds
  • Framework: pytest 8.4.2
  • Python: 3.12.3

Code Location

  • Test Branch: test/feature-tests
  • Path: /sentinel-softserve/tests/

Note:
This documentation describes the implemented tests.
All executable code is located in the test branch of the repository.


Implemented User Stories

US-01 — View incident list

Functionality

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.

Test Type

  • API integration tests using FastAPI TestClient
  • Unit-level behavior with mocked Supabase

Justification

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.

Implemented Tests (4)

  1. test_list_incidents_success_returns_rows
    Verifies that the endpoint returns HTTP 200 and the expected list of incidents.

  2. test_list_incidents_orders_by_created_at_desc
    Ensures that incidents are sorted by creation date in descending order.

  3. test_list_incidents_filters_by_status_query_param
    Confirms that filtering by status works correctly using query parameters.

  4. test_list_incidents_empty_list
    Checks that an empty list is returned when no incidents are found.


US-02 — View full incident details

Functionality

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.

Test Type

  • API integration tests for GET /api/incidents/{id}
  • Unit tests for internal logic and Loki integration (mocked)

Justification

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.

Implemented Tests (7)

  1. test_get_incident_logic_returns_expected_fields
    Confirms that all required fields are returned when the incident exists.

  2. test_get_incident_logic_returns_404_when_not_found
    Ensures the system returns 404 when the incident does not exist.

  3. test_get_incident_api_success_returns_full_details
    Verifies that the API returns complete incident details.

  4. test_get_incident_api_returns_404_when_incident_missing
    Confirms correct behavior for invalid IDs.

  5. test_get_incident_api_simulates_realtime_update
    Simulates updated data between requests to reflect real-time behavior.

  6. test_query_loki_logs_formats_output_lines
    Ensures logs retrieved from Loki are properly formatted.

  7. test_query_loki_logs_returns_empty_when_loki_unavailable
    Verifies graceful handling when Loki is unavailable.


US-03a — Automatic incident detection

Functionality

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.

Test Type

  • API integration tests using FastAPI TestClient
  • External systems (Supabase, Alertmanager) mocked

Justification

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.

Implemented Tests (3)

  1. test_alerts_firing_creates_incident
    Verifies that a valid failure alert creates a new incident.

  2. test_alerts_resolved_does_not_create_incident
    Ensures resolved alerts do not create new incidents.

  3. test_alerts_invalid_payload_returns_unprocessable
    Confirms that invalid alert payloads are rejected with HTTP 422.


US-03b — Manual incident creation

Functionality

This feature allows users to manually create incidents through the system.
Users provide basic information such as title, affected service, and severity.

Test Type

  • API tests using TestClient
  • Supabase mocked

Justification

The tests ensure that valid data is accepted and stored correctly, while invalid or incomplete data is properly rejected.

Implemented Tests (3)

  1. test_create_manual_incident_success
    Confirms that a valid request successfully creates an incident.

  2. test_create_manual_incident_missing_required_fields
    Verifies validation errors when required fields are missing.

  3. test_create_manual_incident_invalid_severity
    Ensures invalid severity values are rejected.


US-04 — Automatic incident classification

Functionality

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.

Test Type

  • Unit tests at the service level
  • LLM and database interactions mocked

Justification

These tests verify that classification results are correctly applied and stored.
They also ensure the system remains stable even when the classification service fails.

Implemented Tests (3)

  1. test_auto_classification_success_persists_valid_label
    Ensures valid classification results are stored correctly.

  2. test_auto_classification_sets_investigating_before_llm_runs
    Confirms that the status changes before classification is completed.

  3. test_auto_classification_llm_error_persists_unknown
    Verifies fallback behavior when classification fails.


US-08a — Automatic root cause analysis

Functionality

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.

Test Type

  • Unit tests at the service level
  • Analyzer and database mocked

Justification

The tests ensure that analysis results are correctly generated and stored, and that failures do not interrupt the system.

Implemented Tests (3)

  1. test_root_cause_analysis_success_persists_reasoning_and_analyzed_status
    Confirms successful analysis and status update.

  2. test_root_cause_analysis_failure_does_not_raise_and_skips_db
    Ensures errors are handled gracefully.

  3. test_root_cause_analysis_insufficient_actions_skips_persist
    Verifies that incomplete results are not stored.


US-15 — Critical incident notifications

Functionality

The system sends notifications for high-priority incidents to ensure quick response.
Only critical and high severity incidents trigger notifications.

Test Type

  • Unit/service tests
  • Notification system mocked

Justification

These tests verify that notifications are sent only when appropriate and that the payload contains the required information.

Implemented Tests (3)

  1. test_notification_sent_for_critical_or_high
    Ensures notifications are sent for high severity incidents.

  2. test_notification_not_sent_for_medium_or_low
    Confirms no notifications are sent for lower severity.

  3. test_notification_payload_has_required_fields
    Verifies the structure and content of the notification.


Execution Guide

  1. Install project and test dependencies
python -m pip install -r Backend/requirements.txt
python -m pip install -r requirements-test.txt
  1. Run all tests
pytest tests/ -v --tb=no

Execution Evidence


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


Description: Full test suite execution with 26 tests passing using pytest.

Manual Validation (UI Testing)

Purpose

This section describes manual tests performed directly from the user interface to validate system behavior from the user's perspective.

Approach

The application is executed locally, and key user flows are tested through the dashboard interface.

What is validated

  • Incident list rendering
  • Filters and sorting behavior
  • Incident detail visualization
  • Manual incident creation form
  • Real-time updates (Supabase Realtime)
  • Notification display
  • Navigation between views

Evidence

US-00: User Login

Test 1: Log in with valid credentials

  • 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.

Test 2: Log in with invalid credentials

  • Expected Result: There should be an error message and user may not log in.
  • Obtained Result: There is an error message.

US-21: User Logout

Test 1: Log out from the system

  • 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.

US-01: View Incident List

Test 1: View incident list with existing data

  • 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.

US-03b: Manual Incident Creation

Test 1: Create incident with valid data

  • 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.

US-02: View Full Incident Details

Test 1: View details of an existing incident

  • 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.

Clone this wiki locally