forked from newrelic/infrastructure-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shutdown-and-terminate.yml
138 lines (113 loc) · 3.54 KB
/
shutdown-and-terminate.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
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
137
138
---
- name: install agent linux (HNR)
hosts: testing_hosts_linux
gather_facts: yes
become: true
vars:
agent_user: root
env_vars:
pre_tasks:
- name: initial cleanup # Only required for shared infra.
include_role:
name: cleanup
tasks:
- name: repo setup
include_role:
name: repo-setup
- name: setup config
include_role:
name: setup-config
vars:
display_name: "{{ iid }}:{{ inventory_hostname }}"
- name: install agent
include_role:
name: agent-install
- name: assert service
include_role:
name: assert-service
- name: install agent windows (HNR)
hosts: testing_hosts_windows
gather_facts: yes
tasks:
- name: setup config
include_role:
name: setup-config
vars:
display_name: "{{ iid }}:{{ inventory_hostname }}"
- name: install agent
include_role:
name: agent-install
vars:
display_name: "{{ iid }}:{{ inventory_hostname }}"
- name: assert service
include_role:
name: assert-service
- name: test agent behaviour on host shutdown
hosts: testing_hosts
vars:
# Add here hosts of the instances that doesn't support Smart HNR (shutdown detection) e.g. - "amd64:ubuntu14.04"
instances_not_supporting_shutdown_detection: {
"amd64:debian-jessie"
}
host_supports_shutdown_detection: >-
{{
true if inventory_hostname not in instances_not_supporting_shutdown_detection
else false
}}
tasks:
- name: pause a bit to let the agent send some data
pause:
minutes: 1
- name: restart the agent
include_role:
name: agent-restart
- name: pause for a bit to let the agent initialize
pause:
seconds: 30
- name: Get entity id
import_role:
name: get_agent_entity_id
- name: assert agent restart don't trigger shutdown event
include_role:
name: agent-host-status-event-assert
vars:
host_status: "shutdown"
expect_change_event: false
since_sec_ago: 30
- name: stop instances
include_role:
name: ec2-stop
- name: pause for a bit to let the event fire
pause:
seconds: 30
- name: assert that the agent detecteded host shutdown and disconnected from the backend (only on hosts that support shutdown detection)
include_role:
name: agent-host-status-event-assert
vars:
host_status: "shutdown"
expect_change_event: "{{ host_supports_shutdown_detection }}"
timestamp_ref: "{{ ec2_stop_time_sec | int }}"
- name: start instances
include_role:
name: ec2-start
- name: assert the agent performed connect to the backend (only on hosts that support shutdown detection)
include_role:
name: agent-host-status-event-assert
vars:
host_status: "running"
expect_change_event: "{{ host_supports_shutdown_detection }}"
timestamp_ref: "{{ ec2_start_time_sec | int }}"
- name: terminate instances
include_role:
name: ec2-terminate
- name: pause for a bit to let the event fire
pause:
seconds: 30
- name: assert that the agent detecteded host termination and disconnected from the backend (only on hosts that support shutdown detection)
include_role:
name: agent-host-status-event-assert
vars:
host_status: "shutdown"
expect_change_event: "{{ host_supports_shutdown_detection }}"
timestamp_ref: "{{ ec2_terminate_time_sec | int }}"
...