Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Mar 4, 2020
1 parent 7117000 commit f174a55
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ func expectDeleteQueries(t *testing.T) {
}

func expectLogsAndUnsubscribe(t *testing.T, logs []LogExpectation, logCh chan interface{}) {
defer vrLogStatsLogger.Unsubscribe(logCh)
t.Helper()
defer vrLogStatsLogger.Unsubscribe(logCh)
failed := false
for i, log := range logs {
if failed {
Expand Down
12 changes: 6 additions & 6 deletions go/vt/vttablet/tabletmanager/vreplication/http_stream_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@ import (
"net/http"
)

//HTTPStreamWriterMock implements http.ResponseWriter and adds a channel to sync writes and reads
// HTTPStreamWriterMock implements http.ResponseWriter and adds a channel to sync writes and reads
type HTTPStreamWriterMock struct {
ch chan interface{}
data []byte
}

//NewHTTPStreamWriterMock returns a new HTTPStreamWriterMock
// NewHTTPStreamWriterMock returns a new HTTPStreamWriterMock
func NewHTTPStreamWriterMock() *HTTPStreamWriterMock {
return &HTTPStreamWriterMock{ch: make(chan interface{}, 1), data: make([]byte, 0)}
}

//Header is a stub
// Header is a stub
func (w *HTTPStreamWriterMock) Header() http.Header {
return nil
}

//WriteHeader is a stub
// WriteHeader is a stub
func (w *HTTPStreamWriterMock) WriteHeader(statuscode int) {
}

//Write buffers sent data
// Write buffers sent data
func (w *HTTPStreamWriterMock) Write(data []byte) (int, error) {
w.data = append(w.data, data...)
return 0, nil
}

//Flush sends buffered data to the channel
// Flush sends buffered data to the channel
func (w *HTTPStreamWriterMock) Flush() {
w.ch <- w.data
w.data = w.data[:0]
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletmanager/vreplication/vplayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestPlayerFilters(t *testing.T) {
output []string
table string
data [][]string
logs []LogExpectation //logs defined only for a few testcases since they are enough to test all log events
logs []LogExpectation // logs are defined for a few testcases since they are enough to test all log events
}{{
// insert with insertNormal
input: "insert into src1 values(1, 'aaa')",
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletmanager/vreplication/vrlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (
Parse("{{.Type}} Event {{.Detail}} {{.LogTime}} {{.DurationNs}}\n"))
)

//VrLogStats collects attributes of a vreplication event for logging
// VrLogStats collects attributes of a vreplication event for logging
type VrLogStats struct {
Type string
Detail string
Expand All @@ -45,12 +45,12 @@ type VrLogStats struct {
DurationNs int64
}

//NewVrLogStats should be called at the start of the event to be logged
// NewVrLogStats should be called at the start of the event to be logged
func NewVrLogStats(eventType string) *VrLogStats {
return &VrLogStats{Type: eventType, StartTime: time.Now()}
}

//Send records the log event, should be called on a stats object constructed by NewVrLogStats()
// Send records the log event, should be called on a stats object constructed by NewVrLogStats()
func (stats *VrLogStats) Send(detail string) {
if stats.StartTime.IsZero() {
stats.Type = "Error: Type not specified"
Expand Down
2 changes: 0 additions & 2 deletions go/vt/vttablet/tabletmanager/vreplication/vrlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (

func TestVrLog(t *testing.T) {
r, _ := http.NewRequest("GET", "/debug/vrlog?timeout=100&limit=10", nil)
//w := httptest.NewRecorder()

w := NewHTTPStreamWriterMock()

ch := vrLogStatsLogger.Subscribe("vrlogstats")
Expand Down

0 comments on commit f174a55

Please sign in to comment.