예제 #1
0
 def test_text_partitioning_incorrect(self):
     form = self._make_form_instance(str(self.p2_uuid))
     super(PartitionedModel, form).save(using=self.db1)
     self.assertEqual(XFormInstanceSQL.objects.using(self.db1).count(), 1)
     matches = get_count_of_unmatched_models_by_shard(self.db1, XFormInstanceSQL)
     self.assertEqual(1, len(matches))
     self.assertEqual((2, 1), matches[0])
예제 #2
0
 def test_uuid_partitioning_incorrect(self):
     instance = BaseSchedulingPartitionedDBAccessorsTest.make_alert_schedule_instance(
         self.p1_uuid, domain=self.domain
     )
     super(PartitionedModel, instance).save(using=self.db2)
     self.assertEqual(AlertScheduleInstance.objects.using(self.db2).count(), 1)
     matches = get_count_of_unmatched_models_by_shard(self.db2, AlertScheduleInstance)
     self.assertEqual(1, len(matches))
     self.assertEqual((0, 1), matches[0])
예제 #3
0
 def test_text_partitioning_correct(self):
     form = self._make_form_instance(str(self.p2_uuid))
     form.save()
     self.assertEqual(XFormInstanceSQL.objects.using(self.db2).count(), 1)
     matches = get_count_of_unmatched_models_by_shard(
         self.db2, XFormInstanceSQL)
     self.assertEqual(0, len(matches))
     all_data = get_count_of_models_by_shard(self.db2, XFormInstanceSQL)
     self.assertEqual(1, len(all_data))
     self.assertEqual((2, 1), all_data[0])
 def handle(self, **options):
     sharded_models = list(get_all_sharded_models())
     for database in get_db_aliases_for_partitioned_query():
         for model in sharded_models:
             invalid_data = get_count_of_unmatched_models_by_shard(database, model)
             if invalid_data:
                 for shard_id, count in invalid_data:
                     print('found {} unexpected {}s in {} (shard {}).'.format(
                         count, model.__name__, database, shard_id)
                     )
예제 #5
0
 def test_text_partitioning_correct(self):
     from corehq.sql_db.shard_data_management import get_count_of_models_by_shard_for_testing
     form = self._make_form_instance(str(self.p2_uuid))
     form.save()
     self.assertEqual(XFormInstanceSQL.objects.using(self.db2).count(), 1)
     matches = get_count_of_unmatched_models_by_shard(self.db2, XFormInstanceSQL)
     self.assertEqual(0, len(matches))
     all_data = get_count_of_models_by_shard_for_testing(self.db2, XFormInstanceSQL)
     self.assertEqual(1, len(all_data))
     self.assertEqual((2, 1), all_data[0])
 def handle(self, **options):
     sharded_models = list(get_all_sharded_models())
     for database in get_db_aliases_for_partitioned_query():
         for model in sharded_models:
             invalid_data = get_count_of_unmatched_models_by_shard(database, model)
             if invalid_data:
                 for shard_id, count in invalid_data:
                     print('found {} unexpected {}s in {} (shard {}).'.format(
                         count, model.__name__, database, shard_id)
                     )
예제 #7
0
 def test_uuid_partitioning_correct(self):
     from corehq.sql_db.shard_data_management import get_count_of_models_by_shard_for_testing
     instance = BaseSchedulingPartitionedDBAccessorsTest.make_alert_schedule_instance(
         self.p1_uuid, domain=self.domain
     )
     save_alert_schedule_instance(instance)
     self.assertEqual(AlertScheduleInstance.objects.using(self.db1).count(), 1)
     matches = get_count_of_unmatched_models_by_shard(self.db1, AlertScheduleInstance)
     self.assertEqual(0, len(matches))
     all_data = get_count_of_models_by_shard_for_testing(self.db1, AlertScheduleInstance)
     self.assertEqual(1, len(all_data))
     self.assertEqual((0, 1), all_data[0])
예제 #8
0
 def test_text_partitioning_correct(self):
     from corehq.sql_db.shard_data_management import get_count_of_models_by_shard_for_testing
     form = self._make_form_instance(str(self.p2_uuid))
     form.save()
     self.assertEqual(XFormInstance.objects.using(self.db2).count(), 1)
     matches = get_count_of_unmatched_models_by_shard(
         self.db2, XFormInstance)
     self.assertEqual(0, len(matches))
     all_data = get_count_of_models_by_shard_for_testing(
         self.db2, XFormInstance)
     self.assertEqual(1, len(all_data))
     self.assertEqual((2, 1), all_data[0])