generated from Skatteetaten/vagrant-hashistack-template
-
Notifications
You must be signed in to change notification settings - Fork 8
/
03_run_tests.yml
111 lines (98 loc) · 3.48 KB
/
03_run_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
- name: set variable
set_fact:
consul_token: "{{ lookup('env', 'consul_master_token') }}"
vault_addr: "{{ lookup('env', 'VAULT_ADDR') }}"
vault_token: "{{ lookup('env', 'vault_master_token') }}"
tags: test
- name: Minio healthchecks pass
uri:
url: http://localhost:8500/v1/health/checks/minio?filter={{ '(Status=="passing")' | urlencode }}
method: GET
return_content: yes
status_code: 200
body_format: json
when: not lookup('env', 'consul_acl') | bool
register: result_minio
retries: 15
delay: 15
until: result_minio.json | length == 2
tags: test
- name: Minio healthchecks pass with token
uri:
url: http://localhost:8500/v1/health/checks/minio?filter={{ '(Status=="passing")' | urlencode }}
method: GET
headers:
X-Consul-Token: "{{ consul_token }}"
return_content: yes
status_code: 200
body_format: json
when: lookup('env', 'consul_acl') | bool and lookup('env', 'consul_acl_default_policy') == 'deny'
register: result_minio
retries: 15
delay: 15
until: result_minio.json | length == 2
tags: test
# https://unix.stackexchange.com/a/148698
- name: Start local proxy on port 9999 to minio service
shell: nohup consul connect proxy -service minio-local -upstream minio:9999 -log-level debug </dev/null >/dev/null 2>&1 &
register: test_output
when: not lookup('env', 'consul_acl') | bool or (lookup('env', 'consul_acl') | bool and lookup('env', 'consul_acl_default_policy') == 'allow')
tags: test
# https://unix.stackexchange.com/a/148698
- name: Start local proxy on port 9999 to minio service with token
shell: nohup consul connect proxy -service minio-local -upstream minio:9999 -log-level debug </dev/null >/dev/null 2>&1 &
register: test_output
when: lookup('env', 'consul_acl') | bool and lookup('env', 'consul_acl_default_policy') == 'deny'
environment:
CONSUL_HTTP_TOKEN: "{{ consul_token }}"
tags: test
- name: Debug test_output
debug:
msg: "{{ test_output }}"
tags: test
- name: Register proxy PID_ID
shell: lsof -t -i:9999
register: PROXY_PID_ID # kill later with smth like `sudo kill -TERM 4635`
tags: test
# To quickly verify that proxy available (without any credentials)
# https://github.com/minio/minio/issues/4851#issuecomment-324543717
- name: Minio curl example. Verify that proxy to minio available
uri:
url: http://127.0.0.1:9999
status_code: 403
register: curl_output
until: curl_output.status == 403
retries: 10
delay: 5
tags: test
- name: Debug curl_output
debug:
msg: "{{curl_output}}"
tags: test
- name: Register access key
shell: docker exec $(docker ps -a -q --filter ancestor="minio/minio:latest") sh -c "env | grep MINIO_ACCESS_KEY=" | cut -f2 -d"="
register: access_key
tags:
- test
- name: Register secret key
shell: docker exec $(docker ps -a -q --filter ancestor="minio/minio:latest") sh -c "env | grep MINIO_SECRET_KEY=" | cut -f2 -d"="
register: secret_key
tags:
- test
- name: Add minio config
shell: mc config host add minio-container http://127.0.0.1:9999 {{ access_key.stdout }} {{ secret_key.stdout }}
tags: test
- name: Verify buckets `one/` exists
shell: mc ls minio-container --json | jq -s . | jq .[] | grep "one/"
register: bucket_output_1
retries: 10
delay: 5
until: bucket_output_1.rc == 0
tags: test
- name: Verify buckets `two/` exists
shell: mc ls minio-container --json | jq -s . | jq .[] | grep "two/"
register: bucket_output_2
retries: 10
delay: 5
until: bucket_output_2.rc == 0
tags: test