提交 ac51683d 编写于 作者: D Daniel Gustafsson

Remove function owner functionality from Tinc

In the past there was functionality to decorate a stacktrace with
the developer in charge of the separate functions. This is not in
use anymore and it's not something we want either.
上级 ba21d4f9
......@@ -34,8 +34,6 @@ import sys
from xml.dom import minidom
_DEFAULT_LOOKUP_FILE = os.path.join(os.environ["TINCHOME"], 'function_owners.csv')
@tinctest.skipLoading("Test model. No tests loaded.")
class OptimizerSQLPerformanceTestCase(SQLPerformanceTestCase):
"""
......@@ -239,8 +237,6 @@ class OptStackFrame(object):
self.line = -1
self.text = None
self._owner_cache = {}
@classmethod
def parse(cls, text):
"""
......@@ -261,33 +257,6 @@ class OptStackFrame(object):
def __str__(self):
return self.text
def get_owner(self, lookup_file = _DEFAULT_LOOKUP_FILE):
"""
By default, find the owner from a lookup file at function_owners.csv in $GPHOME/bin
"""
if self.function in self._owner_cache:
return self._owner_cache[self.function]
if not os.path.exists(lookup_file):
tinctest.logger.warning("Lookup file does not exist - " + lookup_file)
return ''
with open(lookup_file, 'r') as f:
for line in f:
fields = line.split(',')
owner = fields[2].strip()
function = fields[1].strip()
# Note that we also add the default namespace 'gpopt::' while looking up function_owners.csv
# because complexity.csv does not include namespace for functions in .cpp files.
if self.function == function or self.function == 'gpopt::' + function or self.function == 'gpdxl::' + function:
self._owner_cache[self.function] = owner
return owner.strip()
tinctest.logger.warning("Did not find function %s in the lookup file %s " %(self.function, lookup_file))
return ''
class OptimizerTestResult(_SQLTestCaseResult):
"""
A listener for OptimizerSQLTestCase that will collect mini dumps when a test case fails
......@@ -308,6 +277,4 @@ class OptimizerTestResult(_SQLTestCaseResult):
if stack is not None:
stack_hash = stack.get_thread(0).hash(stack_frames)
stack_trace = stack.get_thread(0).text
stack_owner = stack.get_thread(0).get_first_relevant_frame().get_owner()
return (stack_trace, stack_hash, stack_owner)
return (stack_trace, stack_hash)
......@@ -107,34 +107,3 @@ class StackTraceHandlerTests(unittest.TestCase):
hash1 = thread.hash(10)
hash2 = thread.hash(3)
self.assertEqual(hash1, hash2)
def test_get_owner(self):
frame = OptStackFrame.parse("4 0x00000000003544ca COptTasks::PvOptimizeTask + 122")
self.assertEqual(frame.function, 'COptTasks::PvOptimizeTask')
self.assertEqual(frame.number, 4)
self.assertEqual(frame.address, '0x00000000003544ca')
self.assertEqual(frame.line, 122)
self.assertEqual(frame.file, None)
self.assertEqual(frame.text, '4 0x00000000003544ca COptTasks::PvOptimizeTask + 122')
owner = frame.get_owner(lookup_file = os.path.join(os.path.dirname(sys.modules[self.__class__.__module__].__file__), "function_owners.csv"))
self.assertEqual(owner, 'raghav')
self.assertTrue(frame.function in frame._owner_cache)
def test_get_owner_invalid_file(self):
frame = OptStackFrame.parse("4 0x00000000003544ca COptTasks::PvOptimizeTask + 122")
owner = frame.get_owner(lookup_file = "foo_lookup.csv")
self.assertEqual(owner, '')
self.assertFalse(frame.function in frame._owner_cache)
def test_get_owner_invalid_function(self):
frame = OptStackFrame.parse("4 0x00000000003544ca PvOptimizeTask + 122")
owner = frame.get_owner(lookup_file = os.path.join(os.path.dirname(sys.modules[self.__class__.__module__].__file__), "function_owners.csv"))
self.assertEqual(owner, '')
self.assertFalse(frame.function in frame._owner_cache)
def test_get_owner_with_namespace_check(self):
frame = OptStackFrame.parse("2 0x0000000001daa0ea gpopt::CXformImplementUnionAll::Transform + 858")
owner = frame.get_owner(lookup_file = os.path.join(os.path.dirname(sys.modules[self.__class__.__module__].__file__), "function_owners.csv"))
print "Owner: " + owner
self.assertEqual(owner, 'raghav')
self.assertTrue(frame.function in frame._owner_cache)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册