Don't close DB
This commit is contained in:
parent
43e0c71639
commit
6cecc69520
@ -24,6 +24,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -265,8 +266,8 @@ type MimicConfig struct {
|
|||||||
var _ = Describe("Capturehead", Label("head"), func() {
|
var _ = Describe("Capturehead", Label("head"), func() {
|
||||||
|
|
||||||
Describe("Receiving New Head SSE messages", Label("unit", "behavioral"), func() {
|
Describe("Receiving New Head SSE messages", Label("unit", "behavioral"), func() {
|
||||||
Context("Correctly formatted Phase0 Block", Label("leak-head"), func() {
|
Context("Correctly formatted Phase0 Block", func() {
|
||||||
It("Should turn it into a struct successfully.", func() {
|
It("Should process it successfully.", func() {
|
||||||
BeaconNodeTester.SetupBeaconNodeMock(BeaconNodeTester.TestEvents, BeaconNodeTester.TestConfig.protocol, BeaconNodeTester.TestConfig.address, BeaconNodeTester.TestConfig.port, BeaconNodeTester.TestConfig.dummyParentRoot)
|
BeaconNodeTester.SetupBeaconNodeMock(BeaconNodeTester.TestEvents, BeaconNodeTester.TestConfig.protocol, BeaconNodeTester.TestConfig.address, BeaconNodeTester.TestConfig.port, BeaconNodeTester.TestConfig.dummyParentRoot)
|
||||||
defer httpmock.DeactivateAndReset()
|
defer httpmock.DeactivateAndReset()
|
||||||
bc := setUpTest(BeaconNodeTester.TestConfig, "99")
|
bc := setUpTest(BeaconNodeTester.TestConfig, "99")
|
||||||
@ -277,8 +278,9 @@ var _ = Describe("Capturehead", Label("head"), func() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
Context("Correctly formatted Altair Block", func() {
|
Context("Correctly formatted Altair Block", Label("leak-head"), func() {
|
||||||
It("Should turn it into a struct successfully.", func() {
|
It("Should process it successfully.", func() {
|
||||||
|
log.SetLevel(log.DebugLevel)
|
||||||
BeaconNodeTester.SetupBeaconNodeMock(BeaconNodeTester.TestEvents, BeaconNodeTester.TestConfig.protocol, BeaconNodeTester.TestConfig.address, BeaconNodeTester.TestConfig.port, BeaconNodeTester.TestConfig.dummyParentRoot)
|
BeaconNodeTester.SetupBeaconNodeMock(BeaconNodeTester.TestEvents, BeaconNodeTester.TestConfig.protocol, BeaconNodeTester.TestConfig.address, BeaconNodeTester.TestConfig.port, BeaconNodeTester.TestConfig.dummyParentRoot)
|
||||||
defer httpmock.DeactivateAndReset()
|
defer httpmock.DeactivateAndReset()
|
||||||
|
|
||||||
@ -917,6 +919,7 @@ func (tbc TestBeaconNode) testMultipleReorgs(bc *beaconclient.BeaconClient, firs
|
|||||||
|
|
||||||
// A test to validate a single block was processed correctly
|
// A test to validate a single block was processed correctly
|
||||||
func (tbc TestBeaconNode) testProcessBlock(bc *beaconclient.BeaconClient, head beaconclient.Head, epoch int, maxRetry int, expectedSuccessInsert uint64, expectedKnownGaps uint64, expectedReorgs uint64) {
|
func (tbc TestBeaconNode) testProcessBlock(bc *beaconclient.BeaconClient, head beaconclient.Head, epoch int, maxRetry int, expectedSuccessInsert uint64, expectedKnownGaps uint64, expectedReorgs uint64) {
|
||||||
|
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||||
startGoRoutines := runtime.NumGoroutine()
|
startGoRoutines := runtime.NumGoroutine()
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
go bc.CaptureHead(ctx, 2, true)
|
go bc.CaptureHead(ctx, 2, true)
|
||||||
@ -1030,11 +1033,13 @@ func testSszRoot(msg Message) {
|
|||||||
|
|
||||||
// A make shift function to stop head tracking and insure we dont have any goroutine leaks
|
// A make shift function to stop head tracking and insure we dont have any goroutine leaks
|
||||||
func testStopHeadTracking(ctx context.Context, bc *beaconclient.BeaconClient, startGoRoutines int) {
|
func testStopHeadTracking(ctx context.Context, bc *beaconclient.BeaconClient, startGoRoutines int) {
|
||||||
bc.Db.Close()
|
|
||||||
bc.StopHeadTracking(ctx, true)
|
bc.StopHeadTracking(ctx, true)
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
endNum := runtime.NumGoroutine()
|
endNum := runtime.NumGoroutine()
|
||||||
//pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||||
Expect(startGoRoutines).To(Equal(endNum))
|
log.WithField("startNum", startGoRoutines).Info("Start Go routine number")
|
||||||
|
log.WithField("endNum", endNum).Info("End Go routine number")
|
||||||
|
//Expect(endNum <= startGoRoutines).To(BeTrue())
|
||||||
|
Expect(endNum).To(Equal(startGoRoutines))
|
||||||
}
|
}
|
||||||
|
@ -305,14 +305,13 @@ func testStopHistoricProcessing(ctx context.Context, bc *beaconclient.BeaconClie
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
validateAllRowsCheckedOut(bc.Db, hpCheckCheckedOutStmt)
|
validateAllRowsCheckedOut(bc.Db, hpCheckCheckedOutStmt)
|
||||||
err = bc.Db.Close()
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
endNum := runtime.NumGoroutine()
|
endNum := runtime.NumGoroutine()
|
||||||
|
|
||||||
//pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
//pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||||
Expect(startGoRoutines).To(Equal(endNum))
|
//Expect(endNum <= startGoRoutines).To(BeTrue())
|
||||||
|
Expect(endNum).To(Equal(startGoRoutines))
|
||||||
}
|
}
|
||||||
|
|
||||||
// A make shift function to stop head tracking and insure we dont have any goroutine leaks
|
// A make shift function to stop head tracking and insure we dont have any goroutine leaks
|
||||||
@ -322,12 +321,11 @@ func testStopKnownGapProcessing(ctx context.Context, bc *beaconclient.BeaconClie
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
validateAllRowsCheckedOut(bc.Db, kgCheckCheckedOutStmt)
|
validateAllRowsCheckedOut(bc.Db, kgCheckCheckedOutStmt)
|
||||||
err = bc.Db.Close()
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
endNum := runtime.NumGoroutine()
|
endNum := runtime.NumGoroutine()
|
||||||
|
|
||||||
//pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
//pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||||
Expect(startGoRoutines).To(Equal(endNum))
|
//Expect(endNum <= startGoRoutines).To(BeTrue())
|
||||||
|
Expect(endNum).To(Equal(startGoRoutines))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user