Skip to content

Commit

Permalink
Fix #339: Reduce Sleeps in tests
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
  • Loading branch information
hsanjuan committed Mar 16, 2018
1 parent a357b76 commit 7c4e348
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 98 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ check:
golint -set_exit_status -min_confidence 0.3 ./...

test: deps
go test -timeout 20m -loglevel "CRITICAL" -v ./...
go test -loglevel "CRITICAL" -v ./...

test_sharness: $(sharness)
@sh sharness/run-sharness-tests.sh
Expand Down
2 changes: 1 addition & 1 deletion ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang([test: "go test -v -timeout 20m ./..."])
golang([test: "go test -v ./..."])

2 changes: 1 addition & 1 deletion cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func TestClusterRecoverAllLocal(t *testing.T) {
t.Fatal("pin should have worked:", err)
}

time.Sleep(time.Second)
pinDelay()

recov, err := cl.RecoverAllLocal()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (

var logger = logging.Logger("config")

// How often to save the configuration file if it needs saving.
// ConfigSaveInterval specifies how often to save the configuration file if
// it needs saving.
var ConfigSaveInterval = time.Second

// The ComponentConfig interface allows components to define configurations
Expand Down
21 changes: 11 additions & 10 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,25 @@ var testingClusterCfg = []byte(`{
"state_sync_interval": "1m0s",
"ipfs_sync_interval": "2m10s",
"replication_factor": -1,
"monitor_ping_interval": "1s"
"monitor_ping_interval": "200ms",
"peer_watch_interval": "100ms"
}
`)

var testingRaftCfg = []byte(`{
"data_folder": "raftFolderFromTests",
"wait_for_leader_timeout": "30s",
"wait_for_leader_timeout": "10s",
"commit_retries": 1,
"commit_retry_delay": "1s",
"network_timeout": "20s",
"heartbeat_timeout": "1s",
"election_timeout": "1s",
"commit_timeout": "50ms",
"commit_retry_delay": "100ms",
"network_timeout": "5s",
"heartbeat_timeout": "100ms",
"election_timeout": "100ms",
"commit_timeout": "10ms",
"max_append_entries": 64,
"trailing_logs": 10240,
"snapshot_interval": "2m0s",
"snapshot_threshold": 8192,
"leader_lease_timeout": "500ms"
"leader_lease_timeout": "50ms"
}`)

var testingAPICfg = []byte(`{
Expand Down Expand Up @@ -71,11 +72,11 @@ var testingTrackerCfg = []byte(`
`)

var testingMonCfg = []byte(`{
"check_interval": "1s"
"check_interval": "180ms"
}`)

var testingDiskInfCfg = []byte(`{
"metric_ttl": "1s",
"metric_ttl": "200ms",
"metric_type": "freespace"
}`)

Expand Down
4 changes: 2 additions & 2 deletions coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ for dir in $dirs;
do
if ls "$dir"/*.go &> /dev/null;
then
cmdflags="-timeout 20m -v -coverprofile=profile.out -covermode=count $dir"
cmdflags="-v -coverprofile=profile.out -covermode=count $dir"
if [ "$dir" == "." ]; then
cmdflags="-timeout 20m -v -coverprofile=profile.out -covermode=count -loglevel CRITICAL ."
cmdflags="-v -coverprofile=profile.out -covermode=count -loglevel CRITICAL ."
fi
echo go test $cmdflags
go test $cmdflags
Expand Down
Loading

0 comments on commit 7c4e348

Please sign in to comment.