github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/storage/config_test.go (about) 1 package storage 2 3 import ( 4 "time" 5 6 . "github.com/onsi/ginkgo/v2" 7 . "github.com/onsi/gomega" 8 "github.com/sirupsen/logrus" 9 10 "github.com/pyroscope-io/pyroscope/pkg/config" 11 ) 12 13 var _ = Describe("Storage config", func() { 14 cfg := config.Server{ 15 BadgerLogLevel: "debug", 16 StoragePath: "/var/lib/pyroscope", 17 CacheEvictThreshold: 0.25, 18 CacheEvictVolume: 0.33, 19 BadgerNoTruncate: true, 20 MaxNodesSerialization: 2048, 21 HideApplications: []string{"app"}, 22 Retention: 24 * time.Hour, 23 SampleRate: 100, 24 CacheDimensionSize: 1, 25 CacheDictionarySize: 1, 26 CacheSegmentSize: 1, 27 CacheTreeSize: 1, 28 } 29 Context("Basic config", func() { 30 It("NewConfig returns storage config", func() { 31 c := NewConfig(&cfg) 32 Expect(c.badgerLogLevel).To(Equal(logrus.DebugLevel)) 33 Expect(c.badgerNoTruncate).To(BeTrue()) 34 Expect(c.badgerBasePath).To(Equal("/var/lib/pyroscope")) 35 Expect(c.cacheEvictThreshold).To(Equal(0.25)) 36 Expect(c.cacheEvictVolume).To(Equal(0.33)) 37 Expect(c.maxNodesSerialization).To(Equal(2048)) 38 Expect(c.retention).To(Equal(24 * time.Hour)) 39 Expect(c.hideApplications).To(HaveLen(1)) 40 Expect(c.hideApplications).To(ContainElement("app")) 41 Expect(c.inMemory).To(BeFalse()) 42 }) 43 44 It("WithPath returns storage config with overriden storage base path", func() { 45 c := NewConfig(&cfg).WithPath("/tmp/pyroscope") 46 Expect(c.badgerBasePath).To(Equal("/tmp/pyroscope")) 47 }) 48 49 It("WithInMemory returns storage config with overriden in memory", func() { 50 c := NewConfig(&cfg).WithInMemory() 51 Expect(c.inMemory).To(BeTrue()) 52 }) 53 54 It("Invalid log level results in error log level", func() { 55 c := NewConfig(&config.Server{}) 56 Expect(c.badgerLogLevel).To(Equal(logrus.ErrorLevel)) 57 }) 58 }) 59 })