reset nova-compute process name
In masakari-engine, it enable/disable nova-compute service by the process name. So process-monitor need to reset the nova process name to "nova-compute" when trigger process notification. Change-Id: Ia6f22bd1d183093bb0345f323a80268fb62df388 Close-Bug: #1858757
This commit is contained in:
parent
92c934a8e3
commit
f317a24a25
@ -10,6 +10,7 @@ cliff==2.11.0
|
||||
cmd2==0.8.1
|
||||
coverage==4.0
|
||||
cryptography==2.1.4
|
||||
ddt==1.0.1
|
||||
debtcollector==1.19.0
|
||||
decorator==4.2.1
|
||||
deprecation==2.0
|
||||
|
@ -131,7 +131,7 @@ class HandleProcess(object):
|
||||
'generated_time': current_time,
|
||||
'payload': {
|
||||
'event': ec.EventConstants.EVENT_STOPPED,
|
||||
'process_name': process_name
|
||||
'process_name': process_name.split('/')[-1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import socket
|
||||
import testtools
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import eventlet
|
||||
from oslo_utils import timeutils
|
||||
|
||||
@ -28,10 +29,12 @@ from masakarimonitors import utils
|
||||
CONF = masakarimonitors.conf.CONF
|
||||
eventlet.monkey_patch(os=False)
|
||||
|
||||
NOVA_COMPUTE = 'nova-compute'
|
||||
|
||||
MOCK_PROCESS_LIST = [
|
||||
{
|
||||
'id': 1,
|
||||
'process_name': 'mock_process_name_A',
|
||||
'process_name': '/usr/local/bin/nova-compute',
|
||||
'start_command': 'mock_start_command',
|
||||
'pre_start_command': 'mock_pre_start_command',
|
||||
'post_start_command': 'mock_post_start_command',
|
||||
@ -45,7 +48,7 @@ MOCK_PROCESS_LIST = [
|
||||
MOCK_DOWN_PROCESS_LIST = [
|
||||
{
|
||||
'id': 1,
|
||||
'process_name': 'mock_process_name_A',
|
||||
'process_name': '/usr/local/bin/nova-compute',
|
||||
'start_command': 'mock_start_command',
|
||||
'pre_start_command': 'mock_pre_start_command',
|
||||
'post_start_command': 'mock_post_start_command',
|
||||
@ -56,11 +59,13 @@ MOCK_DOWN_PROCESS_LIST = [
|
||||
},
|
||||
]
|
||||
|
||||
PS_RESULT = "\n" \
|
||||
PS_RESULT = \
|
||||
"\n" \
|
||||
"UID PID PPID C STIME TTY TIME CMD\n" \
|
||||
"root 11187 1 0 18:52 ? 00:00:00 mock_process_name_A\n"
|
||||
"root 11187 1 0 18:52 ? 00:00:00 /usr/local/bin/nova-compute\n"
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestHandleProcess(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -73,6 +78,14 @@ class TestHandleProcess(testtools.TestCase):
|
||||
|
||||
self.assertEqual(process_list, obj.process_list)
|
||||
|
||||
@ddt.data("/usr/local/bin/nova-compute", "nova-compute")
|
||||
def test_make_event(self, process_name):
|
||||
obj = handle_process.HandleProcess()
|
||||
event = obj._make_event(process_name)
|
||||
self.assertEqual(
|
||||
NOVA_COMPUTE,
|
||||
event['notification']['payload']['process_name'])
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_start_processes(self,
|
||||
mock_execute):
|
||||
@ -227,7 +240,7 @@ class TestHandleProcess(testtools.TestCase):
|
||||
'generated_time': current_time,
|
||||
'payload': {
|
||||
'event': ec.EventConstants.EVENT_STOPPED,
|
||||
'process_name': down_process_list[0].get('process_name')
|
||||
'process_name': NOVA_COMPUTE
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -289,7 +302,7 @@ class TestHandleProcess(testtools.TestCase):
|
||||
'generated_time': current_time,
|
||||
'payload': {
|
||||
'event': ec.EventConstants.EVENT_STOPPED,
|
||||
'process_name': down_process_list[0].get('process_name')
|
||||
'process_name': NOVA_COMPUTE
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -356,7 +369,7 @@ class TestHandleProcess(testtools.TestCase):
|
||||
'generated_time': current_time,
|
||||
'payload': {
|
||||
'event': ec.EventConstants.EVENT_STOPPED,
|
||||
'process_name': down_process_list[0].get('process_name')
|
||||
'process_name': NOVA_COMPUTE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ os-testr>=1.0.0 # Apache-2.0
|
||||
testrepository>=0.0.18 # Apache-2.0/BSD
|
||||
testscenarios>=0.4 # Apache-2.0/BSD
|
||||
testtools>=2.2.0 # MIT
|
||||
|
||||
ddt>=1.0.1 # MIT
|
||||
# releasenotes
|
||||
reno>=2.5.0 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user