Skip to content

Commit

Permalink
Merge branch 'master' into jacques_ubi
Browse files Browse the repository at this point in the history
Signed-off-by: Jacques Grove <[email protected]>
  • Loading branch information
aquarapid committed Apr 24, 2020
2 parents 8542b2d + 228e6fe commit ea1ad68
Show file tree
Hide file tree
Showing 29 changed files with 795 additions and 693 deletions.
12 changes: 6 additions & 6 deletions config/tablet/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@ db:
user: vt_app # db_app_user
password: # db_app_password
useSsl: true # db_app_use_ssl
preferSocket: true
preferTcp: false
dba:
user: vt_dba # db_dba_user
password: # db_dba_password
useSsl: true # db_dba_use_ssl
preferSocket: true
preferTcp: false
filtered:
user: vt_filtered # db_filtered_user
password: # db_filtered_password
useSsl: true # db_filtered_use_ssl
preferSocket: true
preferTcp: false
repl:
user: vt_repl # db_repl_user
password: # db_repl_password
useSsl: true # db_repl_use_ssl
preferSocket: true
preferTcp: false
appdebug:
user: vt_appdebug # db_appdebug_user
password: # db_appdebug_password
useSsl: true # db_appdebug_use_ssl
preferSocket: true
preferTcp: false
allprivs:
user: vt_allprivs # db_allprivs_user
password: # db_allprivs_password
useSsl: true # db_allprivs_use_ssl
preferSocket: true
preferTcp: false

oltpReadPool:
size: 16 # queryserver-config-pool-size
Expand Down
5 changes: 1 addition & 4 deletions go/cmd/vtcombo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ func main() {
servenv.Init()
tabletenv.Init()

dbcfgs, err := dbconfigs.Init("")
if err != nil {
log.Warning(err)
}
dbcfgs := dbconfigs.GlobalDBConfigs.Init("")
mysqld := mysqlctl.NewMysqld(dbcfgs)
servenv.OnClose(mysqld.Close)

Expand Down
19 changes: 8 additions & 11 deletions go/cmd/vttablet/vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"io/ioutil"

"golang.org/x/net/context"
"sigs.k8s.io/yaml"
"vitess.io/vitess/go/vt/dbconfigs"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/mysqlctl"
Expand All @@ -34,6 +33,7 @@ import (
"vitess.io/vitess/go/vt/vttablet/tabletmanager"
"vitess.io/vitess/go/vt/vttablet/tabletserver"
"vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv"
"vitess.io/vitess/go/yaml2"
)

var (
Expand Down Expand Up @@ -67,12 +67,12 @@ func main() {
if err != nil {
log.Exitf("error reading config file %s: %v", *tabletConfig, err)
}
if err := yaml.Unmarshal(bytes, config); err != nil {
if err := yaml2.Unmarshal(bytes, config); err != nil {
log.Exitf("error parsing config file %s: %v", bytes, err)
}
gotBytes, _ := yaml.Marshal(config)
log.Infof("Loaded config file %s successfully:\n%s", *tabletConfig, gotBytes)
}
gotBytes, _ := yaml2.Marshal(config)
log.Infof("Loaded config file %s successfully:\n%s", *tabletConfig, gotBytes)

servenv.Init()

Expand All @@ -90,7 +90,7 @@ func main() {
// and use the socket from it. If connection parameters were specified,
// we assume that the mysql is not local, and we skip loading mycnf.
// This also means that backup and restore will not be allowed.
if !dbconfigs.HasConnectionParams() {
if !config.DB.HasGlobalSettings() {
var err error
if mycnf, err = mysqlctl.NewMycnfFromFlags(tabletAlias.Uid); err != nil {
log.Exitf("mycnf read failed: %v", err)
Expand All @@ -103,10 +103,7 @@ func main() {
// If connection parameters were specified, socketFile will be empty.
// Otherwise, the socketFile (read from mycnf) will be used to initialize
// dbconfigs.
dbcfgs, err := dbconfigs.Init(socketFile)
if err != nil {
log.Warning(err)
}
config.DB = config.DB.Init(socketFile)

if *tableACLConfig != "" {
// To override default simpleacl, other ACL plugins must set themselves to be default ACL factory
Expand All @@ -133,15 +130,15 @@ func main() {
// Create mysqld and register the health reporter (needs to be done
// before initializing the agent, so the initial health check
// done by the agent has the right reporter)
mysqld := mysqlctl.NewMysqld(dbcfgs)
mysqld := mysqlctl.NewMysqld(config.DB)
servenv.OnClose(mysqld.Close)

// Depends on both query and updateStream.
gRPCPort := int32(0)
if servenv.GRPCPort != nil {
gRPCPort = int32(*servenv.GRPCPort)
}
agent, err = tabletmanager.NewActionAgent(context.Background(), ts, mysqld, qsc, tabletAlias, dbcfgs, mycnf, int32(*servenv.Port), gRPCPort)
agent, err = tabletmanager.NewActionAgent(context.Background(), ts, mysqld, qsc, tabletAlias, config.DB, mycnf, int32(*servenv.Port), gRPCPort)
if err != nil {
log.Exitf("NewActionAgent() failed: %v", err)
}
Expand Down
89 changes: 89 additions & 0 deletions go/jsonutil/json_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package jsonutil

import (
"testing"
)

func TestMarshalNoEscape(t *testing.T) {
cases := []struct {
name string
v interface{}
expected string
}{
{
name: "normal",
v: struct {
Usr string
Pwd string
}{
Usr: "vitess",
Pwd: "vitess",
},
expected: "{\"Usr\":\"vitess\",\"Pwd\":\"vitess\"}",
},
{
name: "not exported",
v: struct {
usr string
pwd string
}{
usr: "vitess",
pwd: "vitess",
},
expected: "{}",
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
json, _ := MarshalNoEscape(c.v)
sjson := string(json[:len(json)-1])
if sjson != c.expected {
t.Errorf("expected: %v, got: %v", c.expected, sjson)
}
})
}
}

func TestMarshalIndentNoEscape(t *testing.T) {
cases := []struct {
name string
v interface{}
prefix string
ident string
expected string
}{
{
name: "normal",
v: struct {
Usr string
Pwd string
}{
Usr: "vitess",
Pwd: "vitess",
},
prefix: "test",
ident: "\t",
expected: "{\ntest\t\"Usr\": \"vitess\",\ntest\t\"Pwd\": \"vitess\"\ntest}",
},
{
name: "not exported",
v: struct {
usr string
pwd string
}{
usr: "vitess",
pwd: "vitess",
},
expected: "{}",
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
json, _ := MarshalIndentNoEscape(c.v, c.prefix, c.ident)
sjson := string(json[:len(json)-1])
if sjson != c.expected {
t.Errorf("expected: %v, got: %v", c.expected, sjson)
}
})
}
}
Loading

0 comments on commit ea1ad68

Please sign in to comment.