Skip to content

Commit

Permalink
add checks for cheese deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Capuccini committed Nov 10, 2016
1 parent b85b07e commit 4f66590
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 6 deletions.
8 changes: 7 additions & 1 deletion test/cheese-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
gather_facts: False
force_handlers: True
vars:
node_count: 6 # see roles/test-terraform/templates
node_count: 6
cf_zone: uservices.cloud
pre_tasks:
- name: "get test timestamp"
set_fact:
test_timestamp: "{{lookup('pipe','date +%Y%m%d%H%M%S')}}"
roles:
- test-terraform
- test-bootstrap
- test-cheese
4 changes: 4 additions & 0 deletions test/roles/test-cheese/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: "clean Cloudflare"
command: ansible-playbook playbooks/clean-cloudflare.yml
args:
chdir: "{{playbook_dir}}/.."
32 changes: 32 additions & 0 deletions test/roles/test-cheese/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
- name: "render cloudflare configuration"
template:
args:
src: "{{playbook_dir}}/secrets-kubenow/cloudflare/conf.yml.j2"
dest: "{{playbook_dir}}/../stacks/traefik-lb/roles/cloudflare/vars/conf.yml"
notify: "clean Cloudflare"

- name: "deploy stack/cheese-deployment"
command: >
ansible-playbook
-e "domain_name={{test_timestamp}}.test.{{cf_zone}}"
stacks/cheese-deployment/main.yml
args:
chdir: "{{playbook_dir}}/.."

- name: "test stilton"
include: >
test-page.yml
cheese=stilton
search_for=Stilton
- name: "test wensleydale"
include: >
test-page.yml
cheese=wensleydale
search_for=Wensleydale
- name: "test cheddar"
include: >
test-page.yml
cheese=cheddar
search_for=Cheddar
20 changes: 20 additions & 0 deletions test/roles/test-cheese/tasks/test-page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: "test endpoint"
command: >
curl --silent --head
-H "host: {{cheese}}.{{test_timestamp}}.test.{{cf_zone}}"
http://{{cheese}}.{{test_timestamp}}.test.{{cf_zone}}
register: head
until: head.stdout.find("200 OK") != -1
retries: 5
delay: 30

- name: "test page"
action: >
uri
url=http://{{cheese}}.{{test_timestamp}}.test.{{cf_zone}}
return_content=yes
register: body

- name: "fail on missing '{{search_for}}' in page"
fail: msg="missing '{{search_for}}' in page"
when: "'{{search_for}}' not in body.content"
4 changes: 0 additions & 4 deletions test/roles/test-terraform/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
- name: "generate test timestamp"
set_fact:
test_timestamp: "{{lookup('pipe','date +%Y%m%d%H%M%S')}}"

- name: "render tfvars"
template:
args:
Expand Down
2 changes: 1 addition & 1 deletion test/secrets-kubenow

0 comments on commit 4f66590

Please sign in to comment.