-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenTelemetry Collector: Add tests and support version latest (#299)
Co-authored-by: Ishan Jain <[email protected]>
- Loading branch information
1 parent
0700e38
commit de4f1e4
Showing
13 changed files
with
387 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
name: OpenTelemetry Collector Molecule | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
working-directory: roles/opentelemetry_collector | ||
|
||
jobs: | ||
molecule: | ||
name: Molecule | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
scenario: | ||
- default | ||
- latest | ||
- non-contrib | ||
|
||
steps: | ||
- name: Check out the codebase. | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3. | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install test dependencies. | ||
run: pip3 install ansible molecule molecule-plugins[docker] docker pytest-testinfra | ||
|
||
- name: Run Molecule tests. | ||
run: molecule test -s ${{ matrix.scenario }} | ||
env: | ||
PY_COLORS: '1' | ||
ANSIBLE_FORCE_COLOR: '1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
roles/opentelemetry_collector/molecule/default/converge.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
- name: "Run role" | ||
hosts: all | ||
any_errors_fatal: true | ||
roles: | ||
- grafana.grafana.opentelemetry_collector | ||
vars: | ||
otel_collector_receivers: | ||
hostmetrics: | ||
scrapers: | ||
cpu: | ||
memory: | ||
otel_collector_processors: | ||
memory_limiter: | ||
check_interval: 2s | ||
limit_percentage: 80 | ||
spike_limit_percentage: 25 | ||
batch: | ||
otel_collector_exporters: | ||
prometheus: | ||
endpoint: '127.0.0.1:9999' | ||
otel_collector_service: | ||
pipelines: | ||
metrics: | ||
receivers: '{{ otel_collector_receivers.keys() }}' | ||
processors: '{{ otel_collector_processors.keys() }}' | ||
exporters: '{{ otel_collector_exporters.keys() }}' |
44 changes: 44 additions & 0 deletions
44
roles/opentelemetry_collector/molecule/default/molecule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
platforms: | ||
- name: almalinux-9 | ||
image: dokken/almalinux-9 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: centos-stream-9 | ||
image: dokken/centos-stream-9 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: debian-11 | ||
image: dokken/debian-11 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: fedora-36 | ||
image: dokken/fedora-36 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: fedora-37 | ||
image: dokken/fedora-37 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: ubuntu-20.04 | ||
image: dokken/ubuntu-20.04 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: ubuntu-22.04 | ||
image: dokken/ubuntu-22.04 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd |
35 changes: 35 additions & 0 deletions
35
roles/opentelemetry_collector/molecule/default/tests/test_default.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
import os | ||
import testinfra.utils.ansible_runner | ||
|
||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
os.environ["MOLECULE_INVENTORY_FILE"] | ||
).get_hosts("all") | ||
|
||
|
||
def test_directories(host): | ||
dirs = [ | ||
"/etc/otel-collector", | ||
] | ||
files = ["/etc/otel-collector/config.yaml"] | ||
for directory in dirs: | ||
d = host.file(directory) | ||
assert d.is_directory | ||
assert d.exists | ||
for file in files: | ||
f = host.file(file) | ||
assert f.exists | ||
assert f.is_file | ||
|
||
|
||
def test_service(host): | ||
s = host.service("otel-collector") | ||
# assert s.is_enabled | ||
assert s.is_running | ||
|
||
|
||
def test_socket(host): | ||
assert host.socket("tcp://127.0.0.1:9999").is_listening |
28 changes: 28 additions & 0 deletions
28
roles/opentelemetry_collector/molecule/latest/converge.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: "Run role" | ||
hosts: all | ||
any_errors_fatal: true | ||
roles: | ||
- grafana.grafana.opentelemetry_collector | ||
vars: | ||
otel_collector_version: latest | ||
otel_collector_receivers: | ||
hostmetrics: | ||
scrapers: | ||
cpu: | ||
memory: | ||
otel_collector_processors: | ||
memory_limiter: | ||
check_interval: 2s | ||
limit_percentage: 80 | ||
spike_limit_percentage: 25 | ||
batch: | ||
otel_collector_exporters: | ||
prometheus: | ||
endpoint: '127.0.0.1:9999' | ||
otel_collector_service: | ||
pipelines: | ||
metrics: | ||
receivers: '{{ otel_collector_receivers.keys() }}' | ||
processors: '{{ otel_collector_processors.keys() }}' | ||
exporters: '{{ otel_collector_exporters.keys() }}' |
44 changes: 44 additions & 0 deletions
44
roles/opentelemetry_collector/molecule/latest/molecule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
platforms: | ||
- name: almalinux-9 | ||
image: dokken/almalinux-9 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: centos-stream-9 | ||
image: dokken/centos-stream-9 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: debian-11 | ||
image: dokken/debian-11 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: fedora-36 | ||
image: dokken/fedora-36 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: fedora-37 | ||
image: dokken/fedora-37 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: ubuntu-20.04 | ||
image: dokken/ubuntu-20.04 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: ubuntu-22.04 | ||
image: dokken/ubuntu-22.04 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd |
35 changes: 35 additions & 0 deletions
35
roles/opentelemetry_collector/molecule/latest/tests/test_default.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
import os | ||
import testinfra.utils.ansible_runner | ||
|
||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
os.environ["MOLECULE_INVENTORY_FILE"] | ||
).get_hosts("all") | ||
|
||
|
||
def test_directories(host): | ||
dirs = [ | ||
"/etc/otel-collector", | ||
] | ||
files = ["/etc/otel-collector/config.yaml"] | ||
for directory in dirs: | ||
d = host.file(directory) | ||
assert d.is_directory | ||
assert d.exists | ||
for file in files: | ||
f = host.file(file) | ||
assert f.exists | ||
assert f.is_file | ||
|
||
|
||
def test_service(host): | ||
s = host.service("otel-collector") | ||
# assert s.is_enabled | ||
assert s.is_running | ||
|
||
|
||
def test_socket(host): | ||
assert host.socket("tcp://127.0.0.1:9999").is_listening |
27 changes: 27 additions & 0 deletions
27
roles/opentelemetry_collector/molecule/non-contrib/converge.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
- name: "Run role" | ||
hosts: all | ||
any_errors_fatal: true | ||
roles: | ||
- grafana.grafana.opentelemetry_collector | ||
vars: | ||
otel_collector_type: '' | ||
otel_collector_receivers: | ||
hostmetrics: | ||
scrapers: | ||
cpu: | ||
memory: | ||
otel_collector_processors: | ||
memory_limiter: | ||
check_interval: 2s | ||
limit_percentage: 80 | ||
spike_limit_percentage: 25 | ||
batch: | ||
otel_collector_exporters: | ||
debug: | ||
otel_collector_service: | ||
pipelines: | ||
metrics: | ||
receivers: '{{ otel_collector_receivers.keys() }}' | ||
processors: '{{ otel_collector_processors.keys() }}' | ||
exporters: '{{ otel_collector_exporters.keys() }}' |
44 changes: 44 additions & 0 deletions
44
roles/opentelemetry_collector/molecule/non-contrib/molecule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
platforms: | ||
- name: almalinux-9 | ||
image: dokken/almalinux-9 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: centos-stream-9 | ||
image: dokken/centos-stream-9 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: debian-11 | ||
image: dokken/debian-11 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: fedora-36 | ||
image: dokken/fedora-36 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: fedora-37 | ||
image: dokken/fedora-37 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: ubuntu-20.04 | ||
image: dokken/ubuntu-20.04 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: ubuntu-22.04 | ||
image: dokken/ubuntu-22.04 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd |
31 changes: 31 additions & 0 deletions
31
roles/opentelemetry_collector/molecule/non-contrib/tests/test_default.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
import os | ||
import testinfra.utils.ansible_runner | ||
|
||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
os.environ["MOLECULE_INVENTORY_FILE"] | ||
).get_hosts("all") | ||
|
||
|
||
def test_directories(host): | ||
dirs = [ | ||
"/etc/otel-collector", | ||
] | ||
files = ["/etc/otel-collector/config.yaml"] | ||
for directory in dirs: | ||
d = host.file(directory) | ||
assert d.is_directory | ||
assert d.exists | ||
for file in files: | ||
f = host.file(file) | ||
assert f.exists | ||
assert f.is_file | ||
|
||
|
||
def test_service(host): | ||
s = host.service("otel-collector") | ||
# assert s.is_enabled | ||
assert s.is_running |
Oops, something went wrong.