*** Settings ***
Documentation    Large-project scaling performance integration tests.
...              Validates that benchmark fixtures exist, thresholds are
...              reasonable, and a small-scale indexing run meets minimum
...              throughput targets.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_scaling_performance.py

*** Test Cases ***
Verify Extended Scale Profiles Exist
    [Documentation]    Verify xlarge and xxlarge profiles are present in metadata
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    check-extended-profiles    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scaling-profiles-ok

Verify Extended Indexing Thresholds Exist
    [Documentation]    Verify 50K and 100K indexing thresholds are present
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    check-extended-thresholds    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scaling-thresholds-ok

Verify Context Assembly Thresholds Exist
    [Documentation]    Verify context assembly threshold section and entries
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    check-context-assembly    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scaling-ctx-assembly-ok

Verify Execution Throughput Thresholds Exist
    [Documentation]    Verify execution throughput threshold section and entries
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    check-execution-throughput    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scaling-exec-throughput-ok

Verify Sub-Linear Scaling Of Extended Thresholds
    [Documentation]    Verify 50K and 100K thresholds scale sub-linearly
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    check-sublinear    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scaling-sublinear-ok

Small Scale Indexing Throughput Check
    [Documentation]    Create a 1K-file fixture, index it, verify throughput
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    run-small-index    cwd=${WORKSPACE}    timeout=180s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scaling-index-ok
