From 1b3fcfed64c9dffb5693d2930ac1f0a696b4aa34 Mon Sep 17 00:00:00 2001
From: Michal Arbet <michal.arbet@ultimum.io>
Date: Wed, 13 Jan 2021 13:52:32 +0000
Subject: [PATCH] [CI] Test ProxySQL with shards in the nova cells scenario
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There are two shards:
One 2-node (to test the clustering), one 1-node.

Change-Id: If3a60ad4cc39d6ad0cd72a934f5f7497cd44021b
Co-Authored-By: Radosław Piliszek <radoslaw.piliszek@gmail.com>
---
 tests/setup_gate.sh                | 4 ++++
 tests/templates/globals-default.j2 | 1 +
 tests/templates/inventory.j2       | 3 ++-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/setup_gate.sh b/tests/setup_gate.sh
index 0318e838d9..5998459c76 100755
--- a/tests/setup_gate.sh
+++ b/tests/setup_gate.sh
@@ -58,6 +58,10 @@ function prepare_images {
         GATE_IMAGES+=",^cinder"
     fi
 
+    if [[ $SCENARIO == "cells" ]]; then
+        GATE_IMAGES+=",^proxysql"
+    fi
+
     if [[ $SCENARIO == "zun" ]]; then
         GATE_IMAGES+=",^zun,^kuryr,^etcd,^cinder,^iscsid"
         if [[ $BASE_DISTRO != "centos" ]]; then
diff --git a/tests/templates/globals-default.j2 b/tests/templates/globals-default.j2
index 3e08e2df29..bd7549a7cf 100644
--- a/tests/templates/globals-default.j2
+++ b/tests/templates/globals-default.j2
@@ -109,6 +109,7 @@ enable_masakari: "yes"
 
 {% if scenario == "cells" %}
 enable_cells: "yes"
+enable_proxysql: "yes"
 {% endif %}
 
 {% if scenario == "mariadb" %}
diff --git a/tests/templates/inventory.j2 b/tests/templates/inventory.j2
index f1222e4134..0b9fdcd527 100644
--- a/tests/templates/inventory.j2
+++ b/tests/templates/inventory.j2
@@ -65,7 +65,7 @@ control
 {% for host in hostvars %}
 {% set cell_name = 'cell' ~ loop.index %}
 [{{ cell_name }}]
-{{ host }} ansible_host={{ hostvars[host]['ansible_host'] }} ansible_user=kolla ansible_ssh_private_key_file={{ ansible_env.HOME ~ '/.ssh/id_rsa_kolla' }}
+{{ host }} ansible_host={{ hostvars[host]['ansible_host'] }} ansible_user=kolla ansible_ssh_private_key_file={{ ansible_env.HOME ~ '/.ssh/id_rsa_kolla' }} mariadb_shard_id={{ loop.index0 % 2 }}
 
 [{{ cell_name }}:vars]
 nova_cell_name = {{ cell_name }}
@@ -73,6 +73,7 @@ nova_cell_compute_group = {{ cell_name }}
 nova_cell_conductor_group = {{ cell_name }}
 nova_cell_novncproxy_group = {{ cell_name }}
 nova_novncproxy_port = {{ 6080 + loop.index0 }}
+nova_cell_database_shard_id = {{ loop.index0 % 2 }}
 
 {% endfor %}
 {% endif %}