Fix #240: Add test flags. Remove build tags for logging control.
License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
parent
2a6f91cd35
commit
bfdd59735c
4
Makefile
4
Makefile
|
@ -68,13 +68,13 @@ check:
|
||||||
golint -set_exit_status -min_confidence 0.3 ./...
|
golint -set_exit_status -min_confidence 0.3 ./...
|
||||||
|
|
||||||
test: deps
|
test: deps
|
||||||
go test -timeout 20m -tags silent -v ./...
|
go test -timeout 20m -loglevel "CRITICAL" -v ./...
|
||||||
|
|
||||||
test_sharness: $(sharness)
|
test_sharness: $(sharness)
|
||||||
@sh sharness/run-sharness-tests.sh
|
@sh sharness/run-sharness-tests.sh
|
||||||
|
|
||||||
test_problem: deps
|
test_problem: deps
|
||||||
go test -timeout 20m -tags debug -v -run $(problematic_test)
|
go test -timeout 20m -loglevel "DEBUG" -v -run $(problematic_test)
|
||||||
|
|
||||||
$(sharness):
|
$(sharness):
|
||||||
@echo "Downloading sharness"
|
@echo "Downloading sharness"
|
||||||
|
|
2
ci/Jenkinsfile
vendored
2
ci/Jenkinsfile
vendored
|
@ -1 +1 @@
|
||||||
golang([test: "go test -tags silent -v ./..."])
|
golang([test: "go test -loglevel CRITICAL -v ./..."])
|
||||||
|
|
10
coverage.sh
10
coverage.sh
|
@ -7,7 +7,15 @@ for dir in $dirs;
|
||||||
do
|
do
|
||||||
if ls "$dir"/*.go &> /dev/null;
|
if ls "$dir"/*.go &> /dev/null;
|
||||||
then
|
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 ];
|
if [ $? -ne 0 ];
|
||||||
then
|
then
|
||||||
exit 1
|
exit 1
|
||||||
|
|
12
debug.go
12
debug.go
|
@ -1,12 +0,0 @@
|
||||||
// +build debug,!silent
|
|
||||||
|
|
||||||
package ipfscluster
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
l := "DEBUG"
|
|
||||||
SetFacilityLogLevel("*", l)
|
|
||||||
|
|
||||||
// for f, _ := range LoggingFacilities {
|
|
||||||
// SetFacilityLogLevel(f, l)
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -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) {
|
func setupAllocation(name string, diskInfCfg *disk.Config, numpinInfCfg *numpin.Config) (ipfscluster.Informer, ipfscluster.PinAllocator) {
|
||||||
switch name {
|
switch name {
|
||||||
case "disk", "disk-freespace":
|
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) {
|
func saveConfig(cfg *config.Manager, force bool) {
|
||||||
if _, err := os.Stat(configPath); err == nil && !force {
|
if _, err := os.Stat(configPath); err == nil && !force {
|
||||||
err := fmt.Errorf("%s exists. Try running: %s -f init", configPath, programName)
|
err := fmt.Errorf("%s exists. Try running: %s -f init", configPath, programName)
|
||||||
|
|
|
@ -32,10 +32,12 @@ import (
|
||||||
//TestClusters*
|
//TestClusters*
|
||||||
var (
|
var (
|
||||||
// number of clusters to create
|
// number of clusters to create
|
||||||
nClusters = *flag.Int("nclusters", 6, "number of clusters to use")
|
nClusters = 6
|
||||||
|
|
||||||
// number of pins to pin/unpin/check
|
// number of pins to pin/unpin/check
|
||||||
nPins = *flag.Int("npins", 500, "number of pins to pin/unpin/check")
|
nPins = 500
|
||||||
|
|
||||||
|
logLevel = "CRITICAL"
|
||||||
|
|
||||||
// ports
|
// ports
|
||||||
clusterPort = 10000
|
clusterPort = 10000
|
||||||
|
@ -44,7 +46,20 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
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())
|
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) {
|
func checkErr(t *testing.T, err error) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ var LoggingFacilities = map[string]string{
|
||||||
|
|
||||||
// LoggingFacilitiesExtra provides logging identifiers
|
// LoggingFacilitiesExtra provides logging identifiers
|
||||||
// used in ipfs-cluster dependencies, which may be useful
|
// 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{
|
var LoggingFacilitiesExtra = map[string]string{
|
||||||
"p2p-gorpc": "CRITICAL",
|
"p2p-gorpc": "CRITICAL",
|
||||||
"swarm2": "ERROR",
|
"swarm2": "ERROR",
|
||||||
|
|
14
nodebug.go
14
nodebug.go
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user