*** Settings ***
Documentation    Scale test fixture validation and performance baseline checks.
...              Validates fixture loading, metadata structure, threshold matrices,
...              and profile generation simulation.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Load Scale Metadata Fixture
    [Documentation]    Load scale_metadata.json and verify structure
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    load-metadata    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}    scale-metadata-ok

Validate Scale Metadata Profiles
    [Documentation]    Verify all expected scale profiles are present with correct fields
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validate-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}    scale-profiles-ok

Load And Validate Baseline Thresholds
    [Documentation]    Load baseline_thresholds.json and verify threshold matrix structure
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validate-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}    scale-thresholds-ok

Verify Threshold Monotonicity
    [Documentation]    Verify p50 < p95 < p99 across all threshold entries
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    check-monotonicity    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}    scale-monotonicity-ok

Simulate Profile File Distribution
    [Documentation]    Generate file count distributions and verify they match language mix
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    simulate-distribution    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}    scale-distribution-ok

Validate Generator Instructions Exist
    [Documentation]    Verify the generator instructions document is present
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    check-generator-docs    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}    scale-generator-docs-ok
