FB-1505 - Fixes for PR: remove underscores from test names, rename TTLRemoval to ViewsRemoval

This commit is contained in:
Hoang Pham 2022-06-30 13:16:39 -05:00 committed by Matthew Jaffee
parent 106c043f57
commit 367448b034
3 changed files with 35 additions and 32 deletions

View file

@ -86,7 +86,7 @@ func TestMarshalUnmarshalTransactionResponse(t *testing.T) {
}
}
func TestUpdateField_TTL(t *testing.T) {
func TestUpdateFieldTTL(t *testing.T) {
c := test.MustRunCluster(t, 3)
defer c.Close()
@ -226,7 +226,7 @@ func TestUpdateField_TTL(t *testing.T) {
}
func TestUpdateField_NoStandardView(t *testing.T) {
func TestUpdateFieldNoStandardView(t *testing.T) {
c := test.MustRunCluster(t, 3)
defer c.Close()

View file

@ -69,18 +69,18 @@ type Server struct { // nolint: maligned
logger logger.Logger
queryLogger logger.Logger
nodeID string
uri pnet.URI
grpcURI pnet.URI
antiEntropyInterval time.Duration
metricInterval time.Duration
diagnosticInterval time.Duration
ttlRemovalInterval time.Duration
maxWritesPerRequest int
confirmDownSleep time.Duration
confirmDownRetries int
syncer holderSyncer
maxQueryMemory int64
nodeID string
uri pnet.URI
grpcURI pnet.URI
antiEntropyInterval time.Duration
metricInterval time.Duration
diagnosticInterval time.Duration
viewsRemovalInterval time.Duration
maxWritesPerRequest int
confirmDownSleep time.Duration
confirmDownRetries int
syncer holderSyncer
maxQueryMemory int64
translationSyncer TranslationSyncer
resetTranslationSyncCh chan struct{}
@ -167,11 +167,11 @@ func OptServerAntiEntropyInterval(interval time.Duration) ServerOption {
}
}
// OptServerTTLRemovalInterval is a functional option on Server
// OptServerViewsRemovalInterval is a functional option on Server
// used to set the ttl removal interval.
func OptServerTTLRemovalInterval(interval time.Duration) ServerOption {
func OptServerViewsRemovalInterval(interval time.Duration) ServerOption {
return func(s *Server) error {
s.ttlRemovalInterval = interval
s.viewsRemovalInterval = interval
return nil
}
}
@ -444,10 +444,10 @@ func NewServer(opts ...ServerOption) (*Server, error) {
gcNotifier: NopGCNotifier,
antiEntropyInterval: 0,
metricInterval: 0,
diagnosticInterval: 0,
ttlRemovalInterval: time.Hour,
antiEntropyInterval: 0,
metricInterval: 0,
diagnosticInterval: 0,
viewsRemovalInterval: time.Hour,
disCo: disco.NopDisCo,
stator: disco.NopStator,
@ -845,20 +845,23 @@ func (s *Server) monitorResetTranslationSync() {
func (s *Server) monitorTTL() {
ctx := context.Background()
// Run TTLRemoval on server start
s.TTLRemoval(ctx)
ticker := time.NewTicker(s.ttlRemovalInterval)
// Run ViewsRemoval on server start
s.ViewsRemoval(ctx)
ticker := time.NewTicker(s.viewsRemovalInterval)
for {
select {
case <-s.closing:
return
case <-ticker.C:
s.TTLRemoval(ctx)
s.ViewsRemoval(ctx)
}
}
}
func (s *Server) TTLRemoval(ctx context.Context) {
// Remove views based on these criterias:
// 1. views that are older than specified TTL
// 2. "standard" view of a field if its "noStandardView" option is set to true
func (s *Server) ViewsRemoval(ctx context.Context) {
for _, index := range s.holder.Indexes() {
for _, field := range index.Fields() {
if field.Options().Type == "time" {

View file

@ -13,7 +13,7 @@ import (
"github.com/molecula/featurebase/v3/test"
)
func TestTTLRemoval_TTL(t *testing.T) {
func TestViewsRemovalTTL(t *testing.T) {
cluster := test.MustRunCluster(t, 1)
node := cluster.GetNode(0)
defer cluster.Close()
@ -166,8 +166,8 @@ func TestTTLRemoval_TTL(t *testing.T) {
t.Fatalf("setting sample data, err: %v", err)
}
// run TTLRemoval
node.Server.TTLRemoval(context.Background())
// run ViewsRemoval
node.Server.ViewsRemoval(context.Background())
// Get all the views for given index + field
views, err := node.API.Views(context.Background(), indexName, test.name)
@ -187,7 +187,7 @@ func TestTTLRemoval_TTL(t *testing.T) {
}
}
func TestTTLRemoval_StandardView(t *testing.T) {
func TestViewsRemovalStandard(t *testing.T) {
cluster := test.MustRunCluster(t, 1)
node := cluster.GetNode(0)
defer cluster.Close()
@ -258,8 +258,8 @@ func TestTTLRemoval_StandardView(t *testing.T) {
t.Fatalf("updating noStandardView, err: %v", err)
}
// run TTLRemoval
node.Server.TTLRemoval(context.Background())
// run ViewsRemoval
node.Server.ViewsRemoval(context.Background())
// get all the views for given index + field
views, err := node.API.Views(context.Background(), indexName, test.name)