Skip to content

Commit

Permalink
Merge pull request #2704 from uselagoon/active_standby_test
Browse files Browse the repository at this point in the history
add back active-standby tests to controller-kubernetes
  • Loading branch information
Toby Bellwood authored Jun 17, 2021
2 parents 22c9590 + 9422683 commit cdc7ff9
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ KIND_VERSION = v0.11.1
GOJQ_VERSION = v0.12.3
CHART_TESTING_VERSION = v3.4.0
KIND_IMAGE = kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
TESTS = [api,features-kubernetes,features-kubernetes-2,nginx,drupal-php73,drupal-php74,drupal-postgres,python,gitlab,github,bitbucket,node-mongodb,elasticsearch]
TESTS = [api,features-kubernetes,features-kubernetes-2,active-standby-kubernetes,nginx,drupal-php73,drupal-php74,drupal-postgres,python,gitlab,github,bitbucket,node-mongodb,elasticsearch]
CHARTS_TREEISH = main

local-dev/kind:
Expand Down
3 changes: 2 additions & 1 deletion tests/tasks/api/add-project.gql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ mutation addProject {
name: "{{ project }}"
openshift: 2001
gitUrl: "{{ git_url }}"
productionEnvironment: "master"
productionEnvironment: "{{ prodenv }}"
standbyProductionEnvironment: "{{ standbyenv }}"
subfolder: "{{ subfolder }}"
privateKey: "-----BEGIN RSA PRIVATE KEY-----\nMIIJKAIBAAKCAgEAxGZZrOV7Islo5p51Moabfd1YB8qbHvQZfJDZJmSU4jNxMf8G\nQH8KIM6ndi60xIiDlkh9R50Gs0fgnPaBwpjMjcUay5EvzBJdMmd/EPhg359+4f5Z\nQiGTVaB5UoGJKg9DEK4Xxi+QLpQ1CiJXvd3QOqnQlJZ2WYwz4kdLxF0d+sRrl+0G\nAISt9Gg9kq6wa7k7RRr4/OyD/9DhDr1GXvHXFPRv6QqKq084CqiUaarP7OcbZKi5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Pa9smEXAjEmS1Rj/ldM\n7eHzPvwlA9p9SFaKJt5x8G25ROCyB1x4RlBEreyutofcCoDSV+8DRPnEY2XN3RhS\nBgCW+wKCAQAyHrqaDSyS2YUXA/UaN59CYlZk9PYmssTa+16+vRfyH+1H0NQpsgd+\neTq4ze3ORpZ3adVN4svxNQ0JjvDVtZkxFPd70aoDJDKL5UqoU3QfDGHCb75FhpiO\n+ze+IVAXf3Ly+pvbU9Edp8PjAsnBqaA9743orXHhYmgJLRtmJWZv/6R3P9ncxLAW\nz9yOXaBu5TmSTBuNsBV9mhs8QQoUjyDJ7f+0yolBJMfAIGnW5EhbkK31pPvhHIrC\nRn4yCr1mW9F77KNpNMMq0BTFD7jE4SFLvRPThSem0Z5Xr8wwxbDJSa7H7DgyhryE\ng6Qp42AwVpdZ/mqfjNdGeWWBQ2UzVxcZAoIBAHNXgjD3umcKciYRAbltNJrXx9xk\ndAv8I69oEMCy4hCmvKUjy/UI9NqXFjBb/G6VGgh6NUE9o9o27t1Y5Plm0izyCA1M\nDFruaRfjyJ8qjbEifcqRtcF3rzsBiXIwdmbN6qT4PUipN2elpUAd7J1OIwGIIe3u\nCWNyOTNL+2+oQ/Eg1Y99mg3yrsVyOwhynVE80/X5cy07bXXR5rv1x4NKSVbPhlnt\nL6J5iAoqoDKICzjcgF5x3mj9YFWZrC3aRxRrN5RoEgeVdcXeK56UJqXHjmKN++m3\nc8OPEIBZiD8UJuhSNSOLiBFrGz6toy6rpHavqqknGhVWotXsAs1h8LNkBe8=\n-----END RSA PRIVATE KEY-----"
}
Expand Down
16 changes: 14 additions & 2 deletions tests/tests/active-standby-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
vars:
testname: "API TOKEN"

