Merge "Ensure the OVSDB and ovn-northd process stop" into stable/2024.2
This commit is contained in:
commit
e832989159
@ -18,15 +18,18 @@ import math
|
||||
import os
|
||||
import random
|
||||
import signal
|
||||
import typing
|
||||
|
||||
from neutron_lib.agent import topics
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import versionutils
|
||||
|
||||
import neutron
|
||||
from neutron.agent.common import ovs_lib
|
||||
from neutron.agent.linux import utils as linux_utils
|
||||
from neutron.db import agents_db
|
||||
|
||||
HOST = 'localhost'
|
||||
@ -278,3 +281,19 @@ class TestTimer(object):
|
||||
|
||||
if self._alarm_fn:
|
||||
self._alarm_fn(timeout)
|
||||
|
||||
|
||||
def pgrep(
|
||||
command: str,
|
||||
entire_command_line: bool = True
|
||||
) -> typing.Optional[str]:
|
||||
cmd = ['pgrep']
|
||||
if entire_command_line:
|
||||
cmd += ['-f']
|
||||
cmd += [command]
|
||||
try:
|
||||
result = linux_utils.execute(cmd)
|
||||
except exceptions.ProcessExecutionError:
|
||||
return
|
||||
|
||||
return result[0] if result else None
|
||||
|
@ -359,7 +359,13 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase,
|
||||
'suffix': file_suffix,
|
||||
'timestamp': timestamp,
|
||||
}
|
||||
self._copy_log_file(src_filename, dst_filename)
|
||||
try:
|
||||
self._copy_log_file(src_filename, dst_filename)
|
||||
except FileNotFoundError:
|
||||
# Some testcases add the method ``_collect_processes_logs``
|
||||
# twice in the cleanup methods. The second time this method
|
||||
# is called, the logs and DBs have been already deleted.
|
||||
pass
|
||||
|
||||
# Copy northd logs
|
||||
northd_log = "ovn_northd"
|
||||
|
@ -15,12 +15,20 @@
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
|
||||
import fixtures
|
||||
import psutil
|
||||
import tenacity
|
||||
|
||||
from neutron.agent.linux import utils
|
||||
from neutron.tests.common import helpers
|
||||
|
||||
|
||||
def _kill_process_if_exists(command: str) -> None:
|
||||
_pid = helpers.pgrep(command)
|
||||
if _pid:
|
||||
utils.kill_process(_pid, signal.SIGKILL)
|
||||
|
||||
|
||||
class DaemonProcessFixture(fixtures.Fixture):
|
||||
@ -86,7 +94,7 @@ class OvnNorthd(DaemonProcessFixture):
|
||||
stop_cmd = ['ovs-appctl', '-t', self.unixctl_path, 'exit']
|
||||
utils.execute(stop_cmd)
|
||||
except Exception:
|
||||
pass
|
||||
_kill_process_if_exists(self.unixctl_path)
|
||||
|
||||
|
||||
class OvsdbServer(DaemonProcessFixture):
|
||||
@ -228,7 +236,7 @@ class OvsdbServer(DaemonProcessFixture):
|
||||
'exit']
|
||||
utils.execute(stop_cmd)
|
||||
except Exception:
|
||||
pass
|
||||
_kill_process_if_exists(ovsdb_process['unixctl_path'])
|
||||
|
||||
def get_ovsdb_connection_path(self, db_type='nb'):
|
||||
for ovsdb_process in self.ovsdb_server_processes:
|
||||
|
Loading…
x
Reference in New Issue
Block a user