From d8733b290e298be098c044fa5c92030faea7c798 Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Tue, 25 Feb 2020 10:22:27 +0000
Subject: [PATCH] CI: Use upper constraints when installing clients

Clients are starting to release versions that don't support Python 2.
The ironic scenario is currently failing on stable branches for this
reason.

Use upper constraints to avoid installing these new versions on stable
branches.

Change-Id: I4f91b53cbf2297d70da4b54d6c402c1427aacdd9
---
 tests/run.yml       |  1 +
 tools/setup_gate.sh | 22 +++++++++++-----------
 zuul.d/base.yaml    |  1 +
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/tests/run.yml b/tests/run.yml
index e9bdfece58..72c0b3a49f 100644
--- a/tests/run.yml
+++ b/tests/run.yml
@@ -269,6 +269,7 @@
         TAG: "{{ build_image_tag }}"
         KOLLA_SRC_DIR: "{{ ansible_env.HOME }}/src/opendev.org/openstack/kolla"
         SCENARIO: "{{ scenario }}"
+        UPPER_CONSTRAINTS: "{{ ansible_env.HOME }}/src/opendev.org/openstack/requirements/upper-constraints.txt"
 
     - name: Run init-swift.sh script
       script:
diff --git a/tools/setup_gate.sh b/tools/setup_gate.sh
index d30d829eac..c06a0bb88d 100755
--- a/tools/setup_gate.sh
+++ b/tools/setup_gate.sh
@@ -10,22 +10,22 @@ GIT_PROJECT_DIR=$(mktemp -d)
 
 function setup_openstack_clients {
     # Prepare virtualenv for openstack deployment tests
+    local packages=(python-openstackclient python-heatclient)
+    if [[ $SCENARIO == zun ]]; then
+        packages+=(python-zunclient)
+    fi
+    if [[ $SCENARIO == ironic ]]; then
+        packages+=(python-ironicclient)
+    fi
+    if [[ $SCENARIO == masakari ]]; then
+        packages+=(python-masakariclient)
+    fi
     if [[ "debian" == $BASE_DISTRO ]]; then
         sudo apt -y install python3-venv
     fi
     python3 -m venv ~/openstackclient-venv
     ~/openstackclient-venv/bin/pip install -U pip
-    ~/openstackclient-venv/bin/pip install python-openstackclient
-    ~/openstackclient-venv/bin/pip install python-heatclient
-    if [[ $SCENARIO == zun ]]; then
-        ~/openstackclient-venv/bin/pip install python-zunclient
-    fi
-    if [[ $SCENARIO == ironic ]]; then
-        ~/openstackclient-venv/bin/pip install python-ironicclient
-    fi
-    if [[ $SCENARIO == masakari ]]; then
-        ~/openstackclient-venv/bin/pip install python-masakariclient
-    fi
+    ~/openstackclient-venv/bin/pip install -c $UPPER_CONSTRAINTS ${packages[@]}
 }
 
 function setup_config {
diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml
index dc30e6ac44..dd66b91fff 100644
--- a/zuul.d/base.yaml
+++ b/zuul.d/base.yaml
@@ -8,6 +8,7 @@
     timeout: 7200
     required-projects:
       - openstack/kolla-ansible
+      - openstack/requirements
     irrelevant-files:
       - ^.*\.rst$
       - ^doc/.*