Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROX-22866 save core dumps to collector ci artifacts with test names #1595

Draft
wants to merge 41 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f7acef7
X-Smart-Branch-Parent: master
JoukoVirtanen Mar 4, 2024
8bc3ded
Trying to get core dumps from CI artifacts.
JoukoVirtanen Mar 6, 2024
1178910
Ansible should get the core dumps and move them to the host machine
JoukoVirtanen Mar 6, 2024
63173a2
Added debugging
JoukoVirtanen Mar 7, 2024
72b4034
Moved the location of abort. Temporarily removed NetworkStatusNotifie…
JoukoVirtanen Mar 7, 2024
fa37810
More debugging
JoukoVirtanen Mar 7, 2024
c42bec5
Not checking if the tests are running locally before modifying the co…
JoukoVirtanen Mar 7, 2024
95dfff1
Not using sudo to modify core_pattern file
JoukoVirtanen Mar 7, 2024
bad2bf4
More debugging
JoukoVirtanen Mar 7, 2024
0d2516c
Trying to change core dump file path in the ansible playbook
JoukoVirtanen Mar 8, 2024
a3c8d0b
Checking tmp directory of integration tests
JoukoVirtanen Mar 8, 2024
c9a5c44
Trying to change the permissions of the core dump file
JoukoVirtanen Mar 8, 2024
3fda8d2
Core dump permissions are changed in the always section
JoukoVirtanen Mar 8, 2024
c41966b
Trying to check tmp directory
JoukoVirtanen Mar 8, 2024
801f645
Better debugging
JoukoVirtanen Mar 9, 2024
9264a4e
Using root user to fetch core dump
JoukoVirtanen Mar 9, 2024
564ae4e
Getting core dump files of the form /tmp/core.out.* not just /tmp/cor…
JoukoVirtanen Mar 9, 2024
b4292c1
Fixed error so that all core dumps should be fetched
JoukoVirtanen Mar 10, 2024
84e4aa3
Fetching core dump files in a loop
JoukoVirtanen Mar 10, 2024
577afc4
Trying to fix error
JoukoVirtanen Mar 10, 2024
56328e2
Using root to fetch core dump files
JoukoVirtanen Mar 10, 2024
3c11cd4
Trying to follow pattern for fetching log files
JoukoVirtanen Mar 10, 2024
f492202
Moving core dump files to their own directory
JoukoVirtanen Mar 10, 2024
4d7a7a7
Clean up
JoukoVirtanen Mar 10, 2024
f683eff
Removed intentional crash. Restored unit tests
JoukoVirtanen Mar 11, 2024
f9268d3
Removed unneeded line
JoukoVirtanen Mar 11, 2024
f645a1d
Removed blank lines
JoukoVirtanen Mar 11, 2024
25eab83
Trying to add test name to core dump path. Adding intentional seg fau…
JoukoVirtanen Mar 11, 2024
9e7f634
Fixed indentation
JoukoVirtanen Mar 11, 2024
9144e14
Trying to fix Write integration test log
JoukoVirtanen Mar 11, 2024
4c5c41a
Not using item for loop_var
JoukoVirtanen Mar 11, 2024
9f1e345
Fixed Output test log. Core dumps are written directly to /tmp/core_d…
JoukoVirtanen Mar 12, 2024
2d73cd3
Should run two tests one at a time
JoukoVirtanen Mar 12, 2024
81e8374
Check if directory exists before creating it
JoukoVirtanen Mar 12, 2024
9126289
Going through all of the integration tests. Not using an if statement…
JoukoVirtanen Mar 12, 2024
63cebb6
Trying to get a list of tests instead of hard coding them
JoukoVirtanen Mar 12, 2024
b3ea430
Cleaned up
JoukoVirtanen Mar 13, 2024
6bb231a
X-Smart-Branch-Parent: jv-ROX-22866-save-core-dumps-to-collector-ci-a…
JoukoVirtanen Mar 13, 2024
4111253
Using grep instead of go to get integration tests
JoukoVirtanen Mar 13, 2024
3d21129
Added debugging
JoukoVirtanen Mar 13, 2024
d7376d6
More debugging
JoukoVirtanen Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 64 additions & 6 deletions ansible/roles/run-test-target/tasks/test-collection-method.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,46 @@
collector_image: "{{ lookup('env', 'COLLECTOR_IMAGE', default='quay.io/rhacs-eng/collector:' + collector_tag_result.stdout) }}"
integration_tests_image: "{{ lookup('env', 'TEST_IMAGE', default='quay.io/rhacs-eng/qa-multi-arch:collector-tests-' + collector_tag_result.stdout) }}"

