From ef4455664d49439bf483f2158c01474d26042583 Mon Sep 17 00:00:00 2001 From: Philip Abbet <philip.abbet@idiap.ch> Date: Mon, 8 May 2017 14:09:31 +0200 Subject: [PATCH] [backend, tests] Fix the tests --- beat/web/backend/tests.py | 50 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/beat/web/backend/tests.py b/beat/web/backend/tests.py index e4cfea7fd..263eb1029 100755 --- a/beat/web/backend/tests.py +++ b/beat/web/backend/tests.py @@ -779,7 +779,7 @@ class Scheduling(BaseBackendTestCase): self.assertEqual(split.job.block.experiment.status, Experiment.RUNNING) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(split) @@ -820,7 +820,7 @@ class Scheduling(BaseBackendTestCase): split.end(Result(status=0)) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.assertEqual(split.job.status, Job.COMPLETED) self.assertEqual(split.job.block.status, Block.CACHED) @@ -930,7 +930,7 @@ class Scheduling(BaseBackendTestCase): self.assertEqual(split.job.block.experiment.status, Experiment.FAILED) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) # assert we have no database traces after the last block is done self.assertEqual(Job.objects.count(), 0) @@ -987,7 +987,7 @@ class Scheduling(BaseBackendTestCase): self.assertEqual(split.job.block.experiment.status, Experiment.RUNNING) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(split) @@ -1028,7 +1028,7 @@ class Scheduling(BaseBackendTestCase): split.end(Result(status=1)) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.assertEqual(split.job.status, Job.FAILED) self.assertEqual(split.job.block.status, Block.FAILED) @@ -1124,7 +1124,7 @@ class Scheduling(BaseBackendTestCase): self.assertEqual(split.job.block.experiment.status, Experiment.RUNNING) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(split) @@ -1266,7 +1266,7 @@ class Scheduling(BaseBackendTestCase): self.assertEqual(split.job.block.experiment.status, Experiment.FAILED) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) # assert we have no database traces after the last block is done self.assertEqual(Job.objects.count(), 0) @@ -1344,7 +1344,7 @@ class Scheduling(BaseBackendTestCase): Experiment.RUNNING) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(split) @@ -1392,7 +1392,7 @@ class Scheduling(BaseBackendTestCase): split.end(Result(status=0)) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.assertEqual(split.job.status, Job.COMPLETED) self.assertEqual(split.job.block.status, Block.CACHED) @@ -1479,7 +1479,7 @@ class Scheduling(BaseBackendTestCase): Experiment.FAILED) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) # assert we have no database traces after the last block is done self.assertEqual(Job.objects.count(), 0) @@ -1554,7 +1554,7 @@ class Scheduling(BaseBackendTestCase): Experiment.RUNNING) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(split) @@ -1761,7 +1761,7 @@ class Scheduling(BaseBackendTestCase): Experiment.RUNNING) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(split) @@ -2161,7 +2161,7 @@ class Working(BaseBackendTestCase): assert all([k.index_checksums() for k in block.outputs.all()]) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(block) @@ -2190,7 +2190,7 @@ class Working(BaseBackendTestCase): split.process() # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) xp.refresh_from_db() block = xp.blocks.last() @@ -2251,7 +2251,7 @@ class Working(BaseBackendTestCase): assert all([not k.exists() for k in block.outputs.all()]) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) assert abs(block.speed_up_real() - 1.0) < 0.1 assert abs(block.speed_up_maximal() - 1.0) < 0.1 @@ -2310,7 +2310,7 @@ class Working(BaseBackendTestCase): assert all([k.index_checksums() for k in block.outputs.all()]) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(block) @@ -2339,7 +2339,7 @@ class Working(BaseBackendTestCase): split.process() # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) xp.refresh_from_db() block = xp.blocks.last() @@ -2409,7 +2409,7 @@ class Working(BaseBackendTestCase): assert all([k.index_checksums() for k in block.outputs.all()]) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(block) @@ -2449,7 +2449,7 @@ class Working(BaseBackendTestCase): split.process() # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) xpc.refresh_from_db() block = xpc.blocks.last() @@ -2520,7 +2520,7 @@ class Working(BaseBackendTestCase): assert all([k.index_checksums() for k in block.outputs.all()]) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) self.check_stats_success(block) @@ -2622,7 +2622,8 @@ class WorkingExternally(TransactionTestCase): xp.refresh_from_db() block = xp.blocks.first() return block.status == Block.CACHED - _sleep(20, condition) + + _sleep(120, condition) # at this point, split should have been successful which shall # trigger job deletion and block update @@ -2636,7 +2637,7 @@ class WorkingExternally(TransactionTestCase): assert all([k.index_checksums() for k in split.job.block.outputs.all()]) # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) # assert we have no database traces after the block is done self.assertEqual(Job.objects.filter(block=split.job.block).count(), 0) @@ -2665,10 +2666,11 @@ class WorkingExternally(TransactionTestCase): def condition(): xp.refresh_from_db() return xp.status == Experiment.DONE - _sleep(20, condition) #wait job completion + + _sleep(120, condition) #wait job completion # checks the number of statistics objects has increased by 1 - self.assertEqual(HourlyStatistics.objects.count(), current_stats + 1) + self.assertTrue(HourlyStatistics.objects.count() > current_stats) # at this point, split should have been successful which shall # trigger job deletion and block update -- GitLab