From 086322fb6024a8273f9061b677b2b17add857b93 Mon Sep 17 00:00:00 2001 From: Jeevan-Darapu Date: Mon, 5 Aug 2024 15:48:07 +0530 Subject: [PATCH] Added support for logging e2e testcases from openshift-test-private repo Signed-off-by: Jeevan-Darapu --- examples/all.yaml | 10 +- .../ocp_logging_tests_private_e2e_vars.yaml | 9 + playbooks/ocp-logging-tests-private-e2e.yml | 7 + playbooks/roles/ocp-e2e/tasks/main.yml | 486 +++++++++--------- .../ocp-logging-tests-private-e2e/README.md | 47 ++ .../defaults/main.yml | 9 + .../tasks/main.yml | 133 +++++ .../vars/main.yml | 7 + 8 files changed, 464 insertions(+), 244 deletions(-) create mode 100644 examples/ocp_logging_tests_private_e2e_vars.yaml create mode 100644 playbooks/ocp-logging-tests-private-e2e.yml create mode 100644 playbooks/roles/ocp-logging-tests-private-e2e/README.md create mode 100644 playbooks/roles/ocp-logging-tests-private-e2e/defaults/main.yml create mode 100644 playbooks/roles/ocp-logging-tests-private-e2e/tasks/main.yml create mode 100644 playbooks/roles/ocp-logging-tests-private-e2e/vars/main.yml diff --git a/examples/all.yaml b/examples/all.yaml index eb23935e..c3415283 100644 --- a/examples/all.yaml +++ b/examples/all.yaml @@ -382,4 +382,12 @@ coo_namespace: "openshift-observability-operator" coo_catalogsource_name: "coo-catalog" coo_catalogsource_image: "brew.registry.redhat.io/rh-osbs/iib:760399" coo_channel: "development" - \ No newline at end of file + +# 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 + diff --git a/examples/ocp_logging_tests_private_e2e_vars.yaml b/examples/ocp_logging_tests_private_e2e_vars.yaml new file mode 100644 index 00000000..e454f8ae --- /dev/null +++ b/examples/ocp_logging_tests_private_e2e_vars.yaml @@ -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 + diff --git a/playbooks/ocp-logging-tests-private-e2e.yml b/playbooks/ocp-logging-tests-private-e2e.yml new file mode 100644 index 00000000..f9732480 --- /dev/null +++ b/playbooks/ocp-logging-tests-private-e2e.yml @@ -0,0 +1,7 @@ +--- + +- name: Run logging related e2e test cases from openshift-tests-private repo + hosts: bastion + roles: + - ocp-logging-tests-private-e2e + diff --git a/playbooks/roles/ocp-e2e/tasks/main.yml b/playbooks/roles/ocp-e2e/tasks/main.yml index 1dd333b3..ec4e7442 100644 --- a/playbooks/roles/ocp-e2e/tasks/main.yml +++ b/playbooks/roles/ocp-e2e/tasks/main.yml @@ -1,243 +1,243 @@ ---- -# 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: "{{ e2e_tests_dir }}/src/github.com/openshift" - results_dir: "{{ ansible_env.HOME }}/e2e_tests_results" - bin_path: "{{ e2e_tests_dir }}/src/github.com/openshift/origin/openshift-tests" - repository_command: "" - -- name: Set repository command -{4.7, 4.8, 4.9, 4.10} - set_fact: - repository_command: "--from-repository quay.io/multi-arch/community-e2e-images" - when: e2e_tests_git_branch == "release-4.7" or e2e_tests_git_branch == "release-4.8" or e2e_tests_git_branch == "release-4.9" or e2e_tests_git_branch == "release-4.10" - -- name: Create test directory - file: - path: "{{ test_dir }}" - state: "{{ item }}" - mode: '0755' - with_items: - - absent - - directory - -- name: Remove existing directory - file: - path: "/usr/local/go" - state: absent - -- name: Download and untar golang - unarchive: - src: "{{ golang_tarball }}" - dest: "/usr/local/" - remote_src: yes - -- name: Clone e2e tests repo - git: - repo: "{{ e2e_tests_git }}" - dest: "{{ test_dir }}/origin" - version: "{{ e2e_tests_git_branch }}" - -- name: Copy invert_excluded python script - template: - src: ../files/invert_excluded.py - dest: "{{ test_dir }}/origin/invert_excluded.py" - mode: '0755' - -- name: Add text for running in debian based OS - shell: - chdir: "{{ test_dir }}/origin" - cmd: sed -i '1s/^/SHELL := \/bin\/bash \n/' Makefile && sed -i '1s/^/#!\/usr\/bin\/python3 \n/' invert_excluded.py - when: ansible_distribution == 'Debian' or - ansible_distribution == 'Ubuntu' - -- name: Run make target - make: - chdir: "{{ test_dir }}/origin" - target: WHAT=cmd/openshift-tests - environment: "{{ e2e_env }}" - -- name: Copy openshift-tests binary - copy: - src: "{{ bin_path }}" - remote_src: true - dest: "/usr/local/bin/" - mode: '0755' - -- name: Copy kube test repo list - template: - src: ../files/kube-test-repo-list - dest: /tmp/kube-test-repo-list - mode: '0755' - -- name: Download exclude e2e tests list file - when: e2e_tests_exclude_list_url != "" and github_token != "" - get_url: - url: "{{ e2e_tests_exclude_list_url }}" - dest: "{{ test_dir }}/origin/excluded_tests" - headers: - Authorization: "token {{ github_token }}" - Accept: application/vnd.github.v3.raw - -- name: Create exclude e2e tests list - when: e2e_tests_exclude_list_url == "" - file: - path: "{{ test_dir }}/origin/excluded_tests" - state: touch - mode: u=rw,g=r,o=r - -- name: Create results directory - file: - path: "{{ results_dir }}" - state: "{{ item }}" - mode: '0755' - with_items: - - absent - - directory - -# Check Nodes status -- name: Check all nodes are Ready - shell: oc wait --all --for=condition=Ready nodes --timeout=300s - -# Check CO status -- name: Check if all co are in AVAILABLE state and check no any co are in PROGRESSING state and DEGRADED state - shell: oc get co -n default --no-headers | awk '{ print $3 $4 $5 }' | grep -w -v TrueFalseFalse | wc -l - register: co_status - until: co_status.stdout|int == 0 - retries: 30 - delay: 120 - ignore_errors: yes - -- name: Fail if Cluster operators are not in good status - fail: - msg: "Cluster operators are not in good status. Skipping E2E tests !!" - when: 0 != co_status.stdout|int - -# 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: yes - -- debug: - msg: "Unhealthy PODS: {{ pods_status.stdout_lines }}" - when: 0 != pods_status.stdout|length - -- name: Get OCP pull-secret and set auth file in the default location - shell: | - oc get secret/pull-secret -n openshift-config -o json | jq -r '.data.".dockerconfigjson"' | base64 -d > authfile - mkdir -p /run/user/0/containers/ - cp authfile /run/user/0/containers/auth.json - when: e2e_tests_git_branch == 'release-4.16' - -# Running E2E -- name: Prepare test suites and run e2e tests - shell: | - openshift-tests run openshift/conformance/parallel --dry-run | ./invert_excluded.py excluded_tests > test-suite.txt - openshift-tests run -f ./test-suite.txt {{ repository_command }} -o {{ results_dir }}/conformance-parallel-out-0.txt --junit-dir {{ results_dir }}/conformance-parallel > {{ results_dir }}/openshift-cmd-out-log-0.txt 2>&1 - sed -e 's/\"/\\"/g;s/.*/\"&\"/' {{ results_dir }}/conformance-parallel-out-0.txt | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -4 > {{ results_dir }}/failed-e2e-results.txt - args: - chdir: "{{ test_dir }}/origin" - environment: "{{ e2e_env }}" - register: opp - when: e2e_tests_enabled and co_status.stdout|int == 0 - -# Re-Running E2E -- name: Re run e2e failed tests - shell: | - cnt=0 - pattern="(error: [0-9]* fail, [0-9]* pass, [0-9]* skip|[0-9]* pass, [0-9]* skip) \(([0-9]*h[0-9]*m[0-9]*s|[0-9]*m[0-9]*s|[0-9.]*s)\)" - IFS=' ' read -ra ADDR1 <<< $(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | tail -5 | grep -oE "${pattern}" | head -1) - if [ "0" -ne "$(wc -l < "{{ results_dir }}/failed-e2e-results.txt")" ] - then - # Storing start time - START_TIME=$(date +%s); - - # Storing the hours, minutes and seconds of the first e2e execution - IFS="hm" read -d '' hr min sec<<< $(echo ${ADDR1[7]} | sed -e 's/[()s]//g') - - while [ $cnt -lt 5 ] - do - f_test="$(wc -l < "{{ results_dir }}/failed-e2e-results.txt")" - cnt=$(( $cnt + 1 )) - openshift-tests run -f {{ results_dir }}/failed-e2e-results.txt {{ repository_command }} -o {{ results_dir }}/conformance-parallel-out-${cnt}.txt --junit-dir {{ results_dir }}/conformance-parallel &> {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt - sed -e 's/\"/\\"/g;s/.*/\"&\"/' "{{ results_dir }}/conformance-parallel-out-${cnt}.txt" | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -4 > {{ results_dir }}/failed-e2e-results.txt - awk -i inplace '/\S/' "{{ results_dir }}/failed-e2e-results.txt" - - IFS=' ' read -ra ADDR2 <<< $(cat {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt | tail -5 | grep -oE "${pattern}" | head -1) - # Calculating the passed and skipped test cases - if [ ${{ "{" }}{{ "#" }}ADDR2[@]} -eq "5" ] - then - ADDR1[3]=$((${ADDR2[0]} + ${ADDR1[3]})) #Pass Count - ADDR1[5]=$((${ADDR2[2]} + ${ADDR1[5]})) #Skip Count - ADDR2[1]=0 #Fail Count - else - if [ ${{ "{" }}{{ "#" }}ADDR2[@]} -eq "0" ] - then - PASS_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt | grep "^passed" | wc -l) - SKIP_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt | grep "^skipped" | wc -l) - FAIL_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt | grep "^failed" | wc -l) - fi - ADDR1[3]=$((${ADDR2[3]:=${PASS_COUNT}} + ${ADDR1[3]})) #Pass Count - ADDR1[5]=$((${ADDR2[5]:=${SKIP_COUNT}} + ${ADDR1[5]})) #Skip Count - fi - - # exiting the loop if no new test passes - if [ "0" -eq "$(wc -l < "{{ results_dir }}/failed-e2e-results.txt")" ] || [ $f_test -eq "$(wc -l < "{{ results_dir }}/failed-e2e-results.txt")" ] - then - break - fi - done - - # Calculating time required for e2e execution - END_TIME=$(date +%s); - diff=$(($sec + END_TIME - START_TIME)) - hrs=$(($hr + ($min + $diff/60)/60)) - mins=$((($min + $diff/60)%60)) - secs=$(($diff%60)) - e2e_time="(${hrs}h${mins}m${secs}s)" - - mv {{ results_dir }}/conformance-parallel-out-${cnt}.txt {{ results_dir }}/conformance-parallel-out.txt - echo " ${ADDR2[1]:=${FAIL_COUNT}} fail, ${ADDR1[3]} pass, ${ADDR1[5]} skip $e2e_time" > {{ results_dir }}/summary.txt - else - if [ ${{ "{" }}{{ "#" }}ADDR1[@]} -eq "0" ] - then - PASS_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | grep "^passed" | wc -l) - SKIP_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | grep "^skipped" | wc -l) - FAIL_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | grep "^failed" | wc -l) - echo " ${FAIL_COUNT} fail, ${PASS_COUNT} pass, ${SKIP_COUNT} skip " > {{ results_dir }}/summary.txt - else - summary=$(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | tail -5 | grep -oE "${pattern}" | head -1) - fi - mv {{ results_dir }}/conformance-parallel-out-0.txt {{ results_dir }}/conformance-parallel-out.txt - sed -e 's/\"/\\"/g;s/.*/\"&\"/' {{ results_dir }}/conformance-parallel-out.txt | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -4 > {{ results_dir }}/failed-e2e-results.txt - echo $summary |sed 's/error://' >> {{ results_dir }}/summary.txt - fi - args: - chdir: "{{ test_dir }}/origin" - executable: /bin/bash - environment: "{{ e2e_env }}" - register: op - when: e2e_tests_enabled and co_status.stdout|int == 0 - ignore_errors: yes - +--- +# 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: "{{ e2e_tests_dir }}/src/github.com/openshift" + results_dir: "{{ ansible_env.HOME }}/e2e_tests_results" + bin_path: "{{ e2e_tests_dir }}/src/github.com/openshift/origin/openshift-tests" + repository_command: "" + +- name: Set repository command -{4.7, 4.8, 4.9, 4.10} + set_fact: + repository_command: "--from-repository quay.io/multi-arch/community-e2e-images" + when: e2e_tests_git_branch == "release-4.7" or e2e_tests_git_branch == "release-4.8" or e2e_tests_git_branch == "release-4.9" or e2e_tests_git_branch == "release-4.10" + +- name: Create test directory + file: + path: "{{ test_dir }}" + state: "{{ item }}" + mode: '0755' + with_items: + - absent + - directory + +- name: Remove existing directory + file: + path: "/usr/local/go" + state: absent + +- name: Download and untar golang + unarchive: + src: "{{ golang_tarball }}" + dest: "/usr/local/" + remote_src: yes + +- name: Clone e2e tests repo + git: + repo: "{{ e2e_tests_git }}" + dest: "{{ test_dir }}/origin" + version: "{{ e2e_tests_git_branch }}" + +- name: Copy invert_excluded python script + template: + src: ../files/invert_excluded.py + dest: "{{ test_dir }}/origin/invert_excluded.py" + mode: '0755' + +- name: Add text for running in debian based OS + shell: + chdir: "{{ test_dir }}/origin" + cmd: sed -i '1s/^/SHELL := \/bin\/bash \n/' Makefile && sed -i '1s/^/#!\/usr\/bin\/python3 \n/' invert_excluded.py + when: ansible_distribution == 'Debian' or + ansible_distribution == 'Ubuntu' + +- name: Run make target + make: + chdir: "{{ test_dir }}/origin" + target: WHAT=cmd/openshift-tests + environment: "{{ e2e_env }}" + +- name: Copy openshift-tests binary + copy: + src: "{{ bin_path }}" + remote_src: true + dest: "/usr/local/bin/" + mode: '0755' + +- name: Copy kube test repo list + template: + src: ../files/kube-test-repo-list + dest: /tmp/kube-test-repo-list + mode: '0755' + +- name: Download exclude e2e tests list file + when: e2e_tests_exclude_list_url != "" and github_token != "" + get_url: + url: "{{ e2e_tests_exclude_list_url }}" + dest: "{{ test_dir }}/origin/excluded_tests" + headers: + Authorization: "token {{ github_token }}" + Accept: application/vnd.github.v3.raw + +- name: Create exclude e2e tests list + when: e2e_tests_exclude_list_url == "" + file: + path: "{{ test_dir }}/origin/excluded_tests" + state: touch + mode: u=rw,g=r,o=r + +- name: Create results directory + file: + path: "{{ results_dir }}" + state: "{{ item }}" + mode: '0755' + with_items: + - absent + - directory + +# Check Nodes status +- name: Check all nodes are Ready + shell: oc wait --all --for=condition=Ready nodes --timeout=300s + +# Check CO status +- name: Check if all co are in AVAILABLE state and check no any co are in PROGRESSING state and DEGRADED state + shell: oc get co -n default --no-headers | awk '{ print $3 $4 $5 }' | grep -w -v TrueFalseFalse | wc -l + register: co_status + until: co_status.stdout|int == 0 + retries: 30 + delay: 120 + ignore_errors: yes + +- name: Fail if Cluster operators are not in good status + fail: + msg: "Cluster operators are not in good status. Skipping E2E tests !!" + when: 0 != co_status.stdout|int + +# 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: yes + +- debug: + msg: "Unhealthy PODS: {{ pods_status.stdout_lines }}" + when: 0 != pods_status.stdout|length + +- name: Get OCP pull-secret and set auth file in the default location + shell: | + oc get secret/pull-secret -n openshift-config -o json | jq -r '.data.".dockerconfigjson"' | base64 -d > authfile + mkdir -p /run/user/0/containers/ + cp authfile /run/user/0/containers/auth.json + when: e2e_tests_git_branch == 'release-4.16' + +# Running E2E +- name: Prepare test suites and run e2e tests + shell: | + openshift-tests run openshift/conformance/parallel --dry-run | ./invert_excluded.py excluded_tests > test-suite.txt + openshift-tests run -f ./test-suite.txt {{ repository_command }} -o {{ results_dir }}/conformance-parallel-out-0.txt --junit-dir {{ results_dir }}/conformance-parallel > {{ results_dir }}/openshift-cmd-out-log-0.txt 2>&1 + sed -e 's/\"/\\"/g;s/.*/\"&\"/' {{ results_dir }}/conformance-parallel-out-0.txt | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -4 > {{ results_dir }}/failed-e2e-results.txt + args: + chdir: "{{ test_dir }}/origin" + environment: "{{ e2e_env }}" + register: opp + when: e2e_tests_enabled and co_status.stdout|int == 0 + +# Re-Running E2E +- name: Re run e2e failed tests + shell: | + cnt=0 + pattern="(error: [0-9]* fail, [0-9]* pass, [0-9]* skip|[0-9]* pass, [0-9]* skip) \(([0-9]*h[0-9]*m[0-9]*s|[0-9]*m[0-9]*s|[0-9.]*s)\)" + IFS=' ' read -ra ADDR1 <<< $(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | tail -5 | grep -oE "${pattern}" | head -1) + if [ "0" -ne "$(wc -l < "{{ results_dir }}/failed-e2e-results.txt")" ] + then + # Storing start time + START_TIME=$(date +%s); + + # Storing the hours, minutes and seconds of the first e2e execution + IFS="hm" read -d '' hr min sec<<< $(echo ${ADDR1[7]} | sed -e 's/[()s]//g') + + while [ $cnt -lt 5 ] + do + f_test="$(wc -l < "{{ results_dir }}/failed-e2e-results.txt")" + cnt=$(( $cnt + 1 )) + openshift-tests run -f {{ results_dir }}/failed-e2e-results.txt {{ repository_command }} -o {{ results_dir }}/conformance-parallel-out-${cnt}.txt --junit-dir {{ results_dir }}/conformance-parallel &> {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt + sed -e 's/\"/\\"/g;s/.*/\"&\"/' "{{ results_dir }}/conformance-parallel-out-${cnt}.txt" | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -4 > {{ results_dir }}/failed-e2e-results.txt + awk -i inplace '/\S/' "{{ results_dir }}/failed-e2e-results.txt" + + IFS=' ' read -ra ADDR2 <<< $(cat {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt | tail -5 | grep -oE "${pattern}" | head -1) + # Calculating the passed and skipped test cases + if [ ${{ "{" }}{{ "#" }}ADDR2[@]} -eq "5" ] + then + ADDR1[3]=$((${ADDR2[0]} + ${ADDR1[3]})) #Pass Count + ADDR1[5]=$((${ADDR2[2]} + ${ADDR1[5]})) #Skip Count + ADDR2[1]=0 #Fail Count + else + if [ ${{ "{" }}{{ "#" }}ADDR2[@]} -eq "0" ] + then + PASS_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt | grep "^passed" | wc -l) + SKIP_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt | grep "^skipped" | wc -l) + FAIL_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-${cnt}.txt | grep "^failed" | wc -l) + fi + ADDR1[3]=$((${ADDR2[3]:=${PASS_COUNT}} + ${ADDR1[3]})) #Pass Count + ADDR1[5]=$((${ADDR2[5]:=${SKIP_COUNT}} + ${ADDR1[5]})) #Skip Count + fi + + # exiting the loop if no new test passes + if [ "0" -eq "$(wc -l < "{{ results_dir }}/failed-e2e-results.txt")" ] || [ $f_test -eq "$(wc -l < "{{ results_dir }}/failed-e2e-results.txt")" ] + then + break + fi + done + + # Calculating time required for e2e execution + END_TIME=$(date +%s); + diff=$(($sec + END_TIME - START_TIME)) + hrs=$(($hr + ($min + $diff/60)/60)) + mins=$((($min + $diff/60)%60)) + secs=$(($diff%60)) + e2e_time="(${hrs}h${mins}m${secs}s)" + + mv {{ results_dir }}/conformance-parallel-out-${cnt}.txt {{ results_dir }}/conformance-parallel-out.txt + echo " ${ADDR2[1]:=${FAIL_COUNT}} fail, ${ADDR1[3]} pass, ${ADDR1[5]} skip $e2e_time" > {{ results_dir }}/summary.txt + else + if [ ${{ "{" }}{{ "#" }}ADDR1[@]} -eq "0" ] + then + PASS_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | grep "^passed" | wc -l) + SKIP_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | grep "^skipped" | wc -l) + FAIL_COUNT=$(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | grep "^failed" | wc -l) + echo " ${FAIL_COUNT} fail, ${PASS_COUNT} pass, ${SKIP_COUNT} skip " > {{ results_dir }}/summary.txt + else + summary=$(cat {{ results_dir }}/openshift-cmd-out-log-0.txt | tail -5 | grep -oE "${pattern}" | head -1) + fi + mv {{ results_dir }}/conformance-parallel-out-0.txt {{ results_dir }}/conformance-parallel-out.txt + sed -e 's/\"/\\"/g;s/.*/\"&\"/' {{ results_dir }}/conformance-parallel-out.txt | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -4 > {{ results_dir }}/failed-e2e-results.txt + echo $summary |sed 's/error://' >> {{ results_dir }}/summary.txt + fi + args: + chdir: "{{ test_dir }}/origin" + executable: /bin/bash + environment: "{{ e2e_env }}" + register: op + when: e2e_tests_enabled and co_status.stdout|int == 0 + ignore_errors: yes + diff --git a/playbooks/roles/ocp-logging-tests-private-e2e/README.md b/playbooks/roles/ocp-logging-tests-private-e2e/README.md new file mode 100644 index 00000000..46a3f5a7 --- /dev/null +++ b/playbooks/roles/ocp-logging-tests-private-e2e/README.md @@ -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 (Jeevan.Darapu@ibm.com) diff --git a/playbooks/roles/ocp-logging-tests-private-e2e/defaults/main.yml b/playbooks/roles/ocp-logging-tests-private-e2e/defaults/main.yml new file mode 100644 index 00000000..8d71f7f9 --- /dev/null +++ b/playbooks/roles/ocp-logging-tests-private-e2e/defaults/main.yml @@ -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" + diff --git a/playbooks/roles/ocp-logging-tests-private-e2e/tasks/main.yml b/playbooks/roles/ocp-logging-tests-private-e2e/tasks/main.yml new file mode 100644 index 00000000..081a0852 --- /dev/null +++ b/playbooks/roles/ocp-logging-tests-private-e2e/tasks/main.yml @@ -0,0 +1,133 @@ +--- + +# 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 + shell: ls -hl {{ test_dir }}/bin/extended-platform-tests | wc -l + args: + chdir: "{{ test_dir }}" + register: bin_output + failed_when: bin_output.stdout|int != 1 + +- 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 Nodes status +- name: Check all nodes are Ready + shell: oc wait --all --for=condition=Ready nodes --timeout=300s + +# Check CO status +- name: Check if all co are in AVAILABLE state and check no any co are in PROGRESSING state and DEGRADED state + shell: oc get co -n default --no-headers | awk '{ print $3 $4 $5 }' | grep -w -v TrueFalseFalse | wc -l + register: co_status + until: co_status.stdout|int == 0 + retries: 30 + delay: 120 + ignore_errors: true + +- name: Fail if Cluster operators are not in good status + fail: + msg: "Cluster operators are not in good status. Skipping E2E tests !!" + when: 0 != co_status.stdout|int + +# 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 + diff --git a/playbooks/roles/ocp-logging-tests-private-e2e/vars/main.yml b/playbooks/roles/ocp-logging-tests-private-e2e/vars/main.yml new file mode 100644 index 00000000..376b31d7 --- /dev/null +++ b/playbooks/roles/ocp-logging-tests-private-e2e/vars/main.yml @@ -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" +