From 243ca5d08fa73a009760c6ce486e7d86c9481398 Mon Sep 17 00:00:00 2001
From: Max Gautier <mg@max.gautier.name>
Date: Wed, 20 Dec 2023 09:59:02 +0100
Subject: [PATCH] Add test case for calico using etcd datastore (#10722)

* Add multinode ci layout

* Add test case for calico using etcd datastore
---
 .gitlab-ci/packet.yml                         |  5 ++++
 docs/test_cases.md                            |  4 ++-
 .../roles/packet-ci/templates/inventory.j2    | 10 +++++++
 .../roles/packet-ci/vars/main.yml             |  1 +
 .../packet_ubuntu22-calico-etcd-datastore.yml | 29 +++++++++++++++++++
 5 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 tests/files/packet_ubuntu22-calico-etcd-datastore.yml

diff --git a/.gitlab-ci/packet.yml b/.gitlab-ci/packet.yml
index d1c5ba0af..de61a1f60 100644
--- a/.gitlab-ci/packet.yml
+++ b/.gitlab-ci/packet.yml
@@ -61,6 +61,11 @@ packet_ubuntu22-calico-all-in-one:
   extends: .packet_pr
   when: on_success
 
+packet_ubuntu22-calico-etcd-datastore:
+  stage: deploy-part2
+  extends: .packet_pr
+  when: on_success
+
 packet_centos7-flannel-addons-ha:
   extends: .packet_pr
   stage: deploy-part2
diff --git a/docs/test_cases.md b/docs/test_cases.md
index 8bfc7bd58..d5aef62f2 100644
--- a/docs/test_cases.md
+++ b/docs/test_cases.md
@@ -1,6 +1,6 @@
 # Node Layouts
 
-There are five node layout types: `default`, `separate`, `ha`, `scale`, and `all-in-one`.
+There are six node layout types: `default`, `separate`, `ha`, `scale`, `all-in-one`, and `multinode`.
 
 `default` is a non-HA two nodes setup with one separate `kube_node`
 and the `etcd` group merged with the `kube_control_plane`.
@@ -18,6 +18,8 @@ never actually deployed, but certificates are generated for them.
 
 `all-in-one` layout use a single node for with `kube_control_plane`, `etcd` and `kube_node` merged.
 
+`multinode` layout consists of two separate `kube_node` and a merged single `etcd+kube_control_plane` node.
+
 Note, the canal network plugin deploys flannel as well plus calico policy controller.
 
 ## Test cases
diff --git a/tests/cloud_playbooks/roles/packet-ci/templates/inventory.j2 b/tests/cloud_playbooks/roles/packet-ci/templates/inventory.j2
index e2b1c9b8c..da7e74969 100644
--- a/tests/cloud_playbooks/roles/packet-ci/templates/inventory.j2
+++ b/tests/cloud_playbooks/roles/packet-ci/templates/inventory.j2
@@ -81,6 +81,16 @@ instance-2
 [broken_etcd]
 instance-1 etcd_member_name=etcd2
 instance-2 etcd_member_name=etcd3
+{% elif mode == "multinode" %}
+[kube_control_plane]
+instance-1
+
+[etcd]
+instance-1
+
+[kube_node]
+instance-2
+instance-3
 {% endif %}
 
 [k8s_cluster:children]
diff --git a/tests/cloud_playbooks/roles/packet-ci/vars/main.yml b/tests/cloud_playbooks/roles/packet-ci/vars/main.yml
index 14cf5917c..5cfe561b7 100644
--- a/tests/cloud_playbooks/roles/packet-ci/vars/main.yml
+++ b/tests/cloud_playbooks/roles/packet-ci/vars/main.yml
@@ -7,6 +7,7 @@ _vm_count_dict:
   ha-recover: 3
   ha-recover-noquorum: 3
   all-in-one: 1
+  multinode: 3
   default: 2
 
 vm_count: "{{ _vm_count_dict[mode | d('default')] }}"
diff --git a/tests/files/packet_ubuntu22-calico-etcd-datastore.yml b/tests/files/packet_ubuntu22-calico-etcd-datastore.yml
new file mode 100644
index 000000000..c95a7602f
--- /dev/null
+++ b/tests/files/packet_ubuntu22-calico-etcd-datastore.yml
@@ -0,0 +1,29 @@
+---
+# Instance settings
+cloud_image: ubuntu-2204
+mode: multinode
+vm_memory: 1600Mi
+
+# Kubespray settings
+auto_renew_certificates: true
+
+# Currently ipvs not available on KVM: https://packages.ubuntu.com/search?suite=focal&arch=amd64&mode=exactfilename&searchon=contents&keywords=ip_vs_sh.ko
+kube_proxy_mode: iptables
+enable_nodelocaldns: False
+
+containerd_registries:
+  "docker.io": "https://mirror.gcr.io"
+
+containerd_registries_mirrors:
+  - prefix: docker.io
+    mirrors:
+      - host: https://mirror.gcr.io
+        capabilities: ["pull", "resolve"]
+        skip_verify: false
+  - prefix: 172.19.16.11:5000
+    mirrors:
+      - host: http://172.19.16.11:5000
+        capabilities: ["pull", "resolve", "push"]
+        skip_verify: true
+
+calico_datastore: "etcd"
-- 
GitLab