Skip to content

Commit 41a776d

Browse files
committed
feat: run integration tests on more platforms
1 parent ef3dd29 commit 41a776d

7 files changed

Lines changed: 98 additions & 41 deletions

File tree

.github/workflows/integration-tests.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
vm:
2828
- fedora-coreos
2929
- fcarm
30+
- rhel
31+
- rhel-arm64
32+
- rhcos
3033

3134
steps:
3235
- uses: actions/checkout@v4
@@ -80,11 +83,25 @@ jobs:
8083
quay:
8184
username: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}
8285
password: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}
86+
excluded_vms:
87+
# RHEL 8 doesn't handle file creation properly,
88+
# need more investigation
89+
- rhel-8
90+
- rhcos-412-86-202402272018-0-gcp-x86-64
91+
- rhcos-414-92-202407091253-0-gcp-x86-64
92+
# BPF trampolines are only implemented starting with RHEL 10
93+
- rhel-9-arm64
8394
EOF
8495
8596
- name: Create Test VMs
97+
env:
98+
ANSIBLE_CONFIG: "${{ github.workspace }}/collector/ansible/ansible.cfg"
8699
run: |
87-
make -C "./collector/ansible" create-ci-vms
100+
ansible-playbook \
101+
-i "${GITHUB_WORKSPACE}/collector/ansible/ci" \
102+
-e @vars.yml \
103+
--tags setup,provision \
104+
"${GITHUB_WORKSPACE}/collector/ansible/integration-tests.yml"
88105
89106
- name: Run the tests
90107
env:
@@ -103,17 +120,17 @@ jobs:
103120
- name: Unarchive logs
104121
if: always()
105122
run: |
106-
cd "${GITHUB_WORKSPACE}/fact/tests"
107-
if [[ -f "logs.tar.gz" ]]; then
108-
tar xzf "logs.tar.gz"
109-
rm -f "logs.tar.gz"
110-
fi
123+
cd "/tmp/fact/tests"
124+
for file in logs/*.tar.gz; do
125+
tar xzf "$file"
126+
rm -f "$file"
127+
done
111128
112129
- name: Test summary
113130
uses: test-summary/action@v2
114131
if: always()
115132
with:
116-
paths: ${{ github.workspace }}/fact/tests/results.xml
133+
paths: /tmp/fact/tests/*-results.xml
117134

118135
- name: Store artifacts
119136
if: always()
@@ -125,6 +142,6 @@ jobs:
125142
with:
126143
name: ${{ matrix.vm }}-test-logs
127144
path: |
128-
${{ github.workspace }}/fact/tests/logs
129-
${{ github.workspace }}/fact/tests/results.xml
145+
/tmp/fact/tests/logs
146+
/tmp/fact/tests/*-results.xml
130147
if-no-files-found: ignore

ansible/group_vars/all.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
runtime_command: docker
3+
runtime_host: 'unix:///var/run/docker.sock'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
ansible_user: core
3+
runtime_host: "unix:///run/podman/podman.sock"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
ansible_user: core
3+
runtime_host: "unix:///run/podman/podman.sock"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
runtime_host: "unix:///run/podman/podman.sock"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
runtime_host: "unix:///run/podman/podman.sock"

ansible/run-tests.yml

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,90 @@
55
FACT_IMAGE_NAME: "{{ fact.image | default(None) }}"
66

77
tasks:
8-
- name: Install dependencies
9-
become: true
10-
community.general.rpm_ostree_pkg:
11-
apply_live: true
12-
name:
13-
- make
14-
- python3-packaging
15-
- python3-requests
16-
state: present
17-
18-
- name: Login to quay.io
19-
community.docker.docker_login:
20-
registry_url: quay.io
21-
username: "{{ quay.username }}"
22-
password: "{{ quay.password }}"
23-
248
- name: Clone the repo
259
ansible.builtin.git:
2610
repo: https://github.com/stackrox/fact
27-
dest: ./fact
11+
dest: /tmp/fact
2812
version: "{{ fact.version }}"
2913
update: false
3014

31-
- name: Install python packages
32-
ansible.builtin.pip:
33-
requirements: ./fact/tests/requirements.txt
34-
chdir: "{{ ansible_env.HOME }}"
35-
virtualenv: ./fact/.venv
36-
virtualenv_command: python3 -m venv
15+
- name: Log into quay.io
16+
become: true
17+
shell:
18+
cmd: "{{ runtime_command }} login -u {{ quay.username }} --password-stdin quay.io"
19+
stdin: "{{ quay.password }}"
20+
21+
- name: Copy podman auth
22+
become: true
23+
shell:
24+
cmd: |
25+
mkdir -p ~/.docker/
26+
if [[ -f "${XDG_RUNTIME_DIR:-}/containers/auth.json" ]]; then
27+
AUTH_FILE="${XDG_RUNTIME_DIR:-}/containers/auth.json"
28+
elif [[ -f "/run/containers/0/auth.json" ]]; then
29+
AUTH_FILE="/run/containers/0/auth.json"
30+
else
31+
echo &>2 "No valid auth.json file found"
32+
exit 1
33+
fi
34+
cp "${AUTH_FILE}" ~/.docker/config.json
35+
creates: ~/.docker/config.json
36+
when: runtime_command == "podman"
3737

3838
- block:
39+
# There are some ansible modules that we could use to modularize
40+
# this next task, however they required some Python modules to be
41+
# installed on the managed VM that may not be available (like
42+
# python3-packaging), so we stick to a shell as ugly as it is.
3943
- name: Run tests
44+
become: true
45+
environment:
46+
DOCKER_HOST: "{{ runtime_host }}"
4047
ansible.builtin.shell:
4148
cmd: |
42-
cd "${HOME}/fact"
43-
source ".venv/bin/activate"
44-
make integration-tests
49+
set -euo pipefail
50+
cd "/tmp/fact/tests"
51+
52+
# Setup the virtual environment
53+
python3 -m venv .venv
54+
source .venv/bin/activate
55+
pip install -r requirements.txt
56+
57+
# Generate gRPC files
58+
python3 -m grpc_tools.protoc \
59+
-I../third_party/stackrox/proto \
60+
--python_out=. \
61+
--pyi_out=. \
62+
--grpc_python_out=. \
63+
../third_party/stackrox/proto/internalapi/sensor/collector.proto \
64+
../third_party/stackrox/proto/internalapi/sensor/sfa.proto \
65+
../third_party/stackrox/proto/internalapi/sensor/sfa_iservice.proto
66+
67+
# Run the tests
68+
pytest --image="${FACT_IMAGE_NAME}" --junit-xml=results.xml
69+
4570
always:
71+
- name: Make logs directories
72+
ansible.builtin.file:
73+
state: directory
74+
path: /tmp/fact/tests/logs
75+
recurse: true
76+
delegate_to: localhost
77+
4678
- name: Retrieve results
4779
ansible.builtin.fetch:
48-
src: "{{ ansible_env.HOME }}/fact/tests/results.xml"
49-
dest: ../tests/
80+
src: /tmp/fact/tests/results.xml
81+
dest: "/tmp/fact/tests/{{ vm_config }}-results.xml"
5082
flat: true
5183

5284
- name: Compress log files
5385
community.general.archive:
54-
path: "{{ ansible_env.HOME }}/fact/tests/logs"
55-
dest: "{{ ansible_env.HOME }}/fact/tests/logs.tar.gz"
86+
path: /tmp/fact/tests/logs
87+
dest: "/tmp/fact/tests/{{ vm_config }}.tar.gz"
5688

5789
- name: Fetch log files
5890
ansible.builtin.fetch:
59-
src: "{{ ansible_env.HOME }}/fact/tests/logs.tar.gz"
60-
dest: ../tests/logs.tar.gz
91+
src: "/tmp/fact/tests/{{ vm_config }}.tar.gz"
92+
dest: /tmp/fact/tests/logs/
93+
validate_checksum: false
6194
flat: true

0 commit comments

Comments
 (0)