# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

#
# This script is executed in the tempest-dsvm-networking-ovn-native-services
# OpenStack CI job that runs DevStack + tempest using OVN's native l3,
# native dhcp, and eventually other native OVN services.
# You can find the CI job configuration here:
#
# http://git.openstack.org/cgit/openstack-infra/project-config/tree/jenkins/jobs/networking-ovn.yaml
#

export OVERRIDE_ENABLED_SERVICES=key,n-api,n-cpu,n-cond,n-sch,n-crt,n-cauth,n-obj,g-api,g-reg,c-sch,c-api,c-vol,horizon,rabbit,mysql,dstat,ovn-northd,ovn-controller,q-svc
if [ -z "${RALLY_SCENARIO}" ] ; then
    # Only include tempest if this is not a rally job.
    export OVERRIDE_ENABLED_SERVICES=${OVERRIDE_ENABLED_SERVICES},tempest
fi
export DEVSTACK_LOCAL_CONFIG+=$'\n'"OVN_L3_CREATE_PUBLIC_NETWORK=True"
export DEVSTACK_LOCAL_CONFIG+=$'\n'"OVN_NATIVE_DHCP=True"

# Begin list of exclusions.
r="^(?!.*"

# exclude the slow tag (part of the default for 'full')
r="$r(?:.*\[.*\bslow\b.*\])"

# exclude things that aren't fully implemented yet in the OVN native L3 agent

# NOTE: Re-enable floating ip tests once floating IPs are implemented
# in OVN (bug 1514995).
r="$r|(?:tempest\.api\.compute\.floating_ips.*)"
r="$r|(?:tempest\.api\.network\.admin\.test_floating_ips_admin_actions.*)"
r="$r|(?:tempest\.api\.network\.test_floating_ips.*)"
r="$r|(?:tempest\.scenario\.test_minimum_basic.*)"
r="$r|(?:tempest\.scenario\.test_network_advanced_server_ops.*)"
r="$r|(?:tempest\.scenario\.test_network_basic_ops.*)"
r="$r|(?:tempest\.scenario\.test_network_v6.*)"
r="$r|(?:tempest\.scenario\.test_security_groups_basic_ops.*)"
r="$r|(?:tempest\.scenario\.test_shelve_instance.*)"
r="$r|(?:tempest\.scenario\.test_snapshot_pattern.*)"
r="$r|(?:tempest\.scenario\.test_stamp_pattern.*)"
r="$r|(?:tempest\.scenario\.test_volume_boot_pattern.*)"

# exclude things that just aren't enabled with OVN
r="$r|(?:tempest\.api\.network\.admin\.test_l3_agent_scheduler.*)"
r="$r|(?:tempest\.api\.network\.admin\.test_quotas\.QuotasTest\.test_lbaas_quotas.*)"
r="$r|(?:tempest\.api\.network\.test_load_balancer.*)"
r="$r|(?:tempest\.scenario\.test_load_balancer.*)"
r="$r|(?:tempest\.api\.network\.admin\.test_load_balancer.*)"
r="$r|(?:tempest\.api\.network\.admin\.test_lbaas.*)"
r="$r|(?:tempest\.api\.network\.test_fwaas_extensions.*)"
r="$r|(?:tempest\.api\.network\.test_metering_extensions.*)"
r="$r|(?:tempest\.thirdparty\.boto\.test_s3.*)"

# exclude dhcp agent tests
r="$r|(?:tempest\.api\.network\.admin\.test_dhcp_agent_scheduler.*)"

# exclude this test case because this expects dhcp interface to be present
r="$r|(?:tempest\.scenario\.test_network_basic_ops\.TestNetworkBasicOps\.test_port_security_macspoofing_port)"

# exclude this test because there are no agents used by OVN
r="$r|(?:tempest\.api\.network\.admin\.test_agent_management.*)"

# exclude some unrelated stuff to make networking-ovn targeted runs go faster
r="$r|(?:tempest\.api\.identity*)"
r="$r|(?:tempest\.api\.image*)"
r="$r|(?:tempest\.api\.volume*)"
r="$r|(?:tempest\.api\.compute\.images*)"
r="$r|(?:tempest\.api\.compute\.keypairs*)"
r="$r|(?:tempest\.api\.compute\.certificates*)"
r="$r|(?:tempest\.api\.compute\.flavors*)"
r="$r|(?:tempest\.api\.compute\.test_quotas*)"
r="$r|(?:tempest\.api\.compute\.test_versions*)"
r="$r|(?:tempest\.api\.compute\.volumes*)"

# End list of exclusions.
r="$r)"

# only run tempest.api/scenario/thirdparty tests (part of the default for 'full')
r="$r(tempest\.(api|scenario|thirdparty)).*$"

export DEVSTACK_GATE_TEMPEST_REGEX="$r"
