2016-05-04 14:50:08 +00:00
|
|
|
/*
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
Copyright 2016 The Perkeep Authors.
|
2016-05-04 14:50:08 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package index_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
"perkeep.org/pkg/index/indextest"
|
|
|
|
"perkeep.org/pkg/sorted"
|
|
|
|
"perkeep.org/pkg/sorted/kvtest"
|
|
|
|
"perkeep.org/pkg/sorted/leveldb"
|
2016-05-04 14:50:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func newLevelDBSorted(t *testing.T) (kv sorted.KeyValue, cleanup func()) {
|
2022-01-23 11:24:37 +00:00
|
|
|
td := t.TempDir()
|
|
|
|
kv, err := leveldb.NewStorage(filepath.Join(td, "leveldb"))
|
2016-05-04 14:50:08 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
return kv, func() {
|
|
|
|
kv.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSorted_LevelDB(t *testing.T) {
|
|
|
|
kv, cleanup := newLevelDBSorted(t)
|
|
|
|
defer cleanup()
|
|
|
|
kvtest.TestSorted(t, kv)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIndex_LevelDB(t *testing.T) {
|
|
|
|
indexTest(t, newLevelDBSorted, indextest.Index)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPathsOfSignerTarget_LevelDB(t *testing.T) {
|
|
|
|
indexTest(t, newLevelDBSorted, indextest.PathsOfSignerTarget)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFiles_LevelDB(t *testing.T) {
|
|
|
|
indexTest(t, newLevelDBSorted, indextest.Files)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEdgesTo_LevelDB(t *testing.T) {
|
|
|
|
indexTest(t, newLevelDBSorted, indextest.EdgesTo)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDelete_LevelDB(t *testing.T) {
|
|
|
|
indexTest(t, newLevelDBSorted, indextest.Delete)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestReindex_LevelDB(t *testing.T) {
|
pkg/index: test showing issue #756
A word of caution: relatedly to the issue demonstrated by the added
tests, an infinite loop can also occur, as it already could in
TestReindex_LevelDB. As it is, after all, a consequence of a race, I
haven't been able to determine what exactly makes the loop occur. But
what I observed is:
1) It seems to be occuring much more easily with LevelDB, which is why I
ended up just disabling TestReindex_LevelDB.
2) I've never seen it happen in TestReindex_Kvfile, but who knows.
3) I've seen it rarely happen with TestShowReindexRace_Kvfile, but it
seems that adding in TestShowReindexRace_Kvfile the kind of timed kill
that I had added TestReindex_LevelDB, actually makes the loop happen
much more often. And it ends up eclipsing the original issue that we
want to demonstrate, which is why I decided against it.
TL;DR: if you use -show_reindex_race=true , be prepared to maybe
have to kill(1) the test manually.
Change-Id: I47fd3c55363c8d0dda17ad19665115cb96f3d58f
2016-08-04 00:31:10 +00:00
|
|
|
t.Skip("Disabled until issue #756 is fixed")
|
|
|
|
t.Log("WARNING: as this test can get into an infinite loop, it will automatically terminate after a few seconds")
|
|
|
|
tim := time.After(2 * time.Second)
|
2016-05-04 14:50:08 +00:00
|
|
|
c := make(chan struct{}, 1)
|
|
|
|
go func() {
|
|
|
|
indexTest(t, newLevelDBSorted, indextest.Reindex)
|
|
|
|
c <- struct{}{}
|
|
|
|
}()
|
|
|
|
select {
|
|
|
|
case <-c:
|
|
|
|
// all good
|
|
|
|
case <-tim:
|
|
|
|
// Because of at least (I suspect) issue #756, we not only
|
|
|
|
// sometimes get a failing test here, but we also get into an
|
pkg/index: test showing issue #756
A word of caution: relatedly to the issue demonstrated by the added
tests, an infinite loop can also occur, as it already could in
TestReindex_LevelDB. As it is, after all, a consequence of a race, I
haven't been able to determine what exactly makes the loop occur. But
what I observed is:
1) It seems to be occuring much more easily with LevelDB, which is why I
ended up just disabling TestReindex_LevelDB.
2) I've never seen it happen in TestReindex_Kvfile, but who knows.
3) I've seen it rarely happen with TestShowReindexRace_Kvfile, but it
seems that adding in TestShowReindexRace_Kvfile the kind of timed kill
that I had added TestReindex_LevelDB, actually makes the loop happen
much more often. And it ends up eclipsing the original issue that we
want to demonstrate, which is why I decided against it.
TL;DR: if you use -show_reindex_race=true , be prepared to maybe
have to kill(1) the test manually.
Change-Id: I47fd3c55363c8d0dda17ad19665115cb96f3d58f
2016-08-04 00:31:10 +00:00
|
|
|
// infinite loop retrying out-of-order indexing.Hence the Fatal
|
|
|
|
// below as a temporary measure to interrupt that loop.
|
|
|
|
t.Fatal("forced interruption of TestReindex_LevelDB infinite loop")
|
2016-05-04 14:50:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEnumStat_LevelDB(t *testing.T) {
|
|
|
|
indexTest(t, newLevelDBSorted, indextest.EnumStat)
|
|
|
|
}
|