- include: api/add-project.yaml
vars:
project: ci-active-standby-{{ cluster_type }}
git_repo_name: active-standby.git
git_url: "{{ localgit_url }}/{{ git_repo_name }}"
prod_env: master-a
standby_env: master-b

- include: active-standby/active-standby.yaml
vars:
testname: "ACTIVE_STANDBY"
git_repo_name: active-standby.git
project: ci-active-standby-{{ cluster_type }}
branch: master-a
prod_branch: master-a
standby_branch: master-b
error_code_check: 404
error_code_check: 404

- include: api/delete-project.yaml
vars:
project: ci-active-standby-{{ cluster_type }}
33 changes: 17 additions & 16 deletions tests/tests/active-standby/active-standby.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
serial: 1
vars:
git_files: "active-standby/first/"
branch: "{{ prod_branch }}"
tasks:
- include: ../../tasks/git-init.yaml
- include: ../../tasks/git-add-commit-push.yaml
Expand All @@ -12,7 +13,7 @@
hosts: localhost
serial: 1
vars:
branch: "{{ branch }}"
branch: "{{ prod_branch }}"
project: "{{ project }}"
tasks:
- include: ../../tasks/api/deploy-no-sha.yaml
Expand All @@ -22,21 +23,22 @@
serial: 1
vars:
git_files: "active-standby/second/"
branch: "{{ standby_branch }}"
tasks:
- include: git-add-commit-push.yaml

- name: "{{ testname }} - standby branch api deployEnvironmentBranch on {{ project }}, which should deploy the first commit"
- name: "{{ testname }} - standby branch api deployEnvironmentBranch {{ standby_branch }} on {{ project }}, which should deploy the first commit"
hosts: localhost
serial: 1
vars:
branch: "{{ standby_branch }}"
project: "{{ project }}"
tasks:
- include: deploy-no-sha.yaml
- include: ../../tasks/api/deploy-no-sha.yaml

- include: pre-switch-check.yaml
vars:
expected_head: "{{ current_head }}"
expected_branch: "{{ branch }}"
project: "{{ project }}"

- name: "{{ testname }} - api switchActiveStandby on {{ project }}, which should switch the routes"
Expand All @@ -50,37 +52,36 @@
- include: post-switch-check.yaml
vars:
expected_head: "{{ current_head }}"
expected_branch: "{{ branch }}"
project: "{{ project }}"

- name: "{{ testname }} - active branch api deleteEnvironment on {{ project }}, which should remove all resources"
- name: "{{ testname }} - api deleteEnvironment {{ prod_branch }} on {{ project }}, which should remove all resources"
hosts: localhost
serial: 1
vars:
project: "{{ project }}"
branch: "{{ branch }}"
branch: "{{ prod_branch }}"
tasks:
- include: ../../tasks/api/delete-environment.yaml

- name: "{{ testname }} - standby branch api deleteEnvironment on {{ project }}, which should remove all resources"
- name: "{{ testname }} - check if {{ prod_branch }} for {{ project }} does not exist anymore"
hosts: localhost
serial: 1
vars:
project: "{{ project }}"
# branch: "{{ standby_branch }}"
url: "http://nginx.{{ project | regex_replace('_', '-') }}.{{ prod_branch | regex_replace('/', '-') }}.{{ route_suffix }}"
expected_returncode: "{{ error_code_check }}"
tasks:
- include: remove.yaml
- include: ../../checks/check-url-returncode.yaml

- name: "{{ testname }} - active branch check if site for {{ project }} does not exist anymore"
- name: "{{ testname }} - api deleteEnvironment {{ standby_branch }} on {{ project }}, which should remove all resources"
hosts: localhost
serial: 1
vars:
url: "http://nginx.{{ project | regex_replace('_', '-') }}.{{ branch | regex_replace('/', '-') }}.{{ route_suffix }}"
expected_returncode: "{{ error_code_check }}"
project: "{{ project }}"
branch: "{{ standby_branch }}"
tasks:
- include: ../../checks/check-url-returncode.yaml
- include: ../../tasks/api/delete-environment.yaml

