Fix molecule failures in tripleo_collectd

* Fixed repo problems by correcting volume mounts
* Combined some scenarios to lower testing time

Closes-Bug: #1979972
Co-Authored-By: Cédric Jeanneret <cjeanner@redhat.com>
Change-Id: Ia78e72bbd20cab537f5ce81de33a332394369d16
(cherry picked from commit 8e9047ba5a)
This commit is contained in:
Chris Sibbitt 2022-11-23 14:46:13 -05:00
parent 64ea7d8b33
commit 291ca72cfe
20 changed files with 86 additions and 432 deletions

View File

@ -1,35 +0,0 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: collectd-test
tasks:
- name: "Set up expected THT vars"
set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
- name: "Use the tripleo_collectd role to configure collectd to export metrics to amqp"
include_role:
name: "{{ playbook_dir }}/../../../tripleo_collectd"
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
# This is not the right things to put here... need to check tripleo_collectd
tripleo_collectd_connection_type: 'amqp1'

View File

@ -1,28 +0,0 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: Verify
hosts: collectd-test
tasks:
- name: "Get amqp conf"
stat:
path: "{{ collectd_conf_output_dir }}/amqp1.conf"
register: amqp_conf
failed_when:
- not amqp_conf.stat.exists

View File

@ -32,6 +32,5 @@
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
tripleo_collectd_amqp_host: collectd-test
# This is not the right things to put here... need to check tripleo_collectd
tripleo_collectd_connection_type: 'amqp1'
tripleo_collectd_amqp_interval: -666

View File

@ -10,9 +10,9 @@ platforms:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
- /etc/dnf/vars:/etc/dnf/vars
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg:O
- /opt/yum.repos.d:/etc/yum.repos.d:O
- /etc/dnf/vars:/etc/dnf/vars:O
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"

View File

@ -1,60 +0,0 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi9/ubi-init
registry:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
- /etc/dnf/vars:/etc/dnf/vars
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

View File

@ -14,9 +14,9 @@ platforms:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
- /etc/dnf/vars:/etc/dnf/vars
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg:O
- /opt/yum.repos.d:/etc/yum.repos.d:O
- /etc/dnf/vars:/etc/dnf/vars:O
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
@ -32,6 +32,7 @@ platforms:
networks:
- name: collectd
ipv4_address: "192.168.42.1"
- name: collectd-server
hostname: collectd-server
image: ubi9/ubi-init
@ -39,6 +40,9 @@ platforms:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg:O
- /opt/yum.repos.d:/etc/yum.repos.d:O
- /etc/dnf/vars:/etc/dnf/vars:O
privileged: true
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
@ -57,6 +61,8 @@ provisioner:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
collectd-server:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"

View File

@ -10,9 +10,9 @@ platforms:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
- /etc/dnf/vars:/etc/dnf/vars
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg:O
- /opt/yum.repos.d:/etc/yum.repos.d:O
- /etc/dnf/vars:/etc/dnf/vars:O
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"

View File

@ -1,34 +0,0 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: collectd-test
tasks:
- set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
fqdn_ctlplane: "standalone.ctlplane.localdomain"
- name: "Use tripleo_collectd to configure collectd with defaults"
include_role:
name: '{{ playbook_dir }}/../../../tripleo_collectd'
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d"
tripleo_collectd_enable_libpodstats: true

View File

@ -1,60 +0,0 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi9/ubi-init
registry:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
- /etc/dnf/vars:/etc/dnf/vars
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

View File

@ -1,52 +0,0 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: "Verify collectd libpodstats plugin"
hosts: collectd-test
tasks:
- name: Check that the libpodstats conf file exists
stat:
path: '/etc/collectd.d/libpodstats.conf'
register: output
failed_when:
- not output.stat.exists
- name: Get contents of libpodstats.conf
slurp:
src: /etc/collectd.d/libpodstats.conf
register: libpodstats_conf
failed_when:
- not 'LoadPlugin "libpodstats"' in libpodstats_conf.content | b64decode
- not '<Plugin "libpodstats">' in libpodstats_conf.content | b64decode
- not '</Plugin>' in libpodstats_conf.content | b64decode
- name: "Check that the TypesDB has been updated"
slurp:
src: /etc/collectd.conf
register: output
failed_when:
- not "TypesDB \"/etc/collectd.d//types.db.libpodstats\"" in output.content | b64decode
- name: "Check that the contents of types.db.libpodstats are as expected"
slurp:
src: /etc/collectd.d/types.db.libpodstats
register: typesdb
failed_when:
- not "pod_cpu percent:GAUGE:0:100.1, time:DERIVE:0:U" in typesdb.content | b64decode
- not "pod_memory value:GAUGE:0:281474976710656" in typesdb.content | b64decode

View File

@ -15,4 +15,6 @@
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
tripleo_collectd_enable_sensubility: true
tripleo_collectd_enable_libpodstats: true
tripleo_collectd_enable_sqlalchemy: true
tripleo_collectd_sensubility_exec_sudo_rule: "collectd ALL = NOPASSWD: ALL"

