dht: extend duration of TestGetFailures
TestGetFailures may just be operating very slowly, instead of completely failing. Right now it gets caught on travis often. not sure if its actually wrong.
Juan Batiz-Benet committed
Jan 4, 2015 at 18:18 UTC
b4be7c5986864b6cfdc3f8bb9585285701700252
1 file changed
+9
-4
routing/dht/ext_test.go
+9
-4
@@ -47,7 +47,7 @@ func TestGetFailures(t *testing.T) {
47
48
// This one should time out
49
// u.POut("Timout Test\n")
50
- ctx1, _ := context.WithTimeout(context.Background(), time.Second)
50
+ ctx1, _ := context.WithTimeout(context.Background(), 200*time.Millisecond)
51
if _, err := d.GetValue(ctx1, u.Key("test")); err != nil {
52
if err != context.DeadlineExceeded {
53
t.Fatal("Got different error than we expected", err)
@@ -78,8 +78,12 @@ func TestGetFailures(t *testing.T) {
78
}
79
})
80
81
- // This one should fail with NotFound
82
- ctx2, _ := context.WithTimeout(context.Background(), 3*time.Second)
81
+ // This one should fail with NotFound.
82
+ // long context timeout to ensure we dont end too early.
83
+ // the dht should be exhausting its query and returning not found.
84
+ // (was 3 seconds before which should be _plenty_ of time, but maybe
85
+ // travis machines really have a hard time...)
86
+ ctx2, _ := context.WithTimeout(context.Background(), 20*time.Second)
87
_, err = d.GetValue(ctx2, u.Key("test"))
88
if err != nil {
89
if err != routing.ErrNotFound {
@@ -187,7 +191,8 @@ func TestNotFound(t *testing.T) {
191
})
192
}
193
190
- ctx, _ = context.WithTimeout(ctx, time.Second*5)
194
+ // long timeout to ensure timing is not at play.
195
+ ctx, _ = context.WithTimeout(ctx, time.Second*20)
196
v, err := d.GetValue(ctx, u.Key("hello"))
197
log.Debugf("get value got %v", v)
198
if err != nil {