- job-template:
    name: '{pipeline}-neutron-dsvm-api{branch-designator}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 125
      - timestamps

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_TIMEOUT=120
          export DEVSTACK_GATE_TEMPEST=1
          export DEVSTACK_GATE_TEMPEST_NOTESTS=1
          export DEVSTACK_GATE_EXERCISES=0
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_GATE_INSTALL_TESTONLY=1
          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi

          function gate_hook {{
              bash -xe $BASE/new/neutron/neutron/tests/contrib/gate_hook.sh api
          }}
          export -f gate_hook

          function post_test_hook {{
              bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh api
          }}
          export -f post_test_hook

          cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
          ./safe-devstack-vm-gate-wrap.sh

    publishers:
      - test-results
      - devstack-logs
      - console-log

- job-template:
    name: '{pipeline}-neutron-dsvm-functional{branch-designator}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 125
      - timestamps

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_UNSTACK=1
          export DEVSTACK_GATE_TIMEOUT=120
          export DEVSTACK_GATE_TEMPEST=0
          export DEVSTACK_GATE_EXERCISES=0
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_GATE_INSTALL_TESTONLY=1
          export BRANCH_OVERRIDE={branch-override}
          # Gate hooks previous to kilo will break if PROJECTS is overridden
          if [[ ! "$BRANCH_OVERRIDE" =~ ^stable/(icehouse|juno)$ ]] && [[ ! "$ZUUL_BRANCH" =~ ^stable/(icehouse|juno)$ ]] ; then
              export DEVSTACK_GATE_PROJECTS_OVERRIDE="openstack-dev/devstack openstack/neutron"
          fi
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi

          function gate_hook {{
              if [[ -e $BASE/new/neutron/neutron/tests/contrib/gate_hook.sh ]]; then
                  bash -xe $BASE/new/neutron/neutron/tests/contrib/gate_hook.sh dsvm-functional
              else
                  # Before kilo
                  bash -xe $BASE/new/neutron/neutron/tests/functional/contrib/gate_hook.sh
              fi
          }}
          export -f gate_hook

          function post_test_hook {{
              if [[ -e $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh ]]; then
                 bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh dsvm-functional
              else
                 # Before kilo
                 bash -xe $BASE/new/neutron/neutron/tests/functional/contrib/post_test_hook.sh
              fi
          }}
          export -f post_test_hook

          cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
          ./safe-devstack-vm-gate-wrap.sh

    publishers:
      - test-results
      - devstack-logs
      - console-log

- job-template:
    name: '{pipeline}-neutronclient-dsvm-functional{branch-designator}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 65
      - timestamps

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_TIMEOUT=60
          export DEVSTACK_GATE_NEUTRON=1
          export BRANCH_OVERRIDE={branch-override}
          export DEVSTACK_PROJECT_FROM_GIT=python-neutronclient
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi

          function post_test_hook {{
              # Configure and run functional tests
              $BASE/new/python-neutronclient/neutronclient/tests/functional/hooks/post_test_hook.sh
          }}
          export -f post_test_hook

          cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
          ./safe-devstack-vm-gate-wrap.sh

    publishers:
      - test-results
      - devstack-logs
      - console-log