From 2700d8cd7159ba9a2bd91df08ff6418ed19d27ab Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:04:14 +0000 Subject: [PATCH 01/11] Add flags to allow specifying collation instead of charset --- internal/raft/net_transport.go | 2 -- pkg/config/config.go | 2 ++ pkg/group/mysql.go | 14 ++++++++++-- pkg/mysql/probe.go | 39 +++++++++++++++++++++++----------- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/internal/raft/net_transport.go b/internal/raft/net_transport.go index 3de2a694..b48bab50 100644 --- a/internal/raft/net_transport.go +++ b/internal/raft/net_transport.go @@ -37,7 +37,6 @@ var ( ) /* - NetworkTransport provides a network based transport that can be used to communicate with Raft on remote machines. It requires an underlying stream layer to provide a stream abstraction, which can @@ -53,7 +52,6 @@ both are encoded using MsgPack. InstallSnapshot is special, in that after the RPC request we stream the entire state. That socket is not re-used as the connection state is not known if there is an error. - */ type NetworkTransport struct { connPool map[string][]*netConn diff --git a/pkg/config/config.go b/pkg/config/config.go index 10e90360..efa3bd6b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -106,6 +106,8 @@ type ConfigurationSettings struct { BackendMySQLSchema string BackendMySQLUser string BackendMySQLPassword string + BackendCollation string + StoresCollation string MemcacheServers []string // if given, freno will report to aggregated values to given memcache MemcachePath string // use as prefix to metric path in memcache key, e.g. if `MemcachePath` is "myprefix" the key would be "myprefix/mysql/maincluster". Default: "freno" EnableProfiling bool // enable pprof profiling http api diff --git a/pkg/group/mysql.go b/pkg/group/mysql.go index d70b715d..135de6a6 100644 --- a/pkg/group/mysql.go +++ b/pkg/group/mysql.go @@ -77,8 +77,18 @@ func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error) { if config.Settings().BackendMySQLHost == "" { return nil, nil } - dbUri := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&charset=utf8mb4,utf8,latin1&timeout=500ms", - config.Settings().BackendMySQLUser, config.Settings().BackendMySQLPassword, config.Settings().BackendMySQLHost, config.Settings().BackendMySQLPort, config.Settings().BackendMySQLSchema, + dsnCharsetCollation := "charset=utf8mb4,utf8,latin1" + if config.Settings().BackendCollation != "" { + // Set collation instead of charset, if BackendCollation is specified + dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().BackendCollation) + } + dbUri := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&%s&timeout=500ms", + config.Settings().BackendMySQLUser, + config.Settings().BackendMySQLPassword, + config.Settings().BackendMySQLHost, + config.Settings().BackendMySQLPort, + config.Settings().BackendMySQLSchema, + dsnCharsetCollation, ) db, _, err := sqlutils.GetDB(dbUri) if err != nil { diff --git a/pkg/mysql/probe.go b/pkg/mysql/probe.go index 46853700..3f6f21bc 100644 --- a/pkg/mysql/probe.go +++ b/pkg/mysql/probe.go @@ -8,6 +8,8 @@ package mysql import ( "fmt" "net" + + "github.com/github/freno/pkg/config" ) const maxPoolConnections = 3 @@ -48,33 +50,46 @@ func NewProbe() *Probe { } // DuplicateCredentials creates a new connection config with given key and with same credentials as this config -func (this *Probe) DuplicateCredentials(key InstanceKey) *Probe { +func (probe *Probe) DuplicateCredentials(key InstanceKey) *Probe { config := &Probe{ Key: key, - User: this.User, - Password: this.Password, + User: probe.User, + Password: probe.Password, } return config } -func (this *Probe) Duplicate() *Probe { - return this.DuplicateCredentials(this.Key) +func (probe *Probe) Duplicate() *Probe { + return probe.DuplicateCredentials(probe.Key) } -func (this *Probe) String() string { - return fmt.Sprintf("%s, user=%s", this.Key.DisplayString(), this.User) +func (probe *Probe) String() string { + return fmt.Sprintf("%s, user=%s", probe.Key.DisplayString(), probe.User) } -func (this *Probe) Equals(other *Probe) bool { - return this.Key.Equals(&other.Key) +func (probe *Probe) Equals(other *Probe) bool { + return probe.Key.Equals(&other.Key) } -func (this *Probe) GetDBUri(databaseName string) string { - hostname := this.Key.Hostname +func (probe *Probe) GetDBUri(databaseName string) string { + hostname := probe.Key.Hostname var ip = net.ParseIP(hostname) if (ip != nil) && (ip.To4() == nil) { // Wrap IPv6 literals in square brackets hostname = fmt.Sprintf("[%s]", hostname) } - return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&charset=utf8mb4,utf8,latin1&timeout=%dms", this.User, this.Password, hostname, this.Key.Port, databaseName, timeoutMillis) + dsnCharsetCollation := "charset=utf8mb4,utf8,latin1" + if config.Settings().StoresCollation != "" { + // Set collation instead of charset, if StoresCollation is specified + dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().StoresCollation) + } + return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&%s&timeout=%dms", + probe.User, + probe.Password, + hostname, + probe.Key.Port, + databaseName, + dsnCharsetCollation, + timeoutMillis, + ) } From 76906c93315b8ba075408fb2c098475d22681ff0 Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:05:03 +0000 Subject: [PATCH 02/11] Support Go 1.18 and 1.19 --- script/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/bootstrap b/script/bootstrap index 2b480604..ff208aaa 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -2,7 +2,7 @@ set -e -readonly supportedGo="go1.1[67]" +readonly supportedGo="go1.1[6789]" # Ensure go is installed if ! command -v go ; then From bae3ebc48fab38d61db3f7155d8d2fb35f09d115 Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:18:06 +0000 Subject: [PATCH 03/11] Move stores collation setting to MySQLConfigurationSettings --- pkg/config/config.go | 3 +-- pkg/config/mysql_config.go | 1 + pkg/mysql/probe.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index efa3bd6b..9097bad0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -106,8 +106,7 @@ type ConfigurationSettings struct { BackendMySQLSchema string BackendMySQLUser string BackendMySQLPassword string - BackendCollation string - StoresCollation string + BackendCollation string // if specified, use this collation instead of charset when connecting to MySQL backend MemcacheServers []string // if given, freno will report to aggregated values to given memcache MemcachePath string // use as prefix to metric path in memcache key, e.g. if `MemcachePath` is "myprefix" the key would be "myprefix/mysql/maincluster". Default: "freno" EnableProfiling bool // enable pprof profiling http api diff --git a/pkg/config/mysql_config.go b/pkg/config/mysql_config.go index 9ccd79e0..fd7938df 100644 --- a/pkg/config/mysql_config.go +++ b/pkg/config/mysql_config.go @@ -63,6 +63,7 @@ type MySQLConfigurationSettings struct { ProxySQLUser string // ProxySQL stats username ProxySQLPassword string // ProxySQL stats password VitessCells []string // Name of the Vitess cells for polling tablet hosts + Collation string // MySQL collation to use for stores, replaces charset if specified Clusters map[string](*MySQLClusterConfigurationSettings) // cluster name -> cluster config } diff --git a/pkg/mysql/probe.go b/pkg/mysql/probe.go index 3f6f21bc..ed18e3a1 100644 --- a/pkg/mysql/probe.go +++ b/pkg/mysql/probe.go @@ -79,9 +79,9 @@ func (probe *Probe) GetDBUri(databaseName string) string { hostname = fmt.Sprintf("[%s]", hostname) } dsnCharsetCollation := "charset=utf8mb4,utf8,latin1" - if config.Settings().StoresCollation != "" { + if config.Settings().Stores.MySQL.Collation != "" { // Set collation instead of charset, if StoresCollation is specified - dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().StoresCollation) + dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().Stores.MySQL.Collation) } return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&%s&timeout=%dms", probe.User, From 3afd9fea4ec54ddba9b94b8cf6694b114e8471a4 Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:20:12 +0000 Subject: [PATCH 04/11] Fix incorrect comment --- pkg/mysql/probe.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/mysql/probe.go b/pkg/mysql/probe.go index ed18e3a1..43860687 100644 --- a/pkg/mysql/probe.go +++ b/pkg/mysql/probe.go @@ -80,7 +80,7 @@ func (probe *Probe) GetDBUri(databaseName string) string { } dsnCharsetCollation := "charset=utf8mb4,utf8,latin1" if config.Settings().Stores.MySQL.Collation != "" { - // Set collation instead of charset, if StoresCollation is specified + // Set collation instead of charset, if Stores.MySQL.Collation is specified dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().Stores.MySQL.Collation) } return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&%s&timeout=%dms", From d54eb8141e25ad71606df1defcd0a022d80f6a80 Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:33:12 +0000 Subject: [PATCH 05/11] bump go version for CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 641776cb..09b6e955 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.17 + go-version: 1.19 id: go - name: Build From b438205d237a36aafe39f98055c66b4c92f5941a Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:34:05 +0000 Subject: [PATCH 06/11] bump go version to 1.19 for release CI job --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71edd10b..2d95024f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: 1.19 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 From dc3667d155074ec757455eec7a554553d9cdfeec Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:51:52 +0000 Subject: [PATCH 07/11] for consistency with other vars: s/BackendCollation/BackendMySQLCollation --- pkg/config/config.go | 38 +++++++++++++++++++------------------- pkg/group/mysql.go | 6 +++--- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 9097bad0..1e6d588f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -92,25 +92,25 @@ func (config *Configuration) Reload() error { // Some of the settinges have reasonable default values, and some other // (like database credentials) are strictly expected from user. type ConfigurationSettings struct { - ListenPort int - DataCenter string - Environment string - Domain string - ShareDomain string - RaftBind string - RaftDataDir string - DefaultRaftPort int // if a RaftNodes entry does not specify port, use this one - RaftNodes []string // Raft nodes to make initial connection with - BackendMySQLHost string - BackendMySQLPort int - BackendMySQLSchema string - BackendMySQLUser string - BackendMySQLPassword string - BackendCollation string // if specified, use this collation instead of charset when connecting to MySQL backend - MemcacheServers []string // if given, freno will report to aggregated values to given memcache - MemcachePath string // use as prefix to metric path in memcache key, e.g. if `MemcachePath` is "myprefix" the key would be "myprefix/mysql/maincluster". Default: "freno" - EnableProfiling bool // enable pprof profiling http api - Stores StoresSettings + ListenPort int + DataCenter string + Environment string + Domain string + ShareDomain string + RaftBind string + RaftDataDir string + DefaultRaftPort int // if a RaftNodes entry does not specify port, use this one + RaftNodes []string // Raft nodes to make initial connection with + BackendMySQLHost string + BackendMySQLPort int + BackendMySQLSchema string + BackendMySQLUser string + BackendMySQLPassword string + BackendMySQLCollation string // if specified, use this collation instead of charset when connecting to MySQL backend + MemcacheServers []string // if given, freno will report to aggregated values to given memcache + MemcachePath string // use as prefix to metric path in memcache key, e.g. if `MemcachePath` is "myprefix" the key would be "myprefix/mysql/maincluster". Default: "freno" + EnableProfiling bool // enable pprof profiling http api + Stores StoresSettings } func newConfigurationSettings() *ConfigurationSettings { diff --git a/pkg/group/mysql.go b/pkg/group/mysql.go index 135de6a6..19e62d3f 100644 --- a/pkg/group/mysql.go +++ b/pkg/group/mysql.go @@ -78,9 +78,9 @@ func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error) { return nil, nil } dsnCharsetCollation := "charset=utf8mb4,utf8,latin1" - if config.Settings().BackendCollation != "" { - // Set collation instead of charset, if BackendCollation is specified - dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().BackendCollation) + if config.Settings().BackendMySQLCollation != "" { + // Set collation instead of charset, if BackendMySQLCollation is specified + dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().BackendMySQLCollation) } dbUri := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&%s&timeout=500ms", config.Settings().BackendMySQLUser, From 5899b992346ca61db013bf866c779ed88b38940c Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Mon, 23 Jan 2023 18:20:00 +0000 Subject: [PATCH 08/11] fix test: times out when running in CI rather than returning 'no such host'; both are acceptable responses --- pkg/proxysql/client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/proxysql/client_test.go b/pkg/proxysql/client_test.go index 59d1ff1a..b69bd152 100644 --- a/pkg/proxysql/client_test.go +++ b/pkg/proxysql/client_test.go @@ -51,8 +51,8 @@ func TestProxySQLGetDB(t *testing.T) { if err == nil { t.Fatal("expected error for failed connection") } - if !strings.HasSuffix(err.Error(), "no such host") { - t.Fatalf("expected a 'no such host' error, got %v", err) + if !strings.HasSuffix(err.Error(), "no such host") && !strings.HasSuffix(err.Error(), "i/o timeout") { + t.Fatalf("expected a 'no such host' or 'i/o timeout' error, got %v", err) } }) } From 3e8b4d7127133786bd58bb1e5a3ed57206f739a7 Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:04:30 +0000 Subject: [PATCH 09/11] add tests for probe DB URI --- pkg/mysql/probe_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/mysql/probe_test.go b/pkg/mysql/probe_test.go index d4145b0c..13c35c4f 100644 --- a/pkg/mysql/probe_test.go +++ b/pkg/mysql/probe_test.go @@ -8,6 +8,7 @@ package mysql import ( "testing" + "github.com/github/freno/pkg/config" "github.com/outbrain/golib/log" test "github.com/outbrain/golib/tests" ) @@ -49,3 +50,19 @@ func TestDuplicate(t *testing.T) { test.S(t).ExpectEquals(dup.User, "gromit") test.S(t).ExpectEquals(dup.Password, "penguin") } + +func TestGetDBUri(t *testing.T) { + c := NewProbe() + c.Key = InstanceKey{Hostname: "myhost", Port: 3306} + c.User = "gromit" + c.Password = "penguin" + + // test default (charset) + dbUri := c.GetDBUri("test_database") + test.S(t).ExpectEquals(dbUri, "gromit:penguin@tcp(myhost:3306)/test_database?interpolateParams=true&charset=utf8mb4,utf8,latin1&timeout=1000ms") + + // test setting collation + config.Settings().Stores.MySQL.Collation = "utf8mb4_unicode_ci" + dbUri = c.GetDBUri("test_database") + test.S(t).ExpectEquals(dbUri, "gromit:penguin@tcp(myhost:3306)/test_database?interpolateParams=true&collation=utf8mb4_unicode_ci&timeout=1000ms") +} From f8eb180fa7d89fe8ebad94ee06c98d2bf0946b49 Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:14:12 +0000 Subject: [PATCH 10/11] move backend DB URI to separate function, add test --- pkg/group/mysql.go | 31 ++++++++++++++++++------------- pkg/group/mysql_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 pkg/group/mysql_test.go diff --git a/pkg/group/mysql.go b/pkg/group/mysql.go index 19e62d3f..ff8991fc 100644 --- a/pkg/group/mysql.go +++ b/pkg/group/mysql.go @@ -77,19 +77,7 @@ func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error) { if config.Settings().BackendMySQLHost == "" { return nil, nil } - dsnCharsetCollation := "charset=utf8mb4,utf8,latin1" - if config.Settings().BackendMySQLCollation != "" { - // Set collation instead of charset, if BackendMySQLCollation is specified - dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().BackendMySQLCollation) - } - dbUri := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&%s&timeout=500ms", - config.Settings().BackendMySQLUser, - config.Settings().BackendMySQLPassword, - config.Settings().BackendMySQLHost, - config.Settings().BackendMySQLPort, - config.Settings().BackendMySQLSchema, - dsnCharsetCollation, - ) + dbUri := GetBackendDBUri() db, _, err := sqlutils.GetDB(dbUri) if err != nil { return nil, err @@ -118,6 +106,23 @@ func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error) { return backend, nil } +// helper function to get the DB URI +func GetBackendDBUri() string { + dsnCharsetCollation := "charset=utf8mb4,utf8,latin1" + if config.Settings().BackendMySQLCollation != "" { + // Set collation instead of charset, if BackendMySQLCollation is specified + dsnCharsetCollation = fmt.Sprintf("collation=%s", config.Settings().BackendMySQLCollation) + } + return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=true&%s&timeout=500ms", + config.Settings().BackendMySQLUser, + config.Settings().BackendMySQLPassword, + config.Settings().BackendMySQLHost, + config.Settings().BackendMySQLPort, + config.Settings().BackendMySQLSchema, + dsnCharsetCollation, + ) +} + // Monitor is a utility function to routinely observe leadership state. // It doesn't actually do much; merely takes notes. func (backend *MySQLBackend) continuousOperations() { diff --git a/pkg/group/mysql_test.go b/pkg/group/mysql_test.go new file mode 100644 index 00000000..3ca3765f --- /dev/null +++ b/pkg/group/mysql_test.go @@ -0,0 +1,35 @@ +/* + Copyright 2023 GitHub Inc. + See https://github.com/github/freno/blob/master/LICENSE +*/ + +package group + +import ( + "testing" + + "github.com/github/freno/pkg/config" + "github.com/outbrain/golib/log" + test "github.com/outbrain/golib/tests" +) + +func init() { + log.SetLevel(log.ERROR) +} + +func TestGetBackendDBUri(t *testing.T) { + config.Settings().BackendMySQLUser = "gromit" + config.Settings().BackendMySQLPassword = "penguin" + config.Settings().BackendMySQLHost = "myhost" + config.Settings().BackendMySQLPort = 3306 + config.Settings().BackendMySQLSchema = "test_database" + + // test default (charset) + dbUri := GetBackendDBUri() + test.S(t).ExpectEquals(dbUri, "gromit:penguin@tcp(myhost:3306)/test_database?interpolateParams=true&charset=utf8mb4,utf8,latin1&timeout=500ms") + + // test setting collation + config.Settings().BackendMySQLCollation = "utf8mb4_unicode_ci" + dbUri = GetBackendDBUri() + test.S(t).ExpectEquals(dbUri, "gromit:penguin@tcp(myhost:3306)/test_database?interpolateParams=true&collation=utf8mb4_unicode_ci&timeout=500ms") +} From 14d9dfa1095691372dd606dc51e60e98aa064ae8 Mon Sep 17 00:00:00 2001 From: dm-2 <45519614+dm-2@users.noreply.github.com> Date: Wed, 25 Jan 2023 10:43:14 +0000 Subject: [PATCH 11/11] make getBackendDBUri private --- pkg/group/mysql.go | 4 ++-- pkg/group/mysql_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/group/mysql.go b/pkg/group/mysql.go index ff8991fc..a2fab611 100644 --- a/pkg/group/mysql.go +++ b/pkg/group/mysql.go @@ -77,7 +77,7 @@ func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error) { if config.Settings().BackendMySQLHost == "" { return nil, nil } - dbUri := GetBackendDBUri() + dbUri := getBackendDBUri() db, _, err := sqlutils.GetDB(dbUri) if err != nil { return nil, err @@ -107,7 +107,7 @@ func NewMySQLBackend(throttler *throttle.Throttler) (*MySQLBackend, error) { } // helper function to get the DB URI -func GetBackendDBUri() string { +func getBackendDBUri() string { dsnCharsetCollation := "charset=utf8mb4,utf8,latin1" if config.Settings().BackendMySQLCollation != "" { // Set collation instead of charset, if BackendMySQLCollation is specified diff --git a/pkg/group/mysql_test.go b/pkg/group/mysql_test.go index 3ca3765f..1049b384 100644 --- a/pkg/group/mysql_test.go +++ b/pkg/group/mysql_test.go @@ -25,11 +25,11 @@ func TestGetBackendDBUri(t *testing.T) { config.Settings().BackendMySQLSchema = "test_database" // test default (charset) - dbUri := GetBackendDBUri() + dbUri := getBackendDBUri() test.S(t).ExpectEquals(dbUri, "gromit:penguin@tcp(myhost:3306)/test_database?interpolateParams=true&charset=utf8mb4,utf8,latin1&timeout=500ms") // test setting collation config.Settings().BackendMySQLCollation = "utf8mb4_unicode_ci" - dbUri = GetBackendDBUri() + dbUri = getBackendDBUri() test.S(t).ExpectEquals(dbUri, "gromit:penguin@tcp(myhost:3306)/test_database?interpolateParams=true&collation=utf8mb4_unicode_ci&timeout=500ms") }