1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 00:39:31 +08:00

chore(tests) add Short() -> SkipNow() to slowest tests

vanilla:
    21.57 real        45.14 user         8.51 sys

short:
    14.40 real        31.13 user         5.56 sys

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
Brian Tiger Chow
2014-11-15 00:19:47 -08:00
committed by Juan Batiz-Benet
parent 25b3106e41
commit ed4a8eb782
14 changed files with 87 additions and 11 deletions

View File

@ -90,6 +90,9 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) {
}
func TestSwarm(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
net := tn.VirtualNetwork()
rs := mock.VirtualRoutingServer()
sg := NewSessionGenerator(net, rs)

View File

@ -83,6 +83,9 @@ func setupIpnsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *fstest.M
// Test writing a file and reading it back
func TestIpnsBasicIO(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
_, mnt := setupIpnsTest(t, nil)
defer mnt.Close()
@ -101,6 +104,9 @@ func TestIpnsBasicIO(t *testing.T) {
// Test to make sure file changes persist over mounts of ipns
func TestFilePersistence(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
node, mnt := setupIpnsTest(t, nil)
fname := "/local/atestfile"
@ -126,6 +132,9 @@ func TestFilePersistence(t *testing.T) {
// Test to make sure the filesystem reports file sizes correctly
func TestFileSizeReporting(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
_, mnt := setupIpnsTest(t, nil)
defer mnt.Close()
@ -144,6 +153,9 @@ func TestFileSizeReporting(t *testing.T) {
// Test to make sure you cant create multiple entries with the same name
func TestDoubleEntryFailure(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
_, mnt := setupIpnsTest(t, nil)
defer mnt.Close()
@ -160,6 +172,9 @@ func TestDoubleEntryFailure(t *testing.T) {
}
func TestAppendFile(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
_, mnt := setupIpnsTest(t, nil)
defer mnt.Close()
@ -198,6 +213,9 @@ func TestAppendFile(t *testing.T) {
}
func TestFastRepublish(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
// make timeout noticeable.
osrt := shortRepublishTimeout
@ -299,6 +317,9 @@ func TestFastRepublish(t *testing.T) {
// Test writing a medium sized file one byte at a time
func TestMultiWrite(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
_, mnt := setupIpnsTest(t, nil)
defer mnt.Close()

View File

@ -21,6 +21,9 @@ func copyBuf(buf []byte) []byte {
}
func TestSizeSplitterIsDeterministic(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
test := func() {
bufR := randBuf(t, 10000000) // crank this up to satisfy yourself.

View File

@ -19,6 +19,9 @@ import (
// These tests tests a combination of unixfs/io/dagreader and importer/chunk.
// Maybe split them up somehow?
func TestBuildDag(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
td := os.TempDir()
fi, err := os.Create(td + "/tmpfi")
if err != nil {
@ -40,6 +43,9 @@ func TestBuildDag(t *testing.T) {
//Test where calls to read are smaller than the chunk size
func TestSizeBasedSplit(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
bs := &chunk.SizeSplitter{Size: 512}
testFileConsistency(t, bs, 32*512)
bs = &chunk.SizeSplitter{Size: 4096}
@ -118,10 +124,16 @@ func arrComp(a, b []byte) error {
}
func TestMaybeRabinConsistency(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
testFileConsistency(t, chunk.NewMaybeRabin(4096), 256*4096)
}
func TestRabinBlockSize(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
buf := new(bytes.Buffer)
nbytes := 1024 * 1024
io.CopyN(buf, rand.Reader, int64(nbytes))

View File

@ -83,7 +83,9 @@ func TestCancel(t *testing.T) {
}
func TestCloseLeak(t *testing.T) {
// t.Skip("Skipping in favor of another test")
if testing.Short() {
t.SkipNow()
}
if os.Getenv("TRAVIS") == "true" {
t.Skip("this doesn't work well on travis")

View File

@ -156,7 +156,9 @@ func setupMultiConns(t *testing.T, ctx context.Context) (a, b *MultiConn) {
}
func TestMulticonnSend(t *testing.T) {
// t.Skip("fooo")
if testing.Short() {
t.SkipNow()
}
log.Info("TestMulticonnSend")
ctx := context.Background()
@ -220,7 +222,9 @@ func TestMulticonnSend(t *testing.T) {
}
func TestMulticonnSendUnderlying(t *testing.T) {
// t.Skip("fooo")
if testing.Short() {
t.SkipNow()
}
log.Info("TestMulticonnSendUnderlying")
ctx := context.Background()

View File

@ -105,7 +105,9 @@ func TestSecureCancel(t *testing.T) {
}
func TestSecureCloseLeak(t *testing.T) {
// t.Skip("Skipping in favor of another test")
if testing.Short() {
t.SkipNow()
}
if os.Getenv("TRAVIS") == "true" {
t.Skip("this doesn't work well on travis")
}

View File

@ -103,6 +103,9 @@ func TestSimpleMuxer(t *testing.T) {
}
func TestSimultMuxer(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
// run muxer
ctx, cancel := context.WithCancel(context.Background())

View File

@ -11,7 +11,9 @@ import (
)
func TestSimultOpen(t *testing.T) {
// t.Skip("skipping for another test")
if testing.Short() {
t.SkipNow()
}
addrs := []string{
"/ip4/127.0.0.1/tcp/1244",
@ -61,6 +63,9 @@ func TestSimultOpenMany(t *testing.T) {
}
func TestSimultOpenFewStress(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
// t.Skip("skipping for another test")
num := 10

View File

@ -167,6 +167,9 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) {
}
func TestSwarm(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
// t.Skip("skipping for another test")
addrs := []string{

View File

@ -73,6 +73,9 @@ func newPeerTime(t time.Time) peer.Peer {
}
func TestSyncQueue(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
ctx := context.Background()
pq := NewXORDistancePQ(u.Key("11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a31"))

View File

@ -231,7 +231,9 @@ func TestProvides(t *testing.T) {
}
func TestProvidesAsync(t *testing.T) {
// t.Skip("skipping test to debug another")
if testing.Short() {
t.SkipNow()
}
ctx := context.Background()
u.Debug = false
@ -295,7 +297,9 @@ func TestProvidesAsync(t *testing.T) {
}
func TestLayeredGet(t *testing.T) {
// t.Skip("skipping test to debug another")
if testing.Short() {
t.SkipNow()
}
ctx := context.Background()
u.Debug = false
@ -347,7 +351,9 @@ func TestLayeredGet(t *testing.T) {
}
func TestFindPeer(t *testing.T) {
// t.Skip("skipping test to debug another")
if testing.Short() {
t.SkipNow()
}
ctx := context.Background()
u.Debug = false
@ -391,7 +397,9 @@ func TestFindPeer(t *testing.T) {
}
func TestConnectCollision(t *testing.T) {
// t.Skip("skipping test to debug another")
if testing.Short() {
t.SkipNow()
}
runTimes := 10

View File

@ -115,7 +115,9 @@ func (f *fauxNet) GetBandwidthTotals() (uint64, uint64) {
func (f *fauxNet) Close() error { return nil }
func TestGetFailures(t *testing.T) {
// t.Skip("skipping test because it makes a lot of output")
if testing.Short() {
t.SkipNow()
}
ctx := context.Background()
fn := &fauxNet{}
@ -211,7 +213,9 @@ func _randPeer() peer.Peer {
}
func TestNotFound(t *testing.T) {
// t.Skip("skipping test because it makes a lot of output")
if testing.Short() {
t.SkipNow()
}
ctx := context.Background()
fn := &fauxNet{}

View File

@ -29,6 +29,9 @@ func TestKey(t *testing.T) {
}
func TestByteChanReader(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
var data bytes.Buffer
var data2 bytes.Buffer