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

Add service tests to the logging job #153

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion roles/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ For cr\_tests.yml tasks:
- polarion ID number for each test of readiness of the CR



Dependencies
------------

Expand Down
2 changes: 2 additions & 0 deletions roles/common/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# defaults file for roles/common
13 changes: 13 additions & 0 deletions roles/common/tasks/container_status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: "[TEST] verify container status"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TEST prefix isn't chosen yet, so this may change

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix will be "TEST"

ansible.builtin.shell:
cmd: |
podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}" | grep "{{ container_name }}" | awk '{print $2}'
changed_when: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a failed_when, if you're going to mark it with a TEST prefix, otherwise, it'll pass as long as the shell cmd returns something.

Alternatively, don't mark this task as a test, but mark the following task as a test.

Currently, we rely on the custom_logger to produce a file that gathers the test-ids=passed|failed output, so there should be a test ID in the second line of the task name.
Hopefully, we can remove this at some point soon, and add a check to report_result that checks the junit output instead.

register: container_status

- name: Fail if container is not 'Up'
ansible.builtin.fail:
msg: "Container '{{ container_name }}' is not in 'Up' status. Current status: {{ container_status.stdout }}"
when:
- "'Up' not in container_status.stdout"
Comment on lines +9 to +13
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, it makes it clear why the test failed.

However, this task should be the one one with TEST in the name.

2 changes: 1 addition & 1 deletion roles/common/tasks/service_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
that:
- "'NotFound' not in output.stderr"
success_msg: "service {{ item }} is running."
fail_msg: "service {{ item }} not running. Error: {{ output.stderr }}"
fail_msg: "service {{ item }} not running. Error: {{ output.stderr }}"
2 changes: 2 additions & 0 deletions roles/common/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for roles/common
Loading