summaryrefslogtreecommitdiffstats
path: root/store/storetest
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-10-25 13:23:01 +0100
committerGitHub <noreply@github.com>2017-10-25 13:23:01 +0100
commit5474cff0ebab8c42f1b0750ac054a8c762b43a37 (patch)
treeb3e470a621b88930cfafbf76d6d727162baee03a /store/storetest
parent16b845c0d77535ea306339f7a8bd22fc72f8a3c5 (diff)
downloadchat-5474cff0ebab8c42f1b0750ac054a8c762b43a37.tar.gz
chat-5474cff0ebab8c42f1b0750ac054a8c762b43a37.tar.bz2
chat-5474cff0ebab8c42f1b0750ac054a8c762b43a37.zip
PLT-7934: Make query for bulk elasticsearch indexing more efficient. (#7664)
Diffstat (limited to 'store/storetest')
-rw-r--r--store/storetest/post_store.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/store/storetest/post_store.go b/store/storetest/post_store.go
index 3460c4d05..b288cde34 100644
--- a/store/storetest/post_store.go
+++ b/store/storetest/post_store.go
@@ -12,6 +12,7 @@ import (
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils"
+ "github.com/stretchr/testify/assert"
)
func TestPostStore(t *testing.T, ss store.Store) {
@@ -1614,7 +1615,7 @@ func testPostStoreGetPostsBatchForIndexing(t *testing.T, ss store.Store) {
o3.Message = "zz" + model.NewId() + "QQQQQQQQQQ"
o3 = (<-ss.Post().Save(o3)).Data.(*model.Post)
- if r := store.Must(ss.Post().GetPostsBatchForIndexing(o1.CreateAt, 100)).([]*model.PostForIndexing); len(r) != 3 {
+ if r := store.Must(ss.Post().GetPostsBatchForIndexing(o1.CreateAt, model.GetMillis()+100000, 100)).([]*model.PostForIndexing); len(r) != 3 {
t.Fatalf("Expected 3 posts in results. Got %v", len(r))
} else {
for _, p := range r {
@@ -1682,3 +1683,31 @@ func testPostStorePermanentDeleteBatch(t *testing.T, ss store.Store) {
t.Fatalf("Should have found post 3 after purge")
}
}
+
+func testPostStoreGetOldest(t *testing.T, ss store.Store) {
+ o0 := &model.Post{}
+ o0.ChannelId = model.NewId()
+ o0.UserId = model.NewId()
+ o0.Message = "zz" + model.NewId() + "b"
+ o0.CreateAt = 3
+ o0 = (<-ss.Post().Save(o0)).Data.(*model.Post)
+
+ o1 := &model.Post{}
+ o1.ChannelId = o0.Id
+ o1.UserId = model.NewId()
+ o1.Message = "zz" + model.NewId() + "b"
+ o1.CreateAt = 2
+ o1 = (<-ss.Post().Save(o1)).Data.(*model.Post)
+
+ o2 := &model.Post{}
+ o2.Id = model.NewId()
+ o2.ChannelId = o1.ChannelId
+ o2.UserId = model.NewId()
+ o2.Message = "zz" + model.NewId() + "b"
+ o2.CreateAt = 1
+ o2 = (<-ss.Post().Save(o2)).Data.(*model.Post)
+
+ r1 := (<-ss.Post().GetOldest()).Data.(*model.Post)
+
+ assert.EqualValues(t, o2.Id, r1.Id)
+}