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(
self._makeComplexComputeNode(with_slave=True)
self.portal.REQUEST['disable_isTestRun'] = True
self.tic()
self.login(self.compute_node_user_id)
user = self.getPortalObject().portal_membership.getAuthenticatedMember().getUserName()
......@@ -532,6 +531,11 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self.compute_node.setAccessStatus(self.compute_node_id)
refresh_etag = self.compute_node._calculateRefreshEtag()
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()
first_etag = self.compute_node._calculateRefreshEtag()
......@@ -625,6 +629,11 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self.compute_node.setAccessStatus(self.compute_node_id)
refresh_etag = self.compute_node._calculateRefreshEtag()
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()
third_etag = self.compute_node._calculateRefreshEtag()
......@@ -666,6 +675,12 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self.compute_node.setAccessStatus(self.compute_node_id)
refresh_etag = self.compute_node._calculateRefreshEtag()
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()
fourth_etag = self.compute_node._calculateRefreshEtag()
fourth_body_fingerprint = hashData(
......
......@@ -75,11 +75,12 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
def test_activate_getFullComputerInformation_first_access(self):
self._makeComplexComputeNode(with_slave=True)
self.portal.REQUEST['disable_isTestRun'] = True
self.tic()
self.login(self.compute_node_user_id)
self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.tic()
self.portal_slap.getFullComputerInformation(self.compute_node_id)
# First access.
# Cache has been filled by interaction workflow
# (luckily, it seems the cache is filled after everything is indexed)
......@@ -174,7 +175,9 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList()))
self.tic()
self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.tic()
# 6th, the instance edition triggered an interaction workflow
# which updated the cache
response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
......@@ -212,6 +215,8 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
self.assertEqual(third_body_fingerprint, hashData(response.body))
self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList()))
self.tic()
self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.tic()
# 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