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

Merge Zuul Logging job #113

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
23 changes: 19 additions & 4 deletions .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-functional-test.yml"
roles:
- zuul: github.com/openstack-k8s-operators/ci-framework
required-projects:
required-projects: &required_projects
- name: github.com/infrawatch/service-telemetry-operator
- name: openstack-k8s-operators/ci-framework
override-checkout: main
Expand All @@ -35,6 +35,21 @@
- README*
- .*/*.md

- job:
name: functional-logging-tests-osp18
parent: telemetry-operator-multinode-logging
description: |
Run the logging functional test on osp18+patched version
vars:
cifmw_extras:
- "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/openstack-k8s-operators/ci-framework'].src_dir }}/scenarios/centos-9/multinode-ci.yml"
- "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/openstack-k8s-operators/telemetry-operator'].src_dir }}/ci/vars-logging.yml"
- "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-logging-test.yml"
roles:
- zuul: github.com/openstack-k8s-operators/ci-framework
required-projects: *required_projects
irrelevant-files: *irrelevant_files

- job:
name: feature-verification-tests-noop
parent: noop
Expand All @@ -45,12 +60,12 @@
- ci/noop.yml
files: *irrelevant_files


- project:
name: infrawatch/feature-verification-tests
github-check:
jobs:
- feature-verification-tests-noop
#- feature-verification-tests-noop
- openstack-k8s-operators-content-provider:
override-checkout: main
- functional-tests-on-osp18
#- functional-tests-on-osp18
- functional-logging-tests-osp18
41 changes: 31 additions & 10 deletions callback_plugins/custom_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import os
import re


from ansible.errors import AnsibleCallbackError
from ansible.errors import AnsibleError
from ansible.plugins.callback import CallbackBase

DOCUMENTATION = '''
Expand Down Expand Up @@ -41,6 +44,7 @@ def playbook_on_stats(self, stats):
self.log_summary_results(host)

def log_task_result(self, host, result, task_name):
print("logging task result: %s - %s - %s" % (host, result, task_name))
# test_run_result.out only interested in the test tasks, not setup or debug.
if "RHELOSP" in task_name or "RHOSO" in task_name:
if "RHELOSP" in task_name:
Expand All @@ -63,18 +67,35 @@ def log_task_result(self, host, result, task_name):
self.results[host][result] += 1

def log_summary_results(self, host):
# The issue is presenting itself in this method
file_path = os.path.join(self.output_dir, f"summary_results.log")
# temperorily add more detail to the output
print(self.results)

with open(file_path, 'w') as f:
f.write(f"Host: {host}\n")
f.write(f"Tasks Succeeded: {self.results[host]['passed']}\n")
f.write(f"Tasks Failed: {self.results[host]['failed']}\n")
f.write(f"Tasks Skipped: {self.results[host]['skipped']}\n")
f.write("Failed Tasks:\n")
for task_name in self.results[host]['failed_task_names']:
f.write(f" - {task_name}\n")
f.write("Succeeded Tasks:\n")
for task_name in self.results[host]['ok_task_names']:
f.write(f" - {task_name}\n")
# This is the failed issue.
# Why is it happening?
# Unknown. But does it happen for the other values.
# It is happening for compute-0
# I need to see the partial log file, so this should NOT cause a failure.
# try/catch ANY exception
# It could be a nice upgrade to use jinja2 template to render this file.
# IS the issue that there were 'f's preceeding the strings?
try:
f.write("Tasks Succeeded: {self.results[host]['passed']}\n")
f.write("Tasks Failed: {self.results[host]['failed']}\n")
f.write("Tasks Skipped: {self.results[host]['skipped']}\n")
f.write("Failed Tasks:\n")
for task_name in self.results[host]['failed_task_names']:
f.write(f" - {task_name}\n")
f.write("Succeeded Tasks:\n")
for task_name in self.results[host]['ok_task_names']:
f.write(f" - {task_name}\n")
except AnsibleError as e:
# this is probably an AnsibleCallbackError
print("Ooops, there was an error")
print(e)

def v2_runner_on_ok(self, result):
host = result._host.get_name()
Expand All @@ -89,4 +110,4 @@ def v2_runner_on_failed(self, result, ignore_errors=False):
def v2_runner_on_skipped(self, result):
host = result._host.get_name()
task_name = result._task.get_name()
self.log_task_result(host, 'skipped', task_name)
self.log_task_result(host, 'skipped', task_name)
3 changes: 3 additions & 0 deletions ci/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ callbacks_enabled = custom_logger
callback_plugins = ../callback_plugins
# additional paths to search for roles
roles_path = ../roles:/usr/share/ansible/roles:/etc/ansible/roles:~/.ansible/roles:../../ci-framework/roles

# temp update to get more information from the playbooks running functional tests
verbosity = 5
63 changes: 63 additions & 0 deletions ci/logging_tests_computes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
- name: Prepare Logging Tests
hosts: computes
gather_facts: false
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars_files:
- vars/common.yml
tasks:
- name: Create log dir
ansible.builtin.file:
path: "{{ logs_dir }}/logging_compute"
state: directory
mode: "0755"

- name: "Verify ctlplane logging containers and files"
hosts: computes
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
container_test_id: "RHOSO-12753"
container_list:
- ceilometer_agent_compute
- ceilometer_agent_ipmi
- node_exporter

file_test_id: "RHOSO-12754"
file_list:
- /etc/rsyslog.d/10-telemetry.conf
tasks:
- name: "Run file and container tests"
ansible.builtin.import_role:
name: common


- name: "Verify logging journalctl identifiers"
hosts: computes
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
identifiers_test_id: "RHOSO-12681"
identifiers_list:
- ceilometer_agent_compute
- nova_compute
tasks:
- name: "Verify journalctl logging identifiers"
ansible.builtin.import_role:
name: telemetry_logging

- name: Include report result
hosts: computes
tasks:
- ansible.builtin.include_tasks:
file: report_result.yml
vars:
test_dir: "{{ logs_dir }}/logging_local"
Loading
Loading