search: add test for earlier fix in commit 1e1183a8bf

Change-Id: I95c0f885079de17cd1c52b9ad40861c96eb5308c
This commit is contained in:
Brad Fitzpatrick 2013-12-07 10:53:30 -08:00
parent 1e1183a8bf
commit b020f60390
2 changed files with 38 additions and 0 deletions

View File

@ -22,6 +22,8 @@ func SetTestHookBug121(hook func()) {
func ExportCandSource() string { return candSource }
func ExportBufferedConst() int { return buffered }
func (s *SearchQuery) ExportPlannedQuery() *SearchQuery {
return s.plannedQuery()
}

View File

@ -566,6 +566,42 @@ func TestQueryRecentPermanodes(t *testing.T) {
})
}
func TestLimitDoesntDeadlock(t *testing.T) {
// TODO: care about classic (allIndexTypes) too?
testQueryTypes(t, memIndexTypes, func(qt *queryTest) {
id := qt.id
const limit = 2
for i := 0; i < ExportBufferedConst()+limit+1; i++ {
pn := id.NewPlannedPermanode(fmt.Sprint(i))
id.SetAttribute(pn, "foo", "bar")
}
req := &SearchQuery{
Constraint: &Constraint{
Permanode: &PermanodeConstraint{},
},
Limit: limit,
Sort: UnspecifiedSort,
Describe: &DescribeRequest{},
}
h := qt.Handler()
gotRes := make(chan bool, 1)
go func() {
_, err := h.Query(req)
if err != nil {
qt.t.Error(err)
}
gotRes <- true
}()
select {
case <-gotRes:
case <-time.After(5 * time.Second):
t.Error("timeout; deadlock?")
}
})
}
func prettyJSON(v interface{}) string {
b, err := json.MarshalIndent(v, "", " ")
if err != nil {