summary: Ensure that commands run when their core provided interfaces are connected

details: |
    Install a test snap that plugs as many core provided interfaces as is 
    possible and verify the command can run (ie, don't test the interface 
    functionality itself). This will help catch things like AppArmor 
    policy syntax errors, seccomp policy parsing, udev querying bugs, etc.

systems: [ubuntu-18*, ubuntu-2*]

environment:
    TEST/100_core_connected: interfaces-core-provided
    CONNECTIONS_PERCENTAGE/100_core_connected: 100
    DISCONNECT_INTERFACES/100_core_connected: false
    NESTED_CPUS/100_core_connected: 1
    NESTED_MEM/100_core_connected: 768
    CPU_LOAD/100_core_connected: .5

    TEST/100_core_disconnected: interfaces-core-provided
    CONNECTIONS_PERCENTAGE/100_core_disconnected: 100
    DISCONNECT_INTERFACES/100_core_disconnected: true
    NESTED_CPUS/100_core_disconnected: 1
    NESTED_MEM/100_core_disconnected: 512
    CPU_LOAD/100_core_disconnected: .6

    TEST/100_snap_connected: interfaces-snap-provided
    CONNECTIONS_PERCENTAGE/100_snap_connected: 100
    DISCONNECT_INTERFACES/100_snap_connected: false
    NESTED_CPUS/100_snap_connected: 1
    NESTED_MEM/100_snap_connected: 768
    CPU_LOAD/100_snap_connected: .5

    TEST/100_snap_disconnected: interfaces-snap-provided
    CONNECTIONS_PERCENTAGE/100_snap_disconnected: 100
    DISCONNECT_INTERFACES/100_snap_disconnected: true
    NESTED_CPUS/100_snap_disconnected: 1
    NESTED_MEM/100_snap_disconnected: 512
    CPU_LOAD/100_snap_disconnected: .6

execute: |
    # Get the nested system to use
    NESTED_SPREAD_SYSTEM="$(tests.nested nested-system)"

    # Get spread
    SPREAD="$(tests.nested download spread)"

    # Run sprad test
    export PERF_CPU_LOAD="$CPU_LOAD"
    export SPREAD_EXTERNAL_ADDRESS=localhost:8022
    export PERF_CONNECTIONS_PERCENTAGE="$CONNECTIONS_PERCENTAGE"
    export PERF_DISCONNECT_INTERFACES="$DISCONNECT_INTERFACES"    

    (
        set -o pipefail
        "$SPREAD" external:"$NESTED_SPREAD_SYSTEM":tests/perf/main/"$TEST" | tee spread.log
    )
