github.com/GuanceCloud/cliutils@v1.1.21/pipeline/manager/patterns_test.go (about) 1 // Unless explicitly stated otherwise all files in this repository are licensed 2 // under the MIT License. 3 // This product includes software developed at Guance Cloud (https://www.guance.com/). 4 // Copyright 2021-present Guance, Inc. 5 6 package manager 7 8 import ( 9 "testing" 10 11 "github.com/GuanceCloud/grok" 12 vgrok "github.com/vjeantet/grok" 13 ) 14 15 func TestParsePattern(t *testing.T) { 16 pattern := grok.CopyDefalutPatterns() 17 if de, errs := grok.DenormalizePatternsFromMap(pattern); len(errs) != 0 { 18 t.Error(errs) 19 } else { 20 if len(pattern) != len(de) { 21 t.Error("length not equal") 22 } 23 for k := range de { 24 if _, ok := de[k]; !ok { 25 t.Errorf("%s not exists", k) 26 } 27 } 28 } 29 } 30 31 func BenchmarkParse(b *testing.B) { 32 for i := 0; i < b.N; i++ { 33 if v, err := grok.DenormalizePatternsFromMap(grok.CopyDefalutPatterns()); err != nil { 34 b.Log(v) 35 b.Error(err) 36 } 37 } 38 } 39 40 func BenchmarkParseVgrok(b *testing.B) { 41 for n := 0; n < b.N; n++ { 42 if g, err := vgrok.NewWithConfig(&vgrok.Config{NamedCapturesOnly: true}); err != nil { 43 b.Error(err) 44 b.Error(g) 45 } 46 } 47 }