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_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 #3
0
def get_migrator(domain, state_dir):
    # Set backend for CouchSqlDomainMigrator._check_for_migration_restrictions
    status = get_couch_sql_migration_status(domain)
    live_migrate = status == MigrationStatus.DRY_RUN
    set_local_domain_sql_backend_override(domain)
    return CouchSqlDomainMigrator(
        domain, state_dir, live_migrate=live_migrate, case_diff="none")
Example #4
0
def get_migrator(domain, state_dir, live):
    # Set backend for CouchSqlDomainMigrator._check_for_migration_restrictions
    set_local_domain_sql_backend_override(domain)
    return CouchSqlDomainMigrator(domain,
                                  state_dir,
                                  live_migrate=live,
                                  diff_process=None)
def do_couch_to_sql_migration(domain, with_progress=True, debug=False, run_timestamp=None):
    set_local_domain_sql_backend_override(domain)
    CouchSqlDomainMigrator(
        domain,
        with_progress=with_progress,
        debug=debug,
        run_timestamp=run_timestamp
    ).migrate()
Example #6
0
def do_couch_to_sql_migration(domain, with_progress=True, debug=False, run_timestamp=None):
    set_local_domain_sql_backend_override(domain)
    CouchSqlDomainMigrator(
        domain,
        with_progress=with_progress,
        debug=debug,
        run_timestamp=run_timestamp
    ).migrate()
 def _migrate_form_and_associated_models_async(self, wrapped_form):
     set_local_domain_sql_backend_override(self.domain)
     try:
         self._migrate_form_and_associated_models(wrapped_form)
     except Exception:
         self.log_error("Unable to migrate form: {}".format(wrapped_form.form_id))
         raise
     finally:
         self.queues.release_lock_for_queue_obj(wrapped_form)
Example #8
0
 def _migrate_form(self, wrapped_form):
     set_local_domain_sql_backend_override(self.domain)
     try:
         self._migrate_form_and_associated_models(wrapped_form)
     except Exception:
         log.exception("Unable to migrate form: %s", wrapped_form.form_id)
     finally:
         self.processed_docs += 1
         self._log_main_forms_processed_count(throttled=True)
Example #9
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))
Example #10
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))
Example #11
0
 def _migrate_form_and_associated_models_async(self, wrapped_form):
     set_local_domain_sql_backend_override(self.domain)
     try:
         self._migrate_form_and_associated_models(wrapped_form)
     except Exception:
         log.exception("Unable to migrate form: %s", wrapped_form.form_id)
     finally:
         self.queues.release_lock_for_queue_obj(wrapped_form)
         self.processed_docs += 1
         self._log_main_forms_processed_count(throttled=True)
Example #12
0
def init_worker(domain, *args):
    def on_break(signum, frame):
        nonlocal clean_break
        if clean_break:
            raise KeyboardInterrupt
        print("clean break... (Ctrl+C to abort)")
        clean_break = True

    clean_break = False
    signal.signal(signal.SIGINT, on_break)
    set_local_domain_sql_backend_override(domain)
    return global_diff_state(domain, *args)
 def _migrate_form(self, couch_form, case_ids):
     set_local_domain_sql_backend_override(self.domain)
     form_id = couch_form.form_id
     self._migrate_form_and_associated_models(couch_form)
     self.case_diff_queue.update(case_ids, form_id)
def do_couch_to_sql_migration(domain, state_dir, **kw):
    set_local_domain_sql_backend_override(domain)
    CouchSqlDomainMigrator(domain, state_dir, **kw).migrate()
Example #15
0
def do_couch_to_sql_migration(domain, with_progress=True):
    set_local_domain_sql_backend_override(domain)
    CouchSqlDomainMigrator(domain, with_progress).migrate()
Example #16
0
def _do_couch_to_sql_migration(domain):
    # (optional) collect some information about the domain's cases and forms for cross-checking
    set_local_domain_sql_backend_override(domain)
    assert should_use_sql_backend(domain)
    _process_main_forms(domain)
    _copy_unprocessed_forms(domain)