Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle pulllogsMeta is nils #276

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions log_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ func (s *LogStore) GetLogsBytes(shardID int, cursor, endCursor string,
// Deprecated: use GetLogsBytesWithQuery instead
func (s *LogStore) GetLogsBytesV2(plr *PullLogRequest) ([]byte, string, error) {
out, plm, err := s.GetLogsBytesWithQuery(plr)
if err != nil {
return nil, "", err
}
return out, plm.NextCursor, err
}

Expand Down Expand Up @@ -655,6 +658,9 @@ func (s *LogStore) PullLogs(shardID int, cursor, endCursor string,
// Deprecated: use PullLogsWithQuery instead
func (s *LogStore) PullLogsV2(plr *PullLogRequest) (*LogGroupList, string, error) {
gl, plm, err := s.PullLogsWithQuery(plr)
if err != nil {
return nil, "", err
}
return gl, plm.NextCursor, err
}

Expand Down
39 changes: 39 additions & 0 deletions logstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,45 @@ func (s *LogstoreTestSuite) TestPullLogs() {
s.Nil(err)
}

func (s *LogstoreTestSuite) TestGetLogByteWithError() {
c := &LogContent{
Key: proto.String("error code"),
Value: proto.String("InternalServerError"),
}
l := &Log{
Time: proto.Uint32(uint32(time.Now().Unix())),
Contents: []*LogContent{
c,
},
}
lg := &LogGroup{
Topic: proto.String("demo topic"),
Source: proto.String("10.230.201.117"),
Logs: []*Log{
l,
},
}

shards, err := s.Logstore.ListShards()
s.True(len(shards) > 0)

err = s.Logstore.PutLogs(lg)
s.Nil(err)

cursor, err := s.Logstore.GetCursor(0, "begin")
s.Nil(err)
endCursor, err := s.Logstore.GetCursor(0, "end")
s.Nil(err)

_, _, err = s.Logstore.GetLogsBytes(1000, cursor, "", 10)
s.Contains(err.Error(), "ShardNotExist")
s.NotNil(err)

_, _, err = s.Logstore.GetLogsBytes(1000, cursor, endCursor, 10)
s.Contains(err.Error(), "ShardNotExist")
s.NotNil(err)
}

func (s *LogstoreTestSuite) TestGetLogs() {
idx, err := s.Logstore.GetIndex()
if err != nil {
Expand Down
Loading