- name: "{{ testname }} - standby branch check if site for {{ project }} does not exist anymore"
- name: "{{ testname }} - check if {{ standby_branch }} for {{ project }} does not exist anymore"
hosts: localhost
serial: 1
vars:
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/active-standby/deploy-active-standby.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
body_format: json
body: '{ "query": "query($projectName: String!) {projectByName(name:$projectName){productionEnvironment,standbyProductionEnvironment}}", "variables": {"projectName":"{{ project }}"}}'
register: switchresult
until: switchresult.json.data.projectByName.productionEnvironment == standby_branch or switchresult.json.data.projectByName.standbyProductionEnvironment == branch
until: switchresult.json.data.projectByName.productionEnvironment == standby_branch or switchresult.json.data.projectByName.standbyProductionEnvironment == prod_branch
retries: 30
delay: 10
15 changes: 0 additions & 15 deletions tests/tests/active-standby/deploy-no-sha.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions tests/tests/active-standby/post-switch-check.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
- name: "{{ testname }} - check if {{ project }} is deployed with searching for 'Hello World!'"
- name: "{{ testname }} - check if {{ project }} is deployed with searching for 'Hello World!' on {{ prod_branch }}"
hosts: localhost
serial: 1
vars:
url: "http://nginx.{{ project | regex_replace('_', '-') }}.{{ branch | regex_replace('/', '-') }}.{{ route_suffix }}"
url: "http://nginx.{{ project | regex_replace('_', '-') }}.{{ prod_branch | regex_replace('/', '-') }}.{{ route_suffix }}"
expected_content: "Hello World!"
tasks:
- include: ../../checks/check-url-content.yaml

- name: "{{ testname }} - check if {{ project }} is deployed with searching for 'Standby Hello World!'"
- name: "{{ testname }} - check if {{ project }} is deployed with searching for 'Standby Hello World!' on {{ standby_branch }}"
hosts: localhost
serial: 1
vars:
Expand All @@ -20,7 +20,7 @@
hosts: localhost
serial: 1
vars:
url: "https://nginx.{{ project | regex_replace('_', '-') }}.{{ branch | regex_replace('/', '-') }}.{{ route_suffix_https }}"
url: "https://nginx.{{ project | regex_replace('_', '-') }}.{{ prod_branch | regex_replace('/', '-') }}.{{ route_suffix_https }}"
host: "active-moving-route.com"
expected_content: "Standby Hello World!"
tasks:
Expand Down
8 changes: 4 additions & 4 deletions tests/tests/active-standby/pre-switch-check.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
- name: "{{ testname }} - check if {{ project }} is deployed with searching for 'Hello World!'"
- name: "{{ testname }} - check if {{ project }} is deployed with searching for 'Hello World!' on {{ prod_branch }}"
hosts: localhost
serial: 1
vars:
url: "http://nginx.{{ project | regex_replace('_', '-') }}.{{ branch | regex_replace('/', '-') }}.{{ route_suffix }}"
url: "http://nginx.{{ project | regex_replace('_', '-') }}.{{ prod_branch | regex_replace('/', '-') }}.{{ route_suffix }}"
expected_content: "Hello World!"
tasks:
- include: ../../checks/check-url-content.yaml

- name: "{{ testname }} - check if {{ project }} is deployed with searching for 'Standby Hello World!'"
- name: "{{ testname }} - check if {{ project }} is deployed with searching for 'Standby Hello World!' on {{ standby_branch }}"
hosts: localhost
serial: 1
vars:
Expand All @@ -20,7 +20,7 @@
hosts: localhost
serial: 1
vars:
url: "https://nginx.{{ project | regex_replace('_', '-') }}.{{ branch | regex_replace('/', '-') }}.{{ route_suffix_https }}"
url: "https://nginx.{{ project | regex_replace('_', '-') }}.{{ prod_branch | regex_replace('/', '-') }}.{{ route_suffix_https }}"
host: "active-moving-route.com"
expected_content: "Hello World!"
tasks:
Expand Down
39 changes: 0 additions & 39 deletions tests/tests/active-standby/remove.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions tests/tests/api/add-project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
project: "{{ project }}"
git_url: "{{ git_url }}"
subfolder: "{{ sub_folder | default('') }}"
prodenv: "{{ prod_env | default('master') }}"
standbyenv: "{{ standby_env | default('') }}"
openshift: 2001
tasks:
- include: ../../tasks/api/add-project.yaml

0 comments on commit cdc7ff9

Please sign in to comment.