From cb202a76df6d83bbb249ef88f24641c3e9d19043 Mon Sep 17 00:00:00 2001
From: Antoine Legrand <2t.antoine@gmail.com>
Date: Mon, 12 Feb 2018 14:28:59 +0100
Subject: [PATCH] Fix tests

---
 .gitlab-ci.yml                      |  6 +++---
 tests/Makefile                      | 16 ++++++++--------
 tests/cloud_playbooks/create-do.yml |  3 +++
 tests/files/ubuntu-canal-ha-do.yml  |  2 +-
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1ab5b5acf..8406ee4e2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,7 +24,7 @@ variables:
   RESET_CHECK: "false"
   UPGRADE_TEST: "false"
   KUBEADM_ENABLED: "false"
-  LOG_LEVEL: "-vv"
+  LOG_LEVEL: "-vvv"
 
 # asia-east1-a
 # asia-northeast1-a
@@ -484,8 +484,8 @@ coreos-calico-aio:
   <<: *job
   <<: *gce
   variables:
-    <<: *gce_variables
     <<: *coreos_calico_aio_variables
+    <<: *gce_variables
   when: on_success
   except: ['triggers']
   # only: [/^pr-.*$/]
@@ -495,7 +495,7 @@ ubuntu-canal-ha-do:
   <<: *job
   <<: *do
   variables:
-    <<: *gce_variables
+    <<: *do_variables
   when: on_success
   except: ['triggers']
   # only: [/^pr-.*$/]
diff --git a/tests/Makefile b/tests/Makefile
index e42aaf9bc..8c4639b29 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -5,17 +5,16 @@ $(HOME)/.ssh/id_rsa:
 
 init-gce: $(HOME)/.ssh/id_rsa
 	# echo $(GCE_PEM_FILE) | base64 -d > $(HOME)/.ssh/gce
-	echo "$(GCE_CREDENTIALS)" > $(HOME)/.ssh/gce.json
-
+	echo "$(GCE_CREDENTIALS_B64)" > $(HOME)/.ssh/gce.json
 
 init-do: $(HOME)/.ssh/id_rsa
-	pip install dopy
+	pip install dopy==0.3.5
 	echo $(DO_PRIVATE_KEY) | base64 -d > $(HOME)/.ssh/id_rsa
 
 create-gce: init-gce
 	ansible-playbook cloud_playbooks/create-gce.yml -i local_inventory/hosts.cfg -c local \
 	$(LOG_LEVEL) \
-	-e @$(CI_TEST_VARS) \
+	-e @"files/${CI_JOB_NAME}.yml" \
 	-e gce_credentials_file=$(HOME)/.ssh/gce.json \
 	-e gce_project_id=$(GCE_PROJECT_ID) \
 	-e gce_service_account_email=$(GCE_ACCOUNT) \
@@ -27,7 +26,7 @@ create-gce: init-gce
 delete-gce:
 	ansible-playbook -i ../inventory/sample/hosts.ini cloud_playbooks/delete-gce.yml -c local \
 	$(LOG_LEVEL) \
-	-e @$(CI_TEST_VARS) \
+	-e @"files/${CI_JOB_NAME}.yml" \
 	-e test_id=$(TEST_ID) \
 	-e gce_project_id=$(GCE_PROJECT_ID) \
 	-e gce_service_account_email=$(GCE_ACCOUNT) \
@@ -35,16 +34,17 @@ delete-gce:
 	-e inventory_path=$(PWD)/inventory/sample/hosts.ini
 
 create-do: init-do
-	ansible-playbook cloud_playbooks/create-do.yml -i tests/local_inventory/hosts.cfg -c local \
+	ansible-playbook cloud_playbooks/create-do.yml -i local_inventory/hosts.cfg -c local \
 	${LOG_LEVEL} \
-	-e @$(CI_TEST_VARS) \
+	-e @"files/${CI_JOB_NAME}.yml" \
 	-e inventory_path=${PWD}/../inventory/hosts.ini \
 	-e test_id=${TEST_ID}
 
 
 delete-do:
-	ansible-playbook -i ../inventory/sample/hosts.ini tests/cloud_playbooks/create-do.yml -c local \
+	ansible-playbook -i ../inventory/sample/hosts.ini cloud_playbooks/create-do.yml -c local \
 	$LOG_LEVEL \
+	-e @"files/${CI_JOB_NAME}.yml" \
 	-e state=absent \
 	-e test_id=${TEST_ID} \
 	-e inventory_path=${PWD}/../inventory/inventory.ini \
diff --git a/tests/cloud_playbooks/create-do.yml b/tests/cloud_playbooks/create-do.yml
index 33a9f935a..18756d294 100644
--- a/tests/cloud_playbooks/create-do.yml
+++ b/tests/cloud_playbooks/create-do.yml
@@ -54,6 +54,9 @@
       set_fact:
         test_name: "{{test_id |regex_replace('\\.', '-')}}"
 
+    - name: show vars
+      debug: msg="{{cloud_region}}, {{cloud_image}}"
+
     - set_fact:
         instance_names: >-
           {%- if mode in ['separate', 'ha'] -%}
diff --git a/tests/files/ubuntu-canal-ha-do.yml b/tests/files/ubuntu-canal-ha-do.yml
index 6fec2bc28..94a4af67a 100644
--- a/tests/files/ubuntu-canal-ha-do.yml
+++ b/tests/files/ubuntu-canal-ha-do.yml
@@ -1,5 +1,5 @@
 cloud_image: ubuntu-16-04-x64
-cloud_region: NYC3
+cloud_region: nyc3
 mode: ha
 
 # Deployment settings
-- 
GitLab