- job-template:
    name: 'periodic-{name}-{python}-with-neutron-lib-master'
    node: ubuntu-xenial

    wrappers:
      - build-timeout:
          timeout: 50
      - timestamps

    builders:
      - print-template-name:
          template-name: "{template-name}"
      - zuul-git-branch-prep-upper-constraints:
          branch: master
      - install-distro-packages
      - extra-test-setup
      - revoke-sudo
      - shell: "/usr/local/jenkins/slave_scripts/run-tox-with-neutron-lib-master.sh {python}"
      - assert-no-extra-files

    publishers:
      - test-results
      - console-log

- job-template:
    name: '{pipeline}-neutron-dsvm-api{which}-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - 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_GATE_NEUTRON=1
          export DEVSTACK_GATE_EXERCISES=0
          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi
          # NOTE(armax): this condition should be revised every time each of the
          # branches below are dropped. Prior to Newton, the API Tempest tests are
          # invoked explicitly and thus we need the following variables set. From
          # Newton onward, everything is taken care of by the Tempest plugin framework
          if [ "$ZUUL_BRANCH" == "stable/mitaka" ] ; then
              export DEVSTACK_GATE_TEMPEST_NOTESTS=1
              export DEVSTACK_GATE_INSTALL_TESTONLY=1
          else
              export DEVSTACK_GATE_TEMPEST_ALL_PLUGINS=1
              export DEVSTACK_GATE_TEMPEST_REGEX="^neutron.tests.tempest.api\."
          fi

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

          function post_test_hook {{
              bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh api{which}
          }}
          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}-tempest-dsvm-neutron-dvr-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - 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_GATE_NEUTRON=1
          export DEVSTACK_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON_DVR=1
          export DEVSTACK_GATE_TLSPROXY=1
          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

# TODO(armax): drop this job after all branches in the gate are tested
# with the native configuration. This will happen when stable/mitaka is
# dropped
- job-template:
    name: '{pipeline}-tempest-dsvm-neutron-dvr-ovs-native-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - timestamps

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - local_conf:
          conf: |
            [[post-config|/$Q_PLUGIN_CONF_FILE]]
            [ovs]
            of_interface=native
            ovsdb_interface=native


      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_TEMPEST=1
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON_DVR=1
          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-dsvm-neutron-dvr-ha-multinode-full-{node-release}{suffix}'
    node: '{node}'

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

    builders:
      - print-template-name:
          template-name: "{template-name}"
      - link-logs
      - net-info
      - devstack-checkout
      - local_conf:
          conf: |
            [[local|localrc]]
            NOVA_VNC_ENABLED=true
            VNCSERVER_LISTEN=0.0.0.0
            VNCSERVER_PROXYCLIENT_ADDRESS=$HOST_IP
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_TEMPEST=1
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_GATE_CONFIGDRIVE=0
          export DEVSTACK_GATE_TEMPEST_FULL=1
          # Test DVR works multinode
          export DEVSTACK_GATE_NEUTRON_DVR=1
          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi
          export DEVSTACK_GATE_TOPOLOGY="multinode"

          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}-neutron-dsvm-functional{python}-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - 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_UNSTACK=1
          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}
          export DEVSTACK_GATE_PROJECTS_OVERRIDE="openstack-dev/devstack openstack/neutron"
          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 dsvm-functional
          }}
          export -f gate_hook

          function post_test_hook {{
              bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh dsvm-functional{python}
          }}
          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-fullstack-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - 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_UNSTACK=1
          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}
          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 dsvm-fullstack
          }}
          export -f gate_hook

          function post_test_hook {{
              bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh dsvm-fullstack
          }}
          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-test-dsvm-{which-test}-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 70
      - 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_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 gate_hook {{
              bash -xe $BASE/new/python-neutronclient/neutronclient/tests/functional/hooks/gate_hook.sh {which-test}
          }}
          export -f gate_hook

          function post_test_hook {{
              # Configure and run functional tests
              $BASE/new/python-neutronclient/neutronclient/tests/functional/hooks/post_test_hook.sh {which-test}
          }}
          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}-tempest-dsvm-neutron-ipv6only{suffix}'
    node: '{node}'

    wrappers:
      - timeout:
          timeout: 130
      - 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_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_LOCAL_CONFIG="IP_VERSION=6"$'\n'"SERVICE_IP_VERSION=6"
          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-dsvm-neutron-serviceipv6{suffix}'
    node: '{node}'

    wrappers:
      - timeout:
          timeout: 130
      - 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_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_LOCAL_CONFIG="SERVICE_IP_VERSION=6"
          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

