Use TransactionCollection when deleting tasks after cluster reset

TaskCollection doesn't contains all the tasks needed to be deleted on
cluster reset, so use TransactionCollection instead.

Change-Id: I49077a3f6402fcfdb1f71e85fd48602734f1923f
Closes-Bug: #1649987
Co-Authored-With: Bulat Gaifullin <gaifullinbf@gmail.com>
This commit is contained in:
Stanislaw Bogatkin 2016-12-22 15:49:23 +03:00
parent 188f884d9a
commit b61cba6d74
2 changed files with 21 additions and 1 deletions

View File

@ -865,7 +865,7 @@ class ClearTaskHistory(TaskManager):
TaskHelper.set_ready_if_not_finished(task)
# clear tasks history
cluster_tasks = objects.TaskCollection.get_cluster_tasks(
cluster_tasks = objects.TransactionCollection.get_transactions(
self.cluster.id
)
cluster_tasks.delete(synchronize_session='fetch')

View File

@ -20,6 +20,7 @@ from oslo_serialization import jsonutils
from nailgun.db.sqlalchemy.models import Notification
from nailgun import consts
from nailgun import objects
from nailgun.rpc.receiver import NailgunReceiver
from nailgun.test.base import BaseIntegrationTest
from nailgun.test.base import fake_tasks
@ -45,6 +46,12 @@ class TestResetEnvironment(BaseIntegrationTest):
]
)
cluster_db = self.env.clusters[0]
cluster_tasks = objects.TransactionCollection.get_transactions(
cluster_db.id
)
self.assertEqual(cluster_tasks.count(), 0L)
supertask = self.env.launch_deployment()
self.assertEqual(supertask.status, consts.TASK_STATUSES.ready)
@ -52,11 +59,24 @@ class TestResetEnvironment(BaseIntegrationTest):
self.assertEqual(n.status, "ready")
self.assertEqual(n.pending_addition, False)
cluster_tasks = objects.TransactionCollection.get_transactions(
cluster_db.id
)
tasks_before_reset = list(set([task.name for task in cluster_tasks]))
self.assertEqual(sorted(tasks_before_reset),
['deploy', 'deployment', 'provision'])
reset_task = self.env.reset_environment()
self.assertEqual(reset_task.status, consts.TASK_STATUSES.ready)
self.assertEqual(cluster_db.status, "new")
cluster_tasks = objects.TransactionCollection.get_transactions(
cluster_db.id
)
tasks_after_reset = list(set([task.name for task in cluster_tasks]))
self.assertEqual(tasks_after_reset, ['reset_environment'])
# FIXME(aroma): remove when stop action will be reworked for ha
# cluster. To get more details, please, refer to [1]
# [1]: https://bugs.launchpad.net/fuel/+bug/1529691