def setUp(self): super(Mysql8Tests, self).setUp() self.template = "/tmp/mysql-passwd.txt" self.connection = mock.MagicMock() self.cursor = mock.MagicMock() self.connection.cursor.return_value = self.cursor self.helper = mysql.MySQL8Helper(rpasswdf_template=self.template, upasswdf_template=self.template) self.helper.connection = self.connection self.user = "******" self.host = "10.5.0.21" self.password = "******" self.db = "mydb"
def get_db_helper(self): """Get an instance of the MySQLDB8Helper class. :param self: Self :type self: MySQLInnoDBClusterCharm instance :returns: Instance of MySQLDB8Helper class :rtype: MySQLDB8Helper instance """ # NOTE: The template paths are an artifact of the original Helper code. # Passwords are injected into leader settings. No passwords are written # to disk by this class. return mysql.MySQL8Helper( rpasswdf_template="/var/lib/charm/{}/mysql.passwd".format( ch_core.hookenv.service_name()), upasswdf_template="/var/lib/charm/{}/mysql-{{}}.passwd".format( ch_core.hookenv.service_name()))
def get_db_helper(self): """Get an instance of the MySQLDB8Helper class. :param self: Self :type self: MySQLRouterCharm instance :returns: Instance of MySQLDB8Helper class :rtype: MySQLDB8Helper instance """ db_helper = mysql.MySQL8Helper( rpasswdf_template="/var/lib/charm/{}/mysql.passwd" .format(ch_core.hookenv.service_name()), upasswdf_template="/var/lib/charm/{}/mysql-{{}}.passwd" .format(ch_core.hookenv.service_name()), user=self.db_router_user, password=self.db_router_password, host=self.cluster_address) return db_helper