Eduardo Olivares 435766502a Fix pep8 errors raised with python3.12 and update advanced guest image
Two recent changes in CI infra have affected
whitebox_neutron_tempest_plugin jobs:
1) After updating of pep8 jobs to ubuntu-noble/python3.12, an error is
   reported and this patch fixes it.
2) Tests using advanced images had issues to boot rocky 9.3 VM instances
   and due to that, this patch updates it to rocky 9.5.
   As a consequence of this change, virt-customize command has been
   updated to:
   * install tcpdump
   * enable dhcp for NetworkManager
   And some tests have been adapted to rocky 9.5 characteristics.

Change-Id: I489ecaf1765570e52b1f2d2676f13a0edc5f6fc4
2024-12-05 11:07:45 +01:00

66 lines
3.1 KiB
Bash

customize_advanced_image(){
# Here we customize an advanced image to make it suitable for the plugin tests.
# Note: the advanced image was downloaded and set by neutron_tempest_plugin.
# However we can't rely on neutron_tempest_plugin capabilities for customizing
# the image since it expects a debian/ubuntu based image which does not fit well
# to this plugin tests.
# This code modifies the downloaded image by adding packages required by this
# plugin, uploads the image to glance and if all passed successfully it updates
# tempest.conf with the new image reference instead of the original one.
install_package guestfs-tools
for image_url in ${IMAGE_URLS//,/ }; do
if [[ $image_url =~ $ADVANCED_IMAGE_NAME ]]; then
image_file=$(basename $image_url)
break
fi
done
if [ -n "$image_file" ] && [ -s "$TOP_DIR/files/$image_file" ]; then
cp -f $TOP_DIR/files/$image_file /tmp
image_file_custom=/tmp/$image_file
dhcp_client_conf_file=/tmp/dhcp-client.conf
echo "[main]" > $dhcp_client_conf_file
echo "dhcp=dhclient" >> $dhcp_client_conf_file
timeout 150 sudo virt-customize -a $image_file_custom --install nmap,keepalived,iperf3,tcpdump,dhcp-client --copy-in $dhcp_client_conf_file:/etc/NetworkManager/conf.d --selinux-relabel
if [ "$?" == "0" ]; then
source $TOP_DIR/openrc admin
old_image_id=$(openstack image show $ADVANCED_IMAGE_NAME -c id -f value)
new_image_id=$(openstack image create --disk-format qcow2 --container-format bare --public $ADVANCED_IMAGE_NAME --file $image_file_custom -c id -f value)
if [ -n "$new_image_id" ]; then
iniset $TEMPEST_CONFIG neutron_plugin_options advanced_image_ref $new_image_id
openstack image delete $old_image_id
fi
fi
fi
}
customize_public_network_and_subnet(){
if [[ $Q_AGENT == "ovn" ]]; then
# Make external network shared with dhcp enabled to allow tests with VMs
# on external network to run. Note, we still keep these settings disabled
# for OVS jobs since they can require additional settings, like ensuring
# that only a single DHCP server is available on the external network.
openstack network set --share $PUBLIC_NETWORK_NAME
openstack subnet set --dhcp $PUBLIC_SUBNET_NAME
# Decrease external network MTU to allow tests from test_mtu.py to run
# (rsafrono) tests from test_mtu.py can not be run due to
# https://bugs.launchpad.net/neutron/+bug/2060828
# The line should be uncommented once the issue is fixed
# openstack network set --mtu 1330 $PUBLIC_NETWORK_NAME
fi
}
if [[ "$1" == "stack" ]]; then
case "$2" in
install)
if [[ "$INSTALL_TEMPEST" == "True" ]]; then
echo "tempest ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/99_tempest
fi
;;
test-config)
customize_advanced_image
customize_public_network_and_subnet
;;
esac
fi