Replace functional tests with molecule
As effort to sunset tests repo, we replace functional test that were running for the role with a molecule. Due to docker limitations, I had to comment out swap tests, as while it's possible to create a container with swap, I didn't find a way to `swapon` from inside of the container. Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/938571 Change-Id: I907dc6ca18ec4a0b966c412dde8eeec3299b1dcc
This commit is contained in:
parent
9c7ebc65fd
commit
1ef65a0e56
46
Vagrantfile
vendored
46
Vagrantfile
vendored
@ -1,46 +0,0 @@
|
|||||||
# Note:
|
|
||||||
# This file is maintained in the openstack-ansible-tests repository.
|
|
||||||
# https://opendev.org/openstack/openstack-ansible-tests/src/Vagrantfile
|
|
||||||
#
|
|
||||||
# If you need to perform any change on it, you should modify the central file,
|
|
||||||
# then, an OpenStack CI job will propagate your changes to every OSA repository
|
|
||||||
# since every repo uses the same Vagrantfile
|
|
||||||
|
|
||||||
# Verify whether required plugins are installed.
|
|
||||||
required_plugins = [ "vagrant-disksize" ]
|
|
||||||
required_plugins.each do |plugin|
|
|
||||||
if not Vagrant.has_plugin?(plugin)
|
|
||||||
raise "The vagrant plugin #{plugin} is required. Please run `vagrant plugin install #{plugin}`"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Vagrant.configure(2) do |config|
|
|
||||||
config.vm.provider "virtualbox" do |v|
|
|
||||||
v.memory = 6144
|
|
||||||
v.cpus = 2
|
|
||||||
# https://github.com/hashicorp/vagrant/issues/9524
|
|
||||||
v.customize ["modifyvm", :id, "--audio", "none"]
|
|
||||||
end
|
|
||||||
|
|
||||||
config.vm.synced_folder ".", "/vagrant", type: "rsync"
|
|
||||||
|
|
||||||
config.vm.provision "shell",
|
|
||||||
privileged: false,
|
|
||||||
inline: <<-SHELL
|
|
||||||
cd /vagrant
|
|
||||||
./run_tests.sh
|
|
||||||
SHELL
|
|
||||||
|
|
||||||
config.vm.define "centos8" do |centos8|
|
|
||||||
centos8.vm.box = "centos/8"
|
|
||||||
end
|
|
||||||
|
|
||||||
config.vm.define "debian10" do |debian10|
|
|
||||||
debian10.vm.box = "debian/buster64"
|
|
||||||
end
|
|
||||||
|
|
||||||
config.vm.define "ubuntu2004" do |focal|
|
|
||||||
focal.disksize.size = "40GB"
|
|
||||||
focal.vm.box = "ubuntu/focal64"
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,24 +0,0 @@
|
|||||||
export VIRTUAL_ENV=$(pwd)
|
|
||||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
|
||||||
export ANSIBLE_SSH_CONTROL_PATH=/tmp/%%h-%%r
|
|
||||||
|
|
||||||
|
|
||||||
# This is required as the default is '/etc/ansible/roles' or a path
|
|
||||||
# specified in ansible.cfg
|
|
||||||
export ANSIBLE_ROLES_PATH=${HOME}/.ansible/roles:$(pwd)/..
|
|
||||||
export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible:$(pwd)/.."
|
|
||||||
export ANSIBLE_COLLECTIONS_PATH="${HOME}/.ansible:$(pwd)/.."
|
|
||||||
|
|
||||||
export ANSIBLE_SSH_ARGS="-o ControlMaster=no \
|
|
||||||
-o UserKnownHostsFile=/dev/null \
|
|
||||||
-o StrictHostKeyChecking=no \
|
|
||||||
-o ServerAliveInterval=64 \
|
|
||||||
-o ServerAliveCountMax=1024 \
|
|
||||||
-o Compression=no \
|
|
||||||
-o TCPKeepAlive=yes \
|
|
||||||
-o VerifyHostKeyDNS=no \
|
|
||||||
-o ForwardX11=no \
|
|
||||||
-o ForwardAgent=yes"
|
|
||||||
|
|
||||||
echo "Run manual functional tests by executing the following:"
|
|
||||||
echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml"
|
|
48
molecule/default/molecule.yml
Normal file
48
molecule/default/molecule.yml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
options:
|
||||||
|
requirements-file: requirements.yml
|
||||||
|
force: true
|
||||||
|
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: "systemd-service-${MOLECULE_SCENARIO_NAME}"
|
||||||
|
image: "${DOCKER_REGISTRY:-quay.io/gotmax23}/${DOCKER_IMAGE_TAG:-debian-systemd:bookworm}"
|
||||||
|
command: ${DOCKER_COMMAND:-""}
|
||||||
|
pre_build_image: true
|
||||||
|
privileged: true
|
||||||
|
systemd: true
|
||||||
|
groups:
|
||||||
|
- network_hosts
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
playbooks:
|
||||||
|
prepare: ../../tests/prepare.yml
|
||||||
|
converge: ../../tests/test.yml
|
||||||
|
side_effect: ../../tests/side_effect.yml
|
||||||
|
config_options:
|
||||||
|
defaults:
|
||||||
|
inject_facts_as_vars: false
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
name: default
|
||||||
|
test_sequence:
|
||||||
|
- dependency
|
||||||
|
- cleanup
|
||||||
|
- destroy
|
||||||
|
- syntax
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
- idempotence
|
||||||
|
- verify ../../tests/verify.yml
|
||||||
|
- side_effect
|
||||||
|
- verify ../../tests/verify_side_effect.yml
|
||||||
|
- cleanup
|
||||||
|
- destroy
|
@ -3,3 +3,6 @@ collections:
|
|||||||
- name: https://opendev.org/openstack/ansible-config_template
|
- name: https://opendev.org/openstack/ansible-config_template
|
||||||
version: master
|
version: master
|
||||||
type: git
|
type: git
|
||||||
|
- name: https://github.com/ansible-collections/ansible.utils
|
||||||
|
version: main
|
||||||
|
type: git
|
||||||
|
88
run_tests.sh
88
run_tests.sh
@ -1,88 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Copyright 2015, Rackspace US, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# PURPOSE:
|
|
||||||
# This script clones the openstack-ansible-tests repository to the
|
|
||||||
# tests/common folder in order to be able to re-use test components
|
|
||||||
# for role testing. This is intended to be the thinnest possible
|
|
||||||
# shim for test execution outside of OpenStack CI.
|
|
||||||
|
|
||||||
# WARNING:
|
|
||||||
# This file is maintained in the openstack-ansible-tests repository.
|
|
||||||
# https://opendev.org/openstack/openstack-ansible-tests/src/run_tests.sh
|
|
||||||
# If you need to modify this file, update the one in the openstack-ansible-tests
|
|
||||||
# repository and then update this file as well. The purpose of this file is to
|
|
||||||
# prepare the host and then execute all the tox tests.
|
|
||||||
#
|
|
||||||
|
|
||||||
## Shell Opts ----------------------------------------------------------------
|
|
||||||
set -xeu
|
|
||||||
|
|
||||||
## Vars ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
WORKING_DIR="$(readlink -f $(dirname $0))"
|
|
||||||
OSA_PROJECT_NAME="$(sed -n 's|^project=openstack/\(.*\).git$|\1|p' $(pwd)/.gitreview)"
|
|
||||||
|
|
||||||
COMMON_TESTS_PATH="${WORKING_DIR}/tests/common"
|
|
||||||
TESTING_HOME=${TESTING_HOME:-$HOME}
|
|
||||||
ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/opendev.org/openstack/openstack-ansible-tests"
|
|
||||||
|
|
||||||
# Use .gitreview as the key to determine the appropriate
|
|
||||||
# branch to clone for tests.
|
|
||||||
TESTING_BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' "${WORKING_DIR}/.gitreview")
|
|
||||||
if [[ "${TESTING_BRANCH}" == "" ]]; then
|
|
||||||
TESTING_BRANCH="master"
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Main ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Source distribution information
|
|
||||||
source /etc/os-release || source /usr/lib/os-release
|
|
||||||
|
|
||||||
# Figure out the appropriate package install command
|
|
||||||
case ${ID,,} in
|
|
||||||
centos|rhel|fedora|rocky) pkg_mgr_cmd="dnf install -y" ;;
|
|
||||||
ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
|
|
||||||
*) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Install git so that we can clone the tests repo if git is not available
|
|
||||||
which git &>/dev/null || eval sudo "${pkg_mgr_cmd}" git
|
|
||||||
|
|
||||||
# Clone the tests repo for access to the common test script
|
|
||||||
if [[ ! -d "${COMMON_TESTS_PATH}" ]]; then
|
|
||||||
# The tests repo doesn't need a clone, we can just
|
|
||||||
# symlink it.
|
|
||||||
if [[ "${OSA_PROJECT_NAME}" == "openstack-ansible-tests" ]]; then
|
|
||||||
ln -s "${WORKING_DIR}" "${COMMON_TESTS_PATH}"
|
|
||||||
|
|
||||||
# In zuul v3 any dependent repository is placed into
|
|
||||||
# /home/zuul/src/opendev.org, so we check to see
|
|
||||||
# if there is a tests checkout there already. If so, we
|
|
||||||
# symlink that and use it.
|
|
||||||
elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then
|
|
||||||
ln -s "${ZUUL_TESTS_CLONE_LOCATION}" "${COMMON_TESTS_PATH}"
|
|
||||||
|
|
||||||
# Otherwise we're clearly not in zuul or using a previously setup
|
|
||||||
# repo in some way, so just clone it from upstream.
|
|
||||||
else
|
|
||||||
git clone -b "${TESTING_BRANCH}" \
|
|
||||||
https://opendev.org/openstack/openstack-ansible-tests \
|
|
||||||
"${COMMON_TESTS_PATH}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Execute the common test script
|
|
||||||
source tests/common/run_tests_common.sh
|
|
@ -1 +0,0 @@
|
|||||||
../ansible-role-requirements.yaml
|
|
@ -1,26 +0,0 @@
|
|||||||
---
|
|
||||||
# Copyright 2018, Rackspace US, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
container_networks:
|
|
||||||
management_address:
|
|
||||||
address: "{{ ansible_host }}"
|
|
||||||
bridge: "br-mgmt"
|
|
||||||
interface: "eth1"
|
|
||||||
netmask: "255.255.255.0"
|
|
||||||
type: "veth"
|
|
||||||
|
|
||||||
physical_host: localhost
|
|
||||||
properties:
|
|
||||||
service_name: "{{ inventory_hostname }}"
|
|
@ -1,26 +0,0 @@
|
|||||||
---
|
|
||||||
# Copyright 2018, Rackspace US, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
neutron_provider_networks:
|
|
||||||
network_types: "vxlan,flat"
|
|
||||||
network_mappings: "flat:eth12"
|
|
||||||
network_vxlan_ranges: "1:1000"
|
|
||||||
|
|
||||||
neutron_local_ip: 10.1.2.1
|
|
||||||
|
|
||||||
|
|
||||||
bridges:
|
|
||||||
- name: "br-mgmt"
|
|
||||||
ip_addr: "10.1.1.1"
|
|
@ -1,2 +0,0 @@
|
|||||||
[all]
|
|
||||||
localhost
|
|
51
tests/prepare.yml
Normal file
51
tests/prepare.yml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2025, Cleura AB.
|
||||||
|
# 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: Prepare
|
||||||
|
hosts: network_hosts
|
||||||
|
vars:
|
||||||
|
iproute_package_name:
|
||||||
|
redhat: iproute
|
||||||
|
debian: iproute2
|
||||||
|
# NOTE: Packages below are potentially needed outside of molecule as well
|
||||||
|
procps_package_name:
|
||||||
|
redhat: procps-ng
|
||||||
|
debian: procps
|
||||||
|
selinux_package_name:
|
||||||
|
redhat: policycoreutils
|
||||||
|
debian: ''
|
||||||
|
udev_package_name:
|
||||||
|
redhat: systemd-udev
|
||||||
|
debian: udev
|
||||||
|
install_packages:
|
||||||
|
- "{{ iproute_package_name[ansible_facts['os_family'] | lower] }}"
|
||||||
|
- "{{ procps_package_name[ansible_facts['os_family'] | lower] }}"
|
||||||
|
- "{{ selinux_package_name[ansible_facts['os_family'] | lower] }}"
|
||||||
|
- "{{ udev_package_name[ansible_facts['os_family'] | lower] }}"
|
||||||
|
- dbus
|
||||||
|
tasks:
|
||||||
|
- name: Install required packages
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: "{{ install_packages | select() }}"
|
||||||
|
update_cache: "{{ (ansible_facts['os_family'] | lower == 'debian') | ternary(true, omit) }}"
|
||||||
|
|
||||||
|
- name: Ensure required services are running
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
masked: false
|
||||||
|
with_items:
|
||||||
|
- dbus
|
||||||
|
- systemd-udevd
|
35
tests/side_effect.yml
Normal file
35
tests/side_effect.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2025, Cleura AB.
|
||||||
|
# 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: Adjusting the previous setup
|
||||||
|
hosts: network_hosts
|
||||||
|
gather_facts: true
|
||||||
|
roles:
|
||||||
|
- role: "{{ playbook_dir | dirname | basename }}"
|
||||||
|
vars:
|
||||||
|
systemd_interface_cleanup: true
|
||||||
|
systemd_run_networkd: yes
|
||||||
|
systemd_netdevs:
|
||||||
|
- NetDev:
|
||||||
|
Name: dummy2
|
||||||
|
Kind: dummy
|
||||||
|
- NetDev:
|
||||||
|
Name: br-test
|
||||||
|
Kind: bridge
|
||||||
|
systemd_networks:
|
||||||
|
- interface: "dummyX"
|
||||||
|
bridge: "br-test"
|
||||||
|
- interface: "br-test"
|
||||||
|
address: "10.1.0.1"
|
||||||
|
netmask: "255.255.255.0"
|
@ -1,26 +0,0 @@
|
|||||||
---
|
|
||||||
# Copyright 2018, Rackspace US, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
tempest_run: yes
|
|
||||||
tempest_venv_tag: "{{ tempest_git_install_branch }}"
|
|
||||||
tempest_venv_bin: "/opt/tempest_{{ tempest_venv_tag }}/bin"
|
|
||||||
tempest_log_dir: "/var/log/"
|
|
||||||
tempest_test_whitelist:
|
|
||||||
- tempest.scenario.test_server_basic_ops.TestServerBasicOps.test_server_basic_ops
|
|
||||||
|
|
||||||
neutron_provider_networks:
|
|
||||||
network_types: "vxlan,flat"
|
|
||||||
network_mappings: "flat:eth12"
|
|
||||||
network_vxlan_ranges: "1:1000"
|
|
103
tests/test.yml
103
tests/test.yml
@ -15,12 +15,10 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
- name: Playbook for role testing
|
- name: Playbook for role testing
|
||||||
hosts: localhost
|
hosts: network_hosts
|
||||||
connection: local
|
|
||||||
become: true
|
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
roles:
|
roles:
|
||||||
- role: "systemd_networkd"
|
- role: "{{ playbook_dir | dirname | basename }}"
|
||||||
vars:
|
vars:
|
||||||
systemd_networkd_link:
|
systemd_networkd_link:
|
||||||
MACAddressPolicy: "persistent"
|
MACAddressPolicy: "persistent"
|
||||||
@ -74,7 +72,7 @@
|
|||||||
mtu: 9000
|
mtu: 9000
|
||||||
usedns: true
|
usedns: true
|
||||||
static_routes:
|
static_routes:
|
||||||
- Gateway: "10.1.0.1"
|
- gateway: "10.1.0.1"
|
||||||
cidr: "10.1.0.0/24"
|
cidr: "10.1.0.0/24"
|
||||||
- Gateway: "10.1.0.100"
|
- Gateway: "10.1.0.100"
|
||||||
Table: 100
|
Table: 100
|
||||||
@ -86,6 +84,7 @@
|
|||||||
Network:
|
Network:
|
||||||
ConfigureWithoutCarrier: true
|
ConfigureWithoutCarrier: true
|
||||||
link_config_overrides:
|
link_config_overrides:
|
||||||
|
Link:
|
||||||
Alias: "dummy-bridge0"
|
Alias: "dummy-bridge0"
|
||||||
- interface: "dummy2"
|
- interface: "dummy2"
|
||||||
bridge: "br-test"
|
bridge: "br-test"
|
||||||
@ -96,97 +95,3 @@
|
|||||||
address: 10.2.0.1
|
address: 10.2.0.1
|
||||||
netmask: "255.255.255.0"
|
netmask: "255.255.255.0"
|
||||||
ipforward: true
|
ipforward: true
|
||||||
|
|
||||||
|
|
||||||
- name: Test networkd
|
|
||||||
hosts: localhost
|
|
||||||
connection: local
|
|
||||||
become: true
|
|
||||||
gather_facts: true
|
|
||||||
tasks:
|
|
||||||
- name: Interface check
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts['dummy0']['active']
|
|
||||||
- ansible_facts['dummy0']['type'] == 'ether'
|
|
||||||
- ansible_facts['dummy0']['mtu'] == 9000
|
|
||||||
- ansible_facts['dummy1']['active']
|
|
||||||
- ansible_facts['dummy1']['type'] == 'ether'
|
|
||||||
- ansible_facts['dummy1']['mtu'] == 9000
|
|
||||||
- ansible_facts['dummy2']['active']
|
|
||||||
- ansible_facts['dummy2']['type'] == 'ether'
|
|
||||||
- name: Bond check
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts['bond0']['active']
|
|
||||||
- ansible_facts['bond0']['type'] == 'bonding'
|
|
||||||
- ansible_facts['bond0']['mtu'] == 9000
|
|
||||||
- name: Bridge check
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts['br_dummy']['active']
|
|
||||||
- ansible_facts['br_dummy']['type'] == 'bridge'
|
|
||||||
- ansible_facts['br_dummy']['ipv4']['address'] == '10.0.0.100'
|
|
||||||
- ansible_facts['br_dummy']['ipv4']['netmask'] == '255.255.255.0'
|
|
||||||
- name: Bridge check
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts['br_test']['active']
|
|
||||||
- ansible_facts['br_test']['type'] == 'bridge'
|
|
||||||
- ansible_facts['br_test']['ipv4']['address'] == '10.1.0.1'
|
|
||||||
- ansible_facts['br_test']['ipv4']['netmask'] == '255.255.255.0'
|
|
||||||
- name: Check link config overrides
|
|
||||||
shell: 'grep -wo "Alias" /etc/systemd/network/*br-dummy.link'
|
|
||||||
changed_when: false
|
|
||||||
- name: Check general link config
|
|
||||||
shell: 'grep -wo "{{ item }}" /etc/systemd/network/*.link'
|
|
||||||
changed_when: false
|
|
||||||
with_items:
|
|
||||||
- MACAddressPolicy
|
|
||||||
- NamePolicy
|
|
||||||
- name: Check forwarding is enabled
|
|
||||||
shell: 'grep -wo ^1$ /proc/sys/net/{{ item }}'
|
|
||||||
changed_when: false
|
|
||||||
with_items:
|
|
||||||
- "ipv4/ip_forward"
|
|
||||||
- "ipv4/conf/all/forwarding"
|
|
||||||
- "ipv4/conf/br-test2/forwarding"
|
|
||||||
|
|
||||||
|
|
||||||
- name: Playbook for role testing with cleanup
|
|
||||||
hosts: localhost
|
|
||||||
connection: local
|
|
||||||
become: true
|
|
||||||
gather_facts: true
|
|
||||||
roles:
|
|
||||||
- role: "systemd_networkd"
|
|
||||||
post_tasks:
|
|
||||||
- name: Interface check
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts['br_test'] is defined
|
|
||||||
- ansible_facts['dummy2']['active']
|
|
||||||
- ansible_facts['dummy2']['type'] == 'ether'
|
|
||||||
- name: Bridge check
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts['br_test']['active']
|
|
||||||
- ansible_facts['br_test']['type'] == 'bridge'
|
|
||||||
- ansible_facts['br_test']['ipv4']['address'] == '10.1.0.1'
|
|
||||||
- ansible_facts['br_test']['ipv4']['netmask'] == '255.255.255.0'
|
|
||||||
vars:
|
|
||||||
systemd_interface_cleanup: true
|
|
||||||
systemd_run_networkd: yes
|
|
||||||
systemd_netdevs:
|
|
||||||
- NetDev:
|
|
||||||
Name: dummy2
|
|
||||||
Kind: dummy
|
|
||||||
- NetDev:
|
|
||||||
Name: br-test
|
|
||||||
Kind: bridge
|
|
||||||
systemd_networks:
|
|
||||||
- interface: "dummyX"
|
|
||||||
bridge: "br-test"
|
|
||||||
- interface: "br-test"
|
|
||||||
address: "10.1.0.1"
|
|
||||||
netmask: "255.255.255.0"
|
|
||||||
|
65
tests/verify.yml
Normal file
65
tests/verify.yml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2025, Cleura AB.
|
||||||
|
# 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: Test networkd initial installation
|
||||||
|
hosts: network_hosts
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: Interface check
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts['dummy0']['active']
|
||||||
|
- ansible_facts['dummy0']['type'] == 'ether'
|
||||||
|
- ansible_facts['dummy0']['mtu'] == 9000
|
||||||
|
- ansible_facts['dummy1']['active']
|
||||||
|
- ansible_facts['dummy1']['type'] == 'ether'
|
||||||
|
- ansible_facts['dummy1']['mtu'] == 9000
|
||||||
|
- ansible_facts['dummy2']['active']
|
||||||
|
- ansible_facts['dummy2']['type'] == 'ether'
|
||||||
|
- name: Bond check
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts['bond0']['active']
|
||||||
|
- ansible_facts['bond0']['type'] == 'bonding'
|
||||||
|
- ansible_facts['bond0']['mtu'] == 9000
|
||||||
|
- name: Bridge check
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts['br_dummy']['active']
|
||||||
|
- ansible_facts['br_dummy']['type'] == 'bridge'
|
||||||
|
- ansible_facts['br_dummy']['ipv4']['address'] == '10.0.0.100'
|
||||||
|
- ansible_facts['br_dummy']['ipv4']['netmask'] == '255.255.255.0'
|
||||||
|
- name: Bridge check
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts['br_test']['active']
|
||||||
|
- ansible_facts['br_test']['type'] == 'bridge'
|
||||||
|
- ansible_facts['br_test']['ipv4']['address'] == '10.1.0.1'
|
||||||
|
- ansible_facts['br_test']['ipv4']['netmask'] == '255.255.255.0'
|
||||||
|
- name: Check link config overrides
|
||||||
|
shell: 'grep -wo "Alias" /etc/systemd/network/*br-dummy.link'
|
||||||
|
changed_when: false
|
||||||
|
- name: Check general link config
|
||||||
|
shell: 'grep -wo "{{ item }}" /etc/systemd/network/*.link'
|
||||||
|
changed_when: false
|
||||||
|
with_items:
|
||||||
|
- MACAddressPolicy
|
||||||
|
- NamePolicy
|
||||||
|
- name: Check forwarding is enabled
|
||||||
|
shell: 'grep -wo ^1$ /proc/sys/net/{{ item }}'
|
||||||
|
changed_when: false
|
||||||
|
with_items:
|
||||||
|
- "ipv4/ip_forward"
|
||||||
|
- "ipv4/conf/all/forwarding"
|
||||||
|
- "ipv4/conf/br-test2/forwarding"
|
31
tests/verify_side_effect.yml
Normal file
31
tests/verify_side_effect.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2025, Cleura AB.
|
||||||
|
# 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: Test networkd after side-effect
|
||||||
|
hosts: network_hosts
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: Interface check
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts['br_test'] is defined
|
||||||
|
- ansible_facts['dummy2']['active']
|
||||||
|
- ansible_facts['dummy2']['type'] == 'ether'
|
||||||
|
- name: Bridge check
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts['br_test']['active']
|
||||||
|
- ansible_facts['br_test']['type'] == 'bridge'
|
||||||
|
- ansible_facts['br_test']['ipv4']['address'] == '10.1.0.1'
|
||||||
|
- ansible_facts['br_test']['ipv4']['netmask'] == '255.255.255.0'
|
54
tox.ini
54
tox.ini
@ -1,7 +1,7 @@
|
|||||||
[tox]
|
[tox]
|
||||||
minversion = 3.1
|
minversion = 4.0
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
envlist = docs,linters,functional
|
envlist = docs,molecule
|
||||||
ignore_basepython_conflict = True
|
ignore_basepython_conflict = True
|
||||||
|
|
||||||
|
|
||||||
@ -67,43 +67,19 @@ commands =
|
|||||||
commands =
|
commands =
|
||||||
{posargs}
|
{posargs}
|
||||||
|
|
||||||
|
[testenv:molecule]
|
||||||
|
# You can use DOCKER_REGISTRY and DOCKER_IMAGE_TAG to switch between
|
||||||
|
# tested distros. I.e:
|
||||||
|
# DOCKER_IMAGE_TAG=ubuntu-systemd:jammy tox -e molecule
|
||||||
|
deps =
|
||||||
|
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
|
-rhttps://opendev.org/openstack/openstack-ansible/raw/branch/{env:TEST_BRANCH:master}/test-requirements.txt
|
||||||
|
|
||||||
[testenv:pep8]
|
|
||||||
commands =
|
commands =
|
||||||
bash -c "{toxinidir}/tests/common/test-pep8.sh"
|
molecule test
|
||||||
|
|
||||||
|
passenv =
|
||||||
[flake8]
|
{[testenv]passenv}
|
||||||
# Ignores the following rules due to how ansible modules work in general
|
DOCKER_REGISTRY
|
||||||
# F403 'from ansible.module_utils.basic import *' used;
|
DOCKER_IMAGE_TAG
|
||||||
# unable to detect undefined names
|
DOCKER_COMMAND
|
||||||
ignore=F403
|
|
||||||
|
|
||||||
|
|
||||||
[testenv:bashate]
|
|
||||||
commands =
|
|
||||||
bash -c "{toxinidir}/tests/common/test-bashate.sh"
|
|
||||||
|
|
||||||
|
|
||||||
[testenv:ansible-syntax]
|
|
||||||
commands =
|
|
||||||
bash -c "{toxinidir}/tests/common/test-ansible-syntax.sh"
|
|
||||||
|
|
||||||
|
|
||||||
[testenv:ansible-lint]
|
|
||||||
commands =
|
|
||||||
bash -c "{toxinidir}/tests/common/test-ansible-lint.sh"
|
|
||||||
|
|
||||||
|
|
||||||
[testenv:functional]
|
|
||||||
commands =
|
|
||||||
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
|
|
||||||
|
|
||||||
|
|
||||||
[testenv:linters]
|
|
||||||
commands =
|
|
||||||
bash -c "{toxinidir}/tests/common/test-ansible-env-prep.sh"
|
|
||||||
{[testenv:pep8]commands}
|
|
||||||
{[testenv:bashate]commands}
|
|
||||||
{[testenv:ansible-lint]commands}
|
|
||||||
{[testenv:ansible-syntax]commands}
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
- project:
|
- project:
|
||||||
templates:
|
templates:
|
||||||
- openstack-ansible-linters-jobs
|
- openstack-ansible-linters-jobs
|
||||||
- openstack-ansible-role-jobs
|
- openstack-ansible-molecule
|
||||||
- openstack-ansible-deploy-aio_metal-jobs
|
- openstack-ansible-deploy-aio_metal-jobs
|
||||||
- openstack-ansible-deploy-aio_distro_metal-jobs
|
- openstack-ansible-deploy-aio_distro_metal-jobs
|
||||||
- check-requirements
|
- check-requirements
|
||||||
|
Loading…
x
Reference in New Issue
Block a user