Skip to content

add case for virtnetworkd not block host shutdown #6384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- virtual_network.network.block_test:
type = virtnetworkd_unblock_systemd_inibit
start_vm = 'no'
take_regular_screendumps = no
cmd = "systemd-inhibit"
check_pattern = "virtnetworkd"
func_supported_since_libvirt_ver = (10, 10, 0)
variants service:
- virtnetworkd_unblock_systemd_inibit:
variants preset_net:
- default_net:
net_name = "default"
- define_net:
net_name = "network_conn"
forward = "'forward': {'mode': 'route'}"
ipv4_attrs = {'netmask': '255.255.255.0', 'address': '192.168.144.1', 'dhcp_ranges': {'attrs': {'end': '192.168.144.254', 'start': '192.168.144.2'}}}
network_attrs = {'name': '${net_name}', ${forward}, 'ips': [${ipv4_attrs}]}
variants network_states:
- active_net:
- inactive_net:
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright Redhat
#
# SPDX-License-Identifier: GPL-2.0

# Author: Nannan Li<[email protected]>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import re

from avocado.utils import process

from virttest import libvirt_version
from virttest import virsh
from virttest.libvirt_xml.network_xml import NetworkXML
from virttest.utils_libvirt import libvirt_network


def run(test, params, env):
"""
Test virtnetworkd should not block host OS shutdown.
"""
def setup_test():
"""
Prepare network and it's status.
"""
test.log.info("TEST_SETUP: Prepare network and it's status.")
if preset_net == "define_net":
libvirt_network.create_or_del_network(network_attrs)
test.log.debug(f'{virsh.net_dumpxml(net_name).stdout_text}')

if network_states == "inactive_net":
virsh.net_destroy(net_name, debug=True)

def run_test():
"""
Check systemd-inhibit for virtnetworkd not existing in the list.
"""
test.log.info("TEST_STEP1:Check systemd-inhibit")
result = process.run(cmd, shell=True).stdout_text.strip()
if re.findall(check_pattern, result):
test.fail("Expected no '%s'", check_pattern)
test.log.debug("Check systemd-inhibit PASS")

def teardown_test():
"""
Recover network.
"""
test.log.info("TEST_TEARDOWN: Recover network.")
if preset_net == "default_net":
bk_net.sync()
libvirt_network.ensure_default_network()
else:
libvirt_network.create_or_del_network(network_attrs, is_del=True)

libvirt_version.is_libvirt_feature_supported(params)
net_name = params.get("net_name")
preset_net = params.get("preset_net")
if preset_net == "default_net":
default_net = NetworkXML.new_from_net_dumpxml(net_name)
bk_net = default_net.copy()
cmd = params.get("cmd")
network_states = params.get("network_states")
network_attrs = eval(params.get('network_attrs', '{}'))
check_pattern = params.get("check_pattern")

try:
setup_test()
run_test()

finally:
teardown_test()