Merge pull request #5707 from heyitsanthony/test-all

test: don't hardcode packages for testing
This commit is contained in:
Anthony Romano
2016-06-17 14:08:46 -07:00
committed by GitHub
9 changed files with 20 additions and 16 deletions

View File

@@ -117,7 +117,7 @@ func (b *DoubleBarrier) Leave() error {
}
// delete self and wait on lowest process
if err := b.myKey.Delete(); err != nil {
if err = b.myKey.Delete(); err != nil {
return err
}

View File

@@ -24,7 +24,7 @@ import (
"golang.org/x/net/context"
)
// Key is a key/revision pair created by the client and stored on etcd
// RemoteKV is a key/revision pair created by the client and stored on etcd
type RemoteKV struct {
kv v3.KV
key string

View File

@@ -54,7 +54,7 @@ type RangeDeleter interface {
DeleteRange(key, end []byte) (int64, int64)
}
// A Lessor is the owner of leases. It can grant, revoke, renew and modify leases for lessee.
// Lessor owns leases. It can grant, revoke, renew and modify leases for lessee.
type Lessor interface {
// SetRangeDeleter sets the RangeDeleter to the Lessor.
// Lessor deletes the items in the revoked or expired lease from the
@@ -172,13 +172,13 @@ func (le *lessor) SetRangeDeleter(rd RangeDeleter) {
le.rd = rd
}
// TODO: when lessor is under high load, it should give out lease
// with longer TTL to reduce renew load.
func (le *lessor) Grant(id LeaseID, ttl int64) (*Lease, error) {
if id == NoLease {
return nil, ErrLeaseNotFound
}
// TODO: when lessor is under high load, it should give out lease
// with longer TTL to reduce renew load.
l := &Lease{ID: id, TTL: ttl, itemSet: make(map[LeaseItem]struct{})}
le.mu.Lock()

View File

@@ -19,6 +19,7 @@ import (
"os"
"path"
"reflect"
"sort"
"testing"
"time"
@@ -96,7 +97,7 @@ func TestLessorRevoke(t *testing.T) {
{"bar"},
}
if err := le.Attach(l.ID, items); err != nil {
if err = le.Attach(l.ID, items); err != nil {
t.Fatalf("failed to attach items to the lease: %v", err)
}
@@ -108,7 +109,8 @@ func TestLessorRevoke(t *testing.T) {
t.Errorf("got revoked lease %x", l.ID)
}
wdeleted := []string{"foo_", "bar_"}
wdeleted := []string{"bar_", "foo_"}
sort.Sort(sort.StringSlice(fd.deleted))
if !reflect.DeepEqual(fd.deleted, wdeleted) {
t.Errorf("deleted= %v, want %v", fd.deleted, wdeleted)
}

View File

@@ -44,11 +44,11 @@ func TestKVProxyRange(t *testing.T) {
}
client, err := clientv3.New(cfg)
if err != nil {
t.Fatalf("err = %v, want nil")
t.Fatalf("err = %v, want nil", err)
}
_, err = client.Get(context.Background(), "foo")
if err != nil {
t.Fatalf("err = %v, want nil")
t.Fatalf("err = %v, want nil", err)
}
}

8
test
View File

@@ -27,9 +27,11 @@ mkdir -p $GOPATH
ln -s ${PWD}/cmd/vendor $GOPATH/src
# Hack: gofmt ./ will recursively check the .git directory. So use *.go for gofmt.
PKGS=`ls pkg/*/*go | cut -f1,2 -d/ | sort | uniq`
TESTABLE_AND_FORMATTABLE="auth client clientv3 discovery error etcdctl/ctlv2 etcdctl/ctlv3 etcdmain etcdserver etcdserver/auth etcdserver/api/v2http etcdserver/api/v2http/httptypes etcdserver/api/v3rpc etcdserver/api/v3rpc/rpctypes $PKGS proxy/httpproxy proxy/tcpproxy raft snap mvcc mvcc/backend store version wal rafthttp"
FORMATTABLE="$TESTABLE_AND_FORMATTABLE *.go etcdctl/ integration clientv3/integration e2e alarm"
IGNORE_PKGS="(cmd|vendor|etcdserverpb|rafttest)"
INTEGRATION_PKGS="(integration|e2e|contrib|functional-tester)"
TEST_PKGS=`find . -name \*_test.go | while read a; do dirname $a; done | sort | uniq | egrep -v "$IGNORE_PKGS" | sed "s|\./||g"`
FORMATTABLE=`find . -name \*.go | while read a; do echo $(dirname $a)/"*.go"; done | sort | uniq | egrep -v "$IGNORE_PKGS" | sed "s|\./||g"`
TESTABLE_AND_FORMATTABLE=`echo "$TEST_PKGS" | egrep -v "$INTEGRATION_PKGS"`
# user has not provided PKG override
if [ -z "$PKG" ]; then

View File

@@ -17,9 +17,11 @@ package client
import "net/rpc"
type Status struct {
// State gives the human-readable status of an agent (e.g., "started" or "terminated")
State string
// TODO: gather more informations
// TODO: memory usage, raft information, etc..
State string
}
type Agent interface {

View File

@@ -39,7 +39,7 @@ type failure interface {
// Recover recovers the injected failure caused by the injection of the
// given round and wait for the recovery of the testing cluster.
Recover(c *cluster, round int) error
// return a description of the failure
// Desc returns a description of the failure
Desc() string
}

View File

@@ -161,8 +161,6 @@ type stresserV2 struct {
KeySuffixRange int
N int
// TODO: not implemented
Interval time.Duration
mu sync.Mutex
failure int