From 0ffe64d837943e70abadcf70a591dc00b68ed805 Mon Sep 17 00:00:00 2001 From: Alex Yefimov <126113326+ayefimov-1@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:44:43 -0400 Subject: [PATCH 01/11] [zuul] Add logging test job Add a job that runs the telemetry_logging role against an openstack cloud. --- .zuul.yaml | 19 +++++++++++++++++-- ci/logging_tests_computes.yml | 17 +++++++++++++++++ ci/vars-logging-test.yml | 8 ++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 ci/logging_tests_computes.yml create mode 100644 ci/vars-logging-test.yml diff --git a/.zuul.yaml b/.zuul.yaml index 62c2773d..f2789b2e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -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 @@ -35,6 +35,21 @@ - README* - .*/*.md +- job: + name: functional-logging-tests-osp18 + parent: telemetry-operator-multinode-logging + description: | + Run the logging functional tests on osp18 + 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 @@ -45,7 +60,6 @@ - ci/noop.yml files: *irrelevant_files - - project: name: infrawatch/feature-verification-tests github-check: @@ -54,3 +68,4 @@ - openstack-k8s-operators-content-provider: override-checkout: main - functional-tests-on-osp18 + - functional-logging-tests-osp18 diff --git a/ci/logging_tests_computes.yml b/ci/logging_tests_computes.yml new file mode 100644 index 00000000..717de0d1 --- /dev/null +++ b/ci/logging_tests_computes.yml @@ -0,0 +1,17 @@ +--- +- name: "Verify logging journalctl identifiers" + hosts: computes + gather_facts: true + ignore_errors: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars: + journal_test_id: "RHOSO-12681" + journal_list: + - ceilometer_agent_compute + - nova_compute + tasks: + - name: "Verify journalctl logging identifiers" + ansible.builtin.import_role: + name: telemetry_logging diff --git a/ci/vars-logging-test.yml b/ci/vars-logging-test.yml new file mode 100644 index 00000000..70ea1ba1 --- /dev/null +++ b/ci/vars-logging-test.yml @@ -0,0 +1,8 @@ +--- +post_deploy_00_fvt_logging_computes: + source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_computes.yml" + config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" + type: playbook +post_deploy_99_collect_results: + source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/report_result.yml" + type: playbook From ab010392cfbd6ee8ad51d3b46bfb235dccd0793c Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Wed, 28 Aug 2024 16:51:31 +0100 Subject: [PATCH 02/11] custom_logger: check for results for a host before creating the summary --- callback_plugins/custom_logger.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/callback_plugins/custom_logger.py b/callback_plugins/custom_logger.py index 19bc706f..665b87ed 100644 --- a/callback_plugins/custom_logger.py +++ b/callback_plugins/custom_logger.py @@ -76,6 +76,13 @@ def log_task_result(self, host, result, task_name): def log_summary_results(self, host): file_path = os.path.join(self.output_dir, f"summary_results.log") + + # Make sure that the there is a result for the host, or else we get + # errors referencing the results dict later + if not self.results.get(host): + print("The host %s does not have any results" % host) + return + with open(file_path, 'w') as f: f.write(f"Host: {host}\n") f.write(f"Tasks Succeeded: {self.results[host]['passed']}\n") From 64fa18b2273bf68cf1886cc75b4066a0ff56b482 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Wed, 11 Sep 2024 20:43:13 +0100 Subject: [PATCH 03/11] [logging] Add common role with tests for pods --- ci/ansible.cfg | 4 + ci/logging_tests_local.yml | 184 +++++++++++++++++++++++++++++++ ci/vars-logging-test.yml | 9 +- roles/common/README.md | 61 ++++++++++ roles/common/tasks/main.yml | 8 ++ roles/common/tasks/pod_tests.yml | 20 ++++ 6 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 ci/logging_tests_local.yml create mode 100644 roles/common/README.md create mode 100644 roles/common/tasks/main.yml create mode 100644 roles/common/tasks/pod_tests.yml diff --git a/ci/ansible.cfg b/ci/ansible.cfg index ff9d632d..49f3ea2f 100644 --- a/ci/ansible.cfg +++ b/ci/ansible.cfg @@ -4,5 +4,9 @@ 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 + [custom_logger] output_dir = /$HOME + diff --git a/ci/logging_tests_local.yml b/ci/logging_tests_local.yml new file mode 100644 index 00000000..b22aebb4 --- /dev/null +++ b/ci/logging_tests_local.yml @@ -0,0 +1,184 @@ +--- +#- name: Prepare Logging Tests +# hosts: controller +# gather_facts: true +# ignore_errors: false +## vars: +## id_rsa_path: "{{ playbook_dir }}/id_rsa.ctlplane" +## 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_local" +# state: directory +# mode: "0755" + +# # This needs to be updated; what do we use elsewhere? +# # Elsewhere, we assume that we're already logged in +# - name: "Log into OCP" +# ansible.builtin.shell: +# cmd: | +# oc login -u kubeadmin -p "12345678" https://api.crc.testing:6443 +# failed_when: false +# changed_when: false +# +# # I don't think we need this, Zuul __should__ have taken care of this already +# - name: "Create id rsa file for ctlplane access" +# ansible.builtin.shell: +# cmd: | +# oc extract -n openstack secrets/dataplane-ansible-ssh-private-key-secret --to=- | grep -v "ssh\-rsa" > "{{ id_rsa_path }}" +# register: rsa_results +# failed_when: rsa_results.rc != 0 +# changed_when: false +# +# # (efoley): Once again, I don't think this is necessary; if it's not needed for zuul, because it's already done, but is needed before running this on other systems, then the README should be updated to reflect this; +# # A troubleshooting section can be added too so users can identify when they are missing these configuration steps +# - name: "Change files permissions" +# ansible.builtin.shell: +# cmd: | +# chmod 600 "{{ id_rsa_path }}" +# changed_when: false + +- name: "Verify logging projects, endpoints, credentials, nodes, pods, services, manifests and subscriptions" + hosts: controller + gather_facts: no + ignore_errors: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars: + pod_test_id: "RHOS0-12672" + pod_status_str: "Running" + pod_nspace: openstack-operators + pod_list: + - telemetry-operator-controller-manager + - dataplane-operator-controller-manager + +- name: "Verify logging pods are running in openstack" + hosts: controller + gather_facts: no + ignore_errors: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars: + pod_test_id: "RHOSO-12752" + pod_status_str: "Running" + pod_nspace: openstack + pod_list: + - openstackclient + tasks: + - name: "Verify Running Pods" + ansible.builtin.import_role: + name: common + + +- name: "Verify logging pods are running in openshift-operators-redhat" + hosts: controller + gather_facts: no + ignore_errors: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars: + pod_test_id: "RHOSO-12673" + pod_status_str: "Running" + pod_nspace: openshift-operators-redhat + pod_list: + - loki-operator-controller-manager + + tasks: + - name: "Verify Pods running" + ansible.builtin.import_role: + name: common + # vars can be passed here, so we can use the same play for this and the next play. + # vars: + # - + +- name: "Verify logging pods are running in openshift-logging" + hosts: controller + gather_facts: no + ignore_errors: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars: + pod_test_id: "RHOSO-12676" + pod_status_str: "Running" + pod_nspace: openshift-logging + pod_list: + - cluster-logging-operator + - collector + - logging-loki-compactor + - logging-loki-distributor + - logging-loki-gateway + - logging-loki-index-gateway + - logging-loki-ingester + - logging-loki-querier + - logging-loki-query-frontend + - logging-view-plugin + + ### see JIRA LOG-5431 if pods not running + tasks: + - name: "Verify Pods running" + ansible.builtin.import_role: + name: common + +- name: "Verify logging pods are running in minio-dev" + hosts: controller + gather_facts: no + ignore_errors: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars: + pod_test_id: "RHOSO-12674" + pod_status_str: "Running" + pod_nspace: minio-dev + pod_list: + - minio + + tasks: + - name: "Run pod running tests" + ansible.builtin.import_role: + name: common + + +- name: "Verify logging pods have complete status in openstack" + hosts: controller + gather_facts: no + ignore_errors: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars: + pod_test_id: "RHOSO-12679" + pod_nspace: openstack + pod_status_str: "Completed" + pod_list: + - bootstrap-edpm-deployment-logging + - configure-network-edpm-deployment-logging + - configure-os-edpm-deployment-logging + - download-cache-edpm-deployment-logging + - install-certs-edpm-deployment-logging + - install-os-edpm-deployment-logging + - libvirt-edpm-deployment-logging + - logging-edpm-deployment-logging-openstack-edpm + - neutron-metadata-edpm-deployment-logging + - nova-custom-edpm-deployment + - ovn-edpm-deployment-logging + - reboot-os-edpm-deployment-logging + - repo-setup-edpm-deployment-logging + - run-os-edpm-deployment-logging + - ssh-known-hosts-edpm-deployment-logging + - telemetry-edpm-deployment-logging + - validate-network-edpm-deployment-logging + tasks: + - name: "Run pods completed tests" + ansible.builtin.import_role: + name: common + diff --git a/ci/vars-logging-test.yml b/ci/vars-logging-test.yml index 70ea1ba1..2c97cebf 100644 --- a/ci/vars-logging-test.yml +++ b/ci/vars-logging-test.yml @@ -1,8 +1,15 @@ --- -post_deploy_00_fvt_logging_computes: +# pre_tests or post_tests are also options for when the FVT roles are run +post_deploy_fvt_logging_01_computes: source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_computes.yml" config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" type: playbook + +post_deploy_fvt_00_logging_controller: + source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_local.yml" + config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" + type: playbook + post_deploy_99_collect_results: source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/report_result.yml" type: playbook diff --git a/roles/common/README.md b/roles/common/README.md new file mode 100644 index 00000000..f76df028 --- /dev/null +++ b/roles/common/README.md @@ -0,0 +1,61 @@ +common +========= + +The tests in this role are not specific to any one functional area but are an aggregate of common tests that can be used in all OSP 18.0/OCP jobs. + +Requirements +------------ + +None + +Role Variables +-------------- +Variable required for all tasks to run: + + For pod_tests.yml tasks: + + pod_test_id + pod_list + - list of pods to validate + pod_status_str + - status of pods to check + pod_nspace + - list of projects where pods exist + + +Dependencies +------------ + +None + +Example Playbook +---------------- + +Typically, for this role the tests should *not* use a "main.yml" and import or include all the tests in the role. On the contrary, a tests should explicitly include specific tests needed for a given job. + + + hosts: controller + gather_facts: no + vars: + proj_out_file: verify_logging_projects_exist_lresults.log + proj_list: + - openshift-openstack-infra + - openshift + - openstack-operators + - openshift-logging + + tasks: + - name: Run projects tests + ansible.builtin.import_role: + name: common + + +License +------- + +Apache 2 + +Author Information +------------------ + +alexy@redhat.com diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml new file mode 100644 index 00000000..27480e58 --- /dev/null +++ b/roles/common/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- name: "Verify pod - {{ pod_test_id }}" + when: + - pod_list is defined + - pod_nspace is defined + - pod_status_str is defined + ansible.builtin.include_tasks: "pod_tests.yml" + loop: "{{ pod_list }}" diff --git a/roles/common/tasks/pod_tests.yml b/roles/common/tasks/pod_tests.yml new file mode 100644 index 00000000..45c13f11 --- /dev/null +++ b/roles/common/tasks/pod_tests.yml @@ -0,0 +1,20 @@ +--- + +- name: Get Pod Instance "{{ pod_status_str }}" + ansible.builtin.shell: + cmd: | + oc get pods -n "{{ pod_nspace }}" | grep "{{ item }}" | grep "{{ pod_status_str }}" | awk '{print $1;}' + register: podinstance + changed_when: false + +- name: Check terminated pod + ansible.builtin.shell: + cmd: | + oc get pod -n "{{ pod_nspace }} {{ podinstance.stdout }}" + register: output + changed_when: false + failed_when: + - output.rc != 0 + - podinstance.stdout == "" + + From c78c83ebc2166174f2b39af36d3cd8a555cd088a Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Thu, 12 Sep 2024 18:08:47 +0100 Subject: [PATCH 04/11] Update hook order to run tests --- ci/vars-logging-test.yml | 4 ++-- roles/common/tasks/pod_tests.yml | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ci/vars-logging-test.yml b/ci/vars-logging-test.yml index 2c97cebf..8599e060 100644 --- a/ci/vars-logging-test.yml +++ b/ci/vars-logging-test.yml @@ -1,11 +1,11 @@ --- # pre_tests or post_tests are also options for when the FVT roles are run -post_deploy_fvt_logging_01_computes: +post_deploy_00_fvt_logging_computes: source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_computes.yml" config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" type: playbook -post_deploy_fvt_00_logging_controller: +post_deploy_00_logging_controller: source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_local.yml" config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" type: playbook diff --git a/roles/common/tasks/pod_tests.yml b/roles/common/tasks/pod_tests.yml index 45c13f11..4c9b5048 100644 --- a/roles/common/tasks/pod_tests.yml +++ b/roles/common/tasks/pod_tests.yml @@ -1,15 +1,14 @@ --- - -- name: Get Pod Instance "{{ pod_status_str }}" +- name: Get Pod Instance "{{ pod_status_str }}" ansible.builtin.shell: cmd: | - oc get pods -n "{{ pod_nspace }}" | grep "{{ item }}" | grep "{{ pod_status_str }}" | awk '{print $1;}' + oc get pods -n "{{ pod_nspace }}" | grep "{{ item }}" | grep "{{ pod_status_str }}" | awk '{print $1;}' register: podinstance changed_when: false -- name: Check terminated pod +- name: Check terminated pod ansible.builtin.shell: - cmd: | + cmd: | oc get pod -n "{{ pod_nspace }} {{ podinstance.stdout }}" register: output changed_when: false @@ -17,4 +16,3 @@ - output.rc != 0 - podinstance.stdout == "" - From 430932f5400e0a209134c1df6c6086929c4d070e Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Thu, 12 Sep 2024 18:31:39 +0100 Subject: [PATCH 05/11] [common] update README and rename vars --- ci/logging_tests_local.yml | 50 ++++++++++++------------- roles/common/README.md | 64 +++++++++++++++++++------------- roles/common/tasks/main.yml | 8 ++-- roles/common/tasks/pod_tests.yml | 6 +-- 4 files changed, 70 insertions(+), 58 deletions(-) diff --git a/ci/logging_tests_local.yml b/ci/logging_tests_local.yml index b22aebb4..20a9fed4 100644 --- a/ci/logging_tests_local.yml +++ b/ci/logging_tests_local.yml @@ -51,10 +51,10 @@ KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" vars: - pod_test_id: "RHOS0-12672" - pod_status_str: "Running" - pod_nspace: openstack-operators - pod_list: + common_pod_test_id: "RHOS0-12672" + common_pod_status_str: "Running" + common_pod_nspace: openstack-operators + common_pod_list: - telemetry-operator-controller-manager - dataplane-operator-controller-manager @@ -66,10 +66,10 @@ KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" vars: - pod_test_id: "RHOSO-12752" - pod_status_str: "Running" - pod_nspace: openstack - pod_list: + common_pod_test_id: "RHOSO-12752" + common_pod_status_str: "Running" + common_pod_nspace: openstack + common_pod_list: - openstackclient tasks: - name: "Verify Running Pods" @@ -85,10 +85,10 @@ KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" vars: - pod_test_id: "RHOSO-12673" - pod_status_str: "Running" - pod_nspace: openshift-operators-redhat - pod_list: + common_pod_test_id: "RHOSO-12673" + common_pod_status_str: "Running" + common_pod_nspace: openshift-operators-redhat + common_pod_list: - loki-operator-controller-manager tasks: @@ -107,10 +107,10 @@ KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" vars: - pod_test_id: "RHOSO-12676" - pod_status_str: "Running" - pod_nspace: openshift-logging - pod_list: + common_pod_test_id: "RHOSO-12676" + common_pod_status_str: "Running" + common_pod_nspace: openshift-logging + common_pod_list: - cluster-logging-operator - collector - logging-loki-compactor @@ -124,7 +124,7 @@ ### see JIRA LOG-5431 if pods not running tasks: - - name: "Verify Pods running" + - name: "Verify Pods running" ansible.builtin.import_role: name: common @@ -136,10 +136,10 @@ KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" vars: - pod_test_id: "RHOSO-12674" - pod_status_str: "Running" - pod_nspace: minio-dev - pod_list: + common_pod_test_id: "RHOSO-12674" + common_pod_status_str: "Running" + common_pod_nspace: minio-dev + common_pod_list: - minio tasks: @@ -156,10 +156,10 @@ KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" vars: - pod_test_id: "RHOSO-12679" - pod_nspace: openstack - pod_status_str: "Completed" - pod_list: + common_pod_test_id: "RHOSO-12679" + common_pod_nspace: openstack + common_pod_status_str: "Completed" + common_pod_list: - bootstrap-edpm-deployment-logging - configure-network-edpm-deployment-logging - configure-os-edpm-deployment-logging diff --git a/roles/common/README.md b/roles/common/README.md index f76df028..75d4b2ab 100644 --- a/roles/common/README.md +++ b/roles/common/README.md @@ -1,25 +1,33 @@ common -========= +====== -The tests in this role are not specific to any one functional area but are an aggregate of common tests that can be used in all OSP 18.0/OCP jobs. +The tests in this role are not specific to any one functional area but are an +aggregate of common tests that can be used in all OSP 18.0/OCP jobs. + +The available tasks tests are: + +* pod tests Requirements ------------ -None +The requirements vary according to the tests run. + +For the pod tests, access to a kubernetes cluster and the oc command is needed, +this is done by passing the KUBECONFIG env var and PATH into the play. Role Variables -------------- -Variable required for all tasks to run: +Variable required for all tasks to run - For pod_tests.yml tasks: +For pod_tests.yml tasks: - pod_test_id - pod_list + common_pod_test_id + common_pod_list - list of pods to validate - pod_status_str + common_pod_status_str - status of pods to check - pod_nspace + common_pod_nspace - list of projects where pods exist @@ -31,23 +39,27 @@ None Example Playbook ---------------- -Typically, for this role the tests should *not* use a "main.yml" and import or include all the tests in the role. On the contrary, a tests should explicitly include specific tests needed for a given job. - - - hosts: controller - gather_facts: no - vars: - proj_out_file: verify_logging_projects_exist_lresults.log - proj_list: - - openshift-openstack-infra - - openshift - - openstack-operators - - openshift-logging - - tasks: - - name: Run projects tests - ansible.builtin.import_role: - name: common +The tasks run in this role are dependant on the vars that are configured +As such, the role can be called multiple times within the same play, with the +tests being configured at the task level (e.g. with import_role) or the vars +can be set at the play level. + + - hosts: controller + gather_facts: no + ignore_errors: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars: + common_pod_test_id: "RHOSO-12752" + common_pod_status_str: "Running" + common_pod_nspace: openstack + common_pod_list: + - openstackclient + tasks: + - name: "Verify Running Pods" + ansible.builtin.import_role: + name: common License diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 27480e58..e5d92dc1 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -1,8 +1,8 @@ --- -- name: "Verify pod - {{ pod_test_id }}" +- name: "Verify pod - {{ common_pod_test_id }}" when: - - pod_list is defined - - pod_nspace is defined - - pod_status_str is defined + - common_pod_list is defined + - common_pod_nspace is defined + - common_pod_status_str is defined ansible.builtin.include_tasks: "pod_tests.yml" loop: "{{ pod_list }}" diff --git a/roles/common/tasks/pod_tests.yml b/roles/common/tasks/pod_tests.yml index 4c9b5048..655c870c 100644 --- a/roles/common/tasks/pod_tests.yml +++ b/roles/common/tasks/pod_tests.yml @@ -1,15 +1,15 @@ --- -- name: Get Pod Instance "{{ pod_status_str }}" +- name: Get Pod Instance "{{ common_pod_status_str }}" ansible.builtin.shell: cmd: | - oc get pods -n "{{ pod_nspace }}" | grep "{{ item }}" | grep "{{ pod_status_str }}" | awk '{print $1;}' + oc get pods -n "{{ common_pod_nspace }}" | grep "{{ item }}" | grep "{{ common_pod_status_str }}" | awk '{print $1;}' register: podinstance changed_when: false - name: Check terminated pod ansible.builtin.shell: cmd: | - oc get pod -n "{{ pod_nspace }} {{ podinstance.stdout }}" + oc get pod -n "{{ common_pod_nspace }} {{ podinstance.stdout }}" register: output changed_when: false failed_when: From 735f8a4c2d0baa18b9be79a59561b7210cbaa112 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Fri, 13 Sep 2024 11:56:20 +0100 Subject: [PATCH 06/11] Run the logging tests from the same playbook --- ci/logging_tests_all.yml | 5 +++++ ci/vars-logging-test.yml | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 ci/logging_tests_all.yml diff --git a/ci/logging_tests_all.yml b/ci/logging_tests_all.yml new file mode 100644 index 00000000..114c9756 --- /dev/null +++ b/ci/logging_tests_all.yml @@ -0,0 +1,5 @@ +- name: Run the compute node tests + ansible.builtin.import_playbook: ci/logging_tests_compute.yml + +- name: Run the controller tests + ansible.builtin.import_playbook: ci/logging_tests_controller.yml diff --git a/ci/vars-logging-test.yml b/ci/vars-logging-test.yml index 8599e060..8ff0f00f 100644 --- a/ci/vars-logging-test.yml +++ b/ci/vars-logging-test.yml @@ -1,15 +1,10 @@ --- # pre_tests or post_tests are also options for when the FVT roles are run -post_deploy_00_fvt_logging_computes: - source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_computes.yml" +post_deploy_00_fvt_logging: + source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_all.yml" config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" type: playbook -post_deploy_00_logging_controller: - source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_local.yml" - config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" - type: playbook - post_deploy_99_collect_results: source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/report_result.yml" type: playbook From 3fc4e91f79c77ce8a4bbbfba54c86ae30b4e79e5 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Fri, 13 Sep 2024 15:02:39 +0100 Subject: [PATCH 07/11] Update paths on imported playbooks --- ci/logging_tests_all.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/logging_tests_all.yml b/ci/logging_tests_all.yml index 114c9756..dda60465 100644 --- a/ci/logging_tests_all.yml +++ b/ci/logging_tests_all.yml @@ -1,5 +1,5 @@ - name: Run the compute node tests - ansible.builtin.import_playbook: ci/logging_tests_compute.yml + ansible.builtin.import_playbook: logging_tests_compute.yml - name: Run the controller tests - ansible.builtin.import_playbook: ci/logging_tests_controller.yml + ansible.builtin.import_playbook: logging_tests_controller.yml From 92753637697da85154f036b27c4ed77427d8c899 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Mon, 16 Sep 2024 13:35:26 +0100 Subject: [PATCH 08/11] rename files --- ci/logging_tests_all.yml | 2 +- ci/{logging_tests_local.yml => logging_tests_controller.yml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename ci/{logging_tests_local.yml => logging_tests_controller.yml} (100%) diff --git a/ci/logging_tests_all.yml b/ci/logging_tests_all.yml index dda60465..bfa84459 100644 --- a/ci/logging_tests_all.yml +++ b/ci/logging_tests_all.yml @@ -1,5 +1,5 @@ - name: Run the compute node tests - ansible.builtin.import_playbook: logging_tests_compute.yml + ansible.builtin.import_playbook: logging_tests_computes.yml - name: Run the controller tests ansible.builtin.import_playbook: logging_tests_controller.yml diff --git a/ci/logging_tests_local.yml b/ci/logging_tests_controller.yml similarity index 100% rename from ci/logging_tests_local.yml rename to ci/logging_tests_controller.yml From 9912035ac9722a119f17d128cf9dd6929ae8db6c Mon Sep 17 00:00:00 2001 From: mgirgisf Date: Mon, 29 Jul 2024 10:06:16 +0300 Subject: [PATCH 09/11] [zuul]Add Graphing Job --- .zuul.yaml | 16 +++++++++++ ci/run_graphing_test.yml | 17 +++++++++++ ci/vars-graphing-test.yml | 9 ++++++ roles/telemetry_graphing/README.md | 26 +++++++++++++++++ roles/telemetry_graphing/tasks/main.yml | 28 +++++++++++++++++++ roles/telemetry_graphing/tasks/prom_query.yml | 16 +++++++++++ roles/telemetry_graphing/tasks/verify_url.yml | 27 ++++++++++++++++++ 7 files changed, 139 insertions(+) create mode 100644 ci/run_graphing_test.yml create mode 100644 ci/vars-graphing-test.yml create mode 100644 roles/telemetry_graphing/README.md create mode 100644 roles/telemetry_graphing/tasks/main.yml create mode 100644 roles/telemetry_graphing/tasks/prom_query.yml create mode 100644 roles/telemetry_graphing/tasks/verify_url.yml diff --git a/.zuul.yaml b/.zuul.yaml index f2789b2e..8d6b180b 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -60,6 +60,21 @@ - ci/noop.yml files: *irrelevant_files +- job: + name: functional-graphing-tests-osp18 + parent: functional-tests-on-osp18 + description: | + Run the UI Graphing test on osp18. + 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-autoscaling.yml" + - "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-functional-test.yml" + - "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-graphing-test.yml" + required-projects: *required_projects + irrelevant-files: *irrelevant_files + + - project: name: infrawatch/feature-verification-tests github-check: @@ -69,3 +84,4 @@ override-checkout: main - functional-tests-on-osp18 - functional-logging-tests-osp18 + - functional-graphing-tests-osp18 diff --git a/ci/run_graphing_test.yml b/ci/run_graphing_test.yml new file mode 100644 index 00000000..7e31c540 --- /dev/null +++ b/ci/run_graphing_test.yml @@ -0,0 +1,17 @@ +--- +- name: "Run functional test playbooks" + hosts: "{{ cifmw_target_hook_host | default('localhost') }}" + gather_facts: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars_files: + - vars/common.yml + tasks: + - name: "Run Graphing Console UI tests" + ansible.builtin.import_role: + name: telemetry_graphing + ignore_errors: true + + + diff --git a/ci/vars-graphing-test.yml b/ci/vars-graphing-test.yml new file mode 100644 index 00000000..ad13898d --- /dev/null +++ b/ci/vars-graphing-test.yml @@ -0,0 +1,9 @@ +# temp: skip os-net-setup +cifmw_os_net_setup_config: [] +post_deploy_00_run_graphing_test: + source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/run_graphing_test.yml" + config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" + type: playbook +post_deploy_99_collect_results: + source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/report_result.yml" + type: playbook diff --git a/roles/telemetry_graphing/README.md b/roles/telemetry_graphing/README.md new file mode 100644 index 00000000..36803b1b --- /dev/null +++ b/roles/telemetry_graphing/README.md @@ -0,0 +1,26 @@ +Telemetry_graphing +========= + +Verify that openstack dashboards exist in the openshift-console URL in RHOSO18 env. + +Requirements +------------ +1- Valid OSP18 env +2- "EnableDashboard:true" in the controlplane + + +Example Playbook +---------------- +No need for any extra steps or vars. + + - hosts: servers + tasks: + ansible.builtin.import_role: + name: telemetry_graphing + +License +------- + +Apache 2 + + diff --git a/roles/telemetry_graphing/tasks/main.yml b/roles/telemetry_graphing/tasks/main.yml new file mode 100644 index 00000000..85b1f987 --- /dev/null +++ b/roles/telemetry_graphing/tasks/main.yml @@ -0,0 +1,28 @@ +--- +- name: "[Test] Enable Graphing" + ansible.builtin.shell: + cmd: | + oc patch oscp/controlplane --type='json' -p '[{"op": "replace", "path": "/spec/telemetry/template/metricStorage/dashboardsEnabled", "value":true}]' + register: oscp_change + changed_when: false + +- name: "Deploy load so ceilometer has metrics to report" + ansible.builtin.shell: + cmd: | + oc rsh openstackclient openstack server create --flavor m1.small --image cirros --network private vm{{ item }} + loop: "{{ range(1, 6) | list }}" + register: vm_creation_result + changed_when: false + +- name: "Display VM creation results" + ansible.builtin.debug: + msg: "VM creation result: {{ item.stdout }}" + loop: "{{ vm_creation_result.results }}" + +- name: "Verify url for graphing test" + ansible.builtin.include_tasks: + file: verify_url.yml + +- name: "Verify promotheus query" + ansible.builtin.include_tasks: + file: prom_query.yml diff --git a/roles/telemetry_graphing/tasks/prom_query.yml b/roles/telemetry_graphing/tasks/prom_query.yml new file mode 100644 index 00000000..58710a06 --- /dev/null +++ b/roles/telemetry_graphing/tasks/prom_query.yml @@ -0,0 +1,16 @@ +- name: "[Test] Run openstack metric query to check Prometheus scrape endpoints" + ansible.builtin.shell: + cmd: | + oc rsh openstackclient openstack metric query up --disable-rbac -c container -c instance -c value + register: metric_query_result + changed_when: false + +- name: Check if query was successful + ansible.builtin.debug: + msg: "Metric query result: {{ metric_query_result.stdout }}" + when: metric_query_result.rc == 0 + +- name: Fail if the query was unsuccessful + ansible.builtin.fail: + msg: "Failed to query metrics or no data returned." + when: metric_query_result.rc != 0 diff --git a/roles/telemetry_graphing/tasks/verify_url.yml b/roles/telemetry_graphing/tasks/verify_url.yml new file mode 100644 index 00000000..c48f02da --- /dev/null +++ b/roles/telemetry_graphing/tasks/verify_url.yml @@ -0,0 +1,27 @@ +--- +- name: "Get OpenShift Console URL" + ansible.builtin.shell: + cmd: | + oc get routes -n openshift-console -o jsonpath='{.items[0].spec.host}' + register: console_url + changed_when: false + +- name: "Set OpenShift Console URL fact" + ansible.builtin.set_fact: + openshift_console_url: "https://{{ console_url.stdout }}" + +#curl -o /dev/null -s -w "%{http_code}\n" "{{ openshift_console_url }}" +- name: "Check OpenShift Console URL is accessible" + ansible.builtin.shell: + cmd: | + curl -o /dev/null -s -w "%{http_code}\n" {{ openshift_console_url }} + register: curl_result + changed_when: false + +- name: "[Test] Verify the OpenShift Console URL is returning status 200" + ansible.builtin.assert: + that: + - curl_result.stdout == "200" + fail_msg: "OpenShift Console URL is not accessible or does not return status 200. Status code: {{ curl_result.stdout }}" + success_msg: "OpenShift Console URL is accessible and returns status 200." + From 9bee7f2b1912379d8312024e044550f67f72adaf Mon Sep 17 00:00:00 2001 From: mgirgisf Date: Mon, 23 Sep 2024 10:09:56 +0200 Subject: [PATCH 10/11] Add UI Cypress test --- .zuul.yaml | 6 +- callback_plugins/custom_logger.py | 4 +- ci/run_graphing_test.yml | 31 ++++++- roles/telemetry_graphing/README.md | 4 +- .../files/cypress.config.js | 8 ++ .../files/dashboard-openstack-cloud.js | 49 +++++++++++ .../telemetry_graphing/tasks/cypress_test.yml | 86 +++++++++++++++++++ roles/telemetry_graphing/tasks/main.yml | 25 +----- roles/telemetry_graphing/tasks/prom_query.yml | 16 ---- roles/telemetry_graphing/tasks/verify_url.yml | 14 +-- roles/telemetry_graphing/vars/main.yml | 4 + 11 files changed, 190 insertions(+), 57 deletions(-) create mode 100644 roles/telemetry_graphing/files/cypress.config.js create mode 100644 roles/telemetry_graphing/files/dashboard-openstack-cloud.js create mode 100644 roles/telemetry_graphing/tasks/cypress_test.yml delete mode 100644 roles/telemetry_graphing/tasks/prom_query.yml create mode 100644 roles/telemetry_graphing/vars/main.yml diff --git a/.zuul.yaml b/.zuul.yaml index 8d6b180b..40b9fcd8 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -62,15 +62,17 @@ - job: name: functional-graphing-tests-osp18 - parent: functional-tests-on-osp18 + parent: telemetry-operator-multinode-autoscaling description: | Run the UI Graphing test on osp18. vars: + cifmw_run_tests: false 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-autoscaling.yml" - - "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-functional-test.yml" - "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-graphing-test.yml" + roles: + - zuul: github.com/openstack-k8s-operators/ci-framework required-projects: *required_projects irrelevant-files: *irrelevant_files diff --git a/callback_plugins/custom_logger.py b/callback_plugins/custom_logger.py index 665b87ed..1dec950b 100644 --- a/callback_plugins/custom_logger.py +++ b/callback_plugins/custom_logger.py @@ -54,11 +54,13 @@ def playbook_on_stats(self, stats): def log_task_result(self, 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 or "RHOSO" in task_name or "UI" in task_name: if "RHELOSP" in task_name: test_id = re.search(r'RHELOSP\S*', task_name).group(0) elif "RHOSO" in task_name: test_id = re.search(r'RHOSO\S*', task_name).group(0) + elif "UI" in task_name: + test_id = re.search(r'UI\S*', task_name).group(0) file_path = os.path.join(self.output_dir, f"test_run_result.out") test_result_message = self.MSG_FORMAT.format(task=test_id, status=result) diff --git a/ci/run_graphing_test.yml b/ci/run_graphing_test.yml index 7e31c540..9349d65c 100644 --- a/ci/run_graphing_test.yml +++ b/ci/run_graphing_test.yml @@ -8,10 +8,33 @@ vars_files: - vars/common.yml tasks: - - name: "Run Graphing Console UI tests" - ansible.builtin.import_role: - name: telemetry_graphing - ignore_errors: true + - block: + - name: "Enable Graphing" + ansible.builtin.shell: + cmd: | + oc patch oscp/controlplane --type='json' -p '[{"op": "replace", "path": "/spec/telemetry/template/metricStorage/dashboardsEnabled", "value":true}]' + register: oscp_change + changed_when: false + + - name: Wait until the oscp is resolved the changes to continue + ansible.builtin.shell: + cmd: | + oc get oscp | grep "Setup complete" + retries: 24 + timeout: 5 + until: output.stdout_lines | length == 1 + register: output + + - name: "Run Graphing Console UI tests" + ansible.builtin.import_role: + name: telemetry_graphing + ignore_errors: true + + always: + - name: "Revert the oscp/controlplane change" + ansible.builtin.shell: + cmd: | + oc patch oscp/controlplane --type='json' -p '[{"op": "replace", "path": "/spec/telemetry/template/metricStorage/dashboardsEnabled", "value":false}]' diff --git a/roles/telemetry_graphing/README.md b/roles/telemetry_graphing/README.md index 36803b1b..28571987 100644 --- a/roles/telemetry_graphing/README.md +++ b/roles/telemetry_graphing/README.md @@ -2,13 +2,15 @@ Telemetry_graphing ========= Verify that openstack dashboards exist in the openshift-console URL in RHOSO18 env. +By deploy Cypress and add the tests inside telemetry_graphing/files/*Cypress to confirm the dashboards exists. Requirements ------------ -1- Valid OSP18 env +1- Valid RHOSO-18 env 2- "EnableDashboard:true" in the controlplane + Example Playbook ---------------- No need for any extra steps or vars. diff --git a/roles/telemetry_graphing/files/cypress.config.js b/roles/telemetry_graphing/files/cypress.config.js new file mode 100644 index 00000000..07d74e72 --- /dev/null +++ b/roles/telemetry_graphing/files/cypress.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('cypress') +module.exports = defineConfig({ + e2e: { + baseUrl: 'https://console-openshift-console.apps-crc.testing', + specPattern: 'cypress/integration/**/*.{js,jsx,ts,tsx}', + supportFile: false, + }, +}) \ No newline at end of file diff --git a/roles/telemetry_graphing/files/dashboard-openstack-cloud.js b/roles/telemetry_graphing/files/dashboard-openstack-cloud.js new file mode 100644 index 00000000..74082157 --- /dev/null +++ b/roles/telemetry_graphing/files/dashboard-openstack-cloud.js @@ -0,0 +1,49 @@ +describe('OpenShift Console Dashboard Test', () => { + const username = 'developer'; + const password = 'developer'; + + before(() => { + // Visit the login page + cy.visit('https://console-openshift-console.apps-crc.testing/login'); + + // Perform login + cy.get('input[id="inputUsername"]').invoke('val', username).trigger('input'); + cy.get('input[id="inputPassword"]').invoke('val', password).trigger('input'); + cy.get('button[type="submit"]').click(); + + cy.wait(5000); + + cy.get('body').then($body => { + if ($body.find('button:contains("Skip tour")').length > 0) { + cy.contains('button', 'Skip tour').click(); // Only click if the button is found + } + }); + + }); + + it('should load and validate the OpenStack dashboards', () => { + // List of dashboards to check + const dashboards = [ + { url: '/grafana-dashboard-openstack-cloud', screenshot: 'openstack-cluster' }, + { url: '/grafana-dashboard-openstack-rabbitmq', screenshot: 'openstack-rabbitmq' }, + { url: '/grafana-dashboard-openstack-node', screenshot: 'openstack-node' }, + { url: '/grafana-dashboard-openstack-vm', screenshot: 'openstack-vms' } + ]; + + + + // Iterate through each dashboard + dashboards.forEach(dashboard => { + cy.visit(`https://console-openshift-console.apps-crc.testing/monitoring/dashboards${dashboard.url}`); + + cy.wait(5000); + + // Wait for the dashboard to load and take a screenshot + cy.get('div[data-test-id="dashboard"]', { timeout: 10000 }) + .find('[data-test-id="panel-"], [data-test-id="panel-cpu"], [data-test-id="panel-overview"]') + + cy.wait(5000); + cy.screenshot(dashboard.screenshot); + }); + }); +}); \ No newline at end of file diff --git a/roles/telemetry_graphing/tasks/cypress_test.yml b/roles/telemetry_graphing/tasks/cypress_test.yml new file mode 100644 index 00000000..604dec37 --- /dev/null +++ b/roles/telemetry_graphing/tasks/cypress_test.yml @@ -0,0 +1,86 @@ +- name: Install cypress and the dependencies + block: + - name: Install Node.js + ansible.builtin.dnf: + name: nodejs + state: present + become: true + + - name: Install dependencies + ansible.builtin.dnf: + name: + - xorg-x11-server-Xvfb + - gtk3-devel + - nss + - alsa-lib + state: present + become: true + +- name: Create required dirs and files + block: + - name: Create cypress-tests directory + ansible.builtin.file: + path: "{{ cypress_tests_dir }}" + state: directory + mode: '0755' + + - name: Create cypress/integration directory + ansible.builtin.file: + path: "{{ cypress_integration_dir }}" + state: directory + mode: '0755' + + - name: Add cypress.config.js + ansible.builtin.copy: + src: "{{ role_path }}/files/cypress.config.js" + dest: "{{ cypress_tests_dir }}/cypress.config.js" + mode: '0644' + + - name: Add dashboard-openstack-cloud test + ansible.builtin.copy: + src: "{{ role_path }}/files/dashboard-openstack-cloud.js" + dest: "{{ cypress_integration_dir }}/dashboard-openstack-cloud.js" + mode: '0644' + + - name: Create screenshot logs dir + ansible.builtin.file: + path: "{{ screenshots_dir }}" + state: directory + mode: '0755' + +- name: Initialize npm project + ansible.builtin.command: npm init -y + args: + chdir: "{{ cypress_tests_dir }}" + changed_when: false + +- name: Install Cypress as a dev dependency + ansible.builtin.command: npm install cypress --save-dev + args: + chdir: "{{ cypress_tests_dir }}" + changed_when: false + +- name: "UI-2 Run Cypress tests to validate dashboards exist" + ansible.builtin.shell: | + Xvfb :99 -ac & + export DISPLAY=:99 + npx cypress run + args: + chdir: "{{ cypress_tests_dir }}" + register: cypress_run + changed_when: false + +- name: Collect the screenshots + ansible.builtin.copy: + src: "{{ cypress_tests_dir }}/cypress/screenshots/dashboard-openstack-cloud.js/" + dest: "{{ screenshots_dir }}" + mode: '0644' + +- name: Show Cypress test output + ansible.builtin.debug: + var: cypress_run.stdout_lines + +- name: "UI-3 Check if all Cypress tests passed" + ansible.builtin.fail: + msg: "Some Cypress tests failed." + when: cypress_run.rc != 0 \ No newline at end of file diff --git a/roles/telemetry_graphing/tasks/main.yml b/roles/telemetry_graphing/tasks/main.yml index 85b1f987..f87c9af4 100644 --- a/roles/telemetry_graphing/tasks/main.yml +++ b/roles/telemetry_graphing/tasks/main.yml @@ -1,28 +1,9 @@ --- -- name: "[Test] Enable Graphing" - ansible.builtin.shell: - cmd: | - oc patch oscp/controlplane --type='json' -p '[{"op": "replace", "path": "/spec/telemetry/template/metricStorage/dashboardsEnabled", "value":true}]' - register: oscp_change - changed_when: false - -- name: "Deploy load so ceilometer has metrics to report" - ansible.builtin.shell: - cmd: | - oc rsh openstackclient openstack server create --flavor m1.small --image cirros --network private vm{{ item }} - loop: "{{ range(1, 6) | list }}" - register: vm_creation_result - changed_when: false - -- name: "Display VM creation results" - ansible.builtin.debug: - msg: "VM creation result: {{ item.stdout }}" - loop: "{{ vm_creation_result.results }}" - - name: "Verify url for graphing test" ansible.builtin.include_tasks: file: verify_url.yml -- name: "Verify promotheus query" +- name: "Run cypress test" ansible.builtin.include_tasks: - file: prom_query.yml + file: cypress_test.yml + diff --git a/roles/telemetry_graphing/tasks/prom_query.yml b/roles/telemetry_graphing/tasks/prom_query.yml deleted file mode 100644 index 58710a06..00000000 --- a/roles/telemetry_graphing/tasks/prom_query.yml +++ /dev/null @@ -1,16 +0,0 @@ -- name: "[Test] Run openstack metric query to check Prometheus scrape endpoints" - ansible.builtin.shell: - cmd: | - oc rsh openstackclient openstack metric query up --disable-rbac -c container -c instance -c value - register: metric_query_result - changed_when: false - -- name: Check if query was successful - ansible.builtin.debug: - msg: "Metric query result: {{ metric_query_result.stdout }}" - when: metric_query_result.rc == 0 - -- name: Fail if the query was unsuccessful - ansible.builtin.fail: - msg: "Failed to query metrics or no data returned." - when: metric_query_result.rc != 0 diff --git a/roles/telemetry_graphing/tasks/verify_url.yml b/roles/telemetry_graphing/tasks/verify_url.yml index c48f02da..4602355e 100644 --- a/roles/telemetry_graphing/tasks/verify_url.yml +++ b/roles/telemetry_graphing/tasks/verify_url.yml @@ -10,18 +10,10 @@ ansible.builtin.set_fact: openshift_console_url: "https://{{ console_url.stdout }}" -#curl -o /dev/null -s -w "%{http_code}\n" "{{ openshift_console_url }}" -- name: "Check OpenShift Console URL is accessible" +- name: "UI-1 Check OpenShift Console URL is accessible" ansible.builtin.shell: cmd: | - curl -o /dev/null -s -w "%{http_code}\n" {{ openshift_console_url }} + curl -o /dev/null -s -w "%{http_code}" -k {{ openshift_console_url }} register: curl_result changed_when: false - -- name: "[Test] Verify the OpenShift Console URL is returning status 200" - ansible.builtin.assert: - that: - - curl_result.stdout == "200" - fail_msg: "OpenShift Console URL is not accessible or does not return status 200. Status code: {{ curl_result.stdout }}" - success_msg: "OpenShift Console URL is accessible and returns status 200." - + failed_when: curl_result.stdout != "200" diff --git a/roles/telemetry_graphing/vars/main.yml b/roles/telemetry_graphing/vars/main.yml new file mode 100644 index 00000000..6d82bcd1 --- /dev/null +++ b/roles/telemetry_graphing/vars/main.yml @@ -0,0 +1,4 @@ +--- +cypress_tests_dir: "{{ ansible_env.HOME }}/cypress-tests" +cypress_integration_dir: "{{ cypress_tests_dir }}/cypress/integration" +screenshots_dir: "{{ ansible_env.HOME }}/ci-framework-data/logs/feature-verification-tests/screenshots" \ No newline at end of file From d3f24472b4cd12cdbccb0da9ff8b2675dae18da1 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Mon, 16 Sep 2024 17:11:28 +0100 Subject: [PATCH 11/11] [Logging] Add Pod Test --- ci/ansible.cfg | 3 - ci/logging_tests_controller.yml | 67 +------------------ ci/vars-logging-test.yml | 1 - roles/common/README.md | 5 ++ roles/common/tasks/main.yml | 4 +- roles/common/tasks/pod_tests.yml | 45 ++++++++----- roles/test_ha/README.md | 38 ----------- roles/test_ha/defaults/main.yml | 2 - roles/test_ha/meta/main.yml | 28 -------- roles/test_ha/tasks/main.yml | 111 ------------------------------- roles/test_ha/vars/main.yml | 2 - stf_functional_tests.yml | 4 -- 12 files changed, 38 insertions(+), 272 deletions(-) delete mode 100644 roles/test_ha/README.md delete mode 100644 roles/test_ha/defaults/main.yml delete mode 100644 roles/test_ha/meta/main.yml delete mode 100644 roles/test_ha/tasks/main.yml delete mode 100644 roles/test_ha/vars/main.yml diff --git a/ci/ansible.cfg b/ci/ansible.cfg index 49f3ea2f..9ac39d6e 100644 --- a/ci/ansible.cfg +++ b/ci/ansible.cfg @@ -4,9 +4,6 @@ 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 - [custom_logger] output_dir = /$HOME diff --git a/ci/logging_tests_controller.yml b/ci/logging_tests_controller.yml index 20a9fed4..928c7023 100644 --- a/ci/logging_tests_controller.yml +++ b/ci/logging_tests_controller.yml @@ -1,48 +1,4 @@ --- -#- name: Prepare Logging Tests -# hosts: controller -# gather_facts: true -# ignore_errors: false -## vars: -## id_rsa_path: "{{ playbook_dir }}/id_rsa.ctlplane" -## 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_local" -# state: directory -# mode: "0755" - -# # This needs to be updated; what do we use elsewhere? -# # Elsewhere, we assume that we're already logged in -# - name: "Log into OCP" -# ansible.builtin.shell: -# cmd: | -# oc login -u kubeadmin -p "12345678" https://api.crc.testing:6443 -# failed_when: false -# changed_when: false -# -# # I don't think we need this, Zuul __should__ have taken care of this already -# - name: "Create id rsa file for ctlplane access" -# ansible.builtin.shell: -# cmd: | -# oc extract -n openstack secrets/dataplane-ansible-ssh-private-key-secret --to=- | grep -v "ssh\-rsa" > "{{ id_rsa_path }}" -# register: rsa_results -# failed_when: rsa_results.rc != 0 -# changed_when: false -# -# # (efoley): Once again, I don't think this is necessary; if it's not needed for zuul, because it's already done, but is needed before running this on other systems, then the README should be updated to reflect this; -# # A troubleshooting section can be added too so users can identify when they are missing these configuration steps -# - name: "Change files permissions" -# ansible.builtin.shell: -# cmd: | -# chmod 600 "{{ id_rsa_path }}" -# changed_when: false - - name: "Verify logging projects, endpoints, credentials, nodes, pods, services, manifests and subscriptions" hosts: controller gather_facts: no @@ -95,9 +51,6 @@ - name: "Verify Pods running" ansible.builtin.import_role: name: common - # vars can be passed here, so we can use the same play for this and the next play. - # vars: - # - - name: "Verify logging pods are running in openshift-logging" hosts: controller @@ -115,7 +68,7 @@ - collector - logging-loki-compactor - logging-loki-distributor - - logging-loki-gateway + #- logging-loki-gateway - logging-loki-index-gateway - logging-loki-ingester - logging-loki-querier @@ -160,23 +113,7 @@ common_pod_nspace: openstack common_pod_status_str: "Completed" common_pod_list: - - bootstrap-edpm-deployment-logging - - configure-network-edpm-deployment-logging - - configure-os-edpm-deployment-logging - - download-cache-edpm-deployment-logging - - install-certs-edpm-deployment-logging - - install-os-edpm-deployment-logging - - libvirt-edpm-deployment-logging - - logging-edpm-deployment-logging-openstack-edpm - - neutron-metadata-edpm-deployment-logging - - nova-custom-edpm-deployment - - ovn-edpm-deployment-logging - - reboot-os-edpm-deployment-logging - - repo-setup-edpm-deployment-logging - - run-os-edpm-deployment-logging - - ssh-known-hosts-edpm-deployment-logging - - telemetry-edpm-deployment-logging - - validate-network-edpm-deployment-logging + - logging-edpm-deployment-openstack-edpm-ipam tasks: - name: "Run pods completed tests" ansible.builtin.import_role: diff --git a/ci/vars-logging-test.yml b/ci/vars-logging-test.yml index 8ff0f00f..89b17d92 100644 --- a/ci/vars-logging-test.yml +++ b/ci/vars-logging-test.yml @@ -4,7 +4,6 @@ post_deploy_00_fvt_logging: source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_all.yml" config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" type: playbook - post_deploy_99_collect_results: source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/report_result.yml" type: playbook diff --git a/roles/common/README.md b/roles/common/README.md index 75d4b2ab..b5e5bdce 100644 --- a/roles/common/README.md +++ b/roles/common/README.md @@ -16,6 +16,10 @@ The requirements vary according to the tests run. For the pod tests, access to a kubernetes cluster and the oc command is needed, this is done by passing the KUBECONFIG env var and PATH into the play. +The following tools are also needed: +* grep +* awk + Role Variables -------------- Variable required for all tasks to run @@ -23,6 +27,7 @@ Variable required for all tasks to run For pod_tests.yml tasks: common_pod_test_id + - polarion ID number for each test. common_pod_list - list of pods to validate common_pod_status_str diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index e5d92dc1..2f4cf281 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -1,8 +1,8 @@ --- -- name: "Verify pod - {{ common_pod_test_id }}" +- name: "Run pod tests" when: - common_pod_list is defined - common_pod_nspace is defined - common_pod_status_str is defined ansible.builtin.include_tasks: "pod_tests.yml" - loop: "{{ pod_list }}" + loop: "{{ common_pod_list }}" diff --git a/roles/common/tasks/pod_tests.yml b/roles/common/tasks/pod_tests.yml index 655c870c..74c35470 100644 --- a/roles/common/tasks/pod_tests.yml +++ b/roles/common/tasks/pod_tests.yml @@ -1,18 +1,31 @@ --- -- name: Get Pod Instance "{{ common_pod_status_str }}" - ansible.builtin.shell: - cmd: | - oc get pods -n "{{ common_pod_nspace }}" | grep "{{ item }}" | grep "{{ common_pod_status_str }}" | awk '{print $1;}' - register: podinstance - changed_when: false - -- name: Check terminated pod - ansible.builtin.shell: - cmd: | - oc get pod -n "{{ common_pod_nspace }} {{ podinstance.stdout }}" - register: output - changed_when: false - failed_when: - - output.rc != 0 - - podinstance.stdout == "" +- block: + # expects that one line will be returned + # todo: define what hapens when there are multiple pods returned + - name: Get Pod Instance name "{{ common_pod_status_str }}" + ansible.builtin.shell: + cmd: | + oc get pods -n "{{ common_pod_nspace }}" | grep "{{ item }}" | grep "{{ common_pod_status_str }}" | awk '{print $1;}' + register: podinstance + failed_when: + - podinstance.stdout_lines | length != 1 + changed_when: false + - name: Check pod {{ common_pod_test_id }} + ansible.builtin.command: + cmd: | + oc get pod -n "{{ common_pod_nspace }}" "{{ podinstance.stdout }}" + register: output + changed_when: false + failed_when: + - output.rc != 0 + - podinstance.stdout == "" + rescue: + - name: Get Pod Instance "{{ item }}" + ansible.builtin.shell: + cmd: | + oc get pods -n "{{ common_pod_nspace }}" | grep "{{ item }}" + register: podinstance + failed_when: + - podinstance.stdout_lines | length == 0 + changed_when: false diff --git a/roles/test_ha/README.md b/roles/test_ha/README.md deleted file mode 100644 index 3197be5c..00000000 --- a/roles/test_ha/README.md +++ /dev/null @@ -1,38 +0,0 @@ -test_ha -============== - -Tests for the High Availability functionality deployed in STF - -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. - -Role Variables --------------- - -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. - -Dependencies ------------- - -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - { role: username.rolename, x: 42 } - -License -------- - -Apache 2 - -Author Information ------------------- - -An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/test_ha/defaults/main.yml b/roles/test_ha/defaults/main.yml deleted file mode 100644 index 7f8fbd77..00000000 --- a/roles/test_ha/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# defaults file for test_ha diff --git a/roles/test_ha/meta/main.yml b/roles/test_ha/meta/main.yml deleted file mode 100644 index 01c7340b..00000000 --- a/roles/test_ha/meta/main.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -galaxy_info: - author: CloudOps - description: "Tests for the HighAvailability functionality deployed in STF" - company: Red Hat - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - license: "Apache-2.0" - - min_ansible_version: "2.1" - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - platforms: - - name: Fedora - versions: - - all - - name: EL - versions: - - all - - galaxy_tags: [] - -dependencies: [] diff --git a/roles/test_ha/tasks/main.yml b/roles/test_ha/tasks/main.yml deleted file mode 100644 index a5634262..00000000 --- a/roles/test_ha/tasks/main.yml +++ /dev/null @@ -1,111 +0,0 @@ ---- -# Assuming we've already logged in... -# Following procedure on https://infrawatch.github.io/documentation/#high-availability_assembly-advanced-features -# Assuming we're in teh right project already... - -- name: "RHELOSP-144992" -# description: "Add highAvailability.enabled: true to the spec section" - ansible.builtin.shell: - cmd: | - oc patch stf/default --type merge -p '{"spec":{"highAvailability":{"enabled": true}}}' - changed_when: false - register: cmd_output - failed_when: cmd_output.rc != 0 - -- name: "Wait 3 minutes to make sure all HA pods are up and running" - ansible.builtin.pause: - minutes: 3 - -- name: "RHELOSP-144994" -# description: Verify that AMQP Interconnect shows two containers - ansible.builtin.shell: - cmd: | - oc get pods | grep default-interconnect| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=2" - changed_when: false - -- name: "RHELOSP-144989" -# description: Verify that Alert Manager shows two containers - ansible.builtin.shell: - cmd: | - oc get pods | grep alertmanager| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=2" - changed_when: false - -- name: "RHELOSP-144995" -# description: "Verify that Prometheus shows two containers" - ansible.builtin.shell: - cmd: | - oc get pods | grep prometheus-default| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=2" - changed_when: false - -- name: "RHELOSP-144993" -# description: "Verify that Ceilometer Events Smartgateway shows two containers" - ansible.builtin.shell: - cmd: | - oc get pods | grep default-cloud1-ceil-event| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=2" - changed_when: false - -- name: "RHELOSP-144991" -# description: "Verify that Ceilometer Metrics Smartgateway shows two containers" - ansible.builtin.shell: - cmd: | - oc get pods | grep default-cloud1-ceil-meter| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=2" - changed_when: false - -- name: "RHELOSP-144990" -# description: "Verify that Collectd Events Smartgateway shows two containers" - ansible.builtin.shell: - cmd: | - oc get pods | grep default-cloud1-coll-event| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=2" - changed_when: false - -- name: "RHELOSP-144999" -# description: "Verify that Collectd Metrics Smartgateway shows two containers" - ansible.builtin.shell: - cmd: | - oc get pods | grep default-cloud1-coll-meter| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=2" - changed_when: false - -- name: "RHELOSP-144998" -# description: "Verify that Collectd Sensubility shows two containers" - ansible.builtin.shell: - cmd: | - oc get pods | grep default-cloud1-sens-meter| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=2" - changed_when: false - -- name: "RHELOSP-144997" -# description: "Verify that ElasticSearch shows three containers" - ansible.builtin.shell: - cmd: | - oc get pods | grep elasticsearch-es-default| wc -l - register: cmd_output - failed_when: "cmd_output.stdout|int !=3" - changed_when: false - -- name: "RHELOSP-144996" -# description: "Disable HighAvailability after running test" - ansible.builtin.shell: - cmd: | - oc patch stf/default --type merge -p '{"spec":{"highAvailability":{"enabled": false}}}' - changed_when: false - register: cmd_output - failed_when: cmd_output.rc != 0 - -- name: "Wait 3 minutes to make sure all HA pods are destroyed" - ansible.builtin.pause: - minutes: 3 diff --git a/roles/test_ha/vars/main.yml b/roles/test_ha/vars/main.yml deleted file mode 100644 index b01dba6f..00000000 --- a/roles/test_ha/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# vars file for test_ha diff --git a/stf_functional_tests.yml b/stf_functional_tests.yml index ed732bf0..60c14ee7 100644 --- a/stf_functional_tests.yml +++ b/stf_functional_tests.yml @@ -65,10 +65,6 @@ ansible.builtin.import_role: name: test_verify_email - - name: "Test HA" - ansible.builtin.import_role: - name: test_ha - - name: "Test observabilityStrategy" ansible.builtin.import_role: name: test_observability_strategy