diff --git a/Makefile b/Makefile index 426d37de..2b0fb4f8 100644 --- a/Makefile +++ b/Makefile @@ -68,13 +68,13 @@ check: golint -set_exit_status -min_confidence 0.3 ./... test: deps - go test -timeout 20m -tags silent -v ./... + go test -timeout 20m -loglevel "CRITICAL" -v ./... test_sharness: $(sharness) @sh sharness/run-sharness-tests.sh test_problem: deps - go test -timeout 20m -tags debug -v -run $(problematic_test) + go test -timeout 20m -loglevel "DEBUG" -v -run $(problematic_test) $(sharness): @echo "Downloading sharness" diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index ddc62b77..607e0ce7 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -1 +1 @@ -golang([test: "go test -tags silent -v ./..."]) +golang([test: "go test -loglevel CRITICAL -v ./..."]) diff --git a/coverage.sh b/coverage.sh index 2b1e842c..ef12c980 100755 --- a/coverage.sh +++ b/coverage.sh @@ -7,7 +7,15 @@ for dir in $dirs; do if ls "$dir"/*.go &> /dev/null; then - go test -timeout 20m -v -coverprofile=profile.out -covermode=count -tags silent "$dir" + if [ "$dir" == "." ]; then + set -x + go test -timeout 20m -v -coverprofile=profile.out -covermode=count "$dir" -loglevel "CRITICAL" + set +x + else + set -x + go test -timeout 20m -v -coverprofile=profile.out -covermode=count "$dir" + set +x + fi if [ $? -ne 0 ]; then exit 1 diff --git a/debug.go b/debug.go deleted file mode 100644 index f381763b..00000000 --- a/debug.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build debug,!silent - -package ipfscluster - -func init() { - l := "DEBUG" - SetFacilityLogLevel("*", l) - - // for f, _ := range LoggingFacilities { - // SetFacilityLogLevel(f, l) - // } -} diff --git a/ipfs-cluster-service/main.go b/ipfs-cluster-service/main.go index ec4c3983..3d110fea 100644 --- a/ipfs-cluster-service/main.go +++ b/ipfs-cluster-service/main.go @@ -504,6 +504,10 @@ func setupLogLevel(lvl string) { } } +func setupDebug() { + ipfscluster.SetFacilityLogLevel("*", "DEBUG") +} + func setupAllocation(name string, diskInfCfg *disk.Config, numpinInfCfg *numpin.Config) (ipfscluster.Informer, ipfscluster.PinAllocator) { switch name { case "disk", "disk-freespace": @@ -525,10 +529,6 @@ func setupAllocation(name string, diskInfCfg *disk.Config, numpinInfCfg *numpin. } } -func setupDebug() { - ipfscluster.SetFacilityLogLevel("*", "DEBUG") -} - func saveConfig(cfg *config.Manager, force bool) { if _, err := os.Stat(configPath); err == nil && !force { err := fmt.Errorf("%s exists. Try running: %s -f init", configPath, programName) diff --git a/ipfscluster_test.go b/ipfscluster_test.go index 1249067a..37ed122b 100644 --- a/ipfscluster_test.go +++ b/ipfscluster_test.go @@ -32,10 +32,12 @@ import ( //TestClusters* var ( // number of clusters to create - nClusters = *flag.Int("nclusters", 6, "number of clusters to use") + nClusters = 6 // number of pins to pin/unpin/check - nPins = *flag.Int("npins", 500, "number of pins to pin/unpin/check") + nPins = 500 + + logLevel = "CRITICAL" // ports clusterPort = 10000 @@ -44,7 +46,20 @@ var ( ) func init() { + flag.StringVar(&logLevel, "loglevel", logLevel, "default log level for tests") + flag.IntVar(&nClusters, "nclusters", nClusters, "number of clusters to use") + flag.IntVar(&nPins, "npins", nPins, "number of pins to pin/unpin/check") + flag.Parse() + rand.Seed(time.Now().UnixNano()) + + for f := range LoggingFacilities { + SetFacilityLogLevel(f, logLevel) + } + + for f := range LoggingFacilitiesExtra { + SetFacilityLogLevel(f, logLevel) + } } func checkErr(t *testing.T, err error) { diff --git a/logging.go b/logging.go index 1c88f49a..881f681c 100644 --- a/logging.go +++ b/logging.go @@ -22,7 +22,7 @@ var LoggingFacilities = map[string]string{ // LoggingFacilitiesExtra provides logging identifiers // used in ipfs-cluster dependencies, which may be useful -// for to display. Along with their default value. +// to display. Along with their default value. var LoggingFacilitiesExtra = map[string]string{ "p2p-gorpc": "CRITICAL", "swarm2": "ERROR", diff --git a/nodebug.go b/nodebug.go deleted file mode 100644 index 9d407f1e..00000000 --- a/nodebug.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build !debug,!silent - -package ipfscluster - -// These are our default log levels -func init() { - for f, l := range LoggingFacilities { - SetFacilityLogLevel(f, l) - } - - for f, l := range LoggingFacilitiesExtra { - SetFacilityLogLevel(f, l) - } -} diff --git a/silent.go b/silent.go deleted file mode 100644 index d03e06d0..00000000 --- a/silent.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !debug,silent - -package ipfscluster - -func init() { - l := "CRITICAL" - SetFacilityLogLevel("*", l) -}