Example #1
0
    def test_local_domain_sql_backend_override(self):
        domain_name = uuid.uuid4().hex
        set_local_domain_sql_backend_override(domain_name)
        self.assertTrue(get_local_domain_sql_backend_override(domain_name))

        clear_local_domain_sql_backend_override(domain_name)
        self.assertFalse(get_local_domain_sql_backend_override(domain_name))
Example #2
0
    def test_dry_run(self):
        self.assertFalse(should_use_sql_backend(self.domain_name))
        call_command(
            'migrate_domain_from_couch_to_sql',
            self.domain_name,
            MIGRATE=True,
            no_input=True,
            dry_run=True
        )
        clear_local_domain_sql_backend_override(self.domain_name)
        with self.assertRaises(CommandError):
            call_command('migrate_domain_from_couch_to_sql', self.domain_name, COMMIT=True, no_input=True)
        self.assertFalse(Domain.get_by_name(self.domain_name).use_sql_backend)

        xml = """<?xml version="1.0" ?>
        <n0:registration xmlns:n0="http://openrosa.org/user/registration">
            <username>W4</username>
            <password>2</password>
            <uuid>P8DU7OLHVLZXU21JR10H3W8J2</uuid>
            <date>2013-11-19</date>
            <registering_phone_id>8H1N48EFPF6PA4UOO8YGZ2KFZ</registering_phone_id>
            <user_data>
                <data key="user_type">standard</data>
             </user_data>
        </n0:registration>
        """
        submit_form_locally(xml, self.domain_name)
        couch_form_ids = self._get_form_ids()
        self.assertEqual(1, len(couch_form_ids))

        call_command('migrate_domain_from_couch_to_sql', self.domain_name, blow_away=True, no_input=True)
        self.assertFalse(Domain.get_by_name(self.domain_name).use_sql_backend)
Example #3
0
def commit_migration(domain_name):
    domain_obj = Domain.get_by_name(domain_name, strict=True)
    domain_obj.use_sql_backend = True
    domain_obj.save()
    clear_local_domain_sql_backend_override(domain_name)
    if not should_use_sql_backend(domain_name):
        Domain.get_by_name.clear(Domain, domain_name)
        assert should_use_sql_backend(domain_name)
    datadog_counter("commcare.couch_sql_migration.total_committed")
    _logger.info("committed migration for {}".format(domain_name))
Example #4
0
    def test_test_local_domain_sql_backend_override_overrides(self):
        domain_name = uuid.uuid4().hex
        create_domain(domain_name)
        self.assertFalse(should_use_sql_backend(domain_name))

        set_local_domain_sql_backend_override(domain_name)
        self.assertTrue(should_use_sql_backend(domain_name))

        clear_local_domain_sql_backend_override(domain_name)
        self.assertFalse(should_use_sql_backend(domain_name))
 def abort(self, domain):
     set_couch_sql_migration_not_started(domain)
     clear_local_domain_sql_backend_override(domain)
     blow_away_migration(domain)
Example #6
0
def commit_migration(domain_name):
    domain = Domain.get_by_name(domain_name)
    domain.use_sql_backend = True
    domain.save()
    clear_local_domain_sql_backend_override(domain_name)
    assert should_use_sql_backend(domain_name)
Example #7
0
 def test_commit(self):
     self._do_migration_and_assert_flags(self.domain_name)
     clear_local_domain_sql_backend_override(self.domain_name)
     call_command('migrate_domain_from_couch_to_sql', self.domain_name, COMMIT=True, no_input=True)
     self.assertTrue(Domain.get_by_name(self.domain_name).use_sql_backend)