diff --git a/go/logstats/logger.go b/go/logstats/logger.go index a035532558d..265e23c82e2 100644 --- a/go/logstats/logger.go +++ b/go/logstats/logger.go @@ -66,9 +66,9 @@ func (log *Logger) appendBVarsJSON(b []byte, bvars map[string]*querypb.BindVaria b = append(b, ',', ' ') } b = strconv.AppendQuote(b, bv.Name) - b = append(b, `: {"type": `...) + b = append(b, `: {"Type": `...) b = strconv.AppendQuote(b, querypb.Type_name[int32(bv.BVar.Type)]) - b = append(b, `, "value": `...) + b = append(b, `, "Value": `...) if sqltypes.IsIntegral(bv.BVar.Type) || sqltypes.IsFloat(bv.BVar.Type) { b = append(b, bv.BVar.Value...) @@ -101,9 +101,9 @@ func (log *Logger) appendBVarsJSONV2(b []byte, bvars map[string]*querypb.BindVar b = append(b, ',', ' ') } b = strconv.AppendQuote(b, bv.Name) - b = append(b, `: {"type": `...) + b = append(b, `: {"Type": `...) b = strconv.AppendQuote(b, querypb.Type_name[int32(bv.BVar.Type)]) - b = append(b, `, "value": `...) + b = append(b, `, "Value": `...) if sqltypes.IsIntegral(bv.BVar.Type) || sqltypes.IsFloat(bv.BVar.Type) { b = append(b, bv.BVar.Value...) diff --git a/go/vt/vtgate/logstats_test.go b/go/vt/vtgate/logstats_test.go index 7a30f7f832c..48dd3a689bc 100644 --- a/go/vt/vtgate/logstats_test.go +++ b/go/vt/vtgate/logstats_test.go @@ -78,7 +78,7 @@ func TestLogStatsFormat(t *testing.T) { { // 0 redact: false, format: "text", - expected: "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1\"\t{\"intVal\": {\"type\": \"INT64\", \"value\": 1}}\t0\t0\t\"\"\t\"MASTER\"\t\"suuid\"\tfalse\t\"ks1.tbl1,ks2.tbl2\"\t\"db\"\n", + expected: "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1\"\t{\"intVal\": {\"Type\": \"INT64\", \"Value\": 1}}\t0\t0\t\"\"\t\"MASTER\"\t\"suuid\"\tfalse\t\"ks1.tbl1,ks2.tbl2\"\t\"db\"\n", bindVars: intBindVar, }, { // 1 redact: true, @@ -88,7 +88,7 @@ func TestLogStatsFormat(t *testing.T) { }, { // 2 redact: false, format: "json", - expected: "{\"BindVars\":{\"intVal\":{\"type\":\"INT64\",\"value\":1}},\"CommitTime\":0,\"Effective Caller\":\"\",\"End\":\"2017-01-01 01:02:04.000001\",\"Error\":\"\",\"ExecuteTime\":0,\"ImmediateCaller\":\"\",\"InTransaction\":false,\"Keyspace\":\"db\",\"Method\":\"test\",\"PlanTime\":0,\"RemoteAddr\":\"\",\"RowsAffected\":0,\"SQL\":\"sql1\",\"SessionUUID\":\"suuid\",\"ShardQueries\":0,\"Start\":\"2017-01-01 01:02:03.000000\",\"StmtType\":\"\",\"Table\":\"ks1.tbl1,ks2.tbl2\",\"TabletType\":\"MASTER\",\"TotalTime\":1.000001,\"Username\":\"\"}", + expected: "{\"BindVars\":{\"intVal\":{\"Type\":\"INT64\",\"Value\":1}},\"CommitTime\":0,\"Effective Caller\":\"\",\"End\":\"2017-01-01 01:02:04.000001\",\"Error\":\"\",\"ExecuteTime\":0,\"ImmediateCaller\":\"\",\"InTransaction\":false,\"Keyspace\":\"db\",\"Method\":\"test\",\"PlanTime\":0,\"RemoteAddr\":\"\",\"RowsAffected\":0,\"SQL\":\"sql1\",\"SessionUUID\":\"suuid\",\"ShardQueries\":0,\"Start\":\"2017-01-01 01:02:03.000000\",\"StmtType\":\"\",\"Table\":\"ks1.tbl1,ks2.tbl2\",\"TabletType\":\"MASTER\",\"TotalTime\":1.000001,\"Username\":\"\"}", bindVars: intBindVar, }, { // 3 redact: true, @@ -98,7 +98,7 @@ func TestLogStatsFormat(t *testing.T) { }, { // 4 redact: false, format: "text", - expected: "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1\"\t{\"strVal\": {\"type\": \"VARBINARY\", \"value\": \"abc\"}}\t0\t0\t\"\"\t\"MASTER\"\t\"suuid\"\tfalse\t\"ks1.tbl1,ks2.tbl2\"\t\"db\"\n", + expected: "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1\"\t{\"strVal\": {\"Type\": \"VARBINARY\", \"Value\": \"abc\"}}\t0\t0\t\"\"\t\"MASTER\"\t\"suuid\"\tfalse\t\"ks1.tbl1,ks2.tbl2\"\t\"db\"\n", bindVars: stringBindVar, }, { // 5 redact: true, @@ -108,7 +108,7 @@ func TestLogStatsFormat(t *testing.T) { }, { // 6 redact: false, format: "json", - expected: "{\"BindVars\":{\"strVal\":{\"type\":\"VARBINARY\",\"value\":\"abc\"}},\"CommitTime\":0,\"Effective Caller\":\"\",\"End\":\"2017-01-01 01:02:04.000001\",\"Error\":\"\",\"ExecuteTime\":0,\"ImmediateCaller\":\"\",\"InTransaction\":false,\"Keyspace\":\"db\",\"Method\":\"test\",\"PlanTime\":0,\"RemoteAddr\":\"\",\"RowsAffected\":0,\"SQL\":\"sql1\",\"SessionUUID\":\"suuid\",\"ShardQueries\":0,\"Start\":\"2017-01-01 01:02:03.000000\",\"StmtType\":\"\",\"Table\":\"ks1.tbl1,ks2.tbl2\",\"TabletType\":\"MASTER\",\"TotalTime\":1.000001,\"Username\":\"\"}", + expected: "{\"BindVars\":{\"strVal\":{\"Type\":\"VARBINARY\",\"Value\":\"abc\"}},\"CommitTime\":0,\"Effective Caller\":\"\",\"End\":\"2017-01-01 01:02:04.000001\",\"Error\":\"\",\"ExecuteTime\":0,\"ImmediateCaller\":\"\",\"InTransaction\":false,\"Keyspace\":\"db\",\"Method\":\"test\",\"PlanTime\":0,\"RemoteAddr\":\"\",\"RowsAffected\":0,\"SQL\":\"sql1\",\"SessionUUID\":\"suuid\",\"ShardQueries\":0,\"Start\":\"2017-01-01 01:02:03.000000\",\"StmtType\":\"\",\"Table\":\"ks1.tbl1,ks2.tbl2\",\"TabletType\":\"MASTER\",\"TotalTime\":1.000001,\"Username\":\"\"}", bindVars: stringBindVar, }, { // 7 redact: true, @@ -155,12 +155,12 @@ func TestLogStatsFilter(t *testing.T) { params := map[string][]string{"full": {}} got := testFormat(t, logStats, params) - want := "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"type\": \"INT64\", \"value\": 1}}\t0\t0\t\"\"\t\"\"\t\"\"\tfalse\t\"\"\t\"\"\n" + want := "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"Type\": \"INT64\", \"Value\": 1}}\t0\t0\t\"\"\t\"\"\t\"\"\tfalse\t\"\"\t\"\"\n" assert.Equal(t, want, got) *streamlog.QueryLogFilterTag = "LOG_THIS_QUERY" got = testFormat(t, logStats, params) - want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"type\": \"INT64\", \"value\": 1}}\t0\t0\t\"\"\t\"\"\t\"\"\tfalse\t\"\"\t\"\"\n" + want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"Type\": \"INT64\", \"Value\": 1}}\t0\t0\t\"\"\t\"\"\t\"\"\tfalse\t\"\"\t\"\"\n" assert.Equal(t, want, got) *streamlog.QueryLogFilterTag = "NOT_THIS_QUERY" @@ -178,12 +178,12 @@ func TestLogStatsRowThreshold(t *testing.T) { params := map[string][]string{"full": {}} got := testFormat(t, logStats, params) - want := "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"type\": \"INT64\", \"value\": 1}}\t0\t0\t\"\"\t\"\"\t\"\"\tfalse\t\"\"\t\"\"\n" + want := "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"Type\": \"INT64\", \"Value\": 1}}\t0\t0\t\"\"\t\"\"\t\"\"\tfalse\t\"\"\t\"\"\n" assert.Equal(t, want, got) *streamlog.QueryLogRowThreshold = 0 got = testFormat(t, logStats, params) - want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"type\": \"INT64\", \"value\": 1}}\t0\t0\t\"\"\t\"\"\t\"\"\tfalse\t\"\"\t\"\"\n" + want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t0.000000\t0.000000\t0.000000\t\t\"sql1 /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"Type\": \"INT64\", \"Value\": 1}}\t0\t0\t\"\"\t\"\"\t\"\"\tfalse\t\"\"\t\"\"\n" assert.Equal(t, want, got) *streamlog.QueryLogRowThreshold = 1 got = testFormat(t, logStats, params) @@ -257,9 +257,9 @@ func TestLogStatsFormatJSONV2(t *testing.T) { bindVar *querypb.BindVariable expected string }{ - { - &querypb.BindVariable{Type: querypb.Type_BINARY, Value: []byte("abc")}, - "YWJj", + { // {"Type": "BINARY", "Value": "\x16k@\xb4J\xbaK\xd6"} breaks JSON, so we base64 endcode the value + &querypb.BindVariable{Type: querypb.Type_BINARY, Value: []byte("\x16k@\xb4J\xbaK\xd6")}, + "FmtAtEq6S9Y=", }, { &querypb.BindVariable{Type: querypb.Type_BIT, Value: []byte("134")}, "MTM0", @@ -305,8 +305,9 @@ func TestLogStatsFormatJSONV2(t *testing.T) { err := json.Unmarshal([]byte(got), &parsed) assert.NoError(t, err) assert.NotNil(t, parsed) - bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["value"] - + bindType := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Type"].(string) + bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Value"] + assert.Equal(t, test.bindVar.Type.String(), bindType) assert.Equal(t, test.expected, bindVal) }) } @@ -363,8 +364,9 @@ func TestLogStatsFormatJSONV2(t *testing.T) { err := json.Unmarshal([]byte(got), &parsed) assert.NoError(t, err) assert.NotNil(t, parsed) - bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["value"] - + bindType := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Type"].(string) + bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Value"] + assert.Equal(t, test.bindVar.Type.String(), bindType) assert.Equal(t, test.expected, bindVal) }) } @@ -415,8 +417,9 @@ func TestLogStatsFormatJSONV2(t *testing.T) { err := json.Unmarshal([]byte(got), &parsed) assert.NoError(t, err) assert.NotNil(t, parsed) - bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["value"] - + bindType := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Type"].(string) + bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Value"] + assert.Equal(t, test.bindVar.Type.String(), bindType) assert.Equal(t, test.expected, bindVal) }) } diff --git a/go/vt/vttablet/tabletserver/tabletenv/logstats_test.go b/go/vt/vttablet/tabletserver/tabletenv/logstats_test.go index 6ae7783806f..9b94fdc41e9 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/logstats_test.go +++ b/go/vt/vttablet/tabletserver/tabletenv/logstats_test.go @@ -76,7 +76,7 @@ func TestLogStatsFormat(t *testing.T) { *streamlog.RedactDebugUIQueries = false *streamlog.QueryLogFormat = "text" got := testFormat(logStats, url.Values(params)) - want := "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql\"\t{\"intVal\": {\"type\": \"INT64\", \"value\": 1}}\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t12345\t1\t\"\"\t\n" + want := "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql\"\t{\"intVal\": {\"Type\": \"INT64\", \"Value\": 1}}\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t12345\t1\t\"\"\t\n" if got != want { t.Errorf("logstats format: got:\n%q\nwant:\n%q\n", got, want) } @@ -101,7 +101,7 @@ func TestLogStatsFormat(t *testing.T) { if err != nil { t.Errorf("logstats format: error marshaling json: %v -- got:\n%v", err, got) } - want = "{\n \"BindVars\": {\n \"intVal\": {\n \"type\": \"INT64\",\n \"value\": 1\n }\n },\n \"CallInfo\": \"\",\n \"ConnWaitTime\": 0,\n \"Effective Caller\": \"\",\n \"End\": \"2017-01-01 01:02:04.000001\",\n \"Error\": \"\",\n \"ImmediateCaller\": \"\",\n \"Method\": \"test\",\n \"MysqlTime\": 0,\n \"OriginalSQL\": \"sql\",\n \"PlanType\": \"\",\n \"Queries\": 1,\n \"QuerySources\": \"mysql\",\n \"ResponseSize\": 1,\n \"RewrittenSQL\": \"sql with pii\",\n \"RowsAffected\": 0,\n \"Start\": \"2017-01-01 01:02:03.000000\",\n \"TotalTime\": 1.000001,\n \"TransactionID\": 12345,\n \"Username\": \"\"\n}" + want = "{\n \"BindVars\": {\n \"intVal\": {\n \"Type\": \"INT64\",\n \"Value\": 1\n }\n },\n \"CallInfo\": \"\",\n \"ConnWaitTime\": 0,\n \"Effective Caller\": \"\",\n \"End\": \"2017-01-01 01:02:04.000001\",\n \"Error\": \"\",\n \"ImmediateCaller\": \"\",\n \"Method\": \"test\",\n \"MysqlTime\": 0,\n \"OriginalSQL\": \"sql\",\n \"PlanType\": \"\",\n \"Queries\": 1,\n \"QuerySources\": \"mysql\",\n \"ResponseSize\": 1,\n \"RewrittenSQL\": \"sql with pii\",\n \"RowsAffected\": 0,\n \"Start\": \"2017-01-01 01:02:03.000000\",\n \"TotalTime\": 1.000001,\n \"TransactionID\": 12345,\n \"Username\": \"\"\n}" if string(formatted) != want { t.Errorf("logstats format: got:\n%q\nwant:\n%v\n", string(formatted), want) } @@ -130,7 +130,7 @@ func TestLogStatsFormat(t *testing.T) { *streamlog.QueryLogFormat = "text" got = testFormat(logStats, url.Values(params)) - want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql\"\t{\"strVal\": {\"type\": \"VARBINARY\", \"value\": \"abc\"}}\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t12345\t1\t\"\"\t\n" + want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql\"\t{\"strVal\": {\"Type\": \"VARBINARY\", \"Value\": \"abc\"}}\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t12345\t1\t\"\"\t\n" if got != want { t.Errorf("logstats format: got:\n%q\nwant:\n%q\n", got, want) } @@ -145,7 +145,7 @@ func TestLogStatsFormat(t *testing.T) { if err != nil { t.Errorf("logstats format: error marshaling json: %v -- got:\n%v", err, got) } - want = "{\n \"BindVars\": {\n \"strVal\": {\n \"type\": \"VARBINARY\",\n \"value\": \"abc\"\n }\n },\n \"CallInfo\": \"\",\n \"ConnWaitTime\": 0,\n \"Effective Caller\": \"\",\n \"End\": \"2017-01-01 01:02:04.000001\",\n \"Error\": \"\",\n \"ImmediateCaller\": \"\",\n \"Method\": \"test\",\n \"MysqlTime\": 0,\n \"OriginalSQL\": \"sql\",\n \"PlanType\": \"\",\n \"Queries\": 1,\n \"QuerySources\": \"mysql\",\n \"ResponseSize\": 1,\n \"RewrittenSQL\": \"sql with pii\",\n \"RowsAffected\": 0,\n \"Start\": \"2017-01-01 01:02:03.000000\",\n \"TotalTime\": 1.000001,\n \"TransactionID\": 12345,\n \"Username\": \"\"\n}" + want = "{\n \"BindVars\": {\n \"strVal\": {\n \"Type\": \"VARBINARY\",\n \"Value\": \"abc\"\n }\n },\n \"CallInfo\": \"\",\n \"ConnWaitTime\": 0,\n \"Effective Caller\": \"\",\n \"End\": \"2017-01-01 01:02:04.000001\",\n \"Error\": \"\",\n \"ImmediateCaller\": \"\",\n \"Method\": \"test\",\n \"MysqlTime\": 0,\n \"OriginalSQL\": \"sql\",\n \"PlanType\": \"\",\n \"Queries\": 1,\n \"QuerySources\": \"mysql\",\n \"ResponseSize\": 1,\n \"RewrittenSQL\": \"sql with pii\",\n \"RowsAffected\": 0,\n \"Start\": \"2017-01-01 01:02:03.000000\",\n \"TotalTime\": 1.000001,\n \"TransactionID\": 12345,\n \"Username\": \"\"\n}" if string(formatted) != want { t.Errorf("logstats format: got:\n%q\nwant:\n%v\n", string(formatted), want) } @@ -167,14 +167,14 @@ func TestLogStatsFilter(t *testing.T) { params := map[string][]string{"full": {}} got := testFormat(logStats, url.Values(params)) - want := "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"type\": \"INT64\", \"value\": 1}}\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t0\t1\t\"\"\t\n" + want := "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"Type\": \"INT64\", \"Value\": 1}}\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t0\t1\t\"\"\t\n" if got != want { t.Errorf("logstats format: got:\n%q\nwant:\n%q\n", got, want) } *streamlog.QueryLogFilterTag = "LOG_THIS_QUERY" got = testFormat(logStats, url.Values(params)) - want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"type\": \"INT64\", \"value\": 1}}\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t0\t1\t\"\"\t\n" + want = "test\t\t\t''\t''\t2017-01-01 01:02:03.000000\t2017-01-01 01:02:04.000001\t1.000001\t\t\"sql /* LOG_THIS_QUERY */\"\t{\"intVal\": {\"Type\": \"INT64\", \"Value\": 1}}\t1\t\"sql with pii\"\tmysql\t0.000000\t0.000000\t0\t0\t1\t\"\"\t\n" if got != want { t.Errorf("logstats format: got:\n%q\nwant:\n%q\n", got, want) } @@ -274,9 +274,9 @@ func TestLogStatsFormatJSONV2(t *testing.T) { bindVar *querypb.BindVariable expected string }{ - { - &querypb.BindVariable{Type: querypb.Type_BINARY, Value: []byte("abc")}, - "YWJj", + { // {"Type": "BINARY", "Value": "\x16k@\xb4J\xbaK\xd6"} breaks JSON, so we base64 endcode the value + &querypb.BindVariable{Type: querypb.Type_BINARY, Value: []byte("\x16k@\xb4J\xbaK\xd6")}, + "FmtAtEq6S9Y=", }, { &querypb.BindVariable{Type: querypb.Type_BIT, Value: []byte("134")}, "MTM0", @@ -316,14 +316,15 @@ func TestLogStatsFormatJSONV2(t *testing.T) { for i, test := range testsEncoded { t.Run(strconv.Itoa(i), func(t *testing.T) { logStats.BindVariables["vtg"] = test.bindVar - got := testFormat(logStats, url.Values(params)) + got := testFormat(logStats, params) t.Logf("got: %s", got) var parsed map[string]interface{} err := json.Unmarshal([]byte(got), &parsed) assert.NoError(t, err) assert.NotNil(t, parsed) - bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["value"] - + bindType := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Type"].(string) + bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Value"] + assert.Equal(t, test.bindVar.Type.String(), bindType) assert.Equal(t, test.expected, bindVal) }) } @@ -374,14 +375,15 @@ func TestLogStatsFormatJSONV2(t *testing.T) { for i, test := range testsUnchanged { t.Run(strconv.Itoa(i), func(t *testing.T) { logStats.BindVariables["vtg"] = test.bindVar - got := testFormat(logStats, url.Values(params)) + got := testFormat(logStats, params) t.Logf("got: %s", got) var parsed map[string]interface{} err := json.Unmarshal([]byte(got), &parsed) assert.NoError(t, err) assert.NotNil(t, parsed) - bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["value"] - + bindType := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Type"].(string) + bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Value"] + assert.Equal(t, test.bindVar.Type.String(), bindType) assert.Equal(t, test.expected, bindVal) }) } @@ -426,14 +428,15 @@ func TestLogStatsFormatJSONV2(t *testing.T) { for i, test := range testsUnchangedTuples { t.Run(strconv.Itoa(i), func(t *testing.T) { logStats.BindVariables["vtg"] = test.bindVar - got := testFormat(logStats, url.Values(params)) + got := testFormat(logStats, params) t.Logf("got: %s", got) var parsed map[string]interface{} err := json.Unmarshal([]byte(got), &parsed) assert.NoError(t, err) assert.NotNil(t, parsed) - bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["value"] - + bindType := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Type"].(string) + bindVal := parsed["BindVars"].(map[string]interface{})["vtg"].(map[string]interface{})["Value"] + assert.Equal(t, test.bindVar.Type.String(), bindType) assert.Equal(t, test.expected, bindVal) }) }