2014-04-01 16:03:20 +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 2012 The Perkeep Authors.
|
2014-04-01 16:03:20 +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 (
|
|
|
|
"testing"
|
|
|
|
|
2015-12-01 16:19:49 +00:00
|
|
|
"go4.org/jsonconfig"
|
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/osutil"
|
|
|
|
"perkeep.org/pkg/sorted"
|
|
|
|
"perkeep.org/pkg/sorted/kvtest"
|
|
|
|
_ "perkeep.org/pkg/sorted/mysql"
|
|
|
|
"perkeep.org/pkg/test/dockertest"
|
2014-04-01 16:03:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func newMySQLSorted(t *testing.T) (kv sorted.KeyValue, clean func()) {
|
|
|
|
dbname := "camlitest_" + osutil.Username()
|
|
|
|
containerID, ip := dockertest.SetupMySQLContainer(t, dbname)
|
|
|
|
|
2014-04-07 23:04:05 +00:00
|
|
|
kv, err := sorted.NewKeyValue(jsonconfig.Obj{
|
|
|
|
"type": "mysql",
|
|
|
|
"host": ip + ":3306",
|
|
|
|
"database": dbname,
|
|
|
|
"user": dockertest.MySQLUsername,
|
|
|
|
"password": dockertest.MySQLPassword,
|
2014-04-01 16:03:20 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
2014-04-09 15:47:58 +00:00
|
|
|
containerID.KillRemove(t)
|
2014-04-01 16:03:20 +00:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
return kv, func() {
|
|
|
|
kv.Close()
|
2014-04-09 15:47:58 +00:00
|
|
|
containerID.KillRemove(t)
|
2014-04-01 16:03:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSorted_MySQL(t *testing.T) {
|
|
|
|
kv, clean := newMySQLSorted(t)
|
|
|
|
defer clean()
|
|
|
|
kvtest.TestSorted(t, kv)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIndex_MySQL(t *testing.T) {
|
|
|
|
indexTest(t, newMySQLSorted, indextest.Index)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPathsOfSignerTarget_MySQL(t *testing.T) {
|
|
|
|
indexTest(t, newMySQLSorted, indextest.PathsOfSignerTarget)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFiles_MySQL(t *testing.T) {
|
|
|
|
indexTest(t, newMySQLSorted, indextest.Files)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEdgesTo_MySQL(t *testing.T) {
|
|
|
|
indexTest(t, newMySQLSorted, indextest.EdgesTo)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDelete_MySQL(t *testing.T) {
|
|
|
|
indexTest(t, newMySQLSorted, indextest.Delete)
|
|
|
|
}
|
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
|
|
|
|
|
|
|
func TestReindex_MySQL(t *testing.T) {
|
|
|
|
indexTest(t, newMySQLSorted, indextest.Reindex)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestShowReindexRace_MySQL(t *testing.T) {
|
|
|
|
indexTest(t, newMySQLSorted, indextest.ShowReindexRace)
|
|
|
|
}
|