Skip to content

Commit

Permalink
Merge pull request #964 from filecoin-project/955-ci-test-logging
Browse files Browse the repository at this point in the history
Connect logging when running tests with the tests
  • Loading branch information
wjam authored Oct 27, 2022
2 parents f3a1830 + 3ab9192 commit ea3595c
Show file tree
Hide file tree
Showing 53 changed files with 153 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
export GOBIN=${HOME}/bin
export PATH=$GOBIN:$PATH
go install gotest.tools/gotestsum@latest
make test-and-report
LOG_LEVEL=debug make test-and-report
no_output_timeout: 20m

- when:
Expand Down
2 changes: 2 additions & 0 deletions cmd/bacalhau/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"
"time"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/publicapi"
"github.com/filecoin-project/bacalhau/pkg/system"
"github.com/spf13/cobra"
Expand All @@ -35,6 +36,7 @@ func (s *CreateSuite) SetupSuite() {

// before each test
func (s *CreateSuite) SetupTest() {
logger.ConfigureTestLogging(s.T())
require.NoError(s.T(), system.InitConfigForTesting())
s.rootCmd = RootCmd
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/bacalhau/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/filecoin-project/bacalhau/pkg/bacerrors"
"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/filecoin-project/bacalhau/pkg/publicapi"
"github.com/filecoin-project/bacalhau/pkg/system"
Expand All @@ -34,6 +35,7 @@ func (suite *DescribeSuite) SetupAllSuite() {

// Before each test
func (suite *DescribeSuite) SetupTest() {
logger.ConfigureTestLogging(suite.T())
require.NoError(suite.T(), system.InitConfigForTesting())
suite.rootCmd = RootCmd
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/bacalhau/docker_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"strconv"

"github.com/filecoin-project/bacalhau/pkg/devstack"
"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/google/uuid"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -57,6 +58,7 @@ func (s *DockerRunSuite) SetupSuite() {

// Before each test
func (s *DockerRunSuite) SetupTest() {
logger.ConfigureTestLogging(s.T())
require.NoError(s.T(), system.InitConfigForTesting())
s.rootCmd = RootCmd
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/bacalhau/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"testing"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/publicapi"
"github.com/filecoin-project/bacalhau/pkg/storage/util"
"github.com/filecoin-project/bacalhau/pkg/system"
Expand Down Expand Up @@ -40,6 +41,7 @@ func (suite *GetSuite) SetupAllSuite() {

// Before each test
func (suite *GetSuite) SetupTest() {
logger.ConfigureTestLogging(suite.T())
require.NoError(suite.T(), system.InitConfigForTesting())
suite.rootCmd = RootCmd
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/bacalhau/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"testing"
"time"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/filecoin-project/bacalhau/pkg/publicapi"
"github.com/filecoin-project/bacalhau/pkg/system"
Expand Down Expand Up @@ -42,6 +43,7 @@ func (suite *ListSuite) SetupAllSuite() {
// Before each test
func (suite *ListSuite) SetupTest() {
suite.rootCmd = RootCmd
logger.ConfigureTestLogging(suite.T())
}

func (suite *ListSuite) TearDownTest() {
Expand Down
2 changes: 2 additions & 0 deletions cmd/bacalhau/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
"time"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/system"
"github.com/filecoin-project/bacalhau/pkg/types"
"github.com/phayes/freeport"
Expand Down Expand Up @@ -39,6 +40,7 @@ func (suite *ServeSuite) SetupSuite() {

// Before each test
func (suite *ServeSuite) SetupTest() {
logger.ConfigureTestLogging(suite.T())
require.NoError(suite.T(), system.InitConfigForTesting())
suite.rootCmd = RootCmd
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/bacalhau/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/filecoin-project/bacalhau/pkg/job"
"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/filecoin-project/bacalhau/pkg/system"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -32,6 +33,7 @@ func (s *UtilsSuite) SetupAllSuite() {
// Before each test
func (s *UtilsSuite) SetupTest() {
s.rootCmd = RootCmd
logger.ConfigureTestLogging(s.T())
}

func (s *UtilsSuite) TearDownTest() {
Expand Down
2 changes: 2 additions & 0 deletions cmd/bacalhau/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"testing"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/publicapi"
"github.com/filecoin-project/bacalhau/pkg/system"
testutils "github.com/filecoin-project/bacalhau/pkg/test/utils"
Expand All @@ -30,6 +31,7 @@ func (s *ValidateSuite) SetupSuite() {

// before each test
func (s *ValidateSuite) SetupTest() {
logger.ConfigureTestLogging(s.T())
require.NoError(s.T(), system.InitConfigForTesting())
s.rootCmd = RootCmd
}
Expand Down
8 changes: 2 additions & 6 deletions cmd/bacalhau/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"net/url"
"testing"

"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/publicapi"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
Expand All @@ -46,6 +46,7 @@ func (suite *VersionSuite) SetupAllSuite() {
// Before each test
func (suite *VersionSuite) SetupTest() {
suite.rootCmd = RootCmd
logger.ConfigureTestLogging(suite.T())
}

func (suite *VersionSuite) TearDownTest() {
Expand All @@ -71,11 +72,6 @@ func (suite *VersionSuite) Test_Version() {
require.Contains(suite.T(), string(out), "Server Version", "Server version not in output")
}

type ThisVersions struct {
ClientVersion model.BuildVersionInfo `json:"clientVersion,omitempty"`
ServerVersion model.BuildVersionInfo `json:"serverVersion,omitempty"`
}

func (suite *VersionSuite) Test_VersionOutputs() {
c, cm := publicapi.SetupRequesterNodeForTests(suite.T())
defer cm.Cleanup()
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/kubectl v0.24.3
mvdan.cc/sh/v3 v3.5.1
)

require (
Expand Down Expand Up @@ -76,12 +75,14 @@ require (
)

require (
github.com/creack/pty v1.1.17 // indirect
github.com/filecoin-project/go-amt-ipld/v4 v4.0.0 // indirect
github.com/filecoin-project/go-bitfield v0.2.4 // indirect
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
go.opencensus.io v0.23.0 // indirect
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0=
github.com/cskr/pubsub v1.0.2/go.mod h1:/8MzYXk/NJAz782G8RPkFzXTZVu63VotefPnR9TIRis=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -1571,6 +1572,7 @@ github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rK
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -1649,6 +1651,7 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
Expand Down Expand Up @@ -2586,8 +2589,6 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I=
mvdan.cc/sh/v3 v3.5.1 h1:hmP3UOw4f+EYexsJjFxvU38+kn+V/s2CclXHanIBkmQ=
mvdan.cc/sh/v3 v3.5.1/go.mod h1:1JcoyAKm1lZw/2bZje/iYKWicU/KMd0rsyJeKHnsK4E=
pgregory.net/rapid v0.4.7 h1:MTNRktPuv5FNqOO151TM9mDTa+XHcX6ypYeISDVD14g=
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
2 changes: 2 additions & 0 deletions pkg/capacitymanager/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/c2h5oh/datasize"
"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/pbnjay/memory"
"github.com/stretchr/testify/require"
Expand All @@ -32,6 +33,7 @@ func (suite *ResourceUsageUtilsSuite) SetupAllSuite() {

// Before each test
func (suite *ResourceUsageUtilsSuite) SetupTest() {
logger.ConfigureTestLogging(suite.T())
}

func (suite *ResourceUsageUtilsSuite) TearDownTest() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/eventhandler/chained_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"testing"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/google/uuid"

"github.com/filecoin-project/bacalhau/pkg/eventhandler/mock_eventhandler"
Expand Down Expand Up @@ -49,6 +50,7 @@ func (suite *jobEventHandlerSuite) SetupTest() {
ClientID: "clientX",
Status: "this is a test event",
}
logger.ConfigureTestLogging(suite.T())
}

func (suite *jobEventHandlerSuite) TearDownTest() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/ipfs/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"testing"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/filecoin-project/bacalhau/pkg/system"
"github.com/stretchr/testify/require"
Expand All @@ -33,6 +34,7 @@ type DownloaderSuite struct {
// Before each test
func (ds *DownloaderSuite) SetupTest() {
ds.cm = *system.NewCleanupManager()
logger.ConfigureTestLogging(ds.T())
require.NoError(ds.T(), system.InitConfigForTesting())

node, err := NewLocalNode(context.Background(), &ds.cm, nil)
Expand Down
3 changes: 2 additions & 1 deletion pkg/ipfs/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"testing"
"time"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/system"
icorepath "github.com/ipfs/interface-go-ipfs-core/path"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand All @@ -31,6 +31,7 @@ func (suite *NodeSuite) SetupAllSuite() {

// Before each test
func (suite *NodeSuite) SetupTest() {
logger.ConfigureTestLogging(suite.T())
require.NoError(suite.T(), system.InitConfigForTesting())
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/job/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strings"
"testing"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand All @@ -29,6 +30,7 @@ func (suite *JobFactorySuite) SetupAllSuite() {

// Before each test
func (suite *JobFactorySuite) SetupTest() {
logger.ConfigureTestLogging(suite.T())
}

func (suite *JobFactorySuite) TearDownTest() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/job/sharding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"
"testing"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/filecoin-project/bacalhau/pkg/model"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand All @@ -30,6 +31,7 @@ func (suite *JobShardingSuite) SetupAllSuite() {

// Before each test
func (suite *JobShardingSuite) SetupTest() {
logger.ConfigureTestLogging(suite.T())
}

func (suite *JobShardingSuite) TearDownTest() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/job/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"
"testing"

"github.com/filecoin-project/bacalhau/pkg/logger"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand All @@ -29,6 +30,7 @@ func (s *JobUtilSuite) SetupAllSuite() {

// Before each test
func (s *JobUtilSuite) SetupTest() {
logger.ConfigureTestLogging(s.T())
}

func (s *JobUtilSuite) TearDownTest() {
Expand Down
Loading

0 comments on commit ea3595c

Please sign in to comment.