Skip to content

Commit

Permalink
refactor: use random port listener in kernel log delivery tests
Browse files Browse the repository at this point in the history
No functional changes, just better tests.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Nov 29, 2021
1 parent bf4c81e commit eaf6d47
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ require (
github.com/talos-systems/go-smbios v0.1.1-0.20211122130416-fd5ec8ce4873
github.com/talos-systems/grpc-proxy v0.2.0
github.com/talos-systems/net v0.3.1-0.20211112122313-0abe5bdae8f8
github.com/talos-systems/siderolink v0.0.0-20211125204118-d86cdd59ee7a
github.com/talos-systems/siderolink v0.1.0
github.com/talos-systems/talos/pkg/machinery v0.14.0-alpha.1.0.20211118180932-1ffa8e048008
github.com/u-root/u-root v7.0.0+incompatible
github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,8 @@ github.com/talos-systems/grpc-proxy v0.2.0 h1:DN75bLfaW4xfhq0r0mwFRnfGhSB+HPhK1L
github.com/talos-systems/grpc-proxy v0.2.0/go.mod h1:sm97Vc/z2cok3pu6ruNeszQej4KDxFrDgfWs4C1mtC4=
github.com/talos-systems/net v0.3.1-0.20211112122313-0abe5bdae8f8 h1:oT2MASZ8V3DuZbhaJWJ8oZ373zfmgXpvw2xLHM5cOYk=
github.com/talos-systems/net v0.3.1-0.20211112122313-0abe5bdae8f8/go.mod h1:zhcGixNJz9dgwFiUwc7gkkAqdVqXagU1SNNoIVXYKGo=
github.com/talos-systems/siderolink v0.0.0-20211125204118-d86cdd59ee7a h1:IFPuVRfl3/Mf+eh3Hqsro1Wsb2Ng31jnNlWRm7OeC9U=
github.com/talos-systems/siderolink v0.0.0-20211125204118-d86cdd59ee7a/go.mod h1:bEGwDYl9QgC3oZ4kdnJTuR2HX/XlUhxZjx/QAakKuBc=
github.com/talos-systems/siderolink v0.1.0 h1:7mkJ9EicQ8J9DHHkwiNYGoccCgFcEIFcmfcKRyI7Y+8=
github.com/talos-systems/siderolink v0.1.0/go.mod h1:bEGwDYl9QgC3oZ4kdnJTuR2HX/XlUhxZjx/QAakKuBc=
github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"fmt"
"log"
"net"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -81,14 +82,17 @@ func (suite *KmsgLogDeliverySuite) SetupTest() {

suite.handler = &logHandler{}

suite.srv, err = logreceiver.NewServer(logger, "localhost:4001", suite.handler.HandleLog)
listener, err := net.Listen("tcp", "localhost:0")
suite.Require().NoError(err)

suite.srv, err = logreceiver.NewServer(logger, listener, suite.handler.HandleLog)
suite.Require().NoError(err)

go func() {
suite.srv.Serve() //nolint:errcheck
}()

suite.cmdline = procfs.NewCmdline(fmt.Sprintf("%s=%s", constants.KernelParamLoggingKernel, "tcp://localhost:4001"))
suite.cmdline = procfs.NewCmdline(fmt.Sprintf("%s=%s", constants.KernelParamLoggingKernel, fmt.Sprintf("tcp://%s", listener.Addr())))
suite.drainer = talosruntime.NewDrainer()

suite.Require().NoError(suite.runtime.RegisterController(&controllerruntime.KmsgLogDeliveryController{
Expand Down

0 comments on commit eaf6d47

Please sign in to comment.