Skip to content

Commit

Permalink
Upload and publish test results (#71)
Browse files Browse the repository at this point in the history
* Add gh actions to publish pre-release's test results
  • Loading branch information
luckslovez authored Oct 31, 2023
1 parent 70d2ee2 commit 41584ad
Show file tree
Hide file tree
Showing 21 changed files with 538 additions and 322 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:

# Runs E2E tests using the packages available in the tmp-pr-#PR prerelease
run_e2e_tests:
needs: [ setup_environment, sign_suse_packages, upload_official_packages_to_prerelease]
needs: [ setup_environment, sign_suse_packages, upload_official_packages_to_prerelease ]
name: Run E2E tests
uses: ./.github/workflows/run_e2e_tests.yml
with:
Expand Down
33 changes: 31 additions & 2 deletions .github/workflows/run_e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,39 @@ jobs:
container_make_target: "ansible/provision-and-execute-tests PR_NUMBER=${{ github.event.pull_request.number }}"
secrets: inherit

report_test_results:
name: Report results
runs-on: ubuntu-20.04
needs: provision_and_execute_tests
env:
GH_TOKEN: ${{ github.token }}
PRE_RELEASE_NAME: tmp-pr-${{ github.event.pull_request.number }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download report from pre-release
run: |
gh release download ${{ env.PRE_RELEASE_NAME }} --pattern 'tests-report.xml'
- name: Tests Report Details
uses: dorny/test-reporter@v1
with:
name: Tests Report Details # Name of the check run which will be created
path: tests-report.xml # Path to test results
reporter: jest-junit

- name: Tests Report Summary
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
tests-report.xml
tear_down_test_executor_instances:
name: Tear down test executor instances
needs: provision_and_execute_tests
needs: report_test_results
uses: ./.github/workflows/run_task.yml
with:
container_make_target: "terraform-clean TERRAFORM_PROJECT=ec2-test-executors PR_NUMBER=${{ github.event.pull_request.number }}"
secrets: inherit
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/run_task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-duration-seconds: 10800 # default to 1 hour, which might not suffice https://github.com/aws-actions/configure-aws-credentials#credential-lifetime
aws-region: us-east-2

- name: Set branch name
Expand Down
2 changes: 1 addition & 1 deletion ansible/provision-and-execute-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include ../Ansible.common.mk

.PHONY: provision-and-execute-tests
provision-and-execute-tests: ansible/dependencies ansible/prepare-inventory
ansible-playbook $(ANSIBLE_FOLDER)/playbook.yml -i $(ANSIBLE_INVENTORY)
ansible-playbook -vvv $(ANSIBLE_FOLDER)/playbook.yml -i $(ANSIBLE_INVENTORY)

.PHONY: clean
clean: ansible/clean
25 changes: 21 additions & 4 deletions ansible/provision-and-execute-tests/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
monitored_systemd_unit: "{{ (tags.os_distro == 'ubuntu' or tags.os_distro == 'debian') | ternary('ssh','sshd') }}"

test_reports_dir: /tmp/test-reports
nr_fb_output_plugin_version: 1.17.1
environment:
NEW_RELIC_API_KEY: "{{ new_relic_api_key }}"
NEW_RELIC_ACCOUNT_ID: "{{ new_relic_account_id }}"
Expand Down Expand Up @@ -61,6 +62,13 @@
gh_prerelease_tag: "tmp-pr-{{ pr_number }}"
when: pr_number is not regex('^local-.*')

- name: Install NR Fluent Bit output
ansible.builtin.include_role:
name: install_nr_fluent_bit_output
vars:
plugin_arch: "{{ (arch == 'x86_64' or arch == 'amd64') | ternary('amd64','arm64') }}"
plugin_version: "{{ nr_fb_output_plugin_version }}"

- name: Copy test suite
ansible.builtin.copy:
src: ../../integration-tests/test-suite
Expand Down Expand Up @@ -122,8 +130,8 @@

monitored_file: 'C:\Users\Administrator\tail-log-file-test'
monitored_tcp_port: 5170
monitored_windows_log_name_using_winevtlog: "Application"
monitored_windows_log_name_using_winlog: "Application"
monitored_windows_log_name_using_winevtlog: 'Application'
monitored_windows_log_name_using_winlog: 'Application'

test_suite_folder: 'C:\Windows\Temp\test-suite'
test_suite_report_path: '{{ test_suite_folder }}\reports\tests\test-report.xml'
Expand All @@ -135,6 +143,8 @@
# the PATH environment using Ansible's "environment" clause for these steps requiring nvm, node or npm to be in the PATH.
nvm_path: 'C:\ProgramData\nvm'
node_path: 'C:\ProgramData\nvm\v{{ node_version }}'

nr_fb_output_plugin_version: '1.17.1'
environment:
NEW_RELIC_API_KEY: "{{ new_relic_api_key }}"
NEW_RELIC_ACCOUNT_ID: "{{ new_relic_account_id }}"
Expand Down Expand Up @@ -172,6 +182,13 @@
gh_prerelease_tag: "tmp-pr-{{ pr_number }}"
when: pr_number is not regex('^local-.*')

- name: Install NR Fluent Bit output
ansible.builtin.include_role:
name: install_nr_fluent_bit_output
vars:
plugin_arch: "{{ (arch == 'win64') | ternary('amd64','386') }}"
plugin_version: "{{ nr_fb_output_plugin_version }}"

- name: Install NVM
win_chocolatey:
name: nvm.install
Expand Down Expand Up @@ -242,7 +259,7 @@
node_version: 18.18.0
controller_scripts_folder: ../../integration-tests/controller-scripts
test_reports_dir: /tmp/test-reports
combined_test_report_name: report.xml
combined_test_report_name: tests-report.xml
pr_number: "{{ lookup('ansible.builtin.env', 'PR_NUMBER') }}"
roles:
- andrewrothstein.gh
Expand All @@ -267,5 +284,5 @@
TEST_REPORT_NAME: "{{ combined_test_report_name }}"

- name: Upload generated artifacts to release
command: "gh release upload tmp-pr-{{ pr_number }} {{ test_reports_dir }}/{{ combined_test_report_name }}"
command: "gh release upload tmp-pr-{{ pr_number }} {{ test_reports_dir }}/{{ combined_test_report_name }} --clobber"
when: pr_number is not regex('^local-.*')
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Role Name
=========

This roles makes the infra agent use a specific version (plugin_arch) of the NR FB output plugin.

Role Variables
--------------

The role requires the following variables:
- `plugin_arch`: The name of the plugin_architecture, matching the case of [the output plugin artifact names](https://github.com/newrelic/newrelic-fluent-bit-output/releases)
(`arm64`, `amd64`, `386`)
- `plugin_version`: The Fluent Bit package name to download from the [NR FB Output Plugin releases](https://github.com/newrelic/newrelic-fluent-bit-output/releases)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- name: Load Linux variables
ansible.builtin.include_vars: "linux.yml"

- name: Stop newrelic-infra service
ansible.builtin.service:
name: newrelic-infra
state: stopped
become: true

- name: Download NR FB Output Plugin
ansible.builtin.get_url:
url: "{{ nr_fb_output_plugin_url }}"
dest: "{{ nr_fb_output_plugin_download_file_path }}"

- name: Modify Infrastructure Agent config to point to downloaded NR FB Output Plugin
ansible.builtin.lineinfile:
path: "{{ infra_agent_config_file_absolute_path }}"
line: 'fluent_bit_nr_lib_path: {{ nr_fb_output_plugin_download_file_path }}'
become: true

- name: Start again newrelic-infra service with new NR FB Output plugin
ansible.builtin.service:
name: newrelic-infra
state: started
become: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Check mandatory variables (all distros)
assert:
that:
- plugin_arch is defined
- plugin_version is defined

- name: Install specific NR Fluent Bit output Linux plugin
include_tasks: "linux.yml"
when: ansible_system == 'Linux'

- name: Install specific NR Fluent Bit output Windows plugin
include_tasks: "windows.yml"
when: ansible_system != 'Linux'
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- name: Load Windows variables
ansible.builtin.include_vars: "windows.yml"

- name: Stop newrelic-infra service
ansible.windows.win_service:
name: newrelic-infra
state: stopped

- name: Download NR FB Output Plugin
ansible.windows.win_get_url:
url: "{{ nr_fb_output_plugin_url }}"
dest: '{{ nr_fb_output_plugin_download_file_path }}'

- name: Modify Infrastructure Agent config to point to downloaded NR FB Output Plugin
community.windows.win_lineinfile:
path: "{{ infra_agent_config_file_absolute_path }}"
line: 'fluent_bit_nr_lib_path: {{ nr_fb_output_plugin_download_file_path }}'

- name: Start again newrelic-infra service with new NR FB Output plugin
ansible.windows.win_service:
name: newrelic-infra
state: started
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
infra_agent_config_file_absolute_path: /etc/newrelic-infra.yml
nr_fb_output_file_extension: 'so'
nr_fb_output_plugin_artifact: 'out_newrelic-linux-{{ plugin_arch }}-{{ plugin_version }}.{{ nr_fb_output_file_extension }}'
nr_fb_output_plugin_url: "https://github.com/newrelic/newrelic-fluent-bit-output/releases/download/v{{ plugin_version }}/{{ nr_fb_output_plugin_artifact }}"
nr_fb_output_plugin_download_file_path: "/tmp/out_newrelic.{{ nr_fb_output_file_extension }}'"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
infra_agent_config_file_absolute_path: C:\Program Files\New Relic\newrelic-infra\newrelic-infra.yml
nr_fb_output_file_extension: 'dll'
nr_fb_output_plugin_artifact: 'out_newrelic-windows-{{ plugin_arch }}-{{ plugin_version }}.{{ nr_fb_output_file_extension }}'
nr_fb_output_plugin_url: "https://github.com/newrelic/newrelic-fluent-bit-output/releases/download/v{{ plugin_version }}/{{ nr_fb_output_plugin_artifact }}"
nr_fb_output_plugin_download_file_path: 'C:\Windows\Temp\out_newrelic.{{ nr_fb_output_file_extension }}'
Loading

0 comments on commit 41584ad

Please sign in to comment.