Commit 651ee4a8 authored by Waleed Akbar's avatar Waleed Akbar
Browse files

feat: Update test payload and logging for analyze and stop-all analyses endpoints

parent abeb8193
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -37,7 +37,9 @@ LOG_FILE="${PWD}/test_api_docker.log"
TEST_FILE="${PWD}/test_api_docker.py"

# Run the test with logging enabled and capture output
pytest $TEST_FILE::test_analyze_endpoint \

pytest $TEST_FILE::test_stop_all_analyses_endpoint \
# pytest $TEST_FILE::test_analyze_endpoint \
    -v -s \
    --log-cli-level=DEBUG \
    --log-file="${LOG_FILE}" \
+6 −5
Original line number Diff line number Diff line
@@ -89,15 +89,15 @@ def test_analyze_endpoint(ai_engine_server_connection_confirmation):
    
    # Prepare test payload with SLA policy configuration
    payload = {
        "simap_id": "L1",
        "simap_id": "E2E-L1",
        "sla_metrics": {
            "latency_threshold_ms":  0,
            "bandwidth_utilization": 0.0
        },
        "history_window_size_sec":      60,
        "forecast_sample_interval_sec": 5,
        "forecast_sample_interval_sec": 30,
        "forecast_sample_count":        50,
        "duration_minutes":             2  # Short duration for testing
        "duration_minutes":             10  # Short duration for testing
    }

    LOGGER.info(f"Sending analyze request with payload: {payload}")
@@ -124,7 +124,7 @@ def test_analyze_endpoint(ai_engine_server_connection_confirmation):
    if response.status_code == 202:
        LOGGER.info("Analysis started successfully")
        assert data['status']             ==  'accepted',       f"Expected status 'accepted',         got '{data['status']}'"
        assert data['simap_id']           ==  'L1',             f"Expected simap_id 'L1',             got '{data['simap_id']}'"
        assert data['simap_id']           ==  'E2E-L1',         f"Expected simap_id 'E2E-L1',         got '{data['simap_id']}'"
        assert data['duration_minutes']   ==  2,                f"Expected duration_minutes 2,        got '{data['duration_minutes']}'"
        assert '/osm/aiAnalyticsEvent/v1' in  data['endpoint'], f"Expected '/osm/aiAnalyticsEvent/v1' in  endpoint"
    elif response.status_code == 503:
@@ -293,7 +293,7 @@ def test_stop_all_analyses_endpoint(ai_engine_server):
    """

    LOGGER.info(">>>>>> Starting test_case test_stop_all_analyses_endpoint: POST /api/v1/analyze/stop-all endpoint")
    started_ids = ["L1"]
    started_ids = ["E2E-L1"]

    
    # Only proceed if at least one analysis started
@@ -330,3 +330,4 @@ def test_stop_all_analyses_endpoint(ai_engine_server):
    LOGGER.info("<<<<<< Finished test_case test_stop_all_analyses_endpoint")


# TODO: Add here test for notify endpoint from     @blueprint.route('/notify', methods=['POST'])
 No newline at end of file