From deeb6b2cacc22f37a702f6b0c0926531a3294f9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9gory=20Wisniewski?= <gregory@nexedi.com>
Date: Wed, 3 Feb 2010 16:29:58 +0000
Subject: [PATCH] expectAssignedCells now takes the process as parameter
 instead of UUID.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1612 71dcc9de-d417-0410-9af5-da40c76e7ee4
---
 neo/tests/functional/__init__.py    |  4 ++--
 neo/tests/functional/testStorage.py | 36 ++++++++++++++---------------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/neo/tests/functional/__init__.py b/neo/tests/functional/__init__.py
index 682f0e15..b5b9aaa8 100644
--- a/neo/tests/functional/__init__.py
+++ b/neo/tests/functional/__init__.py
@@ -427,13 +427,13 @@ class NEOCluster(object):
             return number_of_oudated == number, number_of_oudated
         self.expectCondition(callback, timeout, delay)
 
-    def expectAssignedCells(self, uuid, number, timeout=0, delay=1):
+    def expectAssignedCells(self, process, number, timeout=0, delay=1):
         def callback(last_try):
             row_list = self.neoctl.getPartitionRowList()[1]
             assigned_cells_number = 0
             for row in row_list:
                 for cell in row[1]:
-                    if cell[0] == uuid:
+                    if cell[0] == process.getUUID():
                         assigned_cells_number += 1
             return assigned_cells_number == number, assigned_cells_number
         self.expectCondition(callback, timeout, delay)
diff --git a/neo/tests/functional/testStorage.py b/neo/tests/functional/testStorage.py
index 4ef17740..6a676159 100644
--- a/neo/tests/functional/testStorage.py
+++ b/neo/tests/functional/testStorage.py
@@ -178,7 +178,7 @@ class StorageTests(NEOFunctionalTest):
         self.neo.expectOudatedCells(number=0)
         self.__populate()
         self.neo.expectClusterRunning()
-        self.neo.expectAssignedCells(started[0].getUUID(), number=10)
+        self.neo.expectAssignedCells(started[0], number=10)
 
         # start the second
         stopped[0].start()
@@ -188,7 +188,7 @@ class StorageTests(NEOFunctionalTest):
         # add it to the partition table
         self.neo.neoctl.enableStorageList([stopped[0].getUUID()])
         self.__expectRunning(stopped[0])
-        self.neo.expectAssignedCells(stopped[0].getUUID(), number=10)
+        self.neo.expectAssignedCells(stopped[0], number=10)
         self.neo.expectClusterRunning()
 
         # wait for replication to finish then check
@@ -303,7 +303,7 @@ class StorageTests(NEOFunctionalTest):
             partitions=10, replicas=0)
         self.__expectRunning(started[0])
         self.neo.expectClusterRunning()
-        self.neo.expectAssignedCells(started[0].getUUID(), 10)
+        self.neo.expectAssignedCells(started[0], 10)
         self.neo.expectOudatedCells(number=0)
 
         # start the second and add it to the partition table
@@ -316,8 +316,8 @@ class StorageTests(NEOFunctionalTest):
 
         # the partition table must change, each node should be assigned to
         # five partitions
-        self.neo.expectAssignedCells(started[0].getUUID(), 5)
-        self.neo.expectAssignedCells(stopped[0].getUUID(), 5)
+        self.neo.expectAssignedCells(started[0], 5)
+        self.neo.expectAssignedCells(stopped[0], 5)
 
     def testPartitionTableReorganizedAfterDrop(self):
         """ Check that the partition change when dropping a replicas from a
@@ -329,22 +329,22 @@ class StorageTests(NEOFunctionalTest):
         self.__expectRunning(started[0])
         self.__expectRunning(started[1])
         self.neo.expectOudatedCells(number=0)
-        self.neo.expectAssignedCells(started[0].getUUID(), 10)
-        self.neo.expectAssignedCells(started[1].getUUID(), 10)
+        self.neo.expectAssignedCells(started[0], 10)
+        self.neo.expectAssignedCells(started[1], 10)
 
         # kill one storage, it should be set as unavailable
         started[0].stop()
         self.__expectUnavailable(started[0])
         self.__expectRunning(started[1])
         # and the partition table must not change
-        self.neo.expectAssignedCells(started[0].getUUID(), 10)
-        self.neo.expectAssignedCells(started[1].getUUID(), 10)
+        self.neo.expectAssignedCells(started[0], 10)
+        self.neo.expectAssignedCells(started[1], 10)
 
         # ask neoctl to drop it
         self.neo.neoctl.dropNode(started[0].getUUID())
         self.__expectNotKnown(started[0])
-        self.neo.expectAssignedCells(started[0].getUUID(), 0)
-        self.neo.expectAssignedCells(started[1].getUUID(), 10)
+        self.neo.expectAssignedCells(started[0], 0)
+        self.neo.expectAssignedCells(started[1], 10)
 
     def testReplicationThenRunningWithReplicas(self):
         """ Add a replicas to a cluster, wait for the replication to finish,
@@ -361,7 +361,7 @@ class StorageTests(NEOFunctionalTest):
         self.__populate()
         self.neo.expectClusterRunning()
         self.neo.expectOudatedCells(number=0)
-        self.neo.expectAssignedCells(started[0].getUUID(), 10)
+        self.neo.expectAssignedCells(started[0], 10)
         self.__checkDatabase(self.neo.db_list[0])
 
         # add a second storage
@@ -370,8 +370,8 @@ class StorageTests(NEOFunctionalTest):
         self.neo.neoctl.enableStorageList([stopped[0].getUUID()])
         self.__expectRunning(stopped[0])
         self.neo.expectClusterRunning()
-        self.neo.expectAssignedCells(started[0].getUUID(), 10)
-        self.neo.expectAssignedCells(stopped[0].getUUID(), 10)
+        self.neo.expectAssignedCells(started[0], 10)
+        self.neo.expectAssignedCells(stopped[0], 10)
 
         # wait for replication to finish
         self.neo.expectOudatedCells(number=0)
@@ -382,8 +382,8 @@ class StorageTests(NEOFunctionalTest):
         started[0].stop()
         self.__expectUnavailable(started[0])
         self.neo.expectOudatedCells(number=10)
-        self.neo.expectAssignedCells(started[0].getUUID(), 10)
-        self.neo.expectAssignedCells(stopped[0].getUUID(), 10)
+        self.neo.expectAssignedCells(started[0], 10)
+        self.neo.expectAssignedCells(stopped[0], 10)
         self.neo.expectClusterRunning()
         self.__checkDatabase(self.neo.db_list[0])
 
@@ -391,8 +391,8 @@ class StorageTests(NEOFunctionalTest):
         self.neo.neoctl.dropNode(started[0].getUUID())
         self.__expectNotKnown(started[0])
         self.__expectRunning(stopped[0])
-        self.neo.expectAssignedCells(started[0].getUUID(), 0)
-        self.neo.expectAssignedCells(stopped[0].getUUID(), 10)
+        self.neo.expectAssignedCells(started[0], 0)
+        self.neo.expectAssignedCells(stopped[0], 10)
         self.__checkDatabase(self.neo.db_list[1])
 
     def testStartWithManyPartitions(self):
-- 
2.30.9