Skip to content

Commit

Permalink
Added support for logging e2e testcases from openshift-test-private repo
Browse files Browse the repository at this point in the history
Signed-off-by: Jeevan-Darapu <[email protected]>
  • Loading branch information
Jeevan-Darapu authored and Jeevan-Darapu committed Nov 27, 2024
1 parent eec3810 commit edf4e07
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,12 @@ coo_work_dir: "/tmp/coo_logs"
ocp_etcd_key_rotation_enable: false
encryption_type: "aescbc"
NUMBER: 1

# ocp-logging-tests-private-e2e vars
ocp_logging_tests_private_e2e_enabled: false #Set to true to enable logging e2e tests from openshift-tests-private repo
ocp_logging_tests_private_e2e_dir: /tmp/ocp_logging_tests_private/ #Test directory path
ocp_logging_tests_private_e2e_git: "https://github.com/openshift/openshift-tests-private/" #Git repo url for the e2e tests
ocp_logging_tests_private_e2e_git_branch: "" #Git repo branch for e2e tests
golang_tarball_logging_e2e: "https://dl.google.com/go/go1.22.6.linux-ppc64le.tar.gz" #HTTP URL for golang tarball
logging_e2e_testcases: "" #Set to either all or critical

9 changes: 9 additions & 0 deletions examples/ocp_logging_tests_private_e2e_vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

ocp_logging_tests_private_e2e_enabled: false #Set to true to enable logging e2e tests from openshift-tests-private repo
ocp_logging_tests_private_e2e_dir: /tmp/ocp_logging_tests_private/ #Test directory path
ocp_logging_tests_private_e2e_git: "https://github.com/openshift/openshift-tests-private/" #Git repo url for the e2e tests
ocp_logging_tests_private_e2e_git_branch: "release-4.12" #Git repo branch for e2e tests
golang_tarball_logging_e2e: "https://dl.google.com/go/go1.22.6.linux-ppc64le.tar.gz" #HTTP URL for golang tarball
logging_e2e_testcases: "" #Set to either all or critical

3 changes: 3 additions & 0 deletions playbooks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,6 @@

- import_playbook: ocp-etcd-rotate-encryption-key.yml
when: ocp_etcd_key_rotation_enable is defined and ocp_etcd_key_rotation_enable

- import_playbook: ocp-logging-tests-private-e2e.yml
when: ocp_logging_tests_private_e2e_enabled is defined and ocp_logging_tests_private_e2e_enabled
10 changes: 10 additions & 0 deletions playbooks/ocp-logging-tests-private-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

- name: Run logging related e2e test cases from openshift-tests-private repo
hosts: bastion
tasks:
- name: Run logging related e2e
include_role:
name: ocp-logging-tests-private-e2e
when: ocp_logging_tests_private_e2e_enabled == true

47 changes: 47 additions & 0 deletions playbooks/roles/ocp-logging-tests-private-e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
ocp-logging-tests-private-e2e: OCP End to End Logging Test Cases
=========

This module will run end to end Logging related test cases from openshift-tests-private repo. Results will be stored in ~/ocp_logging_tests_private_e2e_results/ directory on bastion.

Requirements
------------

- Running OCP 4.x cluster is needed.
- **Note:** It is recommended to create catalog source with name "qe-app-registry" before running playbook.

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

| Variable | Required | Default | Comments |
|-----------------------------|----------|--------------------------------------------|-----------------------------------------------------|
| ocp_logging_tests_private_e2e_git | no | https://github.com/openshift/openshift-tests-private/ | Git repo url for the logging e2e tests |
| ocp_logging_tests_private_e2e_git_branch | no | release-4.12 | Git repo branch for e2e tests Eg: To test 5.6.x then use release-4.12 branch, for 5.7.x use release-4.13 branch.....for 6.0.x use release-4.16 branch.|
| ocp_logging_tests_private_e2e_dir | no | /tmp/ocp_logging_tests_private/ | Test directory |
| golang_tarball_logging_e2e | no | https://dl.google.com/go/go1.22.6.linux-ppc64le.tar.gz | HTTP URL for golang tarball |
| ocp_logging_tests_private_e2e_enabled | no | false | Flag to be set to true to enable logging e2e tests playbook |
| logging_e2e_testcases | no | false | If set to critical it will run Critical logging tests else it will run all logging tests |

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

- None

Example Playbook
----------------
```
---
- name: Run logging related e2e test cases from openshift-tests-private repo
hosts: bastion
roles:
- ocp-logging-tests-private-e2e
```

License
-------

See LICENCE.txt

Author Information
------------------

Jeevan Darapu ([email protected])
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

ocp_logging_tests_private_e2e_enabled: false
ocp_logging_tests_private_e2e_dir: /tmp/ocp_logging_tests_private/
ocp_logging_tests_private_e2e_git: "https://github.com/openshift/openshift-tests-private/"
ocp_logging_tests_private_e2e_git_branch: "release-4.12"
golang_tarball_logging_e2e: "https://dl.google.com/go/go1.22.6.linux-ppc64le.tar.gz"
logging_e2e_testcases: "all"

