11502: Avoid races on test by getting the unstripped manifest version before the...
authorLucas Di Pentima <lucas@curoverse.com>
Tue, 18 Apr 2017 16:36:44 +0000 (13:36 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Tue, 18 Apr 2017 16:36:44 +0000 (13:36 -0300)
sdk/python/tests/test_arv_get.py

index 4feac0fd61e70687d9353a71f4f55c5afb871e53..afbe634b12d8439800ff01c24478b7e984cc64f3 100644 (file)
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 
 import io
+import os
 import shutil
 import tempfile
 
@@ -80,13 +81,18 @@ class ArvadosGetTestCase(run_test_server.TestCaseWithServers):
         # Get the collection manifest by UUID
         r = self.run_get([self.col_loc, self.tempdir])
         self.assertEqual(0, r)
-        with open("{}/{}".format(self.tempdir, self.col_loc), "r") as f:
-            self.assertEqual(self.col_manifest, f.read())
+        m_from_collection = collection.Collection(self.col_manifest).manifest_text(strip=True)
+        with open(os.path.join(self.tempdir, self.col_loc), "r") as f:
+            # Strip manifest before comparison to avoid races
+            m_from_file = collection.Collection(f.read()).manifest_text(strip=True)
+            self.assertEqual(m_from_collection, m_from_file)
         # Get the collection manifest by PDH
         r = self.run_get([self.col_pdh, self.tempdir])
         self.assertEqual(0, r)
-        with open("{}/{}".format(self.tempdir, self.col_pdh), "r") as f:
-            self.assertEqual(self.col_manifest, f.read())
+        with open(os.path.join(self.tempdir, self.col_pdh), "r") as f:
+            # Strip manifest before comparison to avoid races
+            m_from_file = collection.Collection(f.read()).manifest_text(strip=True)
+            self.assertEqual(m_from_collection, m_from_file)
 
     def test_get_collection_stripped_manifest(self):
         col_loc, col_pdh, col_manifest = self.write_test_collection(strip_manifest=True)