Skip to content

Commit

Permalink
Merge pull request #171 from crimson-gao/lite_mode_logstore
Browse files Browse the repository at this point in the history
feat(logstore): add parameter "mode"
  • Loading branch information
shabicheng authored Jun 29, 2022
2 parents 28bb45a + 8a4f182 commit f723fcb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions log_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ type LogStore struct {
WebTracking bool `json:"enable_tracking"`
AutoSplit bool `json:"autoSplit"`
MaxSplitShard int `json:"maxSplitShard"`

AppendMeta bool `json:"appendMeta"`
TelemetryType string `json:"telemetryType"`
HotTTL uint32 `json:"hot_ttl,omitempty"`
Mode string `json:"mode,omitempty"` // "lite" or "standard"(default), can't be modified after creation

CreateTime uint32 `json:"createTime,omitempty"`
LastModifyTime uint32 `json:"lastModifyTime,omitempty"`
Expand Down
34 changes: 34 additions & 0 deletions logstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ func (s *LogstoreTestSuite) TestLogstore() {
logstores, err := s.Project.ListLogStore()
s.Nil(err)
s.True(len(logstores) >= 1)

// test parameter "mode" of logstore, default mode is "standard"
time.Sleep(1 * 1000 * time.Millisecond)
logstore, err := s.Project.GetLogStore(logstoreName)
s.Nil(err)
s.Equal(logstore.Mode, "standard")

time.Sleep(1 * 1000 * time.Millisecond)
configs, configCount, err := s.Project.ListConfig(0, 100)
s.Nil(err)
s.True(len(configs) >= 0)
Expand All @@ -317,6 +325,32 @@ func (s *LogstoreTestSuite) TestLogstore() {
s.Nil(err)
}

func (s *LogstoreTestSuite) TestLogstoreLiteMode() {
logstoreName := "github-test"
_ = s.Project.DeleteLogStore(logstoreName)
// create a "lite" mode logstore
lite := &LogStore{
Name: logstoreName,
TTL: 14,
ShardCount: 2,
AutoSplit: true,
MaxSplitShard: 16,
Mode: "lite",
}
err := s.Project.CreateLogStoreV2(lite)
s.Nil(err)
time.Sleep(10 * 1000 * time.Millisecond)

// check if logstore is in "lite" mode
liteResp, err := s.Project.GetLogStore(logstoreName)
s.Nil(err)
s.Equal(liteResp.Mode, "lite")

// clean
err = s.Project.DeleteLogStore(logstoreName)
s.Nil(err)
}

func generateLG() *LogGroup {
content := &LogContent{
Key: proto.String("demo_key"),
Expand Down

0 comments on commit f723fcb

Please sign in to comment.