- job-group:
    name: 'lib-forward-testing-{name}'
    jobs:
      - '{pipeline}-tempest-dsvm-neutron-src-{name}-{node}{suffix}':
          pipeline: gate
          node:
            - ubuntu-trusty
            - ubuntu-xenial
          suffix: ''
          branch-override: default

- job-group:
    name: 'stable-compat-jobs-{name}'
    jobs:
      - '{pipeline}-tempest-dsvm-neutron-src-{name}-{node}{suffix}':
          pipeline: gate
          node: ubuntu-xenial
          suffix: '-newton'
          branch-override: stable/newton
      - '{pipeline}-tempest-dsvm-neutron-src-{name}-{node}{suffix}':
          pipeline: gate
          node: ubuntu-xenial
          suffix: '-ocata'
          branch-override: stable/ocata


- job-template:
    name: '{pipeline}-tempest-dsvm-cinder-v1-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 180
      - timestamps

    builders:
      - print-template-name:
          template-name: "{template-name}"
      - link-logs
      - net-info
      - devstack-checkout
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_TEMPEST=1
          export DEVSTACK_LOCAL_CONFIG="TEMPEST_VOLUME_API_V1=True"
          export DEVSTACK_GATE_TEMPEST_REGEX="volume"
          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi
          cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
          ./safe-devstack-vm-gate-wrap.sh

    publishers:
      - devstack-logs
      - console-log


- job-template:
    name: '{pipeline}-tempest-plugin-sanity-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 30
      - timestamps

    builders:
      - zuul-git-prep
      - install-distro-packages
      - revoke-sudo
      - shell: |
            #!/bin/bash -eux
            cd $WORKSPACE
            # retrieve a list of projects having tempest plugins
            PROJECT_LIST="$(python tools/generate-tempest-plugins-list.py)"
            # function to clone project using zuul-cloner
            function clone_project() {{
                /usr/zuul-env/bin/zuul-cloner --cache-dir /opt/git \
                git://git.openstack.org \
                openstack/"$1"
            }}

            # Clone projects having tempest plugins
            for project in $PROJECT_LIST; do
                clone_project $project
            done
            virtualenv $WORKSPACE/.venv
            export TVENV="$WORKSPACE/tools/with_venv.sh"
            $TVENV pip install .
            # Install other tempest plugins projects
            for project in $PROJECT_LIST; do
                $TVENV pip install $WORKSPACE/openstack/$project
                # Check for test-requirements.txt file in a project then install it.
                if [[ -e $WORKSPACE/openstack/$project/test-requirements.txt ]]; then
                    $TVENV pip install -r $WORKSPACE/openstack/$project/test-requirements.txt
                fi
            done
            # Create tempest workspace
            $TVENV tempest init $WORKSPACE/tempest_sanity
            cd $WORKSPACE/tempest_sanity
            $TVENV tempest list-plugins
            $TVENV tempest run -l

    publishers:
      - console-log