122 changes: 122 additions & 0 deletions playbooks/roles/ocp-logging-tests-private-e2e/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---

# tasks file for ocp4 e2e
- name: Install required packages
package:
name:
- git
state: latest

- name: Install the 'Development tools' package group
package: name="@Development tools" state=latest
when: ansible_distribution == 'CentOS' or
ansible_distribution == 'RedHat' or
ansible_distribution == 'Fedora'

- name: Install the 'Build Essential' package group
package: name="build-essential" state=latest
when: ansible_distribution == 'Debian' or
ansible_distribution == 'Ubuntu'

- name: Set test and results directory path
set_fact:
test_dir: "{{ ocp_logging_tests_private_e2e_dir }}src/github.com/openshift-tests-private"
results_dir: "{{ ansible_env.HOME }}/ocp_logging_tests_private_e2e_results"
bin_path: "{{ ocp_logging_tests_private_e2e_dir }}src/github.com/openshift-tests-private"
repository_command: ""

- name: Create test directory
file:
path: "{{ test_dir }}"
state: "{{ item }}"
mode: '0755'
with_items:
- absent
- directory

- name: Include role for installation of Go lang
include_role:
name: golang-installation
vars:
go_tarball: "{{ golang_tarball_logging_e2e }}"
golang_path: "/usr/local"

- name: Clone e2e tests repo
git:
repo: "https://{{ githubuser | urlencode }}:{{ githubpassword | urlencode }}@github.com/openshift/openshift-tests-private.git"
dest: "{{ test_dir }}"
version: "{{ ocp_logging_tests_private_e2e_git_branch }}"

- name: Run make build command at target
shell: make
environment: "{{ logging_e2e_env }}"
args:
chdir: "{{ test_dir }}"

- name: Check if the binary is created
ansible.builtin.stat:
path: "{{ test_dir }}/bin/extended-platform-tests"
register: bin_output

- name: Check if the binary exists
ansible.builtin.debug:
msg: "The binary exists"
when: bin_output.stat.islnk is defined

- name: Copy openshift-tests-private binary
copy:
src: "{{ bin_path }}"
remote_src: true
dest: "/usr/local/bin/"
mode: '0755'

- name: Create results directory
file:
path: "{{ results_dir }}"
state: "{{ item }}"
mode: '0755'
with_items:
- absent
- directory

# Check cluster health
- name: Check the cluster health
include_role:
name: check-cluster-health

# Check PODS
- name: Verify all PODS are Running or Completed
shell: oc get pods -A | awk 'NR>1 {if($4!="Running" && $4!="Completed" ){print $2" "$4}}'
register: pods_status
until: pods_status.stdout|length == 0
retries: 30
delay: 60
ignore_errors: true

- debug:
msg: "Unhealthy PODS: {{ pods_status.stdout_lines }}"
when: 0 != pods_status.stdout|length

# Running E2E
- name: Prepare test suites and run e2e tests
shell: |
./bin/extended-platform-tests run all --dry-run | grep "logging" > logging_tests.txt
./bin/extended-platform-tests run -f ./logging_tests.txt {{ repository_command }} -o {{ results_dir }}/logging_tests_output.txt
sed -e 's/\"/\\"/g;s/.*/\"&\"/' {{ results_dir }}/logging_tests_private_e2e_output.txt | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -4 > {{ results_dir }}/failed-logging-tests-private-e2e-results.txt
args:
chdir: "{{ test_dir }}"
environment: "{{ logging_e2e_env }}"
when: logging_e2e_testcases == "all" or logging_e2e_testcases == ""
register: opp

- name: Prepare test suites and run critical e2e tests
shell: |
./bin/extended-platform-tests run all --dry-run | grep -E "sig-openshift-logging.*Critical" > logging_tests_critical.txt
./bin/extended-platform-tests run -f ./logging_tests_critical.txt {{ repository_command }} -o {{ results_dir }}/logging_tests_critical_output.txt
sed -e 's/\"/\\"/g;s/.*/\"&\"/' {{ results_dir }}/logging_tests_private_e2e_output.txt | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -4 > {{ results_dir }}/failed-logging-tests-private-e2e-results.txt
args:
chdir: "{{ test_dir }}"
environment: "{{ logging_e2e_env }}"
when: logging_e2e_testcases == "critical"
register: opp

7 changes: 7 additions & 0 deletions playbooks/roles/ocp-logging-tests-private-e2e/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

#var file for logging e2e
logging_e2e_env:
PATH: "/usr/local/go/bin:{{ ansible_env.PATH }}"
KUBECONFIG: "{{ ansible_env.HOME }}/.kube/config"

0 comments on commit edf4e07

Please sign in to comment.