diff --git a/src/internal/acceptance/metric-store/metric_store_test.go b/src/internal/acceptance/metric-store/metric_store_test.go index 425a435e7..883452e8e 100644 --- a/src/internal/acceptance/metric-store/metric_store_test.go +++ b/src/internal/acceptance/metric-store/metric_store_test.go @@ -501,10 +501,6 @@ scrape_configs: value2, _, err := tc.localEgressClient.LabelValues(context.Background(), model.MetricNameLabel, result, minTime, maxTime) - fmt.Println("mintime: ", minTime) - fmt.Println("maxtime: ", maxTime) - - fmt.Println("new value is a: ") fmt.Println(value2) return err @@ -520,6 +516,16 @@ scrape_configs: }, 1).Should(Equal(model.LabelValues{ "metric_name_new", })) + + time.Sleep(time.Second * 10) + + content, err := ioutil.ReadFile("/tmp/testlogfile") + + if err != nil { + log.Fatal(err) + } + + fmt.Println(string(content)) }) }) //1696259961000000000 diff --git a/src/pkg/persistence/influx_adapter.go b/src/pkg/persistence/influx_adapter.go index 8be8f8233..f2813af85 100644 --- a/src/pkg/persistence/influx_adapter.go +++ b/src/pkg/persistence/influx_adapter.go @@ -3,6 +3,8 @@ package persistence import ( "context" "fmt" + "log" + "os" "regexp" "sort" "sync" @@ -218,13 +220,26 @@ func (t *InfluxAdapter) DeleteOldest() error { } func (t *InfluxAdapter) DeleteOlderThan(cutoff int64) (uint64, error) { + adjustedCutoff := time.Unix(0, cutoff).Add(-time.Minute).Truncate(24 * time.Hour).UnixNano() + f, e := os.OpenFile("/tmp/testlogfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + if e != nil { + log.Fatalf("error opening file: %v", e) + } + defer f.Close() + var deleted uint64 for _, shardID := range t.ShardIDsOldestSort() { + + log.Println("BREAKED shardID: ", shardID) if int64(shardID) > adjustedCutoff { break } + log.SetOutput(f) + log.Println("adjustedCutoff: ", adjustedCutoff) + log.Println("PRUNED shardID: ", shardID) + err := t.Delete(shardID) if err != nil { return deleted, err