Commit 6e32236a authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Update test for getCacheComputeNodeInformation

  Since priority is 1 the activies can be called out of order. So calculateEtags can be called before all objects be indexed. This can lead to a intermediate (or old) value, requiring am extra call to the _activateFillComputeNodeInformationCache.

  This is somehow acceptable since the code should expect an ordering of activities execution anyway.
parent 967d42f6
...@@ -524,7 +524,6 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation( ...@@ -524,7 +524,6 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self._makeComplexComputeNode(with_slave=True) self._makeComplexComputeNode(with_slave=True)
self.portal.REQUEST['disable_isTestRun'] = True self.portal.REQUEST['disable_isTestRun'] = True
self.tic()
self.login(self.compute_node_user_id) self.login(self.compute_node_user_id)
user = self.getPortalObject().portal_membership.getAuthenticatedMember().getUserName() user = self.getPortalObject().portal_membership.getAuthenticatedMember().getUserName()
...@@ -532,6 +531,11 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation( ...@@ -532,6 +531,11 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self.compute_node.setAccessStatus(self.compute_node_id) self.compute_node.setAccessStatus(self.compute_node_id)
refresh_etag = self.compute_node._calculateRefreshEtag() refresh_etag = self.compute_node._calculateRefreshEtag()
body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag) body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag)
# This tic and second call is to fix indexation ordering while some sub object
# is created after the etag is computed and stored.
self.tic()
refresh_etag = self.compute_node._calculateRefreshEtag()
body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag)
self.commit() self.commit()
first_etag = self.compute_node._calculateRefreshEtag() first_etag = self.compute_node._calculateRefreshEtag()
...@@ -625,6 +629,11 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation( ...@@ -625,6 +629,11 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self.compute_node.setAccessStatus(self.compute_node_id) self.compute_node.setAccessStatus(self.compute_node_id)
refresh_etag = self.compute_node._calculateRefreshEtag() refresh_etag = self.compute_node._calculateRefreshEtag()
body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag) body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag)
# On the previous tic, the values can be indexed out of order, so recall after indextion
# so the values are propely set.
self.tic()
body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag)
self.commit() self.commit()
third_etag = self.compute_node._calculateRefreshEtag() third_etag = self.compute_node._calculateRefreshEtag()
...@@ -666,6 +675,12 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation( ...@@ -666,6 +675,12 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self.compute_node.setAccessStatus(self.compute_node_id) self.compute_node.setAccessStatus(self.compute_node_id)
refresh_etag = self.compute_node._calculateRefreshEtag() refresh_etag = self.compute_node._calculateRefreshEtag()
body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag) body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag)
# On the previous tic, the values can be indexed out of order, so recall after indextion
# so the values are propely set.
self.tic()
body, etag = self.compute_node._getComputeNodeInformation(user, refresh_etag)
self.commit() self.commit()
fourth_etag = self.compute_node._calculateRefreshEtag() fourth_etag = self.compute_node._calculateRefreshEtag()
fourth_body_fingerprint = hashData( fourth_body_fingerprint = hashData(
......
...@@ -75,11 +75,12 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -75,11 +75,12 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
def test_activate_getFullComputerInformation_first_access(self): def test_activate_getFullComputerInformation_first_access(self):
self._makeComplexComputeNode(with_slave=True) self._makeComplexComputeNode(with_slave=True)
self.portal.REQUEST['disable_isTestRun'] = True self.portal.REQUEST['disable_isTestRun'] = True
self.tic()
self.login(self.compute_node_user_id) self.login(self.compute_node_user_id)
self.portal_slap.getFullComputerInformation(self.compute_node_id) self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.tic()
self.portal_slap.getFullComputerInformation(self.compute_node_id)
# First access. # First access.
# Cache has been filled by interaction workflow # Cache has been filled by interaction workflow
# (luckily, it seems the cache is filled after everything is indexed) # (luckily, it seems the cache is filled after everything is indexed)
...@@ -174,7 +175,9 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -174,7 +175,9 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList())) self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList()))
self.tic() self.tic()
self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.tic()
# 6th, the instance edition triggered an interaction workflow # 6th, the instance edition triggered an interaction workflow
# which updated the cache # which updated the cache
response = self.portal_slap.getFullComputerInformation(self.compute_node_id) response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
...@@ -212,6 +215,8 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -212,6 +215,8 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
self.assertEqual(third_body_fingerprint, hashData(response.body)) self.assertEqual(third_body_fingerprint, hashData(response.body))
self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList())) self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList()))
self.tic()
self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.tic() self.tic()
# 8th access # 8th access
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment