diff --git a/.zuul.yaml b/.zuul.yaml index 2810ef478..5b1f7f083 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -25,6 +25,7 @@ - "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/openstack-k8s-operators/telemetry-operator'].src_dir }}/ci/vars-autoscaling-tempest.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-use-master-containers.yml" + - "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-metric-verification-test.yml" roles: - zuul: github.com/openstack-k8s-operators/ci-framework required-projects: &required_projects @@ -188,6 +189,7 @@ - ci/logging_tests_controller.yml - ci/report_result.yml - .zuul.yaml + - ci/vars-metric-verification-test.yml - functional-periodic-telemetry-with-ceph: files: # Run this job for changes to the volume_pool_metrics test changes as this is diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 000000000..68f56f1d8 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,11 @@ +[defaults] +callbacks_enabled = custom_junit, custom_logger +callback_plugins = callback_plugins +# additional paths to search for roles +roles_path = roles:/usr/share/ansible/roles:/etc/ansible/roles:~/.ansible/roles:../ci-framework/roles + +[custom_logger] +output_dir = /$HOME/ci-framework-data/tests/feature-verification-tests/ + +#[custom_junit] +#output_dir = /var/lib/AnsibleTests/external_files/feature-verification-tests/ diff --git a/ci/ansible-tests-fvt.yaml b/ci/ansible-tests-fvt.yaml new file mode 100644 index 000000000..b649fc5fb --- /dev/null +++ b/ci/ansible-tests-fvt.yaml @@ -0,0 +1,172 @@ +apiVersion: test.openstack.org/v1beta1 +kind: AnsibleTest +metadata: + name: ansible-fvt + namespace: openstack +spec: + #ansibleGitRepo: 'http://github.com/infrawatch/feature-verification-tests' + #ansibleGitRepo: 'http://github.com/elfiesmelfie/feature-verification-tests" -b "test_operator_changes' + # I pushed test_operator_changes to master + ansibleGitRepo: 'http://github.com/elfiesmelfie/feature-verification-tests' + debug: true + containerImage: quay.io/podified-antelope-centos9/openstack-ansible-tests:current-podified + # TODO: try an absolute path for the playbook. + #ansiblePlaybookPath: ci/run_verify_metrics_osp18.yml + storageClass: crc-csi-hostpath-provisioner + computeSSHKeySecretName: dataplane-ansible-ssh-private-key-secret + workloadSSHKeySecretName: dataplane-ansible-ssh-private-key-secret + # ansibleExtraVars: "ANSIBLE_ROLES_PATH=roles" + # need to check where the collection ends up living... + # or indeed, just the ansible playbook. + # /var/lib/ansible/ansible/ci/" + # install_yamls_dir needs to be updated later, maybe removed... the required dirs should be mounted into the pods + ansibleVarFiles: | + install_yamls_dir: "{{ ansible_env.HOME }}/install_yamls" + cifmw_openshift_kubeconfig: ~/.kube.config + cifmw_path: "{{ ansible_env.PATH }}:/var/lib/ansible/bin" + cifmw_openshift_api: api.crc.testing:6443 + cifmw_openshift_password: '12345678' + cifmw_openshift_user: kubeadmin + openstack_cmd: "oc -n openstack rsh openstackclient openstack" + patch_observabilityclient: true + telemetry_verify_metrics_metric_sources_to_test: + - ceilometer_compute_agent + - ceilometer_central_agent + #- ksm + - node_exporter + #- podman_exporter + #- rabbitmq + #- kepler + #- openstack_network_exporter + #- ceilometer_prom_exporter + #- mariadb + #ansibleCollections: "git+https://github.com/infrawatch/feature-verification-tests.git,master" + #ansibleCollections: 'git+https://github.com/elfiesmelfie/feature-verification-tests.git,test_operator_changes" "git+https://github.com/openstack-k8s-operators/ci-framework' + #ansibleCollections: 'git+https://github.com/elfiesmelfie/feature-verification-tests.git,test_operator_changes' + ansibleCollections: 'git+https://github.com/elfiesmelfie/feature-verification-tests.git,master' + # allow privilige escalation so ci_setup/tasks/packages can be run, even if we don't install any packages. + # Since the oc install tasks are in the pre-tasks playbook, and don't use the ci_setup role, this can be removed. + # TODO: Consider updating cifmw ci_setup role to have a separate get_oc_client task. + privileged: true + extraMounts: + - extraVol: + - mounts: + - name: test-operator-logs + mountPath: /var/lib/ansible/ci-framework-data/tests/feature-verification-tests + volumes: [] + ansibleInventory: | + localhost ansible_connection=local ansible_python_interpreter=python3 + compute-0 ansible_host=192.168.122.100 ansible_user=root ansible_ssh_private_key_file=/var/lib/ansible/.ssh/compute_id + compute-1 ansible_host=192.168.122.101 ansible_user=root ansible_ssh_private_key_file=/var/lib/ansible/.ssh/compute_id + [compute] + compute-0 + compute-1 + [controller] + localhost + [local] + localhost + workflow: + - stepName: verify-metrics + ansiblePlaybookPath: ci/run_verify_metrics_osp18.yml + - stepName: logging + ansiblePlaybookPath: ci/logging_tests_all.yml + - stepName: autoscaling + ansiblePlaybookPath: ci/run_autoscaling_tests.yml + - stepName: graphing + ansblePlaybookPath: ci/run_graphing_test.yml + - stepName: report-results + ansiblePlaybookPath: ci/report_result.yml + #FIELDS: + # SELinuxLevel + # A SELinuxLevel that should be used for test pods spawned by the test + # operator. + # + # TODO: check this option in test-operator, since it only seems to support a sigle extra collection at the moment + # TODO: Correct this to requirements.yml instead of requirements.yaml (or support both) + # ansibleCollections + # AnsibleCollections - extra ansible collections to instal in additionn to the + # ones exist in the requirements.yaml + # + # ansibleExtraVars + # AnsibleExtraVars - string to pass parameters to ansible using + # + # ansibleGitRepo -required- + # AnsibleGitRepo - git repo to clone into container + # ansibleInventory + # AnsibleInventory - string that contains the inventory file content + # + # ansiblePlaybookPath -required- + # AnsiblePlaybookPath - path to ansible playbook + # + # TODO: If the repos from the hosts are copied into the extraMounts, we can skip using the ansibleVarFiles interface, and use ansibleExtraVars: @ instead. + # ansibleVarFiles + # AnsibleVarFiles - interface to create ansible var files Those get added to + # the + # + # backoffLimit + # BackoffLimit allows to define the maximum number of retried executions + # (defaults to 0). + # + # computeSSHKeySecretName + # ComputeSSHKeySecretName is the name of the k8s secret that contains an ssh + # key for computes. + # The key is mounted to ~/.ssh/id_ecdsa in the ansible pod + # containerImage + # A URL of a container image that should be used by the test-operator for + # tests execution. + # + # debug + # Run ansible playbook with -vvvv + # extraConfigmapsMounts <[]Object> + # Extra configmaps for mounting inside the pod + # TODO: Investigate preparing a PV and populating it with the git repos from the host. + # This would removed the need to install from galaxy and push to elfie/master in order to run a playbook. + # The git repos could then be cloned from the local copy of the repo. + # + # extraMounts <[]Object> + # ExtraMounts containing conf files, credentials and storage volumes + # + # nodeSelector + # This value contains a nodeSelector value that is applied to test pods + # spawned by the test operator. + # + # openStackConfigMap + # OpenStackConfigMap is the name of the ConfigMap containing the clouds.yaml + # + # openStackConfigSecret + # OpenStackConfigSecret is the name of the Secret containing the secure.yaml + # TODO: add openstack config secrets, then skip running openstack commands in openstackclient. This also means that the version of promclient, observabilityclient and apdh client can be updated without patching the containers. + # clouds.yaml is included by default. Need to check the cloudname. + # The OS_CLOUD_NAME can be set in the env to select the cloud. + # clouds.yaml is mounted at /etc/openstack/clouds.yaml + # The cloud is called default. + # privileged + # Use with caution! This parameter specifies whether test-operator should + # spawn + # test pods with allowedPrivilegedEscalation: true, readOnlyRootFilesystem: + # false, + # runAsNonRoot: false, automountServiceAccountToken: true, and the default + # capabilities on top of capabilities that are usually needed by the test + # pods (NET_ADMIN, NET_RAW). This parameter is deemed insecure but it is + # needed for certain test-operator functionalities to work properly (e.g.: + # extraRPMs in Tempest CR, or certain set of tobiko tests). + # + # resources + # The desired amount of resources that should be assigned to each test pod + # spawned using the AnsibleTest CR. + # https://pkg.go.dev/k8s.io/api/core/v1#ResourceRequirements + # + # storageClass + # StorageClass used to create any test-operator related PVCs. + # + # tolerations <[]Object> + # This value contains a toleration that is applied to pods spawned by the + # test pods that are spawned by the test-operator. + # + # workflow <[]Object> + # A parameter that contains a workflow definition. + # + # workloadSSHKeySecretName + # WorkloadSSHKeySecretName is the name of the k8s secret that contains an ssh + # key for the ansible workload. + # The key is mounted to ~/test_keypair.key in the ansible pod diff --git a/ci/logging_tests_all.yml b/ci/logging_tests_all.yml index bfa844596..30b94a417 100644 --- a/ci/logging_tests_all.yml +++ b/ci/logging_tests_all.yml @@ -1,3 +1,7 @@ +- name: Run pre-test steps + ansible.builtin.import_playbook: pre-test-steps.yml + + - name: Run the compute node tests ansible.builtin.import_playbook: logging_tests_computes.yml diff --git a/ci/logging_tests_computes.yml b/ci/logging_tests_computes.yml index 6acd3cd96..449b54d95 100644 --- a/ci/logging_tests_computes.yml +++ b/ci/logging_tests_computes.yml @@ -12,6 +12,15 @@ - nova_compute common_file_list: - /etc/rsyslog.d/10-telemetry.conf + pre_tasks: + - name: "Skip logging test by run_logging_test false" + ansible.builtin.meta: end_play + when: not run_logging_test | default(true) | bool + + - name: "Skip logging test by logging disabled" + ansible.builtin.meta: end_play + when: not logging_enabled | bool + tasks: - name: "Run Telemetry Logging tests" ansible.builtin.import_role: @@ -33,6 +42,14 @@ common_container_list: - ceilometer_agent_compute - node_exporter + pre_tasks: + - name: "Skip logging test by run_logging_test false" + ansible.builtin.meta: end_play + when: not run_logging_test | default(true) | bool + + - name: "Skip logging test by logging disabled" + ansible.builtin.meta: end_play + when: not logging_enabled | bool tasks: - name: "Run the tests from the common role" ansible.builtin.import_role: diff --git a/ci/logging_tests_controller.yml b/ci/logging_tests_controller.yml index 7ebba7a87..6326c752f 100644 --- a/ci/logging_tests_controller.yml +++ b/ci/logging_tests_controller.yml @@ -68,6 +68,15 @@ - logging-loki-query-frontend-grpc - logging-loki-query-frontend-http - openstack-logging + pre_tasks: + - name: "Skip logging test by run_logging_test false" + ansible.builtin.meta: end_play + when: not run_logging_test | default(true) | bool + + - name: "Skip logging test by logging disabled" + ansible.builtin.meta: end_play + when: not logging_enabled | bool + tasks: - name: "Verify logging infrastructure components" ansible.builtin.import_role: @@ -105,6 +114,15 @@ common_pod_nspace: openshift-operators-redhat common_pod_list: - loki-operator-controller-manager + pre_tasks: + - name: "Skip logging test by run_logging_test false" + ansible.builtin.meta: end_play + when: not run_logging_test | default(true) | bool + + - name: "Skip logging test by logging disabled" + ansible.builtin.meta: end_play + when: not logging_enabled | bool + tasks: - name: "Verify Pods running" ansible.builtin.import_role: @@ -131,7 +149,15 @@ - logging-loki-querier - logging-loki-query-frontend - collector + pre_tasks: + - name: "Skip logging test by run_logging_test false" + ansible.builtin.meta: end_play + when: not run_logging_test | default(true) | bool + - name: "Skip logging test by logging disabled" + ansible.builtin.meta: end_play + when: not logging_enabled | bool + ### see JIRA LOG-5431 if pods not running tasks: - name: "Verify Pods running" @@ -151,6 +177,15 @@ common_pod_nspace: minio-dev common_pod_list: - minio + pre_tasks: + - name: "Skip logging test by run_logging_test false" + ansible.builtin.meta: end_play + when: not run_logging_test | default(true) | bool + + - name: "Skip logging test by logging disabled" + ansible.builtin.meta: end_play + when: not logging_enabled | bool + tasks: - name: "Run pod running tests" ansible.builtin.import_role: @@ -183,7 +218,17 @@ - ssh-known-hosts-edpm-deployment - telemetry-edpm-deployment-openstack-edpm-ipam - validate-network-edpm-deployment-openstack-edpm-ipam + pre_tasks: + - name: "Skip logging test by run_logging_test false" + ansible.builtin.meta: end_play + when: not run_logging_test | default(true) | bool + + - name: "Skip logging test by logging disabled" + ansible.builtin.meta: end_play + when: not logging_enabled | bool + tasks: + - name: "Run pods completed tests" ansible.builtin.import_role: name: common @@ -209,6 +254,15 @@ - lokistacks.loki.grafana.com - recordingrules.loki.grafana.com - rulerconfigs.loki.grafana.com + pre_tasks: + - name: "Skip logging test by run_logging_test false" + ansible.builtin.meta: end_play + when: not run_logging_test | default(true) | bool + + - name: "Skip logging test by logging disabled" + ansible.builtin.meta: end_play + when: not logging_enabled | bool + tasks: - name: "Run Services and CRD tests" ansible.builtin.import_role: diff --git a/ci/pre-test-steps.yml b/ci/pre-test-steps.yml new file mode 100644 index 000000000..cfb20d6e9 --- /dev/null +++ b/ci/pre-test-steps.yml @@ -0,0 +1,81 @@ +--- +- name: Run telemetry tests to verify metrics on osp18 + hosts: "{{ cifmw_target_hook_host | default('localhost') }}" + gather_facts: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}:/var/lib/ansible/bin" + vars_files: + - vars/common.yml + - vars/osp18_env.yml + vars: + cifmw_ci_setup_oc_install_path: "{{ ansible_user_dir ~ '/bin' }}" + # openshift client + cifmw_ci_setup_openshift_client_download_uri: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp" + cifmw_ci_setup_openshift_minimum_version: 4 + cifmw_ci_setup_openshift_client_version: 'stable-4.16' + tasks: + #TODO: Add this as a common playbook so it can be added to the other tests as well. + #- name: Install oc + # ansible.builtin.include_role: + # name: cifmw.general.ci_setup + # tasks_from: packages + # vars: + # cifmw_ci_setup_packages: [] + #TODO: use ci_setup one deps installation is sorted + - name: Ensure openshift client install path is present + ansible.builtin.file: + path: "{{ cifmw_ci_setup_oc_install_path }}" + state: directory + mode: "0755" + + - name: Install openshift client + ansible.builtin.unarchive: + src: "{{ cifmw_ci_setup_openshift_client_download_uri }}/{{ cifmw_ci_setup_openshift_client_version }}/openshift-client-linux.tar.gz" + dest: "{{ cifmw_ci_setup_oc_install_path }}" + remote_src: true + mode: "0755" + creates: "{{ cifmw_ci_setup_oc_install_path }}/oc" + + - name: Add the OC path to cifmw_path if needed + vars: + _cifmw_paths_list: >- + {{ + cifmw_path | split(':') + if cifmw_path is defined else [] + }} + when: cifmw_ci_setup_oc_install_path not in _cifmw_paths_list + ansible.builtin.set_fact: + cifmw_path: "{{ cifmw_ci_setup_oc_install_path }}:{{ ansible_env.PATH }}" + cacheable: true + + - name: Inject oc completion in local profile + block: + - name: Create completion file + ansible.builtin.shell: # noqa: risky-shell-pipe + cmd: >- + {{ cifmw_ci_setup_oc_install_path }}/oc completion bash | + tee -a ~/.oc_completion + creates: "{{ ansible_user_dir }}/.oc_completion" + no_log: true + + - name: Source completion from within .bashrc + ansible.builtin.blockinfile: + create: true + mode: "0644" + path: "{{ ansible_user_dir }}/.bashrc" + block: |- + if [ -f ~/.oc_completion ]; then + source ~/.oc_completion + fi + + - name: Log into openshift + ansible.builtin.shell: + cmd: | + oc login -u {{ cifmw_openshift_user }} -p {{ cifmw_openshift_password }} --insecure-skip-tls-verify {{ cifmw_openshift_api }} + register: cmd + retries: 10 + delay: 10 + until: cmd.rc == 0 + + diff --git a/ci/report_result.yml b/ci/report_result.yml index 3b44962e2..4fcdfdf04 100644 --- a/ci/report_result.yml +++ b/ci/report_result.yml @@ -1,15 +1,15 @@ --- -- name: "Create the output directory" - hosts: - - controller - vars_files: - - vars/common.yml - tasks: - - name: Create log dir - ansible.builtin.file: - path: "{{ logs_dir }}" - state: directory - mode: "0755" +#- name: "Create the output directory" +# hosts: +# - controller +# vars_files: +# - vars/common.yml +# tasks: +# - name: Create log dir +# ansible.builtin.file: +# path: "{{ logs_dir }}" +# state: directory +# mode: "0755" - name: Check the XML file for failed tasks hosts: controller diff --git a/ci/run_autoscaling_tests.yml b/ci/run_autoscaling_tests.yml index e5c5c48d9..f3a478ecf 100644 --- a/ci/run_autoscaling_tests.yml +++ b/ci/run_autoscaling_tests.yml @@ -1,4 +1,8 @@ --- +- name: Run pre-test steps + ansible.builtin.import_playbook: pre-test-steps.yml + + - name: Run telemetry autoscaling tests on osp18 hosts: "{{ cifmw_target_hook_host | default('localhost') }}" gather_facts: true @@ -40,11 +44,21 @@ tasks: - block: - name: Include vars from the extra_vars files + when: cifmw_basedir is defined ansible.builtin.include_vars: dir: "{{ cifmw_basedir }}/artifacts/parameters" + - when: install_yamls_dir is not defined + set_fact: + install_yamls_dir: '{{ ansible_env.HOME }}/{{ zuul.projects["github.com/openstack-k8s-operators/install_yamls"].src_dir }}/devsetup' + + - when: zuul is not defined + shell: + cmd: | + git clone http://github.com/openstack-k8s-operators/install_yamls + chdir: "{{ ansible_env.HOME }}/" - community.general.make: - chdir: '{{ ansible_env.HOME }}/{{ zuul.projects["github.com/openstack-k8s-operators/install_yamls"].src_dir }}/devsetup' + chdir: '{{ install_yamls_dir }}/devsetup' target: edpm_deploy_instance tags: - setup @@ -52,9 +66,10 @@ - name: Patch observabilityclient into openstackclient ansible.builtin.shell: cmd: | - oc exec openstackclient -- python3 -m ensurepip --upgrade - oc exec openstackclient -- python3 -m pip install --upgrade aodhclient - oc exec openstackclient -- python3 -m pip install --upgrade python-observabilityclient + oc exec -n openstack openstackclient -- python3 -m ensurepip --upgrade + oc exec -n openstack openstackclient -- python3 -m pip install --upgrade aodhclient + oc exec -n openstack openstackclient -- python3 -m pip install --upgrade python-observabilityclient + oc exec -n openstack openstackclient -- python3 -m pip install --upgrade prometheus-client when: patch_observabilityclient | default(false) | bool tags: - setup diff --git a/ci/run_cloudkitty_tests.yml b/ci/run_cloudkitty_tests.yml new file mode 100644 index 000000000..9bca36c29 --- /dev/null +++ b/ci/run_cloudkitty_tests.yml @@ -0,0 +1,76 @@ +--- +- name: Run pre-test steps + ansible.builtin.import_playbook: pre-test-steps.yml + +- name: Run cloudkitty tests on osp18 + hosts: "{{ cifmw_target_hook_host | default('localhost') }}" + gather_facts: true + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + vars_files: + - vars/common.yml + - vars/osp18_env.yml + tasks: + - block: + # TODO: consider mounting these dirs into the pod + #- name: Include vars from the extra_vars files + # ansible.builtin.include_vars: + # dir: "{{ cifmw_basedir }}/artifacts/parameters" + + - name: Patch cloudkittyclient into openstackclient + ansible.builtin.shell: + cmd: | + oc exec -n openstack openstackclient -- python3 -m ensurepip --upgrade + oc exec -n openstack openstackclient -- python3 -m pip install --upgrade git+https://github.com/openstack/python-cloudkittyclient@master + + - name: Check what rating modules are available + ansible.builtin.shell: + cmd: | + {{ openstack_cmd }} rating module list + + - name: Enable the hashmap rating module + ansible.builtin.shell: + cmd: | + {{ openstack_cmd }} rating module enable hashmap + + - name: Set priority on hashmap rating + ansible.builtin.shell: + cmd: | + {{ openstack_cmd }} rating module set priority hashmap 100 + + - name: Check that the API is available + ansible.builtin.shell: + cmd: | + {{ openstack_cmd }} rating module list + export GROUP_NAME=test_group_instance_uptime_flavor_id + export SERVICE_NAME=test_service_instance + export FIELD_NAME="flavor_id" + + {{ openstack_cmd }} rating hashmap group create $GROUP_NAME || true + export GROUP_ID=$({{ openstack_cmd }} rating hashmap group list -f value -c Name -c 'Group ID' | grep $GROUP_NAME| awk '{ print $2}') + + {{ openstack_cmd }} rating hashmap service create $SERVICE_NAME || true + export SERVICE_ID=$({{ openstack_cmd }} rating hashmap service list -f value -c Name -c 'Service ID' | grep $SERVICE_NAME | awk '{ print $2 }') + + {{ openstack_cmd }} rating hashmap field create $SERVICE_ID $FIELD_NAME || true + export FLAVOR_FIELD_ID=$({{ openstack_cmd }} rating hashmap field list $SERVICE_ID -f value -c Name -c 'Field ID' | grep $FIELD_NAME | awk '{ print $2}') + + export FLAVOR_NAME=m1.small + export FLAVOR_ID=$({{ openstack_cmd }} flavor list -f value -c Name -c ID | grep $FLAVOR_NAME | awk '{print $2}') + + {{ openstack_cmd }} rating hashmap mapping create 0.01 --field-id $FLAVOR_FIELD_ID --value $FLAVOR_ID -g $GROUP_ID -t flat + ignore_errors: true + + - name: Delete the created resources + ansible.builtin.shell: + cmd: | + export GROUP_NAME=test_group_instance_uptime_flavor_id + export SERVICE_NAME=test_service_instance + + export GROUP_ID=$({{ openstack_cmd }} rating hashmap group list -f value -c Name -c 'Group ID' | grep $GROUP_NAME| awk '{ print $2}') + export SERVICE_ID=$({{ openstack_cmd }} rating hashmap service list -f value -c Name -c 'Service ID' | grep $SERVICE_NAME | awk '{ print $2 }') + {{ openstack_cmd }} rating hashmap group delete $GROUP_ID + {{ openstack_cmd }} rating hashmap service delete $SERVICE_ID + + diff --git a/ci/run_functional_tests.yml b/ci/run_functional_tests.yml index 2c21864d7..41a91e373 100644 --- a/ci/run_functional_tests.yml +++ b/ci/run_functional_tests.yml @@ -1,3 +1,9 @@ +- name: Run pre-test steps + ansible.builtin.import_playbook: pre-test-steps.yml + +- name: Run Logging test + ansible.builtin.import_playbook: logging_tests_all.yml + - name: Run Autoscaling test ansible.builtin.import_playbook: run_autoscaling_tests.yml diff --git a/ci/run_graphing_test.yml b/ci/run_graphing_test.yml index 178127c39..82db5ce03 100644 --- a/ci/run_graphing_test.yml +++ b/ci/run_graphing_test.yml @@ -1,4 +1,8 @@ --- +- name: Run pre-test steps + ansible.builtin.import_playbook: pre-test-steps.yml + + - name: "Run functional test playbooks" hosts: "{{ cifmw_target_hook_host | default('localhost') }}" gather_facts: true @@ -43,4 +47,4 @@ - name: "Run Graphing Console UI tests" ansible.builtin.import_role: name: telemetry_graphing - ignore_errors: true \ No newline at end of file + ignore_errors: true diff --git a/ci/run_verify_metrics_osp18.yml b/ci/run_verify_metrics_osp18.yml index f7ace9df0..9fdcea7a2 100644 --- a/ci/run_verify_metrics_osp18.yml +++ b/ci/run_verify_metrics_osp18.yml @@ -1,29 +1,34 @@ --- +- name: Run pre-test steps + ansible.builtin.import_playbook: pre-test-steps.yml + - name: Run telemetry tests to verify metrics on osp18 hosts: "{{ cifmw_target_hook_host | default('localhost') }}" gather_facts: true environment: KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" - PATH: "{{ cifmw_path }}" + PATH: "{{ cifmw_path }}:/var/lib/ansible/bin" vars_files: - vars/common.yml - vars/osp18_env.yml tasks: - name: Include vars from the extra_vars files + when: cifmw_basedir is defined ansible.builtin.include_vars: dir: "{{ cifmw_basedir }}/artifacts/parameters" - name: Patch observabilityclient into openstackclient ansible.builtin.shell: cmd: | - oc exec openstackclient -- python3 -m ensurepip --upgrade - oc exec openstackclient -- python3 -m pip install --upgrade aodhclient - oc exec openstackclient -- python3 -m pip install --upgrade python-observabilityclient + oc exec -n openstack openstackclient -- python3 -m ensurepip --upgrade + oc exec -n openstack openstackclient -- python3 -m pip install --upgrade aodhclient + oc exec -n openstack openstackclient -- python3 -m pip install --upgrade python-observabilityclient + oc exec -n openstack openstackclient -- python3 -m pip install --upgrade prometheus-client when: patch_observabilityclient | default(false) | bool tags: - setup - name: "Run Telemetry Verify Metrics tests" ansible.builtin.import_role: - name: telemetry_verify_metrics + name: infrawatch.fvt.telemetry_verify_metrics ignore_errors: true diff --git a/ci/vars-metric-verification-test.yml b/ci/vars-metric-verification-test.yml index 6c730143b..6f66fa73f 100644 --- a/ci/vars-metric-verification-test.yml +++ b/ci/vars-metric-verification-test.yml @@ -1,12 +1,17 @@ --- +#pre_tests_00_fvt_verify_metrics: +# source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/run_verify_metrics_osp18.yml" +# type: playbook +# config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" + pre_tests_00_fvt_verify_metrics: - source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/run_verify_metrics_osp18.yml" - type: playbook - config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg" + source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible-tests-fvt.yaml" + type: cr + state: present cifmw_run_tests: true cifmw_test_operator_tempest_include_list: | ^tempest.*\[.*\bsmoke\b.*\] -post_tests_99_collect_results: - source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/report_result.yml" - type: playbook + #post_tests_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/galaxy.yml b/galaxy.yml index 69fe420e3..ae2ebb8d8 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,8 +1,8 @@ --- namespace: 'infrawatch' -name: 'functional_tests' +name: 'fvt' version: '0.0.1' -repository: http://github.com/infrawatch/functional-tests +repository: http://github.com/infrawatch/feature-verification-tests description: "Tests for STF components" license: - "Apache-2.0" diff --git a/roles/common/tasks/cr_tests.yml b/roles/common/tasks/cr_tests.yml index a9eaccd03..bdee66868 100644 --- a/roles/common/tasks/cr_tests.yml +++ b/roles/common/tasks/cr_tests.yml @@ -1,9 +1,12 @@ --- +- set_fact: + namespace: "{{ item.namespace | default('openstack') }}" + - name: | TEST Verify that the {{ item.kind }} {{ item.name }} CR exists ansible.builtin.command: cmd: | - oc get {{ item.kind }} {{ item.name }} + oc get -n {{ namespace }} {{ item.kind }} {{ item.name }} register: result changed_when: false failed_when: @@ -12,7 +15,7 @@ - name: Verify that a CR is ready ansible.builtin.command: cmd: | - oc get {{ item.kind }} {{ item.name }} -o jsonpath='{.status.conditions[?(@.type=="{{ item.condition_type }}")].status}{"\n"}' + oc get -n {{ namespace }} {{ item.kind }} {{ item.name }} -o jsonpath='{.status.conditions[?(@.type=="{{ item.condition_type }}")].status}{"\n"}' register: result changed_when: false failed_when: diff --git a/roles/telemetry_autoscaling/tasks/creating_stack.yml b/roles/telemetry_autoscaling/tasks/creating_stack.yml index 6276f8bc4..574435e68 100644 --- a/roles/telemetry_autoscaling/tasks/creating_stack.yml +++ b/roles/telemetry_autoscaling/tasks/creating_stack.yml @@ -1,9 +1,10 @@ --- +# TODO: Consider using a var for openstack namespace; this would make testing multi-openstack deployments possible. - name: Copy the templates to openstackclient pod ansible.builtin.shell: | - oc cp $HOME/templates/autoscaling/vnf/template.yaml openstackclient:/tmp - oc cp $HOME/templates/autoscaling/vnf/resources.yaml openstackclient:/tmp - oc cp $HOME/templates/autoscaling/vnf/instance.yaml openstackclient:/tmp + oc cp -n openstack $HOME/templates/autoscaling/vnf/template.yaml openstackclient:/tmp + oc cp -n openstack $HOME/templates/autoscaling/vnf/resources.yaml openstackclient:/tmp + oc cp -n openstack $HOME/templates/autoscaling/vnf/instance.yaml openstackclient:/tmp # template location was $HOME/templates/autoscaling/vnf/ - name: "[temp] Set the location to copy the template to" diff --git a/roles/telemetry_autoscaling/tasks/main.yml b/roles/telemetry_autoscaling/tasks/main.yml index fd0dcd50b..e1c350d1b 100644 --- a/roles/telemetry_autoscaling/tasks/main.yml +++ b/roles/telemetry_autoscaling/tasks/main.yml @@ -19,6 +19,13 @@ file: configure_heat.yml tags: setup + # TODO: moave this elsewhere later +- name: Install sshpass + become: true + ansible.builtin.dnf: + name: sshpass + state: present + - name: Launch the stack ansible.builtin.include_tasks: file: creating_stack.yml diff --git a/roles/telemetry_autoscaling/tasks/post_teardown.yml b/roles/telemetry_autoscaling/tasks/post_teardown.yml index b60c1c780..1fc42c1d8 100644 --- a/roles/telemetry_autoscaling/tasks/post_teardown.yml +++ b/roles/telemetry_autoscaling/tasks/post_teardown.yml @@ -2,19 +2,20 @@ - name: Check that the stack exists ansible.builtin.command: cmd: | - oc rsh openstackclient openstack stack show {{ stack_name }} + {{ openstack_cmd }} stack show {{ stack_name }} ignore_errors: true register: output - name: Remove the stack if it exists ansible.builtin.command: cmd: | - oc rsh openstackclient openstack stack delete {{ stack_name }} + {{ openstack_cmd }} stack delete {{ stack_name }} when: output.rc == 0 - name: Wait until the stack is deleted ansible.builtin.shell: - cmd: oc rsh openstackclient openstack stack list | grep {{ stack_name }} | wc -l + cmd: | + {{ openstack_cmd }} stack list | grep {{ stack_name }} | wc -l register: output until: output.stdout == '0' ignore_errors: true diff --git a/roles/telemetry_autoscaling/tasks/test_autoscaling.yml b/roles/telemetry_autoscaling/tasks/test_autoscaling.yml index c4ab08161..04388db2c 100644 --- a/roles/telemetry_autoscaling/tasks/test_autoscaling.yml +++ b/roles/telemetry_autoscaling/tasks/test_autoscaling.yml @@ -28,22 +28,22 @@ register: instance_count1 failed_when: instance_count1.stdout_lines | length != 1 -- shell: | - cat {{ ansible_env.HOME }}/.ssh/known_hosts | grep "{{ item | trim }}" - with_items: "{{ vnf_instance_ip.stdout_lines }}" - ignore_errors: true - -- name: Remove the existing hostkey, if there is one for the target IP - ansible.builtin.lineinfile: - dest: '{{ ansible_env.HOME }}/.ssh/known_hosts' - state: absent - regexp: "{{ item | trim }}" - with_items: "{{ vnf_instance_ip.stdout_lines }}" - -- shell: | - cat {{ ansible_env.HOME }}/.ssh/known_hosts | grep "{{ item | trim }}" - with_items: "{{ vnf_instance_ip.stdout_lines }}" - ignore_errors: true + #- shell: | + # cat {{ ansible_env.HOME }}/.ssh/known_hosts | grep "{{ item | trim }}" + # with_items: "{{ vnf_instance_ip.stdout_lines }}" + # ignore_errors: true + # + #- name: Remove the existing hostkey, if there is one for the target IP + # ansible.builtin.lineinfile: + # dest: '{{ ansible_env.HOME }}/.ssh/known_hosts' + # state: absent + # regexp: "{{ item | trim }}" + # with_items: "{{ vnf_instance_ip.stdout_lines }}" + # + #- shell: | + # cat {{ ansible_env.HOME }}/.ssh/known_hosts | grep "{{ item | trim }}" + # with_items: "{{ vnf_instance_ip.stdout_lines }}" + # ignore_errors: true # NOTE: Disabling strict host key checking so that ssh doesn't give an error # when the host key changes i.e. if a new VM has been assigned a @@ -55,10 +55,16 @@ # The key removal should move to some pre/pre-run stage. - name: Test automatic scaling up of instances ansible.builtin.shell: | - sshpass -p gocubsgo ssh -o StrictHostKeyChecking=False cirros@{{ item | trim }} "sudo yes > /dev/null &" + sshpass -p gocubsgo ssh -o StrictHostKeyChecking=no cirros@{{ item | trim }} "sudo yes > /dev/null &" register: busy_process with_items: "{{ vnf_instance_ip.stdout_lines }}" + +- name: Check that the busy process is active + ansible.builtin.shell: | + sshpass -p gocubsgo ssh -o StrictHostKeyChecking=no cirros@{{ item | trim }} "sudo ps aux | grep yes" + with_items: "{{ vnf_instance_ip.stdout_lines }}" + - name: Show ceilometer_cpu metrics from Prometheus when: metrics_backend == "prometheus" block: @@ -101,6 +107,7 @@ - name: | TEST Verify orchestration scaled up instances + when: result is succeeded ansible.builtin.shell: | # source ~/overcloudrc; {{ openstack_cmd }} server list --long | grep -i metering.server_group @@ -111,20 +118,30 @@ - name: Ensure Scaling Up instance result is set ansible.builtin.set_fact: - scaling_up_success: "{{ instance_count2.stdout_lines | length == 3 }}" + scaling_up_success: "{{ instance_count2 is succeeded and instance_count2 is not skipped }}" - - name: Debug scaling_up_success - ansible.builtin.debug: - var: scaling_up_success + - name: Check the scaling_up_success var + debug: + msg: | + scaling_up_success: {{ scaling_up_success | bool }} + + - name: Check the scaling_up_success var + debug: + msg: | + scaling up succeed? {{ instance_count2 is succeeded }} + - name: Check the task output + debug: + msg: | + {{ instance_count2 }} - name: Stop the busy process ansible.builtin.shell: | - sshpass -p gocubsgo ssh cirros@{{ item | trim }} "sudo killall yes" + sshpass -p gocubsgo ssh -o StrictHostKeyChecking=no cirros@{{ item | trim }} sudo killall yes register: kill_busy_process with_items: "{{ vnf_instance_ip.stdout_lines }}" -- name: TEST Scaling down instance +- name: TEST Scaling down instance when: scaling_up_success | bool block: - name: | @@ -142,6 +159,7 @@ - name: | TEST Verify Orchestration scaled down instances + when: result.stdout == "alarm" ansible.builtin.shell: | # source ~/overcloudrc; export STACK_ID=$({{ openstack_cmd }} stack show {{ stack_name }} -c id -f value) diff --git a/roles/telemetry_autoscaling/tasks/test_services.yml b/roles/telemetry_autoscaling/tasks/test_services.yml index c5fe87368..496869825 100644 --- a/roles/telemetry_autoscaling/tasks/test_services.yml +++ b/roles/telemetry_autoscaling/tasks/test_services.yml @@ -4,7 +4,7 @@ - name: Verify that custom resource HEAT is ready ansible.builtin.command: cmd: | - oc get heat heat -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}' + oc get -n openstack heat heat -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}' register: result failed_when: - result.stdout != "True" @@ -12,7 +12,7 @@ - name: Verify that custom resource CEILOMETER is ready ansible.builtin.command: cmd: | - oc get ceilometer ceilometer -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}' + oc get -n openstack ceilometer ceilometer -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}' register: result failed_when: - result.stdout != "True" @@ -22,7 +22,7 @@ - name: Verify that custom resource AUTOSCALING is ready ansible.builtin.command: cmd: | - oc get autoscaling autoscaling -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}' + oc get -n openstack autoscaling autoscaling -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}' register: result failed_when: - result.stdout != "True" @@ -32,8 +32,8 @@ cmd: "{{ item }}" register: autoscaling_result with_items: - - oc get autoscaling autoscaling -oyaml - - oc get telemetry telemetry -oyaml + - oc get -n openstack autoscaling autoscaling -oyaml + - oc get -n openstack telemetry telemetry -oyaml failed_when: autoscaling_result.rc >= 1 - name: Print the result @@ -43,7 +43,7 @@ - name: Verify that custom resource METRICSTORAGE is ready ansible.builtin.command: cmd: | - oc get metricstorage metric-storage -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}' + oc get -n openstack metricstorage metric-storage -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}{"\n"}' register: result failed_when: - result.stdout != "True" diff --git a/roles/telemetry_autoscaling/tasks/verify_autoscaling.yml b/roles/telemetry_autoscaling/tasks/verify_autoscaling.yml index 1813e795d..adc7e1f43 100644 --- a/roles/telemetry_autoscaling/tasks/verify_autoscaling.yml +++ b/roles/telemetry_autoscaling/tasks/verify_autoscaling.yml @@ -26,6 +26,7 @@ # need selection criteria to decide when to run these. # Need alternative for OSP18. - name: Verify that the services are running on the overcloud + when: metrics_backend == "gnocchi" ansible.builtin.shell: | # source ~/overcloudrc; sudo podman ps --filter=name='heat|gnocchi|ceilometer|aodh'; diff --git a/roles/telemetry_verify_metrics/tasks/main.yml b/roles/telemetry_verify_metrics/tasks/main.yml index ee212092f..bd6de5495 100644 --- a/roles/telemetry_verify_metrics/tasks/main.yml +++ b/roles/telemetry_verify_metrics/tasks/main.yml @@ -3,6 +3,7 @@ ansible.builtin.include_role: name: common vars: + # TODO: add in the namespace for the CRs common_cr_list: - kind: telemetry name: telemetry diff --git a/roles/telemetry_verify_metrics/tasks/verify_ceilometer_prom_exporter_metrics.yml b/roles/telemetry_verify_metrics/tasks/verify_ceilometer_prom_exporter_metrics.yml index 46fcbe396..1a6112715 100644 --- a/roles/telemetry_verify_metrics/tasks/verify_ceilometer_prom_exporter_metrics.yml +++ b/roles/telemetry_verify_metrics/tasks/verify_ceilometer_prom_exporter_metrics.yml @@ -11,7 +11,7 @@ - name: Verify prometheus target for exporters ansible.builtin.shell: | - oc exec -i prometheus-metric-storage-0 -c prometheus -- curl -k 'https://metric-storage-prometheus:9090/api/v1/targets' | jq | grep {{ exporter.port }} + oc exec -n openstack -i prometheus-metric-storage-0 -c prometheus -- curl -k 'https://metric-storage-prometheus:9090/api/v1/targets' | jq | grep {{ exporter.port }} register: result changed_when: false failed_when: "'{{ exporter.port }}' not in result.stdout" diff --git a/roles/telemetry_verify_metrics/tasks/verify_mariadb_metrics.yml b/roles/telemetry_verify_metrics/tasks/verify_mariadb_metrics.yml index e53d1a902..87f50ca48 100644 --- a/roles/telemetry_verify_metrics/tasks/verify_mariadb_metrics.yml +++ b/roles/telemetry_verify_metrics/tasks/verify_mariadb_metrics.yml @@ -8,7 +8,7 @@ - name: TEST Get galera CR names ansible.builtin.shell: | - oc get galeras -o custom-columns=NAME:.metadata.name --no-headers + oc get -n openstack galeras -o custom-columns=NAME:.metadata.name --no-headers register: cr_names changed_when: false failed_when: cr_names.rc >= 1 or cr_names.stdout == "" @@ -33,7 +33,7 @@ - name: TEST Check mariadb metric endpoints ansible.builtin.shell: | - oc rsh openstackclient curl https://mysqld-exporter.openstack.svc:9104/probe?{{ item }}.openstack.svc.3306&auth_module=client.{{ item }}.openstack.svc + oc rsh -n openstack openstackclient curl https://mysqld-exporter.openstack.svc:9104/probe?{{ item }}.openstack.svc.3306&auth_module=client.{{ item }}.openstack.svc register: result changed_when: false failed_when: result.rc >= 1 diff --git a/roles/telemetry_verify_metrics/tasks/verify_rabbitmq_metrics.yml b/roles/telemetry_verify_metrics/tasks/verify_rabbitmq_metrics.yml index 94a5a9472..c9d51bca1 100644 --- a/roles/telemetry_verify_metrics/tasks/verify_rabbitmq_metrics.yml +++ b/roles/telemetry_verify_metrics/tasks/verify_rabbitmq_metrics.yml @@ -8,7 +8,7 @@ - name: Get rabbitmq CR names ansible.builtin.shell: | - oc get rabbitmqs -o custom-columns=NAME:.metadata.name --no-headers + oc get -n openstack rabbitmqs -o custom-columns=NAME:.metadata.name --no-headers register: cr_names changed_when: false failed_when: cr_names.rc >= 1 or cr_names.stdout == "" @@ -27,7 +27,7 @@ - name: Check rabbitmq metric endpoints ansible.builtin.shell: | - oc rsh openstackclient curl https://{{ item }}.openstack.svc:15691/metrics + oc rsh -n openstack openstackclient curl https://{{ item }}.openstack.svc:15691/metrics register: result changed_when: false failed_when: result.rc >= 1