Skip to content

Commit 96f7814

Browse files
test: add onhost eBPF e2e test (#1631)
1 parent 23e28f1 commit 96f7814

File tree

7 files changed

+152
-19
lines changed

7 files changed

+152
-19
lines changed

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
uses: ./.github/workflows/component_onhost_e2e.yaml
8383
needs: [ upload-packages-s3 ]
8484
with:
85-
scenarios: '["migration.yaml", "remote_config.yaml"]'
85+
scenarios: '["migration.yaml", "remote_config.yaml", "ebpf_agent.yaml"]'
8686
repository_endpoint: "http://nr-downloads-ohai-testing.s3-website-us-east-1.amazonaws.com/preview"
8787
package_version: 0.100.${{ github.run_id }}
8888
secrets:

.github/workflows/prerelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
uses: ./.github/workflows/component_onhost_e2e.yaml
106106
needs: [ upload ]
107107
with:
108-
scenarios: '["migration.yaml", "remote_config.yaml"]'
108+
scenarios: '["migration.yaml", "remote_config.yaml", "ebpf_agent.yaml"]'
109109
repository_endpoint: "http://nr-downloads-ohai-testing.s3-website-us-east-1.amazonaws.com/preview"
110110
package_version: ${{ github.event.inputs.tag || github.event.release.tag_name }}
111111
secrets:
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
- name: Test eBPF Agent
3+
hosts: 127.0.0.1
4+
connection: local
5+
become: true
6+
gather_facts: yes
7+
8+
tasks:
9+
- name: Test eBPF Agent
10+
block:
11+
- name: Cleanup
12+
include_tasks: ./tasks/clean_all.yaml
13+
14+
# Currently eBPF Agent is not embedded in the AC package but installed along side it with the recipe.
15+
# NEW_RELIC_AGENT_CONTROL=true disables the systemd service so the Agent is controlled by AC.
16+
- name: Install eBPF Agent
17+
shell: |
18+
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | \
19+
bash && sudo \
20+
NEW_RELIC_CLI_SKIP_CORE=1 \
21+
NEW_RELIC_LICENSE_KEY={{ nr_license_key }} \
22+
NEW_RELIC_API_KEY={{ nr_api_key }} \
23+
NEW_RELIC_ACCOUNT_ID={{ nr_account_id }} \
24+
NEW_RELIC_REGION=US \
25+
NEW_RELIC_AGENT_CONTROL=true \
26+
/usr/local/bin/newrelic install -n ebpf-agent-installer
27+
register: out
28+
- debug:
29+
var: out.stdout_lines
30+
31+
- name: Install Agent Control
32+
include_role:
33+
name: newrelic-agent-control
34+
35+
- name: Register agent control version
36+
command: "/usr/bin/newrelic-agent-control --version"
37+
register: version
38+
39+
- name: Assert version
40+
include_role:
41+
name: caos.ansible_roles.assert_version
42+
vars:
43+
target_versions:
44+
- exec: "/usr/bin/newrelic-agent-control --version"
45+
version: "{{ package_version }}"
46+
when: package_version | length > 0
47+
48+
- name: Debug agent control version
49+
debug:
50+
var: version.stdout
51+
52+
- name: Setup AC config
53+
include_role:
54+
name: edit_yaml_config
55+
vars:
56+
config_path: "/etc/newrelic-agent-control/config.yaml"
57+
update_config:
58+
log:
59+
format:
60+
ansi_colors: true
61+
target: true
62+
level: debug
63+
agents:
64+
nr-infra:
65+
agent_type: "newrelic/com.newrelic.infrastructure:0.1.0"
66+
nr-ebpf:
67+
agent_type: "newrelic/com.newrelic.ebpf:0.1.0"
68+
69+
- name: Add license to service
70+
shell: echo 'NEW_RELIC_LICENSE_KEY="{{ nr_license_key }}"' >> {{ agent_control_service_conf }}
71+
72+
- name: Set test identifier
73+
set_fact:
74+
test_id: "onhost-e2e-ebpf_{{ lookup('pipe', 'date +%Y-%m-%d_%H-%M-%S') }}"
75+
76+
- name: eBPF Agent config folder
77+
file:
78+
path: /etc/newrelic-agent-control/fleet/agents.d/nr-ebpf/values/
79+
state: directory
80+
81+
- name: eBPF Agent local config
82+
copy:
83+
dest: /etc/newrelic-agent-control/fleet/agents.d/nr-ebpf/values/values.yaml
84+
content: |
85+
config_agent:
86+
DEPLOYMENT_NAME: {{ test_id }}
87+
88+
# The infra-agent is used to generate traffic for ebpf metrics to appear.
89+
- name: Infra Agent config folder
90+
file:
91+
path: /etc/newrelic-agent-control/fleet/agents.d/nr-infra/values/
92+
state: directory
93+
94+
- name: Infra Agent local config
95+
copy:
96+
dest: /etc/newrelic-agent-control/fleet/agents.d/nr-infra/values/values.yaml
97+
content: |
98+
config_agent: |+
99+
status_server_enabled: true
100+
status_server_port: 18003
101+
license_key: {{'{{'}}NEW_RELIC_LICENSE_KEY{{'}}'}}
102+
103+
- name: Restart Agent Control
104+
include_role:
105+
name: caos.ansible_roles.service_status
106+
vars:
107+
service_name: "newrelic-agent-control"
108+
action: "restart"
109+
110+
- name: Assert that the eBPF Agent is reporting data
111+
include_role:
112+
name: nrql_api_request
113+
apply:
114+
become: false
115+
vars:
116+
nrql_query: >-
117+
SELECT *
118+
FROM Metric
119+
WHERE metricName = 'ebpf.tcp.connection_duration'
120+
AND deployment.name = '{{ test_id }}'
121+
LIMIT 1
122+
retries: 60
123+
delay: 5
124+
125+
always:
126+
- name: AC logs
127+
shell: journalctl -u newrelic-agent-control --no-pager
128+
register: ac_logs
129+
130+
- name: Debug AC logs
131+
debug:
132+
var: ac_logs.stdout_lines
133+
134+
- name: Cleanup
135+
include_tasks: ./tasks/clean_all.yaml

test/onhost-e2e/ansible/migration.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@
1616
test_id: "migration_infra_to_ac_{{ lookup('pipe', 'date +%Y-%m-%d_%H-%M-%S') }}"
1717

1818
- name: Install Infra Agent
19-
include_role:
20-
name: newrelic.newrelic_install
21-
apply:
22-
environment:
23-
NEW_RELIC_API_KEY: "{{ nr_api_key }}"
24-
NEW_RELIC_ACCOUNT_ID: "{{ nr_account_id | int }}"
25-
NEW_RELIC_REGION: "US"
26-
vars:
27-
targets:
28-
- infrastructure
29-
- logs
19+
shell: |
20+
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | \
21+
bash && sudo \
22+
NEW_RELIC_CLI_SKIP_CORE=1 \
23+
NEW_RELIC_LICENSE_KEY={{ nr_license_key }} \
24+
NEW_RELIC_API_KEY={{ nr_api_key }} \
25+
NEW_RELIC_ACCOUNT_ID={{ nr_account_id }} \
26+
NEW_RELIC_REGION=US \
27+
/usr/local/bin/newrelic install -n infrastructure-agent-installer
28+
register: out
29+
- debug:
30+
var: out.stdout_lines
3031

3132
- name: Change Infra Agent config
3233
copy:

test/onhost-e2e/ansible/remote_config.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@
6262
log:
6363
format:
6464
target: true
65-
# newrelic_agent_control::sub_agent::on_host::command::logging=debug -> sub agent logs
66-
# opamp_client=trace -> opamp raw messages
67-
insecure_fine_grained_level: "newrelic_agent_control=info,newrelic_agent_control::sub_agent::on_host::command::logging=debug,opamp_client=trace,off"
65+
level: debug
6866
agents:
6967
nr-infra:
7068
agent_type: "newrelic/com.newrelic.infrastructure:0.1.0"

test/onhost-e2e/ansible/requirements.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ collections:
22
- name: git+https://github.com/newrelic-experimental/caos-ansible-roles.git#/caos.ansible_roles/
33
type: git
44
- name: ansible.utils
5-
6-
roles:
7-
- name: newrelic.newrelic_install

test/onhost-e2e/ansible/tasks/clean_all.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
- /var/run/newrelic-infra
1515
- /var/log/newrelic-infra
1616
- /etc/systemd/system/newrelic-infra.service
17+
- /etc/newrelic-ebpf-agent
1718
packages_to_cleanup:
1819
- newrelic-agent-control
1920
- newrelic-infra
21+
- newrelic-ebpf-agent
2022
services_to_stop:
2123
- newrelic-agent-control
2224
- newrelic-infra

0 commit comments

Comments
 (0)