View File

@ -10,9 +10,9 @@ platforms:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
- /etc/dnf/vars:/etc/dnf/vars
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg:O
- /opt/yum.repos.d:/etc/yum.repos.d:O
- /etc/dnf/vars:/etc/dnf/vars:O
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"

View File

@ -59,3 +59,65 @@
register: sensubility_sudoers
failed_when:
- 'not "collectd ALL = NOPASSWD: ALL" in sensubility_sudoers.content | b64decode'
- name: "Verify collectd libpodstats plugin"
hosts: collectd-test
tasks:
- name: Check that the libpodstats conf file exists
stat:
path: '/etc/collectd.d/libpodstats.conf'
register: output
failed_when:
- not output.stat.exists
- name: Get contents of libpodstats.conf
slurp:
src: /etc/collectd.d/libpodstats.conf
register: libpodstats_conf
failed_when:
- not 'LoadPlugin "libpodstats"' in libpodstats_conf.content | b64decode
- not '<Plugin "libpodstats">' in libpodstats_conf.content | b64decode
- not '</Plugin>' in libpodstats_conf.content | b64decode
- name: "Check that the TypesDB has been updated"
slurp:
src: /etc/collectd.conf
register: output
failed_when:
- not "TypesDB \"/etc/collectd.d//types.db.libpodstats\"" in output.content | b64decode
- name: "Check that the contents of types.db.libpodstats are as expected"
slurp:
src: /etc/collectd.d/types.db.libpodstats
register: typesdb
failed_when:
- not "pod_cpu percent:GAUGE:0:100.1, time:DERIVE:0:U" in typesdb.content | b64decode
- not "pod_memory value:GAUGE:0:281474976710656" in typesdb.content | b64decode
- name: Verify collectd sqlalchemy plugin
hosts: collectd-test
tasks:
- name: "Make sure python.conf exists"
stat:
path: "{{ collectd_conf_output_dir }}/python.conf"
register: python_conf
failed_when:
- not python_conf.stat.exists
- name: "Get contents of python.conf"
slurp:
path: "{{ collectd_conf_output_dir }}/python.conf"
register: python_conf
- name: "Check that the config imports sqlalchemy"
assert:
that:
- '"Import \"sqlalchemy_collectd.server.plugin\"" in python_conf.content | b64decode'
fail_msg: "SQLAlchemy is not imported by python config"
- name: "Check that collectd_sqlalchemy is configured as expected"
assert:
that:
- '"<Module \"sqlalchemy_collectd.server.plugin\">" in python_conf.content | b64decode'
- '"listen \"localhost\" 25827" in python_conf.content | b64decode'
- '"loglevel \"info\"" in python_conf.content | b64decode'

View File

@ -1,34 +0,0 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: collectd-test
tasks:
- name: "Set up expected THT vars"
set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
- name: "Include tripleo-collectd-ansible-role"
include_role:
name: '{{ playbook_dir }}/../../../tripleo_collectd'
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
tripleo_collectd_enable_sqlalchemy: true

View File

@ -1,60 +0,0 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi9/ubi-init
registry:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
- /etc/dnf/vars:/etc/dnf/vars
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

View File

@ -1,6 +0,0 @@
---
- src: git+https://github.com/infrawatch/functional-tests
name: functional_tests
- src: git+http://github.com/infrawatch/collectd-config-ansible-role
name: collectd_config

View File

@ -1,46 +0,0 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: Verify
hosts: collectd-test
tasks:
- name: "Make sure python.conf exists"
stat:
path: "{{ collectd_conf_output_dir }}/python.conf"
register: python_conf
failed_when:
- not python_conf.stat.exists
- name: "Get contents of python.conf"
slurp:
path: "{{ collectd_conf_output_dir }}/python.conf"
register: python_conf
- name: "Check that the config imports sqlalchemy"
assert:
that:
- '"Import \"sqlalchemy_collectd.server.plugin\"" in python_conf.content | b64decode'
fail_msg: "SQLAlchemy is not imported by python config"
- name: "Check that collectd_sqlalchemy is configured as expected"
assert:
that:
- '"<Module \"sqlalchemy_collectd.server.plugin\">" in python_conf.content | b64decode'
- '"listen \"localhost\" 25827" in python_conf.content | b64decode'
- '"loglevel \"info\"" in python_conf.content | b64decode'

View File

@ -10,9 +10,9 @@ platforms:
url: registry.access.redhat.com
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
- /etc/dnf/vars:/etc/dnf/vars
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg:O
- /opt/yum.repos.d:/etc/yum.repos.d:O
- /etc/dnf/vars:/etc/dnf/vars:O
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"

View File

@ -386,7 +386,7 @@
enable_fips: true
nslookup_target: opendev.org
tripleo_role_name: tripleo_collectd
voting: false
voting: true
- job:
files:
- ^molecule-requirements.txt