-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.yaml
136 lines (136 loc) · 5.98 KB
/
test.yaml
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Gather facts
- hosts: hyperfoil
ignore_unreachable: true
tasks: []
- hosts: hyperfoil_controller
tasks:
- name: Start test
include_role:
name: hyperfoil.hyperfoil_test
when: hyperfoil_deployer == "ssh"
vars:
test_name: test
- hosts: openshift
tasks:
- set_fact:
http2: "{{ http2 | default('true', true) }}"
fork: "{{ fork | default('all', true) }}"
num_apps: "{{ (num_dc | int) // 5 }}"
record_envoy_stats: "{{ record_envoy_stats | default('false', true) | bool }}"
use_istio: "{{ use_istio | default('true', true) | bool }}"
- when: single_node is not defined
block:
- name: Find workload nodes
shell: "oc get node -l test.role=workload -o json | jq -r '.items[].metadata.name'"
register: workload_cmd
- name: Get workload pod count
loop: "{{ workload_cmd.stdout.split() }}"
shell: "oc get pod -n {{ namespace }} -l app=scale-test --field-selector=spec.nodeName={{item}},status.phase=Running -o json | jq '.items | length'"
register: workload_counts
- name: Calculate pod count difference
set_fact:
min_pods: "{{ workload_counts.results | map(attribute='stdout') | list | min }}"
max_pods: "{{ workload_counts.results | map(attribute='stdout') | list | max }}"
total_pods: "{{ workload_counts.results | map(attribute='stdout') | list | map('int') | sum }}"
- when: single_node is defined
block:
- name: Get number of pods
shell: oc get pod -n {{ namespace }} -l app=scale-test --field-selector=status.phase=Running -o json | jq '.items | length'
register: workload_count
- name: Number of pods to number
set_fact:
min_pods: "{{ workload_count.stdout | int }}"
max_pods: "{{ workload_count.stdout | int }}"
total_pods: "{{ workload_count.stdout | int }}"
- name: Test total number of pods
when: "(total_pods | int) != (num_dc | int) * (pods_per_dc | int)"
fail:
msg: "Incorrect number of pods: expected {{ (num_dc | int) * (pods_per_dc | int) }} found {{ total_pods }}"
- name: Test difference
when: "(max_pods | int) - (min_pods | int) > 1"
fail:
msg: "Unbalanced pods: min = {{ min_pods }}, max = {{ max_pods }} "
- name: Make sure all services are reachable
shell: "{{ playbook_dir }}/check-services.sh {{ wildcard_domain }} {{ num_apps }}"
register: services_result
until: services_result.rc == 0
retries: 10
delay: 10
- when: target == 'routers'
block:
- name: Find routers
command: "oc get po -n openshift-ingress -o jsonpath='{.items[*].status.hostIP}'"
register: router_cmd
- name: Get number of ingress gateways
when: use_istio | bool
shell: "oc get po -n {{ control_plane }} -l istio=ingressgateway -o json | jq '.items | length'"
register: gateway_cmd
- name: Set routers
set_fact:
endpoints: "{{ router_cmd.stdout.split() }}"
num_routers: "{{ router_cmd.stdout.split() | length }}"
endpoint_port: 443
num_gateways: "{{ gateway_cmd.stdout if use_istio | bool else 0}}"
failed_when: num_routers != expected_routers or num_gateways != expected_gateways
- when: target == 'gateways'
block:
- name: Get ingress gateways
shell: "oc get po -n {{ control_plane }} -l istio=ingressgateway -o jsonpath='{.items[*].status.podIP}'"
register: gateway_cmd
- set_fact:
endpoints: "{{ gateway_cmd.stdout.split() }}"
num_gateways: "{{ gateway_cmd.stdout.split() | length }}"
num_routers: 0
endpoint_port: 8443
failed_when: num_gateways != expected_gateways
- when: target == 'services'
block:
- name: Find services
command: "oc get svc -n {{ namespace }} -o jsonpath='{.items[*].spec.clusterIP}'"
register: svc_cmd
- name: Set endpoints
set_fact:
endpoints: "{{ svc_cmd.stdout.split() }}"
num_routers: 0
num_gateways: 0
endpoint_port: 8443
failed_when: (endpoints | length) == 0
- name: Get number of virtual services
shell: "oc get vs -n {{ namespace }} -o json | jq '.items | length'"
register: virtualservices
- name: Get ingressgateway names
when: use_istio
shell: "oc get po -n {{ control_plane }} -l istio=ingressgateway -o name --no-headers | cut -f 2 -d '/'"
register: gateway_pods
- name: Get workload pod names
shell: "oc get po -n {{ namespace }} -l app=scale-test -o name --no-headers | cut -f 2 -d '/'"
register: workload_pods
- name: Reset counters
when: use_istio and record_envoy_stats
loop: "{{ gateway_pods.stdout.split() | product([ control_plane ]) | list + workload_pods.stdout.split() | product([ namespace ]) | list }}"
shell: "oc exec -n {{ item[1] }} -c istio-proxy {{ item[0] }} -- curl -s localhost:15000/reset_counters -X POST"
async: 60
poll: 0
register: stats_reset
- name: Wait for the info
when: use_istio and record_envoy_stats
loop: "{{ stats_reset.results }}"
async_status:
jid: "{{ item.ansible_job_id }}"
- name: Start test
include_role:
name: hyperfoil.hyperfoil_test
when: hyperfoil_deployer == "k8s"
vars:
# run_description: "{{ namespace }}%20R%3D{{ num_routers }}%20G%3D{{ num_gateways }}%20P%3D{{ total_pods }}%20VS%3D{{ virtualservices.stdout }}"
run_description: "sm2.1%20G%3D{{ num_gateways }}%20P%3D{{ total_pods }}%20{{ fork }}%20{{ (http2 == 'true') | ternary('http2', 'http1.1') }}"
- name: Capture info after test
when: use_istio and record_envoy_stats
include_tasks: capture-envoy-info.yaml
vars:
dest: "/tmp/envoy_{{test_runid}}_r{{ num_routers }}_g{{ num_gateways }}_d{{ num_dc }}.zip"
- name: Show run ID
debug:
msg: "Run ID was {{ test_runid }}"
- name: Fetch Hyperfoil stats
shell: "curl -s -k {{ hyperfoil_controller_protocol }}://{{ hyperfoil_controller_host }}:{{ hyperfoil_controller_port}}/run/{{ test_runid }}/stats/all -H 'accept: application/json' > /tmp/hf_{{ test_runid }}_r{{ num_routers }}_g{{ num_gateways }}_d{{ num_dc }}.json"