###################################
# job configuration for functest
###################################
- project:
    name: yardstick

    project: '{name}'

#--------------------------------
# BRANCH ANCHORS
#--------------------------------
    master: &master
        stream: master
        branch: '{stream}'
        gs-pathname: ''
        docker-tag: 'latest'
    brahmaputra: &brahmaputra
        stream: brahmaputra
        branch: 'stable/{stream}'
        gs-pathname: '{stream}'
        docker-tag: 'brahmaputra.1.0'
#--------------------------------
# POD, INSTALLER, AND BRANCH MAPPING
#--------------------------------
#    Installers using labels
#            CI PODs
# This section should only contain the installers
# that have been switched using labels for slaves
#--------------------------------
    pod:
# fuel CI PODs
        - baremetal:
            slave-label: fuel-baremetal
            installer: fuel
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - virtual:
            slave-label: fuel-virtual
            installer: fuel
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - baremetal:
            slave-label: fuel-baremetal
            installer: fuel
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *brahmaputra
        - virtual:
            slave-label: fuel-virtual
            installer: fuel
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *brahmaputra
# joid CI PODs
        - baremetal:
            slave-label: joid-baremetal
            installer: joid
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - virtual:
            slave-label: joid-virtual
            installer: joid
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - baremetal:
            slave-label: joid-baremetal
            installer: joid
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *brahmaputra
        - virtual:
            slave-label: joid-virtual
            installer: joid
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *brahmaputra

# compass CI PODs
        - baremetal:
            slave-label: compass-baremetal
            installer: compass
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - virtual:
            slave-label: compass-virtual
            installer: compass
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - baremetal:
            slave-label: compass-baremetal
            installer: compass
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *brahmaputra
        - virtual:
            slave-label: compass-virtual
            installer: compass
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *brahmaputra
#--------------------------------
#    Installers not using labels
#            CI PODs
# This section should only contain the installers
# that have not been switched using labels for slaves
#--------------------------------
        - lf-pod1:
            slave-label: '{pod}'
            installer: apex
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - lf-pod1:
            slave-label: '{pod}'
            installer: apex
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *brahmaputra
#--------------------------------
#        None-CI PODs
#--------------------------------
        - orange-pod2:
            slave-label: '{pod}'
            installer: joid
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *brahmaputra
        - zte-pod1:
            slave-label: '{pod}'
            installer: fuel
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - orange-pod2:
            slave-label: '{pod}'
            installer: joid
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - huawei-pod2:
            slave-label: '{pod}'
            installer: compass
            auto-trigger-name: 'daily-trigger-disabled'
            <<: *master
        - huawei-pod3:
            slave-label: '{pod}'
            installer: compass
            auto-trigger-name: 'yardstick-daily-huawei-pod3-trigger'
            <<: *master
        - huawei-pod4:
            slave-label: '{pod}'
            installer: compass
            auto-trigger-name: 'yardstick-daily-huawei-pod4-trigger'
            <<: *master
#--------------------------------
    testsuite:
        - 'daily'

    jobs:
        - 'yardstick-{installer}-{pod}-{testsuite}-{stream}'

################################
# job templates
################################
- job-template:
    name: 'yardstick-{installer}-{pod}-{testsuite}-{stream}'

    disabled: false

    concurrent: true

    properties:
        - throttle:
            enabled: true
            max-per-node: 1
            option: 'project'

    wrappers:
        - build-name:
            name: '$BUILD_NUMBER - Scenario: $DEPLOY_SCENARIO'
        - timeout:
            timeout: 180
            abort: true

    triggers:
        - '{auto-trigger-name}'

    parameters:
        - project-parameter:
            project: '{project}'
        - '{slave-label}-defaults'
        - '{installer}-defaults'
        - 'yardstick-params-{slave-label}'
        - string:
            name: DEPLOY_SCENARIO
            default: 'os-odl_l2-nofeature-ha'
        - string:
            name: DOCKER_TAG
            default: '{docker-tag}'
            description: 'Tag to pull docker image'
        - string:
            name: YARDSTICK_SCENARIO_SUITE_NAME
            default: opnfv_${{DEPLOY_SCENARIO}}_{testsuite}.yaml
            description: 'Path to test scenario suite'
        - string:
            name: CI_DEBUG
            default: 'false'
            description: "Show debut output information"

    scm:
        - git-scm:
            credentials-id: '{ssh-credentials}'
            refspec: ''
            branch: '{branch}'

    builders:
        - description-setter:
            description: "POD: $NODE_NAME"
        - 'yardstick-cleanup'
        #- 'yardstick-fetch-os-creds'
        - 'yardstick-{testsuite}'

    publishers:
        - email:
            recipients: jean.gaoliang@huawei.com matthew.lijun@huawei.com

########################
# builder macros
########################
- builder:
    name: yardstick-daily
    builders:
        - shell:
            !include-raw: ./yardstick-daily.sh

- builder:
    name: yardstick-vtcdaily
    builders:
        - shell:
            !include-raw: ./yardstick-vtcdaily.sh

- builder:
    name: yardstick-fetch-os-creds
    builders:
        - shell:
            !include-raw: ../../utils/fetch_os_creds.sh

- builder:
    name: yardstick-cleanup
    builders:
        - shell:
            !include-raw: ./yardstick-cleanup.sh
########################
# parameter macros
########################
- parameter:
    name: 'yardstick-params-fuel-baremetal'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: '-i 104.197.68.199:8086'
            description: 'Arguments to use in order to choose the backend DB'
- parameter:
    name: 'yardstick-params-fuel-virtual'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: ''
            description: 'Arguments to use in order to choose the backend DB'
- parameter:
    name: 'yardstick-params-joid-baremetal'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: '-i 104.197.68.199:8086'
            description: 'Arguments to use in order to choose the backend DB'
- parameter:
    name: 'yardstick-params-joid-virtual'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: ''
            description: 'Arguments to use in order to choose the backend DB'
- parameter:
    name: 'yardstick-params-intel-pod8'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: ''
            description: 'Arguments to use in order to choose the backend DB'
- parameter:
    name: 'yardstick-params-lf-pod1'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: '-i 104.197.68.199:8086'
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-lf-pod2'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: '-i 104.197.68.199:8086'
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-compass-baremetal'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: '-i 104.197.68.199:8086'
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-huawei-pod2'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: '-i 104.197.68.199:8086'
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-zte-pod1'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: '-i 104.197.68.199:8086'
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-orange-pod2'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: '-i 104.197.68.199:8086'
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-virtual'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: ''
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-compass-virtual'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: ''
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-huawei-pod3'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: ''
            description: 'Arguments to use in order to choose the backend DB'

- parameter:
    name: 'yardstick-params-huawei-pod4'
    parameters:
        - string:
            name: YARDSTICK_DB_BACKEND
            default: ''
            description: 'Arguments to use in order to choose the backend DB'

#######################
## trigger macros
#######################
# trigger for PODs to only run yardstick test suites
- trigger:
    name: 'yardstick-daily-huawei-pod3-trigger'
    triggers:
        - timed: '0 1 * * *'

- trigger:
    name: 'yardstick-daily-huawei-pod4-trigger'
    triggers:
        - timed: '0 1 * * *'