Add goroutine checking to integration test
continuous-integration/drone/pr Build is pending Details
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2021-09-03 12:02:15 -07:00
parent d91d5ffdd3
commit edd130b56f
1 changed files with 16 additions and 0 deletions

View File

@ -18,12 +18,16 @@ import (
"os" "os"
"os/user" "os/user"
"path" "path"
"runtime"
"runtime/pprof"
"testing" "testing"
"time" "time"
) )
func TestFileSharing(t *testing.T) { func TestFileSharing(t *testing.T) {
numGoRoutinesStart := runtime.NumGoroutine()
os.RemoveAll("cwtch.out.png") os.RemoveAll("cwtch.out.png")
os.RemoveAll("cwtch.out.png.manifest") os.RemoveAll("cwtch.out.png.manifest")
@ -96,6 +100,7 @@ func TestFileSharing(t *testing.T) {
t.Fatalf("Error!") t.Fatalf("Error!")
} }
// Wait for the messages to arrive...
time.Sleep(time.Second * 10) time.Sleep(time.Second * 10)
for _, message := range bob.GetContact(alice.GetOnion()).Timeline.GetMessages() { for _, message := range bob.GetContact(alice.GetOnion()).Timeline.GetMessages() {
@ -126,7 +131,18 @@ func TestFileSharing(t *testing.T) {
t.Fatalf("file hash does not match expected %x: ", manifest.RootHash) t.Fatalf("file hash does not match expected %x: ", manifest.RootHash)
} }
queueOracle.Shutdown()
app.Shutdown() app.Shutdown()
acn.Close() acn.Close()
numGoRoutinesPostACN := runtime.NumGoroutine()
// Printing out the current goroutines
// Very useful if we are leaking any.
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
if numGoRoutinesStart != numGoRoutinesPostACN {
t.Errorf("Number of GoRoutines at start (%v) does not match number of goRoutines after cleanup of peers and servers (%v), clean up failed, leak detected!", numGoRoutinesStart, numGoRoutinesPostACN)
}
} }