# Murano and Congress integration functional tests
- job-template:
    name: 'gate-murano-congress-devstack-dsvm-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 70
      - timestamps

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_NEUTRON=1
          export ENABLED_SERVICES=tempest
          export PROJECTS="openstack/heat $PROJECTS"
          export PROJECTS="openstack/python-heatclient $PROJECTS"
          export PROJECTS="openstack/murano $PROJECTS"
          export PROJECTS="openstack/murano-dashboard $PROJECTS"
          export PROJECTS="openstack/python-muranoclient $PROJECTS"
          export PROJECTS="openstack/congress $PROJECTS"
          export PROJECTS="openstack/python-congressclient $PROJECTS"
          export PROJECTS="openstack/mistral $PROJECTS"
          export PROJECTS="openstack/mistral-dashboard $PROJECTS"
          export PROJECTS="openstack/python-mistralclient $PROJECTS"
          export KEEP_LOCALRC=1

          export DEVSTACK_LOCAL_CONFIG="enable_plugin heat git://git.openstack.org/openstack/heat"
          export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin mistral git://git.openstack.org/openstack/mistral"
          export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin congress git://git.openstack.org/openstack/congress"
          export DEVSTACK_LOCAL_CONFIG+=$'\n'"MURANO_ENABLE_MODEL_POLICY_ENFORCEMENT=True"

          # Enable murano devstack plugin. Provided repo should be cloned by zuul before devstack run
          # and below provided link should not be used.
          export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin murano git://git.openstack.org/openstack/murano"

          function pre_test_hook {{
              cd /opt/stack/new/murano/functionaltests
              ./pre_test_hook_congress.sh
              ./pre_test_hook_mistral.sh
              ./pre_test_hook.sh
          }}
          export -f pre_test_hook

          function post_test_hook {{
              cd /opt/stack/new/murano/functionaltests
              ./post_test_hook.sh congress_mistral
          }}
          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}-muranoclient-dsvm-functional-{mode}-{node}{suffix}'
    node: '{node}'

    wrappers:
      - build-timeout:
          timeout: 70
      - timestamps

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_NEUTRON=1
          export DEVSTACK_PROJECT_FROM_GIT=python-muranoclient
          export BRANCH_OVERRIDE={branch-override}

          export ENABLED_SERVICES=tempest
          export PROJECTS="openstack/heat $PROJECTS"
          export PROJECTS="openstack/python-heatclient $PROJECTS"
          export PROJECTS="openstack/murano $PROJECTS"
          export PROJECTS="openstack/murano-dashboard $PROJECTS"
          export KEEP_LOCALRC=1

          # Enable murano devstack plugin. Provided repo should be cloned by zuul before devstack run
          # and below provided link should not be used.
          export DEVSTACK_LOCAL_CONFIG="enable_plugin heat git://git.openstack.org/openstack/heat"
          export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin murano git://git.openstack.org/openstack/murano"

          if [ "{mode}" = "glare-backend" ]; then
              export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_service g-glare"
              export DEVSTACK_LOCAL_CONFIG+=$'\n'"MURANO_USE_GLARE=True"
          fi

          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi

          function pre_test_hook {{
              # Install Murano devstack modules
              cd /opt/stack/new/murano/functionaltests
              ./pre_test_hook.sh
          }}
          export -f pre_test_hook

          function post_test_hook {{
              # Configure and run functional tests
              /opt/stack/new/python-muranoclient/muranoclient/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

- job-template:
    name: 'gate-tempest-dsvm-murano-{mode}-{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_NEUTRON=1
          # Allow tempest to use site-packages with plugins
          export DEVSTACK_GATE_TEMPEST_ALL_PLUGINS=1
          export PROJECTS="openstack/heat $PROJECTS"
          export PROJECTS="openstack/python-heatclient $PROJECTS"
          export PROJECTS="openstack/murano $PROJECTS"
          export PROJECTS="openstack/murano-dashboard $PROJECTS"
          export PROJECTS="openstack/python-muranoclient $PROJECTS"
          export DEVSTACK_LOCAL_CONFIG="enable_plugin heat git://git.openstack.org/openstack/heat"
          export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin murano git://git.openstack.org/openstack/murano"
          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi
          if [ "{mode}" = "cfapi" ]; then
              export ENABLED_SERVICES+=,murano-cfapi
              export DEVSTACK_GATE_TEMPEST_REGEX="service_broker"
          elif [ "{mode}" = "api" ]; then
              export DEVSTACK_GATE_TEMPEST_REGEX="application_catalog"
          elif [ "{mode}" = "glare-backend" ]; then
              export DEVSTACK_GATE_TEMPEST_REGEX="application_catalog"
              export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_service g-glare"
              export DEVSTACK_LOCAL_CONFIG+=$'\n'"MURANO_USE_GLARE=True"
          fi
          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: 'gate-dsvm-{name}-{murano-app}-unittest-{node}{suffix}'
    node: '{node}'

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

    builders:
      - link-logs
      - net-info
      - zuul-git-prep
      - devstack-checkout
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_NEUTRON=1
          export KEYSTONE_USE_MOD_WSGI=False
          # Allow tempest to use site-packages with plugins
          export PROJECTS="openstack/murano $PROJECTS"
          export PROJECTS="openstack/python-muranoclient $PROJECTS"
          export PROJECTS="openstack/murano-dashboard $PROJECTS"
          export DEVSTACK_LOCAL_CONFIG="enable_plugin murano git://git.openstack.org/openstack/murano"
          export DEVSTACK_LOCAL_CONFIG+=$'\n'"disable_service heat h-api h-api-cfn h-api-cw h-eng"
          function post_test_hook {{
              # Configure and run functional tests
              . /opt/stack/new/devstack/openrc admin admin
              cd ${{WORKSPACE}}
              tox -ve {murano-app}-unittest
          }}
          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

# Experimental murano functional pipeline in place of outdated murano-ci.
- job-template:
    name: 'gate-murano-dsvm-functional-{node}{suffix}'
    node: '{node}'

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

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - local_conf:
          conf: |
            [[local|localrc]]
            enable_plugin heat git://git.openstack.org/openstack/heat
            enable_plugin murano git://git.openstack.org/openstack/murano
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_TEMPEST=0
          export DEVSTACK_GATE_TEMPEST_NOTESTS=1
          export DEVSTACK_GATE_NEUTRON=1

          export PROJECTS="openstack/heat $PROJECTS"
          export PROJECTS="openstack/python-heatclient $PROJECTS"
          export PROJECTS="openstack/murano $PROJECTS"
          export PROJECTS="openstack/murano-dashboard $PROJECTS"
          export PROJECTS="openstack/python-muranoclient $PROJECTS"

          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi

          function post_test_hook {{
              source $BASE/new/murano/functionaltests/post_test_hook_experimental.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

# Experimental murano functional pipeline in place of outdated murano-ci.
- job-template:
    name: 'gate-dashboard-dsvm-selenium-{type}-{node}{suffix}'
    node: '{node}'

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

    builders:
      - link-logs
      - net-info
      - devstack-checkout
      - local_conf:
          conf: |
            [[local|localrc]]
            enable_plugin murano git://git.openstack.org/openstack/murano
      - shell: |
          #!/bin/bash -xe
          export PYTHONUNBUFFERED=true
          export DEVSTACK_GATE_TEMPEST=0
          export DEVSTACK_GATE_TEMPEST_NOTESTS=1
          export DEVSTACK_GATE_NEUTRON=1

          export PROJECTS="openstack/murano $PROJECTS"
          export PROJECTS="openstack/murano-dashboard $PROJECTS"
          export PROJECTS="openstack/python-muranoclient $PROJECTS"

          export BRANCH_OVERRIDE={branch-override}
          if [ "$BRANCH_OVERRIDE" != "default" ] ; then
              export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
          fi

          function post_test_hook {{
              source $BASE/new/murano-dashboard/muranodashboard/tests/contrib/post_test_hook_experimental.sh \
                {type}
          }}
          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