Skip to content

Commit

Permalink
Merge pull request #172 from ganga-devs/bugfix/FixingBugsIn6115Testing
Browse files Browse the repository at this point in the history
Bugfix/fixing bugs in 6.1.15 testing
  • Loading branch information
milliams committed Feb 2, 2016
2 parents 7624205 + 5fe0fbb commit 9d3ebde
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 83 deletions.
3 changes: 1 addition & 2 deletions python/Ganga/Core/GangaRepository/GangaRepositoryXML.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,7 @@ def lock(self, ids):
def unlock(self, ids):
released_ids = self.sessionlock.release_ids(ids)
if len(released_ids) < len(ids):
logger.error(
"The write locks of some objects could not be released!")
logger.error("The write locks of some objects could not be released!")

def get_lock_session(self, this_id):
"""get_lock_session(id)
Expand Down
3 changes: 2 additions & 1 deletion python/Ganga/Core/GangaRepository/Registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,8 @@ def __release_lock(self, _obj):
oid = self.find(obj)
if getattr(obj, _reg_id_str) in self.dirty_objs.keys():
self.repository.flush([oid])
del self.dirty_objs[getattr(obj, _reg_id_str)]
if getattr(obj, _reg_id_str) in self.dirty_objs:
del self.dirty_objs[getattr(obj, _reg_id_str)]
obj._registry_locked = False
self.repository.unlock([oid])
except (RepositoryError, RegistryAccessError, RegistryLockError, ObjectNotInRegistryError) as err:
Expand Down
16 changes: 9 additions & 7 deletions python/Ganga/GPIDev/Base/Objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,22 +365,24 @@ def __get__(self, obj, cls):
return cls._schema[name]

if self._getter_name:
return self._bind_method(obj, self._getter_name)()
returnable = self._bind_method(obj, self._getter_name)()
if isinstance(returnable, GangaObject):
returnable._setParent(self)
return returnable


# First we want to try to get the information without prompting a load from disk

# ._data takes priority ALWAYS over ._index_cache
# This access should not cause the object to be loaded
obj_data = obj.getNodeData()
if obj_data is not None:
if name in obj_data:
return obj_data[name]
if name in obj_data:
return obj_data[name]

# Then try to get it from the index cache
obj_index = obj.getNodeIndexCache()
if obj_index is not None:
if name in obj_index:
return obj_index[name]
if name in obj_index:
return obj_index[name]

# Since we couldn't find the information in the cache, we will need to fully load the object

Expand Down
23 changes: 17 additions & 6 deletions python/Ganga/GPIDev/Base/Proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,23 @@ def __recursive_strip(_val):
if not isinstance(_val, str) and (isType(_val, getKnownLists()) or\
(hasattr(stripProxy(_val), '__len__') and hasattr(stripProxy(_val), '__getitem__'))):
val = stripProxy(_val).__class__()
for elem in _val:
GangaObject = _getGangaObject()
if isType(elem, GangaObject):
val.append(ProxyDataDescriptor.__recursive_strip(stripProxy(elem)))
else:
val.append(stripProxy(elem))
GangaObject = _getGangaObject()
if type(val) is dict:
for _key, elem in _val.iteritems():
if isType(_key, GangaObject):
key = stripProxy(_key)
else:
key = _key
if isType(elem, GangaObject):
val[key] = ProxyDataDescriptor.__recursive_strip(stripProxy(elem))
else:
val[key] = elem
else:
for elem in _val:
if isType(elem, GangaObject):
val.append(ProxyDataDescriptor.__recursive_strip(stripProxy(elem)))
else:
val.append(elem)
else:
val = stripProxy(_val)
return val
Expand Down
39 changes: 30 additions & 9 deletions python/Ganga/GPIDev/Lib/GangaList/GangaList.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ def _export___add__(self, obj_list):
def __contains__(self, obj):
return self._list.__contains__(self.strip_proxy(obj))

def __clone__(self):
return makeGangaListByRef(_list=copy.copy(self._list), preparable=self._is_preparable)
# def __clone__(self):
# return makeGangaListByRef(_list=copy.copy(self._list), preparable=self._is_preparable)

def __copy__(self):
"""Bypass any checking when making the copy"""
Expand Down Expand Up @@ -293,16 +293,22 @@ def __deepcopy__(self, memo):
return new_list
#super(GangaList, self).__deepcopy__(memo)

@staticmethod
def __getListToCompare(input_list):
if isType(input_list, GangaList):
return stripProxy(input_list)._list
elif isinstance(input_list, tuple):
return list(input_list)
else:
return input_list

def __eq__(self, obj_list):
if obj_list is self: # identity check
return True
result = False
if self.is_list(self.strip_proxy(obj_list)):
result = self._list.__eq__(self.strip_proxy_list(obj_list))
return result
return self._list == self.__getListToCompare(obj_list)

def __ge__(self, obj_list):
return self._list.__ge__(self.strip_proxy_list(obj_list))
return self._list.__ge__(self.__getListToCompare(obj_list))

def __getitem__(self, index):
return self._list.__getitem__(index)
Expand Down Expand Up @@ -430,10 +436,25 @@ def __str__(self):
return self.toString()

def append(self, obj, my_filter=True):
if isType(obj, GangaList):
self._list.append(obj._list)
return
elem = self.strip_proxy(obj, my_filter)
list_objs = (list, tuple)
if isType(elem, GangaObject):
stripProxy(elem)._setParent(stripProxy(self)._getParent())
self._list.append(elem)
stripProxy(elem)._setParent(self._getParent())
self._list.append(elem)
elif isinstance(elem, list_objs):
new_list = []
for _obj in elem:
if isType(_obj, GangaObject):
new_list.append(stripProxy(_obj))
stripProxy(_obj)._setParent(self._getParent())
else:
new_list.append(_obj)
self._list.append(new_list)
else:
self._list.append(elem)

def _export_append(self, obj):
self.checkReadOnly()
Expand Down
4 changes: 2 additions & 2 deletions python/Ganga/test/GPI/GangaList/TestCopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def testCopy(self):
assert len(gl) == numberOfFiles, 'Right number of files must be made'

gl2 = copy.copy(gl)
assert gl2 == gl, 'lists must be equal'
assert len(gl2) == len(gl), 'lists must be equal'
assert gl2 is not gl, 'list must be copies'
#assert gl[0] is gl2[0], 'the references must be copied' ## rcurrie 09/12/15 Not sure this is valid given we have to cope with GangaObjects here which may not be copyable!

Expand All @@ -58,6 +58,6 @@ def testDeepCopy(self):
assert len(gl) == numberOfFiles, 'Right number of files must be made'

gl2 = copy.deepcopy(gl)
assert gl2 == gl, 'lists must be equal'
assert len(gl2) == len(gl), 'lists must be equal'
assert gl2 is not gl, 'list must be copies'
assert gl[0] is not gl2[0], 'the references must be copied'
68 changes: 25 additions & 43 deletions python/Ganga/test/GPI/GangaList/TestGangaList.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ def setUp(self):
self.proxied2 = GangaList()
self.proxied2.extend(self.plain2[:])

assert len(getProxyAttr(self.proxied1, '_list')) == len(
self.plain1), 'Somthings wrong with construction'
assert len(getProxyAttr(self.proxied2, '_list')) == len(
self.plain2), 'Somthings wrong with construction'
assert len(getProxyAttr(self.proxied1, '_list')) == len(self.plain1), 'Somthings wrong with construction 1'
assert len(getProxyAttr(self.proxied2, '_list')) == len(self.plain2), 'Somthings wrong with construction 2'

def testAllListMethodsExported(self):
"""Tests that all methods on list are exposed by GangaList"""
Expand Down Expand Up @@ -101,17 +99,17 @@ def testNonZero(self):

def testAdd(self):
"""Test __add__"""
assert (self.plain1 + self.plain2) == (self.proxied1 + self.proxied2)
assert len(self.plain1 + self.plain2) == len(self.proxied1 + self.proxied2)
assert isProxy(self.proxied1 + self.proxied2)

def testAddMixed(self):
"""Test __add__ with mixed lists and GangaLists"""
assert (self.plain1 + self.plain2) == (self.proxied1 + self.plain2)
assert (self.plain2 + self.plain1) == (self.plain2 + self.proxied1)
assert len(self.plain1 + self.plain2) == len(self.proxied1 + self.plain2)
assert len(self.plain2 + self.plain1) == len(self.plain2 + self.proxied1)
assert isProxy(self.proxied1 + self.plain2)

assert (self.plain2 + self.plain1) == (self.plain2 + self.proxied1)
assert (self.plain1 + self.plain2) == (self.plain1 + self.proxied2)
assert len(self.plain2 + self.plain1) == len(self.plain2 + self.proxied1)
assert len(self.plain1 + self.plain2) == len(self.plain1 + self.proxied2)
assert isinstance(self.plain1 + self.proxied2, list)

def testAddMixed2(self):
Expand All @@ -121,15 +119,11 @@ def testAddMixed2(self):

assert isProxy(self.proxied2[-1]), 'Element access must get proxies'
assert not isProxy(self.plain1[0]), 'Element access must not proxies'
assert isProxy(
(self.plain1 + self.proxied2)[-1]), 'File objects should remain proxies'
assert not isProxy(
(self.plain1 + self.proxied2)[0]), 'Objects in plain lists should be left alone'
assert isProxy((self.plain1 + self.proxied2)[-1]), 'File objects should remain proxies'
assert not isProxy((self.plain1 + self.proxied2)[0]), 'Objects in plain lists should be left alone'

assert (
self.plain1 + self.proxied2)[-1] == self.proxied2[-1], 'File objects should be equal'
assert (
self.plain1 + self.proxied2)[-1] is self.proxied2[-1], 'File objects should be identical'
assert (self.plain1 + self.proxied2)[-1] == self.proxied2[-1], 'File objects should be equal'
assert (self.plain1 + self.proxied2)[-1] is self.proxied2[-1], 'File objects should be identical'

def testAddStr(self):
"""Makes sure that only lists can be added."""
Expand Down Expand Up @@ -165,13 +159,10 @@ def testDelItem(self):
def testGE(self):
"""Test __ge__"""

assert (self.plain1 >= self.plain2) == (
self.proxied1 >= self.proxied2), 'The lists should have the same ge'
assert (self.plain2 >= self.plain1) == (
self.proxied2 >= self.proxied1), 'The lists should have the same ge'
assert (self.plain1 >= self.plain2) == (self.proxied1 >= self.proxied2), 'The lists should have the same ge'
assert (self.plain2 >= self.plain1) == (self.proxied2 >= self.proxied1), 'The lists should have the same ge'

assert (self.proxied1 >= self.proxied2) != (
self.proxied2 >= self.proxied1), 'The gt should invert correctly'
assert (self.proxied1 >= self.proxied2) != (self.proxied2 >= self.proxied1), 'The gt should invert correctly'

def testGetItem(self):
"""Test __getitem__"""
Expand All @@ -185,8 +176,7 @@ def testGetSlice(self):
slices = [(0, 0), (0, len(self.plain1))]

for s in slices:
assert self.plain1[s[0]:s[1]] == self.proxied1[
s[0]:s[1]], 'Slices %s should be the same' % str(s)
assert self.plain1[s[0]:s[1]] == self.proxied1[s[0]:s[1]], 'Slices %s should be the same' % str(s)

t = self.plain1[:]
assert t is not self.plain1, 'Slice should be a copy.'
Expand All @@ -199,13 +189,10 @@ def testGetSlice(self):
def testGT(self):
"""Test __gt__"""

assert (self.plain1 > self.plain2) == (
self.proxied1 > self.proxied2), 'The lists should have the same gt'
assert (self.plain2 > self.plain1) == (
self.proxied2 > self.proxied1), 'The lists should have the same gt'
assert (self.plain1 > self.plain2) == (self.proxied1 > self.proxied2), 'The lists should have the same gt'
assert (self.plain2 > self.plain1) == (self.proxied2 > self.proxied1), 'The lists should have the same gt'

assert (self.proxied1 > self.proxied2) != (
self.proxied2 > self.proxied1), 'The gt should invert correctly'
assert (self.proxied1 > self.proxied2) != (self.proxied2 > self.proxied1), 'The gt should invert correctly'

def testIAdd(self):
"""Test __iadd__"""
Expand Down Expand Up @@ -293,23 +280,19 @@ def testLE(self):

def testLen(self):
"""Tests __len__"""
assert len(self.plain1) == len(
self.proxied1), 'Lengths should be the same'
assert len(self.plain1) == len(self.proxied1), 'Lengths should be the same'

def testLT(self):
"""Test __lt__"""

assert (self.plain1 < self.plain2) == (
self.proxied1 < self.proxied2), 'The lists should have the same lt'
assert (self.plain2 < self.plain1) == (
self.proxied2 < self.proxied1), 'The lists should have the same lt'
assert (self.plain1 < self.plain2) == (self.proxied1 < self.proxied2), 'The lists should have the same lt'
assert (self.plain2 < self.plain1) == (self.proxied2 < self.proxied1), 'The lists should have the same lt'

assert (self.proxied1 < self.proxied2) != (
self.proxied2 < self.proxied1), 'The lt should invert correctly'
assert (self.proxied1 < self.proxied2) != (self.proxied2 < self.proxied1), 'The lt should invert correctly'

def testMul(self):
"""Test __mul__"""
assert (self.plain1 * 7) == (self.proxied1 * 7)
assert len(self.plain1 * 7) == len(self.proxied1 * 7)
assert isProxy(self.proxied1 * 9)

for p in self.proxied1:
Expand All @@ -322,16 +305,15 @@ def testNE(self):
assert self.proxied1 != self.proxied2, 'Lists should be different'

assert self.plain1[0:5] != self.plain1[2:7]
assert self.proxied1[0:5] != self.proxied1[
2:7], 'Lists should be different'
assert self.proxied1[0:5] != self.proxied1[2:7], 'Lists should be different'

def testRMul(self):
"""Test __rmul__"""

t1 = 5 * self.plain1
t2 = 5 * self.proxied1

assert t1 == t2, 'Multiplication should be the same'
assert len(t1) == len(t2), 'Multiplication should be the same'

def testReversed(self):
"""Test the __reversed__ feature (new in python 2.4)."""
Expand Down
2 changes: 1 addition & 1 deletion python/Ganga/test/GPI/Resubmit.gpi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from GangaTest.Framework.utils import sleep_until_completed

j = Job()
j = Job(application=Executable(exe='sleep', args=['3']))
j.submit()
assert(sleep_until_completed(j,60))

Expand Down
2 changes: 2 additions & 0 deletions python/Ganga/test/GPI/WorkspaceRemoval.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Configuration]
autoGenerateJobWorkspace = True
5 changes: 3 additions & 2 deletions python/Ganga/test/Internals/TestRegistry.gpim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os, getpass, random, threading, time
from Ganga.Core.GangaThread.GangaThread import GangaThread
from GangaTest.Framework.tests import GangaGPITestCase, ICheckTest, MultipassTest
from Ganga.Core.GangaRepository.GangaRepositoryXML import GangaRepositoryLocal
from GangaTest.Lib.TestObjects import TestGangaObject
Expand All @@ -16,15 +17,15 @@ type = config['repositorytype']
from Ganga.Utility.logging import getLogger
logger = getLogger(modulename=True)

class HammerThread(threading.Thread):
class HammerThread(GangaThread):
def __init__(self,id,reg):
self.id = id
self.reg = reg
self.rng = random.Random()
self.owned_ids = []
self.owned_objs = {}
self.done = False
super(HammerThread, self).__init__()
super(HammerThread, self).__init__("HammerThread_%s"%str(id))

def updown(self):
logger.info(str(self.id) + " shutdown()")
Expand Down

0 comments on commit 9d3ebde

Please sign in to comment.