From f3b6855f55cc7570f9518ee074eb6d6c1ff19f78 Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Thu, 25 Mar 2021 17:27:36 +0100 Subject: [PATCH] Testing... --- .../FileManager/FileManagerBase.py | 4 ++-- src/DIRAC/WorkloadManagementSystem/DB/JobDB.py | 12 ++++++++---- tests/Integration/Core/Test_ElasticsearchDB.py | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileManager/FileManagerBase.py b/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileManager/FileManagerBase.py index a99636ffc83..065b5d96d76 100755 --- a/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileManager/FileManagerBase.py +++ b/src/DIRAC/DataManagementSystem/DB/FileCatalogComponents/FileManager/FileManagerBase.py @@ -870,7 +870,7 @@ def exists(self, lfns, connection=False): # either {lfn : guid} # or P lfn : {PFN : .., GUID : ..} } if isinstance(lfns, dict): - val = lfns.values() + val = list(lfns.values()) # We have values, take the first to identify the type if val: @@ -881,7 +881,7 @@ def exists(self, lfns, connection=False): guidList = [lfns[lfn]['GUID'] for lfn in lfns] elif isinstance(val, six.string_types): # We hope that it is the GUID which is given - guidList = lfns.values() + guidList = list(lfns.values()) if guidList: # A dict { guid: lfn to which it is supposed to be associated } diff --git a/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py b/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py index 01c9155b509..9dc9a55c3ae 100755 --- a/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py +++ b/src/DIRAC/WorkloadManagementSystem/DB/JobDB.py @@ -46,16 +46,20 @@ def compressJDL(jdl): """Return compressed JDL string.""" - return zlib.compress(jdl, -1).encode('base64') + return base64.b64encode(zlib.compress(jdl.encode(), -1)).decode() def extractJDL(compressedJDL): """Return decompressed JDL string.""" # the starting bracket is guaranteeed by JobManager.submitJob # we need the check to be backward compatible - if compressedJDL.startswith('['): - return compressedJDL - return zlib.decompress(compressedJDL.decode('base64')) + if isinstance(compressedJDL, bytes): + if compressedJDL.startswith(b'['): + return compressedJDL.decode() + else: + if compressedJDL.startswith('['): + return compressedJDL + return zlib.decompress(base64.b64decode(compressedJDL)).decode() ############################################################################# diff --git a/tests/Integration/Core/Test_ElasticsearchDB.py b/tests/Integration/Core/Test_ElasticsearchDB.py index 6cbb6450c93..1cf4e66a6e8 100644 --- a/tests/Integration/Core/Test_ElasticsearchDB.py +++ b/tests/Integration/Core/Test_ElasticsearchDB.py @@ -182,9 +182,9 @@ def test_getDocTypes(self): result = self.elasticSearchDB.getDocTypes(self.index_name) self.assertTrue(result) if '_doc' in result['Value']: - self.assertEqual(list(result['Value']['_doc']['properties']), [u'Color', u'timestamp', u'Product', u'quantity']) + self.assertEqual(set(result['Value']['_doc']['properties']), {u'Color', u'timestamp', u'Product', u'quantity'}) else: - self.assertEqual(list(result['Value']['properties']), [u'Color', u'timestamp', u'Product', u'quantity']) + self.assertEqual(set(result['Value']['properties']), {u'Color', u'timestamp', u'Product', u'quantity'}) def test_existingIndex(self): result = self.elasticSearchDB.existingIndex(self.index_name)