mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-23 21:05:00 +00:00
Fix expecting iter.Close()
Adding prof.Stop() ensures iterator gets closed
This commit is contained in:
@@ -89,6 +89,7 @@ func TestRegularIterator(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
prof.Start()
|
prof.Start()
|
||||||
|
defer prof.Stop()
|
||||||
select {
|
select {
|
||||||
case queries := <-prof.QueriesChan():
|
case queries := <-prof.QueriesChan():
|
||||||
if !reflect.DeepEqual(queries, want) {
|
if !reflect.DeepEqual(queries, want) {
|
||||||
@@ -150,6 +151,7 @@ func TestIteratorTimeout(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prof.Start()
|
prof.Start()
|
||||||
|
defer prof.Stop()
|
||||||
gotTimeout := false
|
gotTimeout := false
|
||||||
|
|
||||||
// Get a timeout
|
// Get a timeout
|
||||||
@@ -174,8 +176,6 @@ func TestIteratorTimeout(t *testing.T) {
|
|||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
t.Error("Didn't get any query after 2 seconds")
|
t.Error("Didn't get any query after 2 seconds")
|
||||||
}
|
}
|
||||||
|
|
||||||
prof.Stop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTailIterator(t *testing.T) {
|
func TestTailIterator(t *testing.T) {
|
||||||
@@ -251,6 +251,7 @@ func TestTailIterator(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
prof.Start()
|
prof.Start()
|
||||||
|
defer prof.Stop()
|
||||||
index := 0
|
index := 0
|
||||||
// Since the mocked iterator has a Sleep(1500 ms) between Next methods calls,
|
// Since the mocked iterator has a Sleep(1500 ms) between Next methods calls,
|
||||||
// we are going to have two ticker ticks and on every tick it will return one document.
|
// we are going to have two ticker ticks and on every tick it will return one document.
|
||||||
@@ -300,6 +301,7 @@ func TestCalcStats(t *testing.T) {
|
|||||||
prof := NewProfiler(iter, filters, nil, s)
|
prof := NewProfiler(iter, filters, nil, s)
|
||||||
|
|
||||||
prof.Start()
|
prof.Start()
|
||||||
|
defer prof.Stop()
|
||||||
select {
|
select {
|
||||||
case queries := <-prof.QueriesChan():
|
case queries := <-prof.QueriesChan():
|
||||||
s := queries.CalcQueriesStats(1)
|
s := queries.CalcQueriesStats(1)
|
||||||
@@ -349,6 +351,7 @@ func TestCalcTotalStats(t *testing.T) {
|
|||||||
prof := NewProfiler(iter, filters, nil, s)
|
prof := NewProfiler(iter, filters, nil, s)
|
||||||
|
|
||||||
prof.Start()
|
prof.Start()
|
||||||
|
defer prof.Stop()
|
||||||
select {
|
select {
|
||||||
case queries := <-prof.QueriesChan():
|
case queries := <-prof.QueriesChan():
|
||||||
s := queries.CalcTotalQueriesStats(1)
|
s := queries.CalcTotalQueriesStats(1)
|
||||||
|
Reference in New Issue
Block a user