- name: Get list of tests
become: "{{ runtime_as_root }}"
shell: |
cd {{ collector_root }}/integration-tests
grep "func Test" integration_test.go | awk '{print $2}' | sed 's|(.*||'
#grep func\ Test integration_test.go | awk '{print $2}' | sed 's|(.*||'
#go test -list Test -test.run=^$
register: test_list

- name: Get contents of integration_test.go
become: "{{ runtime_as_root }}"
shell: |
cd {{ collector_root }}/integration-tests
cat integration_test.go
register: test_contents

- name: Output test contents
debug:
msg: "{{ test_contents.stdout_lines }}"

- name: Output test contents 2
debug:
msg: "{{ test_contents.stdout }}"

- name: Output list of tests
debug:
msg: "{{ test_list.stdout_lines }}"

- name: Output list of tests 2
debug:
msg: "{{ test_list.stdout }}"

- set_fact:
run_args: -test.run {{ collector_test }} -test.timeout 60m -test.count=1
tests_to_run:
- "{{ collector_test }}"
when: collector_test != "ci-integration-tests"

- set_fact:
run_args: -test.timeout 120m -test.short
when: collector_test == "ci-integration-tests"
tests_to_run: "{{ test_list.stdout_lines | select('regex', '^(Test\\w+)$') | map('regex_replace', '^(Test\\w+)$', '\\1') | list }}"
when: collector_test == "ci-integration-tests"

- name: Make logs directory
file:
Expand All @@ -50,6 +83,11 @@
creates: ~/.docker/config.json
when: runtime_command == "podman"

- name: Make core dumps directory
become: yes
shell: |
mkdir /tmp/core_dumps || true

- block:

# Some considerations for running the test container:
Expand All @@ -65,6 +103,7 @@
- name: Run integration tests
become: "{{ runtime_as_root }}"
shell: |
echo '/tmp/core_dumps/core-{{ test_to_run }}.out' | sudo tee /proc/sys/kernel/core_pattern
{{ runtime_command }} run -it --rm \
-v {{ remote_log_mount }}:{{ container_logs_root }} \
-v ~/.docker:/root/.docker \
Expand All @@ -78,7 +117,7 @@
-e COLLECTOR_QA_TAG \
-e COLLECTOR_LOG_LEVEL \
{{ integration_tests_image }} \
{{ run_args }} -test.v 2>&1
-test.run {{ test_to_run }} -test.timeout 60m -test.count=1 -test.v 2>&1
environment:
COLLECTION_METHOD: "{{ collection_method }}"
VM_CONFIG: "{{ vm_config }}"
Expand All @@ -89,6 +128,9 @@
register: test_result
# ensure that this is printed
tags: [print_action]
loop: "{{ tests_to_run }}"
loop_control:
loop_var: test_to_run

rescue:
- name: Set tests as failed
Expand All @@ -97,7 +139,7 @@

- name: Output test log
debug:
msg: "{{ test_result.stdout }}"
msg: "{{ test_result.results | map(attribute='stdout') | join('\n') }}"
tags: [print_action]

always:
Expand All @@ -123,10 +165,26 @@

- name: Write integration test log
copy:
content: "{{ test_result.stdout }}"
content: "{{ test_result.results | map(attribute='stdout') | join('\n') }}"
dest: "{{ logs_root }}/integration-test.log"
delegate_to: localhost

- name: Get core dump file paths
become: yes
find:
paths: "/tmp/core_dumps/"
register: core_files

- name: Fetch each core dump file
become: yes
fetch:
src: "{{ core_file }}"
dest: "{{ logs_root }}/"
flat: true
loop: "{{ core_files.files | map(attribute='path') | list }}"
loop_control:
loop_var: core_file

- name: Report
community.general.make:
chdir: "{{ integration_tests_root }}"
Expand Down
2 changes: 2 additions & 0 deletions collector/lib/NetworkStatusNotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ void NetworkStatusNotifier::RunSingleAfterglow(IDuplexClientWriter<sensor::Netwo
return;
}
}
int* ptr = nullptr;
*ptr = 10;
}
}

Expand Down
Loading
Loading