Example #1
0
    def InitDatastore(self):
        if self.disabled:
            raise unittest.SkipTest(
                "Skipping since Mysql db is not reachable.")

        self.token = access_control.ACLToken(username="******",
                                             reason="Running tests")
        # Use separate tables for benchmarks / tests so they can be run in parallel.
        with test_lib.ConfigOverrider({
                "Mysql.database_name":
                "grr_test_%s" % self.__class__.__name__,
                "Mysql.max_connect_wait":
                2
        }):
            try:
                data_store.DB = mysql_advanced_data_store.MySQLAdvancedDataStore(
                )
                data_store.DB.Initialize()
                data_store.DB.flusher_thread.Stop()
                data_store.DB.security_manager = test_lib.MockSecurityManager()
                data_store.DB.RecreateTables()
            except Exception as e:
                logging.debug("Error while connecting to MySQL db: %s.", e)
                MysqlAdvancedTestMixin.disabled = True
                raise unittest.SkipTest(
                    "Skipping since Mysql db is not reachable.")
  def InitDatastore(self):
    self.token = access_control.ACLToken(username="******",
                                         reason="Running tests")
    # Use separate tables for benchmarks / tests so they can be run in parallel.
    config_lib.CONFIG.Set("Mysql.database_name", "grr_test_%s" %
                          self.__class__.__name__)

    try:
      data_store.DB = mysql_advanced_data_store.MySQLAdvancedDataStore()
      data_store.DB.security_manager = test_lib.MockSecurityManager()
      data_store.DB.RecreateTables()
    except Exception as e:
      logging.debug("Error while connecting to MySQL db: %s.", e)
      raise unittest.SkipTest("Skipping since Mysql db is not reachable.")