-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreindex_test.go
56 lines (52 loc) · 1.06 KB
/
reindex_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package eskeeper
import (
"context"
"testing"
)
func TestReindex(t *testing.T) {
tests := []struct {
name string
dest string
reindex reindex
setup func(tb testing.TB)
cleanup func(tb testing.TB)
}{
{
name: "reindex",
dest: "reindex-dest",
reindex: reindex{
Source: "reindex-src",
Slices: 3,
WaitForCompletion: true,
On: "firstCreated",
},
setup: func(tb testing.TB) {
createTmpIndexHelper(tb, "reindex-src")
createTmpIndexHelper(tb, "reindex-dest")
postDocHelper(tb, "reindex-src")
},
cleanup: func(tb testing.TB) {
deleteIndexHelper(tb, []string{"reindex-src", "reindex-dest"})
},
},
}
es, err := newEsClient([]string{url}, "", "")
if err != nil {
t.Fatal(err)
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := context.Background()
if tt.setup != nil {
tt.setup(t)
}
err := es.reindex(ctx, tt.dest, tt.reindex)
if err != nil {
t.Error(err)
}
if tt.cleanup != nil {
tt.cleanup(t)
}
})
}
}