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

fix(notification): support notification retention configuration #515

Merged
merged 5 commits into from
Sep 19, 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
2 changes: 2 additions & 0 deletions cmd/server/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func init() {
Cmd.Flags().StringVar(&conf.DataDir, "data-dir", "./data/db", "Directory where to store data")
Cmd.Flags().StringVar(&conf.WalDir, "wal-dir", "./data/wal", "Directory for write-ahead-logs")
Cmd.Flags().DurationVar(&conf.WalRetentionTime, "wal-retention-time", 1*time.Hour, "Retention time for the entries in the write-ahead-log")
Cmd.Flags().DurationVar(&conf.NotificationsRetentionTime, "notifications-retention-time", 1*time.Hour, "Retention time for the db notifications to clients")

Cmd.Flags().BoolVar(&conf.WalSyncData, "wal-sync-data", true, "Whether to sync data in write-ahead-log")
Cmd.Flags().Int64Var(&conf.DbBlockCacheMB, "db-cache-size-mb", kv.DefaultFactoryOptions.CacheSizeMB,
"Max size of the shared DB cache")
Expand Down
56 changes: 56 additions & 0 deletions cmd/server/cmd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2024 StreamNative, Inc.
//
// 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 server

import (
"strings"
"testing"
"time"

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"github.com/streamnative/oxia/server"
)

func TestServerCmd(t *testing.T) {
for _, test := range []struct {
args []string
expectedConf server.Config
isErr bool
}{
{[]string{}, server.Config{
PublicServiceAddr: "0.0.0.0:6648",
InternalServiceAddr: "0.0.0.0:6649",
MetricsServiceAddr: "0.0.0.0:8080",
DataDir: "./data/db",
WalDir: "./data/wal",
WalRetentionTime: 1 * time.Hour,
WalSyncData: true,
NotificationsRetentionTime: 1 * time.Hour,
DbBlockCacheMB: 100,
}, false},
} {
t.Run(strings.Join(test.args, "_"), func(t *testing.T) {
Cmd.SetArgs(test.args)
Cmd.RunE = func(cmd *cobra.Command, args []string) error {
return nil
}
err := Cmd.Execute()
assert.Equal(t, test.isErr, err != nil)
assert.Equal(t, test.expectedConf, conf)
})
}
}
Loading