github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/dnet/DEVELOPING.md (about)

     1  ## Working on dnet
     2  
     3  The `dnet` package contains a bunch of tests that are just running our
     4  types through `nettest.TestConn`.  Unfortunately, in the event of a
     5  failure, `nettest.TestConn` has proven a little tricky to debug.  Here
     6  are my tips:
     7  
     8   - Unfortunately, the most common failure-mode seems to be "the test
     9     hangs" rather than "the test reports a failure".
    10  
    11   - With that in mind, I find it helpful to use `go test -timeout=15s`.
    12  
    13   - When a test times out, it prints a stack trace/thread dump.  One of
    14     my main debugging techniques has been to save that to a file, and
    15     annotate each goroutine with what it is ("klog runtime", "test
    16     main", "conn1.Read"), and so I can reason out which goroutine
    17     hanging is the "root" of the hang.
    18  
    19   - I also find it useful to temporarily add log statements to
    20     golang.org/x/net/nettest for whichever thing I'm debugging.
    21  
    22   - I find it helpful to use `go test
    23     -run=TestKubectlPortForward/Client/BasicIO` (or whichever subtest)
    24     to work on just one subtest at a time.