# TODO(armax): drop this job after all branches in the gate are tested
# with the native configuration. This will happen when stable/mitaka is
# dropped
- job-template:
    name: '{pipeline}-tempest-dsvm-neutron-ovs-native-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - timestamps

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_TEMPEST=1
          export DEVSTACK_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON=1
          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi
          # Add configrations for ovs native interface in local.conf
          function pre_test_hook {{
              local localconf=$BASE/new/devstack/local.conf
              echo "[[post-config|/\$Q_PLUGIN_CONF_FILE]]" >> $localconf
              echo "[ovs]" >> $localconf
              echo "of_interface=native" >> $localconf
              echo "ovsdb_interface=native" >> $localconf
          }}
          export -f pre_test_hook

          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-dsvm-neutron-linuxbridge-{node}{suffix}'
    node: '{node}'

    wrappers:
      - timeout:
          timeout: 130
      - 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_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_GATE_TLSPROXY=1
          export DEVSTACK_LOCAL_CONFIG="Q_AGENT=linuxbridge"$'\n'"PHYSICAL_NETWORK=default"$'\n'
          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-dsvm-neutron-scenario-linuxbridge-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - 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_GATE_NEUTRON=1
          export DEVSTACK_GATE_EXERCISES=0
          export BRANCH_OVERRIDE={branch-override}
          export DEVSTACK_LOCAL_CONFIG="Q_AGENT=linuxbridge"$'\n'"PHYSICAL_NETWORK=default"$'\n'
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi
          export DEVSTACK_GATE_TEMPEST_ALL_PLUGINS=1
          export DEVSTACK_GATE_TEMPEST_REGEX="^neutron.tests.tempest.scenario\."
          export TEMPEST_CONCURRENCY=2

          function gate_hook {{
              bash -xe $BASE/new/neutron/neutron/tests/contrib/gate_hook.sh dsvm-scenario-linuxbridge dvrskip
          }}
          export -f gate_hook

          function post_test_hook {{
              bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh dsvm-scenario-linuxbridge
          }}
          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}-tempest-dsvm-neutron-{which}-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - 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_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON=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 full-{which}
          }}
          export -f gate_hook

          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

# run tempest with:
# 1) neutron enabled
# 2) oslo.messaging from git
# 3) specific oslo.messaging driver enabled
# 4) plug-in configuration (optional)
- job-template:
    name: 'gate-tempest-neutron-dsvm-src-oslo.messaging-{plugin}-{config}-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 130
      - 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_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON=1

          export PROJECTS="openstack/devstack-plugin-{plugin} $PROJECTS"
          export DEVSTACK_LOCAL_CONFIG="enable_plugin devstack-plugin-{plugin} git://git.openstack.org/openstack/devstack-plugin-{plugin}"

          export DEVSTACK_PROJECT_FROM_GIT="oslo.messaging"

          if [ "{plugin}" == "amqp1" ]; then
              # The AMQP 1.0 plugin supports a couple of different message bus configurations
              # 'hybrid' - use RabbitMQ for Notifications, qdrouterd for RPC
              # 'dual' - use qpidd for Notifications, qdrouterd for RPC
              # default: use qpidd for Notifications and for RPC
              case "{config}" in
                hybrid)
                    export DEVSTACK_LOCAL_CONFIG+=$'\n'"AMQP1_SERVICE=qpid-hybrid"
                    ;;
                dual)
                    export DEVSTACK_LOCAL_CONFIG+=$'\n'"AMQP1_SERVICE=qpid-dual"
                    ;;
              esac
          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-dsvm-neutron-dvr-multinode-scenario-{node-release}{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_GATE_NEUTRON=1
          export DEVSTACK_GATE_CONFIGDRIVE=0
          export DEVSTACK_GATE_TEMPEST_ALL_PLUGINS=1
          export DEVSTACK_GATE_TEMPEST_REGEX="^neutron\.tests\.tempest\.scenario\."
          export TEMPEST_CONCURRENCY=2
          # Test DVR works multinode
          export DEVSTACK_GATE_NEUTRON_DVR=1
          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi
          export DEVSTACK_GATE_TOPOLOGY="multinode"

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

          function post_test_hook {{
              bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh dsvm-scenario-ovs
          }}
          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:
      - devstack-logs
      - console-log

- job-template:
    name: '{pipeline}-tempest-dsvm-neutron-with-ryu-master-{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_GATE_TEMPEST_FULL=1
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_GATE_TLSPROXY=1
          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi

          function gate_hook {{
              local ryu_path=$BASE/new/ryu_master
              if [ ! -d $ryu_path ]; then
                  git clone https://github.com/osrg/ryu $ryu_path
              fi
              sudo pip install -e $ryu_path
              $BASE/new/devstack-gate/devstack-vm-gate.sh
          }}
          export -f gate_hook

          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