mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
build: use gofumpt
Undecided if we need to use it. I think it's nice.
This commit is contained in:
@@ -24,6 +24,7 @@ func (c *Startable) Start() error {
|
|||||||
c.Started = true
|
c.Started = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Stopable) Stop() error {
|
func (c *Stopable) Stop() error {
|
||||||
c.Stopped = true
|
c.Stopped = true
|
||||||
return nil
|
return nil
|
||||||
@@ -39,10 +40,12 @@ type ComponentStop struct {
|
|||||||
type ComponentStart struct {
|
type ComponentStart struct {
|
||||||
Startable
|
Startable
|
||||||
}
|
}
|
||||||
type ComponentNone struct{}
|
type (
|
||||||
type ComponentStartError struct {
|
ComponentNone struct{}
|
||||||
Stopable
|
ComponentStartError struct {
|
||||||
}
|
Stopable
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func (c ComponentStartError) Start() error {
|
func (c ComponentStartError) Start() error {
|
||||||
return errors.New("nooo")
|
return errors.New("nooo")
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ module1:
|
|||||||
workers: -5
|
workers: -5
|
||||||
`
|
`
|
||||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||||
ioutil.WriteFile(configFile, []byte(config), 0644)
|
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||||
|
|
||||||
c := cmd.ConfigRelatedOptions{
|
c := cmd.ConfigRelatedOptions{
|
||||||
Path: configFile,
|
Path: configFile,
|
||||||
@@ -117,7 +117,7 @@ module2:
|
|||||||
- name: second
|
- name: second
|
||||||
`
|
`
|
||||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||||
ioutil.WriteFile(configFile, []byte(config), 0644)
|
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||||
|
|
||||||
c := cmd.ConfigRelatedOptions{
|
c := cmd.ConfigRelatedOptions{
|
||||||
Path: configFile,
|
Path: configFile,
|
||||||
@@ -198,7 +198,7 @@ module2:
|
|||||||
interval-value: 20m
|
interval-value: 20m
|
||||||
`
|
`
|
||||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||||
ioutil.WriteFile(configFile, []byte(config), 0644)
|
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||||
|
|
||||||
// Environment
|
// Environment
|
||||||
clean := func() {
|
clean := func() {
|
||||||
@@ -319,7 +319,7 @@ module1:
|
|||||||
workers: 10
|
workers: 10
|
||||||
`
|
`
|
||||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||||
ioutil.WriteFile(configFile, []byte(config), 0644)
|
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||||
|
|
||||||
c := cmd.ConfigRelatedOptions{Path: configFile}
|
c := cmd.ConfigRelatedOptions{Path: configFile}
|
||||||
|
|
||||||
@@ -339,7 +339,7 @@ module1:
|
|||||||
workers: 10
|
workers: 10
|
||||||
`
|
`
|
||||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||||
ioutil.WriteFile(configFile, []byte(config), 0644)
|
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||||
|
|
||||||
c := cmd.ConfigRelatedOptions{Path: configFile}
|
c := cmd.ConfigRelatedOptions{Path: configFile}
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ modules:
|
|||||||
topic: flows2
|
topic: flows2
|
||||||
`
|
`
|
||||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||||
ioutil.WriteFile(configFile, []byte(config), 0644)
|
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||||
|
|
||||||
c := cmd.ConfigRelatedOptions{
|
c := cmd.ConfigRelatedOptions{
|
||||||
Path: configFile,
|
Path: configFile,
|
||||||
|
|||||||
@@ -51,8 +51,10 @@ func TestOrchestratorConfig(t *testing.T) {
|
|||||||
root := RootCmd
|
root := RootCmd
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
root.SetOut(buf)
|
root.SetOut(buf)
|
||||||
root.SetArgs([]string{"orchestrator", "--dump", "--check",
|
root.SetArgs([]string{
|
||||||
filepath.Join("testdata/configurations", test.Name(), "in.yaml")})
|
"orchestrator", "--dump", "--check",
|
||||||
|
filepath.Join("testdata/configurations", test.Name(), "in.yaml"),
|
||||||
|
})
|
||||||
if err := root.Execute(); err != nil {
|
if err := root.Execute(); err != nil {
|
||||||
t.Fatalf("`orchestrator` command error:\n%+v", err)
|
t.Fatalf("`orchestrator` command error:\n%+v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
6
common/helpers/cache/cache.go
vendored
6
common/helpers/cache/cache.go
vendored
@@ -14,10 +14,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// ErrVersion is triggered when loading a cache from an incompatible version
|
||||||
// ErrVersion is triggered when loading a cache from an incompatible version
|
var ErrVersion = errors.New("cache version mismatch")
|
||||||
ErrVersion = errors.New("cache version mismatch")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Cache is a thread-safe in-memory key/value store
|
// Cache is a thread-safe in-memory key/value store
|
||||||
type Cache[K comparable, V any] struct {
|
type Cache[K comparable, V any] struct {
|
||||||
|
|||||||
1
common/helpers/cache/persist.go
vendored
1
common/helpers/cache/persist.go
vendored
@@ -36,7 +36,6 @@ func (c *Cache[K, V]) Save(cacheFile string) error {
|
|||||||
return fmt.Errorf("unable to write cache file %q: %w", cacheFile, err)
|
return fmt.Errorf("unable to write cache file %q: %w", cacheFile, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load loads the cache from the provided location.
|
// Load loads the cache from the provided location.
|
||||||
|
|||||||
@@ -155,7 +155,6 @@ func TestParametrizedConfig(t *testing.T) {
|
|||||||
Error: true,
|
Error: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
t.Run("marshal", func(t *testing.T) {
|
t.Run("marshal", func(t *testing.T) {
|
||||||
config1 := OuterConfiguration{
|
config1 := OuterConfiguration{
|
||||||
|
|||||||
@@ -150,5 +150,4 @@ func TestTLSConfiguration(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ func (l *kafkaLogger) Print(v ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *kafkaLogger) Println(v ...interface{}) {
|
func (l *kafkaLogger) Println(v ...interface{}) {
|
||||||
r := l.r.Load()
|
r := l.r.Load()
|
||||||
if r != nil {
|
if r != nil {
|
||||||
@@ -51,6 +52,7 @@ func (l *kafkaLogger) Println(v ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *kafkaLogger) Printf(format string, v ...interface{}) {
|
func (l *kafkaLogger) Printf(format string, v ...interface{}) {
|
||||||
r := l.r.Load()
|
r := l.r.Load()
|
||||||
if r != nil {
|
if r != nil {
|
||||||
|
|||||||
@@ -187,6 +187,5 @@ func ChannelHealthcheck(ctx context.Context, contact chan<- ChannelHealthcheckFu
|
|||||||
case result := <-answerChan:
|
case result := <-answerChan:
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type Logger struct {
|
|||||||
// New creates a new logger
|
// New creates a new logger
|
||||||
func New(config Configuration) (Logger, error) {
|
func New(config Configuration) (Logger, error) {
|
||||||
// Initialize the logger
|
// Initialize the logger
|
||||||
var logger = log.Logger.Hook(contextHook{})
|
logger := log.Logger.Hook(contextHook{})
|
||||||
return Logger{logger}, nil
|
return Logger{logger}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func ExampleNew() {
|
|||||||
// Initialize zerolog
|
// Initialize zerolog
|
||||||
log.Logger = zerolog.New(os.Stdout).With().Timestamp().Logger()
|
log.Logger = zerolog.New(os.Stdout).With().Timestamp().Logger()
|
||||||
zerolog.TimestampFunc = func() time.Time {
|
zerolog.TimestampFunc = func() time.Time {
|
||||||
return time.Date(2008, 1, 8, 17, 5, 05, 0, time.UTC)
|
return time.Date(2008, 1, 8, 17, 5, 5, 0, time.UTC)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize logger
|
// Initialize logger
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ func TestMetrics(t *testing.T) {
|
|||||||
|
|
||||||
gauge3 := r.GaugeVec(reporter.GaugeOpts{
|
gauge3 := r.GaugeVec(reporter.GaugeOpts{
|
||||||
Name: "gauge3",
|
Name: "gauge3",
|
||||||
Help: "Another gauge"},
|
Help: "Another gauge",
|
||||||
|
},
|
||||||
[]string{"label1", "label2"})
|
[]string{"label1", "label2"})
|
||||||
gauge3.WithLabelValues("value1", "value2").Set(44)
|
gauge3.WithLabelValues("value1", "value2").Set(44)
|
||||||
gauge3.WithLabelValues("value3", "value4").Set(48)
|
gauge3.WithLabelValues("value3", "value4").Set(48)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ var pcStackPool = sync.Pool{
|
|||||||
func poolBuf() []uintptr {
|
func poolBuf() []uintptr {
|
||||||
return pcStackPool.Get().([]uintptr)
|
return pcStackPool.Get().([]uintptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func putPoolBuf(p []uintptr) {
|
func putPoolBuf(p []uintptr) {
|
||||||
pcStackPool.Put(p)
|
pcStackPool.Put(p)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,12 +134,14 @@ func flows() Schema {
|
|||||||
ClickHouseMainOnly: true,
|
ClickHouseMainOnly: true,
|
||||||
ClickHouseType: "IPv6",
|
ClickHouseType: "IPv6",
|
||||||
ClickHouseCodec: "ZSTD(1)",
|
ClickHouseCodec: "ZSTD(1)",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnSrcNetMask,
|
Key: ColumnSrcNetMask,
|
||||||
ClickHouseMainOnly: true,
|
ClickHouseMainOnly: true,
|
||||||
ClickHouseType: "UInt8",
|
ClickHouseType: "UInt8",
|
||||||
ConsoleNotDimension: true,
|
ConsoleNotDimension: true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnSrcNetPrefix,
|
Key: ColumnSrcNetPrefix,
|
||||||
ClickHouseMainOnly: true,
|
ClickHouseMainOnly: true,
|
||||||
ClickHouseType: "String",
|
ClickHouseType: "String",
|
||||||
@@ -154,39 +156,48 @@ END`,
|
|||||||
Key: ColumnSrcNetName,
|
Key: ColumnSrcNetName,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'name', SrcAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'name', SrcAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDstNetName,
|
Key: ColumnDstNetName,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'name', DstAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'name', DstAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnSrcNetRole,
|
Key: ColumnSrcNetRole,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'role', SrcAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'role', SrcAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDstNetRole,
|
Key: ColumnDstNetRole,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'role', DstAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'role', DstAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnSrcNetSite,
|
Key: ColumnSrcNetSite,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'site', SrcAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'site', SrcAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDstNetSite,
|
Key: ColumnDstNetSite,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'site', DstAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'site', DstAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnSrcNetRegion,
|
Key: ColumnSrcNetRegion,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'region', SrcAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'region', SrcAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDstNetRegion,
|
Key: ColumnDstNetRegion,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'region', DstAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'region', DstAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnSrcNetTenant,
|
Key: ColumnSrcNetTenant,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'tenant', SrcAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'tenant', SrcAddr, '')",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDstNetTenant,
|
Key: ColumnDstNetTenant,
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'tenant', DstAddr, '')",
|
ClickHouseGenerateFrom: "dictGetOrDefault('networks', 'tenant', DstAddr, '')",
|
||||||
@@ -197,26 +208,31 @@ END`,
|
|||||||
Key: ColumnDstASPath,
|
Key: ColumnDstASPath,
|
||||||
ClickHouseMainOnly: true,
|
ClickHouseMainOnly: true,
|
||||||
ClickHouseType: "Array(UInt32)",
|
ClickHouseType: "Array(UInt32)",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDst1stAS,
|
Key: ColumnDst1stAS,
|
||||||
Depends: []ColumnKey{ColumnDstASPath},
|
Depends: []ColumnKey{ColumnDstASPath},
|
||||||
ClickHouseType: "UInt32",
|
ClickHouseType: "UInt32",
|
||||||
ClickHouseGenerateFrom: "c_DstASPath[1]",
|
ClickHouseGenerateFrom: "c_DstASPath[1]",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDst2ndAS,
|
Key: ColumnDst2ndAS,
|
||||||
Depends: []ColumnKey{ColumnDstASPath},
|
Depends: []ColumnKey{ColumnDstASPath},
|
||||||
ClickHouseType: "UInt32",
|
ClickHouseType: "UInt32",
|
||||||
ClickHouseGenerateFrom: "c_DstASPath[2]",
|
ClickHouseGenerateFrom: "c_DstASPath[2]",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDst3rdAS,
|
Key: ColumnDst3rdAS,
|
||||||
Depends: []ColumnKey{ColumnDstASPath},
|
Depends: []ColumnKey{ColumnDstASPath},
|
||||||
ClickHouseType: "UInt32",
|
ClickHouseType: "UInt32",
|
||||||
ClickHouseGenerateFrom: "c_DstASPath[3]",
|
ClickHouseGenerateFrom: "c_DstASPath[3]",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDstCommunities,
|
Key: ColumnDstCommunities,
|
||||||
ClickHouseMainOnly: true,
|
ClickHouseMainOnly: true,
|
||||||
ClickHouseType: "Array(UInt32)",
|
ClickHouseType: "Array(UInt32)",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDstLargeCommunities,
|
Key: ColumnDstLargeCommunities,
|
||||||
ClickHouseMainOnly: true,
|
ClickHouseMainOnly: true,
|
||||||
ClickHouseType: "Array(UInt128)",
|
ClickHouseType: "Array(UInt128)",
|
||||||
@@ -279,13 +295,16 @@ END`,
|
|||||||
ClickHouseType: "UInt64",
|
ClickHouseType: "UInt64",
|
||||||
ClickHouseAlias: "intDiv(Bytes, Packets)",
|
ClickHouseAlias: "intDiv(Bytes, Packets)",
|
||||||
ConsoleNotDimension: true,
|
ConsoleNotDimension: true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnPacketSizeBucket,
|
Key: ColumnPacketSizeBucket,
|
||||||
Depends: []ColumnKey{ColumnPacketSize},
|
Depends: []ColumnKey{ColumnPacketSize},
|
||||||
ClickHouseType: "LowCardinality(String)",
|
ClickHouseType: "LowCardinality(String)",
|
||||||
ClickHouseAlias: func() string {
|
ClickHouseAlias: func() string {
|
||||||
boundaries := []int{64, 128, 256, 512, 768, 1024, 1280, 1501,
|
boundaries := []int{
|
||||||
2048, 3072, 4096, 8192, 10240, 16384, 32768, 65536}
|
64, 128, 256, 512, 768, 1024, 1280, 1501,
|
||||||
|
2048, 3072, 4096, 8192, 10240, 16384, 32768, 65536,
|
||||||
|
}
|
||||||
conditions := []string{}
|
conditions := []string{}
|
||||||
last := 0
|
last := 0
|
||||||
for _, boundary := range boundaries {
|
for _, boundary := range boundaries {
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ func TestProtobufDefinition(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Key: ColumnSrcAddr,
|
Key: ColumnSrcAddr,
|
||||||
ClickHouseType: "IPv6",
|
ClickHouseType: "IPv6",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnSrcNetMask,
|
Key: ColumnSrcNetMask,
|
||||||
ClickHouseType: "UInt8",
|
ClickHouseType: "UInt8",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnSrcNetPrefix,
|
Key: ColumnSrcNetPrefix,
|
||||||
ClickHouseType: "String",
|
ClickHouseType: "String",
|
||||||
ClickHouseAlias: `something`,
|
ClickHouseAlias: `something`,
|
||||||
@@ -47,7 +49,8 @@ func TestProtobufDefinition(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Key: ColumnDstASPath,
|
Key: ColumnDstASPath,
|
||||||
ClickHouseType: "Array(UInt32)",
|
ClickHouseType: "Array(UInt32)",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Key: ColumnDstLargeCommunities,
|
Key: ColumnDstLargeCommunities,
|
||||||
ClickHouseType: "Array(UInt128)",
|
ClickHouseType: "Array(UInt128)",
|
||||||
ClickHouseTransformFrom: []Column{
|
ClickHouseTransformFrom: []Column{
|
||||||
@@ -107,7 +110,6 @@ message FlowMessagevLH2TTFF7P352DSYYCJYWFCXHAM {
|
|||||||
if diff := helpers.Diff(strings.Split(got, "\n"), strings.Split(expected, "\n")); diff != "" {
|
if diff := helpers.Diff(strings.Split(got, "\n"), strings.Split(expected, "\n")); diff != "" {
|
||||||
t.Fatalf("ProtobufDefinition() (-got, +want): %s", diff)
|
t.Fatalf("ProtobufDefinition() (-got, +want): %s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProtobufMarshal(t *testing.T) {
|
func TestProtobufMarshal(t *testing.T) {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ func TestEnableDisableColumns(t *testing.T) {
|
|||||||
} else if !column.Disabled {
|
} else if !column.Disabled {
|
||||||
t.Fatal("DstCountry is not disabled")
|
t.Fatal("DstCountry is not disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDisableForbiddenColumns(t *testing.T) {
|
func TestDisableForbiddenColumns(t *testing.T) {
|
||||||
|
|||||||
@@ -37,34 +37,34 @@ AND engine LIKE '%MergeTree'
|
|||||||
Return(nil).
|
Return(nil).
|
||||||
SetArg(1, []struct {
|
SetArg(1, []struct {
|
||||||
T time.Time `ch:"t"`
|
T time.Time `ch:"t"`
|
||||||
}{{time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC)}})
|
}{{time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC)}})
|
||||||
mockConn.EXPECT().
|
mockConn.EXPECT().
|
||||||
Select(gomock.Any(), gomock.Any(), `SELECT MIN(TimeReceived) AS t FROM flows_1h0m0s`).
|
Select(gomock.Any(), gomock.Any(), `SELECT MIN(TimeReceived) AS t FROM flows_1h0m0s`).
|
||||||
Return(nil).
|
Return(nil).
|
||||||
SetArg(1, []struct {
|
SetArg(1, []struct {
|
||||||
T time.Time `ch:"t"`
|
T time.Time `ch:"t"`
|
||||||
}{{time.Date(2022, 01, 10, 15, 45, 10, 0, time.UTC)}})
|
}{{time.Date(2022, 1, 10, 15, 45, 10, 0, time.UTC)}})
|
||||||
mockConn.EXPECT().
|
mockConn.EXPECT().
|
||||||
Select(gomock.Any(), gomock.Any(), `SELECT MIN(TimeReceived) AS t FROM flows_1m0s`).
|
Select(gomock.Any(), gomock.Any(), `SELECT MIN(TimeReceived) AS t FROM flows_1m0s`).
|
||||||
Return(nil).
|
Return(nil).
|
||||||
SetArg(1, []struct {
|
SetArg(1, []struct {
|
||||||
T time.Time `ch:"t"`
|
T time.Time `ch:"t"`
|
||||||
}{{time.Date(2022, 04, 20, 15, 45, 10, 0, time.UTC)}})
|
}{{time.Date(2022, 4, 20, 15, 45, 10, 0, time.UTC)}})
|
||||||
mockConn.EXPECT().
|
mockConn.EXPECT().
|
||||||
Select(gomock.Any(), gomock.Any(), `SELECT MIN(TimeReceived) AS t FROM flows_5m0s`).
|
Select(gomock.Any(), gomock.Any(), `SELECT MIN(TimeReceived) AS t FROM flows_5m0s`).
|
||||||
Return(nil).
|
Return(nil).
|
||||||
SetArg(1, []struct {
|
SetArg(1, []struct {
|
||||||
T time.Time `ch:"t"`
|
T time.Time `ch:"t"`
|
||||||
}{{time.Date(2022, 02, 10, 15, 45, 10, 0, time.UTC)}})
|
}{{time.Date(2022, 2, 10, 15, 45, 10, 0, time.UTC)}})
|
||||||
if err := c.refreshFlowsTables(); err != nil {
|
if err := c.refreshFlowsTables(); err != nil {
|
||||||
t.Fatalf("refreshFlowsTables() error:\n%+v", err)
|
t.Fatalf("refreshFlowsTables() error:\n%+v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := []flowsTable{
|
expected := []flowsTable{
|
||||||
{"flows", time.Duration(0), time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC)},
|
{"flows", time.Duration(0), time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1h0m0s", time.Hour, time.Date(2022, 01, 10, 15, 45, 10, 0, time.UTC)},
|
{"flows_1h0m0s", time.Hour, time.Date(2022, 1, 10, 15, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 04, 20, 15, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 4, 20, 15, 45, 10, 0, time.UTC)},
|
||||||
{"flows_5m0s", 5 * time.Minute, time.Date(2022, 02, 10, 15, 45, 10, 0, time.UTC)},
|
{"flows_5m0s", 5 * time.Minute, time.Date(2022, 2, 10, 15, 45, 10, 0, time.UTC)},
|
||||||
}
|
}
|
||||||
if diff := helpers.Diff(c.flowsTables, expected); diff != "" {
|
if diff := helpers.Diff(c.flowsTables, expected); diff != "" {
|
||||||
t.Fatalf("refreshFlowsTables() diff:\n%s", diff)
|
t.Fatalf("refreshFlowsTables() diff:\n%s", diff)
|
||||||
@@ -83,8 +83,8 @@ func TestFinalizeQuery(t *testing.T) {
|
|||||||
Description: "simple query without additional tables",
|
Description: "simple query without additional tables",
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 86400,
|
Points: 86400,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
||||||
@@ -92,106 +92,106 @@ func TestFinalizeQuery(t *testing.T) {
|
|||||||
Description: "query with source port",
|
Description: "query with source port",
|
||||||
Query: "SELECT TimeReceived, SrcPort FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
Query: "SELECT TimeReceived, SrcPort FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
MainTableRequired: true,
|
MainTableRequired: true,
|
||||||
Points: 86400,
|
Points: 86400,
|
||||||
},
|
},
|
||||||
Expected: "SELECT TimeReceived, SrcPort FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
Expected: "SELECT TimeReceived, SrcPort FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
||||||
}, {
|
}, {
|
||||||
Description: "only flows table available",
|
Description: "only flows table available",
|
||||||
Tables: []flowsTable{{"flows", 0, time.Date(2022, 03, 10, 15, 45, 10, 0, time.UTC)}},
|
Tables: []flowsTable{{"flows", 0, time.Date(2022, 3, 10, 15, 45, 10, 0, time.UTC)}},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 86400,
|
Points: 86400,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
||||||
}, {
|
}, {
|
||||||
Description: "timefilter.Start and timefilter.Stop",
|
Description: "timefilter.Start and timefilter.Stop",
|
||||||
Tables: []flowsTable{{"flows", 0, time.Date(2022, 03, 10, 15, 45, 10, 0, time.UTC)}},
|
Tables: []flowsTable{{"flows", 0, time.Date(2022, 3, 10, 15, 45, 10, 0, time.UTC)}},
|
||||||
Query: "SELECT {{ .TimefilterStart }}, {{ .TimefilterEnd }}",
|
Query: "SELECT {{ .TimefilterStart }}, {{ .TimefilterEnd }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 86400,
|
Points: 86400,
|
||||||
},
|
},
|
||||||
Expected: "SELECT toDateTime('2022-04-10 15:45:10', 'UTC'), toDateTime('2022-04-11 15:45:10', 'UTC')",
|
Expected: "SELECT toDateTime('2022-04-10 15:45:10', 'UTC'), toDateTime('2022-04-11 15:45:10', 'UTC')",
|
||||||
}, {
|
}, {
|
||||||
Description: "only flows table and out of range request",
|
Description: "only flows table and out of range request",
|
||||||
Tables: []flowsTable{{"flows", 0, time.Date(2022, 04, 10, 22, 45, 10, 0, time.UTC)}},
|
Tables: []flowsTable{{"flows", 0, time.Date(2022, 4, 10, 22, 45, 10, 0, time.UTC)}},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 86400,
|
Points: 86400,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
||||||
}, {
|
}, {
|
||||||
Description: "select consolidated table",
|
Description: "select consolidated table",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 03, 10, 22, 45, 10, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 3, 10, 22, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 04, 2, 22, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 4, 2, 22, 45, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 720, // 2-minute resolution
|
Points: 720, // 2-minute resolution
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows_1m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:00', 'UTC') AND toDateTime('2022-04-11 15:45:00', 'UTC') // 120",
|
Expected: "SELECT 1 FROM flows_1m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:00', 'UTC') AND toDateTime('2022-04-11 15:45:00', 'UTC') // 120",
|
||||||
}, {
|
}, {
|
||||||
Description: "select consolidated table out of range",
|
Description: "select consolidated table out of range",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 04, 10, 22, 45, 10, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 4, 10, 22, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 04, 10, 17, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 4, 10, 17, 45, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 720, // 2-minute resolution,
|
Points: 720, // 2-minute resolution,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows_1m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:00', 'UTC') AND toDateTime('2022-04-11 15:45:00', 'UTC')",
|
Expected: "SELECT 1 FROM flows_1m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:00', 'UTC') AND toDateTime('2022-04-11 15:45:00', 'UTC')",
|
||||||
}, {
|
}, {
|
||||||
Description: "select flows table out of range",
|
Description: "select flows table out of range",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 04, 10, 16, 45, 10, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 4, 10, 16, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 04, 10, 17, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 4, 10, 17, 45, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 720, // 2-minute resolution,
|
Points: 720, // 2-minute resolution,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC')",
|
||||||
}, {
|
}, {
|
||||||
Description: "use flows table for resolution (control for next case)",
|
Description: "use flows table for resolution (control for next case)",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 04, 10, 10, 45, 10, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 4, 10, 10, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 03, 10, 10, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 3, 10, 10, 45, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 2880, // 30-second resolution
|
Points: 2880, // 30-second resolution
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC') // 30",
|
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC') // 30",
|
||||||
}, {
|
}, {
|
||||||
Description: "use flows table for resolution (but flows_1m0s for data)",
|
Description: "use flows table for resolution (but flows_1m0s for data)",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 04, 10, 10, 45, 10, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 4, 10, 10, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 03, 10, 10, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 3, 10, 10, 45, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 03, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 3, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 03, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 3, 11, 15, 45, 10, 0, time.UTC),
|
||||||
StartForInterval: func() *time.Time {
|
StartForInterval: func() *time.Time {
|
||||||
t := time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC)
|
t := time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC)
|
||||||
return &t
|
return &t
|
||||||
}(),
|
}(),
|
||||||
Points: 2880, // 30-second resolution
|
Points: 2880, // 30-second resolution
|
||||||
@@ -200,55 +200,55 @@ func TestFinalizeQuery(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
Description: "select flows table with better resolution",
|
Description: "select flows table with better resolution",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 03, 10, 16, 45, 10, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 3, 10, 16, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 03, 10, 17, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 3, 10, 17, 45, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 2880,
|
Points: 2880,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC') // 30",
|
Expected: "SELECT 1 FROM flows WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:10', 'UTC') AND toDateTime('2022-04-11 15:45:10', 'UTC') // 30",
|
||||||
}, {
|
}, {
|
||||||
Description: "select consolidated table with better resolution",
|
Description: "select consolidated table with better resolution",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 03, 10, 22, 45, 10, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 3, 10, 22, 45, 10, 0, time.UTC)},
|
||||||
{"flows_5m0s", 5 * time.Minute, time.Date(2022, 04, 2, 22, 45, 10, 0, time.UTC)},
|
{"flows_5m0s", 5 * time.Minute, time.Date(2022, 4, 2, 22, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 04, 2, 22, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 4, 2, 22, 45, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }} // {{ .Interval }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 720, // 2-minute resolution,
|
Points: 720, // 2-minute resolution,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows_1m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:00', 'UTC') AND toDateTime('2022-04-11 15:45:00', 'UTC') // 120",
|
Expected: "SELECT 1 FROM flows_1m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:00', 'UTC') AND toDateTime('2022-04-11 15:45:00', 'UTC') // 120",
|
||||||
}, {
|
}, {
|
||||||
Description: "select consolidated table with better range",
|
Description: "select consolidated table with better range",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 04, 10, 22, 45, 10, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 4, 10, 22, 45, 10, 0, time.UTC)},
|
||||||
{"flows_5m0s", 5 * time.Minute, time.Date(2022, 04, 2, 22, 45, 10, 0, time.UTC)},
|
{"flows_5m0s", 5 * time.Minute, time.Date(2022, 4, 2, 22, 45, 10, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 04, 10, 22, 45, 10, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 4, 10, 22, 45, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 46, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 46, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 46, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 46, 10, 0, time.UTC),
|
||||||
Points: 720, // 2-minute resolution,
|
Points: 720, // 2-minute resolution,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows_5m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:00', 'UTC') AND toDateTime('2022-04-11 15:45:00', 'UTC')",
|
Expected: "SELECT 1 FROM flows_5m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:45:00', 'UTC') AND toDateTime('2022-04-11 15:45:00', 'UTC')",
|
||||||
}, {
|
}, {
|
||||||
Description: "select best resolution when equality for oldest data",
|
Description: "select best resolution when equality for oldest data",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", 0, time.Date(2022, 04, 10, 22, 40, 55, 0, time.UTC)},
|
{"flows", 0, time.Date(2022, 4, 10, 22, 40, 55, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 04, 10, 22, 40, 00, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 4, 10, 22, 40, 0, 0, time.UTC)},
|
||||||
{"flows_1h0m0s", time.Hour, time.Date(2022, 04, 10, 22, 00, 10, 0, time.UTC)},
|
{"flows_1h0m0s", time.Hour, time.Date(2022, 4, 10, 22, 0, 10, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
Query: "SELECT 1 FROM {{ .Table }} WHERE {{ .Timefilter }}",
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 46, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 46, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 46, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 46, 10, 0, time.UTC),
|
||||||
Points: 720, // 2-minute resolution,
|
Points: 720, // 2-minute resolution,
|
||||||
},
|
},
|
||||||
Expected: "SELECT 1 FROM flows_1m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:46:00', 'UTC') AND toDateTime('2022-04-11 15:46:00', 'UTC')",
|
Expected: "SELECT 1 FROM flows_1m0s WHERE TimeReceived BETWEEN toDateTime('2022-04-10 15:46:00', 'UTC') AND toDateTime('2022-04-11 15:46:00', 'UTC')",
|
||||||
@@ -256,8 +256,8 @@ func TestFinalizeQuery(t *testing.T) {
|
|||||||
Description: "query with escaped template",
|
Description: "query with escaped template",
|
||||||
Query: `SELECT TimeReceived, SrcPort WHERE InIfDescription = '{{"{{"}} hello }}'`,
|
Query: `SELECT TimeReceived, SrcPort WHERE InIfDescription = '{{"{{"}} hello }}'`,
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 86400,
|
Points: 86400,
|
||||||
},
|
},
|
||||||
Expected: `SELECT TimeReceived, SrcPort WHERE InIfDescription = '{{ hello }}'`,
|
Expected: `SELECT TimeReceived, SrcPort WHERE InIfDescription = '{{ hello }}'`,
|
||||||
@@ -265,8 +265,8 @@ func TestFinalizeQuery(t *testing.T) {
|
|||||||
Description: "use of ToStartOfInterval",
|
Description: "use of ToStartOfInterval",
|
||||||
Query: `{{ call .ToStartOfInterval "TimeReceived" }}`,
|
Query: `{{ call .ToStartOfInterval "TimeReceived" }}`,
|
||||||
Context: inputContext{
|
Context: inputContext{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 720,
|
Points: 720,
|
||||||
},
|
},
|
||||||
Expected: `toStartOfInterval(TimeReceived + INTERVAL 50 second, INTERVAL 120 second) - INTERVAL 50 second`,
|
Expected: `toStartOfInterval(TimeReceived + INTERVAL 50 second, INTERVAL 120 second) - INTERVAL 50 second`,
|
||||||
@@ -274,8 +274,8 @@ func TestFinalizeQuery(t *testing.T) {
|
|||||||
Description: "Small interval outside main table expiration",
|
Description: "Small interval outside main table expiration",
|
||||||
Query: "SELECT InIfProvider FROM {{ .Table }}",
|
Query: "SELECT InIfProvider FROM {{ .Table }}",
|
||||||
Tables: []flowsTable{
|
Tables: []flowsTable{
|
||||||
{"flows", time.Duration(0), time.Date(2022, 11, 06, 12, 0, 0, 0, time.UTC)},
|
{"flows", time.Duration(0), time.Date(2022, 11, 6, 12, 0, 0, 0, time.UTC)},
|
||||||
{"flows_1h0m0s", time.Hour, time.Date(2022, 04, 25, 18, 0, 0, 0, time.UTC)},
|
{"flows_1h0m0s", time.Hour, time.Date(2022, 4, 25, 18, 0, 0, 0, time.UTC)},
|
||||||
{"flows_1m0s", time.Minute, time.Date(2022, 11, 14, 12, 0, 0, 0, time.UTC)},
|
{"flows_1m0s", time.Minute, time.Date(2022, 11, 14, 12, 0, 0, 0, time.UTC)},
|
||||||
{"flows_5m0s", 5 * time.Minute, time.Date(2022, 8, 23, 12, 0, 0, 0, time.UTC)},
|
{"flows_5m0s", 5 * time.Minute, time.Date(2022, 8, 23, 12, 0, 0, 0, time.UTC)},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ func TestConfigHandler(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"homepageTopWidgets": []string{"src-as", "src-port", "protocol", "src-country", "etype"},
|
"homepageTopWidgets": []string{"src-as", "src-port", "protocol", "src-country", "etype"},
|
||||||
"dimensionsLimit": 50,
|
"dimensionsLimit": 50,
|
||||||
"dimensions": []string{"ExporterAddress",
|
"dimensions": []string{
|
||||||
|
"ExporterAddress",
|
||||||
"ExporterName",
|
"ExporterName",
|
||||||
"ExporterGroup",
|
"ExporterGroup",
|
||||||
"ExporterRole",
|
"ExporterRole",
|
||||||
|
|||||||
@@ -23,13 +23,15 @@ func HumanError(err error) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Errors represents a serializable list of errors.
|
// Errors represents a serializable list of errors.
|
||||||
type Errors []oneError
|
type (
|
||||||
type oneError struct {
|
Errors []oneError
|
||||||
Message string `json:"message"`
|
oneError struct {
|
||||||
Line int `json:"line"`
|
Message string `json:"message"`
|
||||||
Column int `json:"column"`
|
Line int `json:"line"`
|
||||||
Offset int `json:"offset"`
|
Column int `json:"column"`
|
||||||
}
|
Offset int `json:"offset"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// AllErrors returns all parsed errors. The returned value can be serialized to JSON.
|
// AllErrors returns all parsed errors. The returned value can be serialized to JSON.
|
||||||
func AllErrors(err error) Errors {
|
func AllErrors(err error) Errors {
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ func TestValidFilter(t *testing.T) {
|
|||||||
MetaOut Meta
|
MetaOut Meta
|
||||||
}{
|
}{
|
||||||
{Input: `ExporterName = 'something'`, Output: `ExporterName = 'something'`},
|
{Input: `ExporterName = 'something'`, Output: `ExporterName = 'something'`},
|
||||||
{Input: `ExporterName = 'something'`, Output: `ExporterName = 'something'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `ExporterName = 'something'`, Output: `ExporterName = 'something'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `exportername = 'something'`, Output: `ExporterName = 'something'`},
|
{Input: `exportername = 'something'`, Output: `ExporterName = 'something'`},
|
||||||
{Input: `ExporterName='something'`, Output: `ExporterName = 'something'`},
|
{Input: `ExporterName='something'`, Output: `ExporterName = 'something'`},
|
||||||
{Input: `ExporterName="something"`, Output: `ExporterName = 'something'`},
|
{Input: `ExporterName="something"`, Output: `ExporterName = 'something'`},
|
||||||
@@ -39,59 +41,75 @@ func TestValidFilter(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Input: `ExporterAddress << 2001:db8:0::/64`,
|
Input: `ExporterAddress << 2001:db8:0::/64`,
|
||||||
Output: `ExporterAddress BETWEEN toIPv6('2001:db8::') AND toIPv6('2001:db8::ffff:ffff:ffff:ffff')`,
|
Output: `ExporterAddress BETWEEN toIPv6('2001:db8::') AND toIPv6('2001:db8::ffff:ffff:ffff:ffff')`,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `ExporterAddress << 2001:db8::c000/115`,
|
Input: `ExporterAddress << 2001:db8::c000/115`,
|
||||||
Output: `ExporterAddress BETWEEN toIPv6('2001:db8::c000') AND toIPv6('2001:db8::dfff')`,
|
Output: `ExporterAddress BETWEEN toIPv6('2001:db8::c000') AND toIPv6('2001:db8::dfff')`,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `ExporterAddress << 192.168.0.0/24`,
|
Input: `ExporterAddress << 192.168.0.0/24`,
|
||||||
Output: `ExporterAddress BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
Output: `ExporterAddress BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `DstAddr << 192.168.0.0/24`,
|
Input: `DstAddr << 192.168.0.0/24`,
|
||||||
Output: `DstAddr BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
Output: `DstAddr BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `DstAddr << 192.168.0.0/24`,
|
Input: `DstAddr << 192.168.0.0/24`,
|
||||||
Output: `SrcAddr BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
Output: `SrcAddr BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
||||||
MetaIn: Meta{ReverseDirection: true},
|
MetaIn: Meta{ReverseDirection: true},
|
||||||
MetaOut: Meta{ReverseDirection: true, MainTableRequired: true},
|
MetaOut: Meta{ReverseDirection: true, MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `SrcAddr << 192.168.0.1/24`,
|
Input: `SrcAddr << 192.168.0.1/24`,
|
||||||
Output: `SrcAddr BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
Output: `SrcAddr BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `DstAddr !<< 192.168.0.0/24`,
|
Input: `DstAddr !<< 192.168.0.0/24`,
|
||||||
Output: `DstAddr NOT BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
Output: `DstAddr NOT BETWEEN toIPv6('::ffff:192.168.0.0') AND toIPv6('::ffff:192.168.0.255')`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `DstAddr !<< 192.168.0.128/27`,
|
Input: `DstAddr !<< 192.168.0.128/27`,
|
||||||
Output: `DstAddr NOT BETWEEN toIPv6('::ffff:192.168.0.128') AND toIPv6('::ffff:192.168.0.159')`,
|
Output: `DstAddr NOT BETWEEN toIPv6('::ffff:192.168.0.128') AND toIPv6('::ffff:192.168.0.159')`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `DstNetPrefix = 192.168.0.128/27`,
|
Input: `DstNetPrefix = 192.168.0.128/27`,
|
||||||
Output: `DstAddr BETWEEN toIPv6('::ffff:192.168.0.128') AND toIPv6('::ffff:192.168.0.159') AND DstNetMask = 27`,
|
Output: `DstAddr BETWEEN toIPv6('::ffff:192.168.0.128') AND toIPv6('::ffff:192.168.0.159') AND DstNetMask = 27`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `SrcNetPrefix = 192.168.0.128/27`,
|
Input: `SrcNetPrefix = 192.168.0.128/27`,
|
||||||
Output: `SrcAddr BETWEEN toIPv6('::ffff:192.168.0.128') AND toIPv6('::ffff:192.168.0.159') AND SrcNetMask = 27`,
|
Output: `SrcAddr BETWEEN toIPv6('::ffff:192.168.0.128') AND toIPv6('::ffff:192.168.0.159') AND SrcNetMask = 27`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `SrcNetPrefix = 2001:db8::/48`,
|
Input: `SrcNetPrefix = 2001:db8::/48`,
|
||||||
Output: `SrcAddr BETWEEN toIPv6('2001:db8::') AND toIPv6('2001:db8:0:ffff:ffff:ffff:ffff:ffff') AND SrcNetMask = 48`,
|
Output: `SrcAddr BETWEEN toIPv6('2001:db8::') AND toIPv6('2001:db8:0:ffff:ffff:ffff:ffff:ffff') AND SrcNetMask = 48`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
},
|
},
|
||||||
{Input: `ExporterGroup= "group"`, Output: `ExporterGroup = 'group'`},
|
{Input: `ExporterGroup= "group"`, Output: `ExporterGroup = 'group'`},
|
||||||
{Input: `SrcAddr=203.0.113.1`, Output: `SrcAddr = toIPv6('203.0.113.1')`,
|
{
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
Input: `SrcAddr=203.0.113.1`, Output: `SrcAddr = toIPv6('203.0.113.1')`,
|
||||||
{Input: `DstAddr=203.0.113.2`, Output: `DstAddr = toIPv6('203.0.113.2')`,
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
},
|
||||||
|
{
|
||||||
|
Input: `DstAddr=203.0.113.2`, Output: `DstAddr = toIPv6('203.0.113.2')`,
|
||||||
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
|
},
|
||||||
{Input: `SrcNetName="alpha"`, Output: `SrcNetName = 'alpha'`},
|
{Input: `SrcNetName="alpha"`, Output: `SrcNetName = 'alpha'`},
|
||||||
{Input: `DstNetName="alpha"`, Output: `DstNetName = 'alpha'`},
|
{Input: `DstNetName="alpha"`, Output: `DstNetName = 'alpha'`},
|
||||||
{Input: `DstNetRole="stuff"`, Output: `DstNetRole = 'stuff'`},
|
{Input: `DstNetRole="stuff"`, Output: `DstNetRole = 'stuff'`},
|
||||||
{Input: `SrcNetTenant="mobile"`, Output: `SrcNetTenant = 'mobile'`},
|
{Input: `SrcNetTenant="mobile"`, Output: `SrcNetTenant = 'mobile'`},
|
||||||
{Input: `SrcAS=12322`, Output: `SrcAS = 12322`},
|
{Input: `SrcAS=12322`, Output: `SrcAS = 12322`},
|
||||||
{Input: `SrcAS=AS12322`, Output: `SrcAS = 12322`},
|
{Input: `SrcAS=AS12322`, Output: `SrcAS = 12322`},
|
||||||
{Input: `SrcAS=AS12322`, Output: `DstAS = 12322`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `SrcAS=AS12322`, Output: `DstAS = 12322`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `SrcAS=as12322`, Output: `SrcAS = 12322`},
|
{Input: `SrcAS=as12322`, Output: `SrcAS = 12322`},
|
||||||
{Input: `SrcAS IN(12322, 29447)`, Output: `SrcAS IN (12322, 29447)`},
|
{Input: `SrcAS IN(12322, 29447)`, Output: `SrcAS IN (12322, 29447)`},
|
||||||
{Input: `SrcAS IN( 12322 , 29447 )`, Output: `SrcAS IN (12322, 29447)`},
|
{Input: `SrcAS IN( 12322 , 29447 )`, Output: `SrcAS IN (12322, 29447)`},
|
||||||
@@ -99,88 +117,134 @@ func TestValidFilter(t *testing.T) {
|
|||||||
{Input: `SrcAS NOTIN (AS12322, 29447)`, Output: `SrcAS NOT IN (12322, 29447)`},
|
{Input: `SrcAS NOTIN (AS12322, 29447)`, Output: `SrcAS NOT IN (12322, 29447)`},
|
||||||
{Input: `DstAS=12322`, Output: `DstAS = 12322`},
|
{Input: `DstAS=12322`, Output: `DstAS = 12322`},
|
||||||
{Input: `SrcCountry='FR'`, Output: `SrcCountry = 'FR'`},
|
{Input: `SrcCountry='FR'`, Output: `SrcCountry = 'FR'`},
|
||||||
{Input: `SrcCountry='FR'`, Output: `DstCountry = 'FR'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `SrcCountry='FR'`, Output: `DstCountry = 'FR'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `DstCountry='FR'`, Output: `DstCountry = 'FR'`},
|
{Input: `DstCountry='FR'`, Output: `DstCountry = 'FR'`},
|
||||||
{Input: `DstCountry='FR'`, Output: `SrcCountry = 'FR'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `DstCountry='FR'`, Output: `SrcCountry = 'FR'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `InIfName='Gi0/0/0/1'`, Output: `InIfName = 'Gi0/0/0/1'`},
|
{Input: `InIfName='Gi0/0/0/1'`, Output: `InIfName = 'Gi0/0/0/1'`},
|
||||||
{Input: `InIfName='Gi0/0/0/1'`, Output: `OutIfName = 'Gi0/0/0/1'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `InIfName='Gi0/0/0/1'`, Output: `OutIfName = 'Gi0/0/0/1'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `OutIfName = 'Gi0/0/0/1'`, Output: `OutIfName = 'Gi0/0/0/1'`},
|
{Input: `OutIfName = 'Gi0/0/0/1'`, Output: `OutIfName = 'Gi0/0/0/1'`},
|
||||||
{Input: `OutIfName = 'Gi0/0/0/1'`, Output: `InIfName = 'Gi0/0/0/1'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `OutIfName = 'Gi0/0/0/1'`, Output: `InIfName = 'Gi0/0/0/1'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `InIfDescription='Some description'`, Output: `InIfDescription = 'Some description'`},
|
{Input: `InIfDescription='Some description'`, Output: `InIfDescription = 'Some description'`},
|
||||||
{Input: `InIfDescription='Some description'`, Output: `OutIfDescription = 'Some description'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `InIfDescription='Some description'`, Output: `OutIfDescription = 'Some description'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `OutIfDescription='Some other description'`, Output: `OutIfDescription = 'Some other description'`},
|
{Input: `OutIfDescription='Some other description'`, Output: `OutIfDescription = 'Some other description'`},
|
||||||
{Input: `OutIfDescription='Some other description'`, Output: `InIfDescription = 'Some other description'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `OutIfDescription='Some other description'`, Output: `InIfDescription = 'Some other description'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `InIfSpeed>=1000`, Output: `InIfSpeed >= 1000`},
|
{Input: `InIfSpeed>=1000`, Output: `InIfSpeed >= 1000`},
|
||||||
{Input: `InIfSpeed>=1000`, Output: `OutIfSpeed >= 1000`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `InIfSpeed>=1000`, Output: `OutIfSpeed >= 1000`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `InIfSpeed!=1000`, Output: `InIfSpeed != 1000`},
|
{Input: `InIfSpeed!=1000`, Output: `InIfSpeed != 1000`},
|
||||||
{Input: `InIfSpeed<1000`, Output: `InIfSpeed < 1000`},
|
{Input: `InIfSpeed<1000`, Output: `InIfSpeed < 1000`},
|
||||||
{Input: `OutIfSpeed!=1000`, Output: `OutIfSpeed != 1000`},
|
{Input: `OutIfSpeed!=1000`, Output: `OutIfSpeed != 1000`},
|
||||||
{Input: `OutIfSpeed!=1000`, Output: `InIfSpeed != 1000`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `OutIfSpeed!=1000`, Output: `InIfSpeed != 1000`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `InIfConnectivity = 'pni'`, Output: `InIfConnectivity = 'pni'`},
|
{Input: `InIfConnectivity = 'pni'`, Output: `InIfConnectivity = 'pni'`},
|
||||||
{Input: `InIfConnectivity = 'pni'`, Output: `OutIfConnectivity = 'pni'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `InIfConnectivity = 'pni'`, Output: `OutIfConnectivity = 'pni'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `OutIfConnectivity = 'ix'`, Output: `OutIfConnectivity = 'ix'`},
|
{Input: `OutIfConnectivity = 'ix'`, Output: `OutIfConnectivity = 'ix'`},
|
||||||
{Input: `OutIfConnectivity = 'ix'`, Output: `InIfConnectivity = 'ix'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `OutIfConnectivity = 'ix'`, Output: `InIfConnectivity = 'ix'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `InIfProvider = 'cogent'`, Output: `InIfProvider = 'cogent'`},
|
{Input: `InIfProvider = 'cogent'`, Output: `InIfProvider = 'cogent'`},
|
||||||
{Input: `InIfProvider = 'cogent'`, Output: `OutIfProvider = 'cogent'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `InIfProvider = 'cogent'`, Output: `OutIfProvider = 'cogent'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `OutIfProvider = 'telia'`, Output: `OutIfProvider = 'telia'`},
|
{Input: `OutIfProvider = 'telia'`, Output: `OutIfProvider = 'telia'`},
|
||||||
{Input: `OutIfProvider = 'telia'`, Output: `InIfProvider = 'telia'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `OutIfProvider = 'telia'`, Output: `InIfProvider = 'telia'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `InIfBoundary = external`, Output: `InIfBoundary = 'external'`},
|
{Input: `InIfBoundary = external`, Output: `InIfBoundary = 'external'`},
|
||||||
{Input: `InIfBoundary = external`, Output: `OutIfBoundary = 'external'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `InIfBoundary = external`, Output: `OutIfBoundary = 'external'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `InIfBoundary = EXTERNAL`, Output: `InIfBoundary = 'external'`},
|
{Input: `InIfBoundary = EXTERNAL`, Output: `InIfBoundary = 'external'`},
|
||||||
{Input: `InIfBoundary = EXTERNAL`, Output: `OutIfBoundary = 'external'`,
|
{
|
||||||
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true}},
|
Input: `InIfBoundary = EXTERNAL`, Output: `OutIfBoundary = 'external'`,
|
||||||
|
MetaIn: Meta{ReverseDirection: true}, MetaOut: Meta{ReverseDirection: true},
|
||||||
|
},
|
||||||
{Input: `OutIfBoundary != internal`, Output: `OutIfBoundary != 'internal'`},
|
{Input: `OutIfBoundary != internal`, Output: `OutIfBoundary != 'internal'`},
|
||||||
{Input: `EType = ipv4`, Output: `EType = 2048`},
|
{Input: `EType = ipv4`, Output: `EType = 2048`},
|
||||||
{Input: `EType != ipv6`, Output: `EType != 34525`},
|
{Input: `EType != ipv6`, Output: `EType != 34525`},
|
||||||
{Input: `Proto = 1`, Output: `Proto = 1`},
|
{Input: `Proto = 1`, Output: `Proto = 1`},
|
||||||
{Input: `Proto = 'gre'`, Output: `dictGetOrDefault('protocols', 'name', Proto, '???') = 'gre'`},
|
{Input: `Proto = 'gre'`, Output: `dictGetOrDefault('protocols', 'name', Proto, '???') = 'gre'`},
|
||||||
{Input: `SrcPort = 80`, Output: `SrcPort = 80`,
|
{
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
Input: `SrcPort = 80`, Output: `SrcPort = 80`,
|
||||||
{Input: `SrcPort = 80`, Output: `DstPort = 80`,
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Input: `SrcPort = 80`, Output: `DstPort = 80`,
|
||||||
MetaIn: Meta{ReverseDirection: true},
|
MetaIn: Meta{ReverseDirection: true},
|
||||||
MetaOut: Meta{ReverseDirection: true, MainTableRequired: true}},
|
MetaOut: Meta{ReverseDirection: true, MainTableRequired: true},
|
||||||
{Input: `DstPort > 1024`, Output: `DstPort > 1024`,
|
},
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
{
|
||||||
|
Input: `DstPort > 1024`, Output: `DstPort > 1024`,
|
||||||
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
|
},
|
||||||
{Input: `ForwardingStatus >= 128`, Output: `ForwardingStatus >= 128`},
|
{Input: `ForwardingStatus >= 128`, Output: `ForwardingStatus >= 128`},
|
||||||
{Input: `PacketSize > 1500`, Output: `PacketSize > 1500`},
|
{Input: `PacketSize > 1500`, Output: `PacketSize > 1500`},
|
||||||
{Input: `DstPort > 1024 AND SrcPort < 1024`, Output: `DstPort > 1024 AND SrcPort < 1024`,
|
{
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
Input: `DstPort > 1024 AND SrcPort < 1024`, Output: `DstPort > 1024 AND SrcPort < 1024`,
|
||||||
{Input: `DstPort > 1024 OR SrcPort < 1024`, Output: `DstPort > 1024 OR SrcPort < 1024`,
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
},
|
||||||
{Input: `NOT DstPort > 1024 AND SrcPort < 1024`, Output: `NOT DstPort > 1024 AND SrcPort < 1024`,
|
{
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
Input: `DstPort > 1024 OR SrcPort < 1024`, Output: `DstPort > 1024 OR SrcPort < 1024`,
|
||||||
{Input: `not DstPort > 1024 and SrcPort < 1024`, Output: `NOT DstPort > 1024 AND SrcPort < 1024`,
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
},
|
||||||
|
{
|
||||||
|
Input: `NOT DstPort > 1024 AND SrcPort < 1024`, Output: `NOT DstPort > 1024 AND SrcPort < 1024`,
|
||||||
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Input: `not DstPort > 1024 and SrcPort < 1024`, Output: `NOT DstPort > 1024 AND SrcPort < 1024`,
|
||||||
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Input: `DstPort > 1024 AND SrcPort < 1024 OR InIfSpeed >= 1000`,
|
Input: `DstPort > 1024 AND SrcPort < 1024 OR InIfSpeed >= 1000`,
|
||||||
Output: `DstPort > 1024 AND SrcPort < 1024 OR InIfSpeed >= 1000`,
|
Output: `DstPort > 1024 AND SrcPort < 1024 OR InIfSpeed >= 1000`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
Input: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
||||||
Output: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
Output: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: ` DstPort > 1024 AND ( SrcPort < 1024 OR InIfSpeed >= 1000 ) `,
|
Input: ` DstPort > 1024 AND ( SrcPort < 1024 OR InIfSpeed >= 1000 ) `,
|
||||||
Output: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
Output: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `DstPort > 1024 AND(SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
Input: `DstPort > 1024 AND(SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
||||||
Output: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
Output: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `DstPort > 1024
|
Input: `DstPort > 1024
|
||||||
AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
||||||
Output: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
Output: `DstPort > 1024 AND (SrcPort < 1024 OR InIfSpeed >= 1000)`,
|
||||||
@@ -196,10 +260,12 @@ DstPort > 1024 -- Non-privileged port
|
|||||||
AND SrcAS = AS12322 -- Proxad ASN`,
|
AND SrcAS = AS12322 -- Proxad ASN`,
|
||||||
Output: `DstPort > 1024 AND SrcAS = 12322`,
|
Output: `DstPort > 1024 AND SrcAS = 12322`,
|
||||||
MetaOut: Meta{MainTableRequired: true},
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `InIfDescription = "This contains a -- comment" -- nope`,
|
Input: `InIfDescription = "This contains a -- comment" -- nope`,
|
||||||
Output: `InIfDescription = 'This contains a -- comment'`,
|
Output: `InIfDescription = 'This contains a -- comment'`,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Input: `InIfDescription = "This contains a /* comment"`,
|
Input: `InIfDescription = "This contains a /* comment"`,
|
||||||
Output: `InIfDescription = 'This contains a /* comment'`,
|
Output: `InIfDescription = 'This contains a /* comment'`,
|
||||||
},
|
},
|
||||||
@@ -217,14 +283,22 @@ output provider */ = 'telia'`,
|
|||||||
{Input: `DstCommunities != 65000:100:200`, Output: `NOT has(DstLargeCommunities, bitShiftLeft(65000::UInt128, 64) + bitShiftLeft(100::UInt128, 32) + 200::UInt128)`, MetaOut: Meta{MainTableRequired: true}},
|
{Input: `DstCommunities != 65000:100:200`, Output: `NOT has(DstLargeCommunities, bitShiftLeft(65000::UInt128, 64) + bitShiftLeft(100::UInt128, 32) + 200::UInt128)`, MetaOut: Meta{MainTableRequired: true}},
|
||||||
{Input: `SrcVlan = 1000`, Output: `SrcVlan = 1000`},
|
{Input: `SrcVlan = 1000`, Output: `SrcVlan = 1000`},
|
||||||
{Input: `DstVlan = 1000`, Output: `DstVlan = 1000`},
|
{Input: `DstVlan = 1000`, Output: `DstVlan = 1000`},
|
||||||
{Input: `SrcAddrNAT = 203.0.113.4`, Output: `SrcAddrNAT = toIPv6('203.0.113.4')`,
|
{
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
Input: `SrcAddrNAT = 203.0.113.4`, Output: `SrcAddrNAT = toIPv6('203.0.113.4')`,
|
||||||
{Input: `DstAddrNAT = 203.0.113.4`, Output: `DstAddrNAT = toIPv6('203.0.113.4')`,
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
},
|
||||||
{Input: `SrcPortNAT = 22`, Output: `SrcPortNAT = 22`,
|
{
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
Input: `DstAddrNAT = 203.0.113.4`, Output: `DstAddrNAT = toIPv6('203.0.113.4')`,
|
||||||
{Input: `DstPortNAT = 22`, Output: `DstPortNAT = 22`,
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
MetaOut: Meta{MainTableRequired: true}},
|
},
|
||||||
|
{
|
||||||
|
Input: `SrcPortNAT = 22`, Output: `SrcPortNAT = 22`,
|
||||||
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Input: `DstPortNAT = 22`, Output: `DstPortNAT = 22`,
|
||||||
|
MetaOut: Meta{MainTableRequired: true},
|
||||||
|
},
|
||||||
{Input: `SrcMAC = 00:11:22:33:44:55`, Output: `SrcMAC = MACStringToNum('00:11:22:33:44:55')`},
|
{Input: `SrcMAC = 00:11:22:33:44:55`, Output: `SrcMAC = MACStringToNum('00:11:22:33:44:55')`},
|
||||||
{Input: `DstMAC = 00:11:22:33:44:55`, Output: `DstMAC = MACStringToNum('00:11:22:33:44:55')`},
|
{Input: `DstMAC = 00:11:22:33:44:55`, Output: `DstMAC = MACStringToNum('00:11:22:33:44:55')`},
|
||||||
{Input: `SrcMAC != 00:0c:fF:33:44:55`, Output: `SrcMAC != MACStringToNum('00:0c:ff:33:44:55')`},
|
{Input: `SrcMAC != 00:0c:fF:33:44:55`, Output: `SrcMAC != MACStringToNum('00:0c:ff:33:44:55')`},
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ LIMIT 20`,
|
|||||||
}{
|
}{
|
||||||
{"th2-router1"},
|
{"th2-router1"},
|
||||||
{"th2-router2"},
|
{"th2-router2"},
|
||||||
{"th2-router3"}}).
|
{"th2-router3"},
|
||||||
|
}).
|
||||||
Return(nil)
|
Return(nil)
|
||||||
mockConn.EXPECT().
|
mockConn.EXPECT().
|
||||||
Select(gomock.Any(), gomock.Any(), `
|
Select(gomock.Any(), gomock.Any(), `
|
||||||
@@ -138,7 +139,8 @@ LIMIT 20`, "6540").
|
|||||||
JSONInput: gin.H{"filter": `InIfName = "Gi0/0/0/1"`},
|
JSONInput: gin.H{"filter": `InIfName = "Gi0/0/0/1"`},
|
||||||
JSONOutput: gin.H{
|
JSONOutput: gin.H{
|
||||||
"message": "ok",
|
"message": "ok",
|
||||||
"parsed": `InIfName = 'Gi0/0/0/1'`},
|
"parsed": `InIfName = 'Gi0/0/0/1'`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
URL: "/api/v0/console/filter/validate",
|
URL: "/api/v0/console/filter/validate",
|
||||||
@@ -152,7 +154,8 @@ LIMIT 20`, "6540").
|
|||||||
"message": "string literal not terminated",
|
"message": "string literal not terminated",
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "column", "prefix": "dSt"},
|
JSONInput: gin.H{"what": "column", "prefix": "dSt"},
|
||||||
@@ -173,7 +176,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "DstNetTenant", "detail": "column name", "quoted": false},
|
{"label": "DstNetTenant", "detail": "column name", "quoted": false},
|
||||||
{"label": "DstPort", "detail": "column name", "quoted": false},
|
{"label": "DstPort", "detail": "column name", "quoted": false},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "operator", "column": "ExporterName"},
|
JSONInput: gin.H{"what": "operator", "column": "ExporterName"},
|
||||||
@@ -187,7 +191,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "NOTIN (", "detail": "comparison operator", "quoted": false},
|
{"label": "NOTIN (", "detail": "comparison operator", "quoted": false},
|
||||||
{"label": "UNLIKE", "detail": "comparison operator", "quoted": false},
|
{"label": "UNLIKE", "detail": "comparison operator", "quoted": false},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "outifboundary"},
|
JSONInput: gin.H{"what": "value", "column": "outifboundary"},
|
||||||
@@ -196,7 +201,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "external", "detail": "network boundary", "quoted": false},
|
{"label": "external", "detail": "network boundary", "quoted": false},
|
||||||
{"label": "undefined", "detail": "network boundary", "quoted": false},
|
{"label": "undefined", "detail": "network boundary", "quoted": false},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "etype"},
|
JSONInput: gin.H{"what": "value", "column": "etype"},
|
||||||
@@ -204,7 +210,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "IPv4", "detail": "ethernet type", "quoted": false},
|
{"label": "IPv4", "detail": "ethernet type", "quoted": false},
|
||||||
{"label": "IPv6", "detail": "ethernet type", "quoted": false},
|
{"label": "IPv6", "detail": "ethernet type", "quoted": false},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "proto", "prefix": "I"},
|
JSONInput: gin.H{"what": "value", "column": "proto", "prefix": "I"},
|
||||||
@@ -216,7 +223,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "IPv4", "detail": "protocol", "quoted": true},
|
{"label": "IPv4", "detail": "protocol", "quoted": true},
|
||||||
{"label": "IPv6", "detail": "protocol", "quoted": true},
|
{"label": "IPv6", "detail": "protocol", "quoted": true},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "exportername", "prefix": "th2-"},
|
JSONInput: gin.H{"what": "value", "column": "exportername", "prefix": "th2-"},
|
||||||
@@ -225,7 +233,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "th2-router2", "detail": "exporter name", "quoted": true},
|
{"label": "th2-router2", "detail": "exporter name", "quoted": true},
|
||||||
{"label": "th2-router3", "detail": "exporter name", "quoted": true},
|
{"label": "th2-router3", "detail": "exporter name", "quoted": true},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "dstAS", "prefix": "goog"},
|
JSONInput: gin.H{"what": "value", "column": "dstAS", "prefix": "goog"},
|
||||||
@@ -242,7 +251,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "AS36987", "detail": "Google Kenya", "quoted": false},
|
{"label": "AS36987", "detail": "Google Kenya", "quoted": false},
|
||||||
{"label": "AS41264", "detail": "Google Switzerland", "quoted": false},
|
{"label": "AS41264", "detail": "Google Switzerland", "quoted": false},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "dstcommunities", "prefix": "6540"},
|
JSONInput: gin.H{"what": "value", "column": "dstcommunities", "prefix": "6540"},
|
||||||
@@ -252,7 +262,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "65401:13", "detail": "community", "quoted": false},
|
{"label": "65401:13", "detail": "community", "quoted": false},
|
||||||
{"label": "65402:200:100", "detail": "large community", "quoted": false},
|
{"label": "65402:200:100", "detail": "large community", "quoted": false},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "dstASpath", "prefix": "goog"},
|
JSONInput: gin.H{"what": "value", "column": "dstASpath", "prefix": "goog"},
|
||||||
@@ -269,7 +280,8 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "AS36987", "detail": "Google Kenya", "quoted": false},
|
{"label": "AS36987", "detail": "Google Kenya", "quoted": false},
|
||||||
{"label": "AS41264", "detail": "Google Switzerland", "quoted": false},
|
{"label": "AS41264", "detail": "Google Switzerland", "quoted": false},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "srcnetName", "prefix": "c"},
|
JSONInput: gin.H{"what": "value", "column": "srcnetName", "prefix": "c"},
|
||||||
@@ -278,19 +290,22 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "customer-2", "detail": "network name", "quoted": true},
|
{"label": "customer-2", "detail": "network name", "quoted": true},
|
||||||
{"label": "customer-3", "detail": "network name", "quoted": true},
|
{"label": "customer-3", "detail": "network name", "quoted": true},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONInput: gin.H{"what": "value", "column": "dstnetRole", "prefix": "c"},
|
JSONInput: gin.H{"what": "value", "column": "dstnetRole", "prefix": "c"},
|
||||||
JSONOutput: gin.H{"completions": []gin.H{
|
JSONOutput: gin.H{"completions": []gin.H{
|
||||||
{"label": "customer", "detail": "network name", "quoted": true},
|
{"label": "customer", "detail": "network name", "quoted": true},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Description: "list, no filters",
|
Description: "list, no filters",
|
||||||
URL: "/api/v0/console/filter/saved",
|
URL: "/api/v0/console/filter/saved",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
JSONOutput: gin.H{"filters": []gin.H{}},
|
JSONOutput: gin.H{"filters": []gin.H{}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Description: "store one filter",
|
Description: "store one filter",
|
||||||
URL: "/api/v0/console/filter/saved",
|
URL: "/api/v0/console/filter/saved",
|
||||||
StatusCode: 204,
|
StatusCode: 204,
|
||||||
@@ -299,7 +314,8 @@ LIMIT 20`, "6540").
|
|||||||
"content": "InIfBoundary = external",
|
"content": "InIfBoundary = external",
|
||||||
},
|
},
|
||||||
ContentType: "application/json; charset=utf-8",
|
ContentType: "application/json; charset=utf-8",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Description: "list stored filters",
|
Description: "list stored filters",
|
||||||
URL: "/api/v0/console/filter/saved",
|
URL: "/api/v0/console/filter/saved",
|
||||||
JSONOutput: gin.H{"filters": []gin.H{
|
JSONOutput: gin.H{"filters": []gin.H{
|
||||||
@@ -311,7 +327,8 @@ LIMIT 20`, "6540").
|
|||||||
"content": "InIfBoundary = external",
|
"content": "InIfBoundary = external",
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Description: "list stored filters as another user",
|
Description: "list stored filters as another user",
|
||||||
URL: "/api/v0/console/filter/saved",
|
URL: "/api/v0/console/filter/saved",
|
||||||
Header: func() netHTTP.Header {
|
Header: func() netHTTP.Header {
|
||||||
@@ -320,7 +337,8 @@ LIMIT 20`, "6540").
|
|||||||
return headers
|
return headers
|
||||||
}(),
|
}(),
|
||||||
JSONOutput: gin.H{"filters": []gin.H{}},
|
JSONOutput: gin.H{"filters": []gin.H{}},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Description: "delete stored filter as another user",
|
Description: "delete stored filter as another user",
|
||||||
Method: "DELETE",
|
Method: "DELETE",
|
||||||
URL: "/api/v0/console/filter/saved/1",
|
URL: "/api/v0/console/filter/saved/1",
|
||||||
@@ -331,19 +349,22 @@ LIMIT 20`, "6540").
|
|||||||
}(),
|
}(),
|
||||||
StatusCode: 404,
|
StatusCode: 404,
|
||||||
JSONOutput: gin.H{"message": "filter not found"},
|
JSONOutput: gin.H{"message": "filter not found"},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Description: "delete stored filter",
|
Description: "delete stored filter",
|
||||||
Method: "DELETE",
|
Method: "DELETE",
|
||||||
URL: "/api/v0/console/filter/saved/1",
|
URL: "/api/v0/console/filter/saved/1",
|
||||||
StatusCode: 204,
|
StatusCode: 204,
|
||||||
ContentType: "application/json; charset=utf-8",
|
ContentType: "application/json; charset=utf-8",
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Description: "delete stored filter with invalid ID",
|
Description: "delete stored filter with invalid ID",
|
||||||
Method: "DELETE",
|
Method: "DELETE",
|
||||||
URL: "/api/v0/console/filter/saved/kjgdfhgh",
|
URL: "/api/v0/console/filter/saved/kjgdfhgh",
|
||||||
StatusCode: 400,
|
StatusCode: 400,
|
||||||
JSONOutput: gin.H{"message": "bad ID format"},
|
JSONOutput: gin.H{"message": "bad ID format"},
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
Description: "list stored filter after delete",
|
Description: "list stored filter after delete",
|
||||||
URL: "/api/v0/console/filter/saved",
|
URL: "/api/v0/console/filter/saved",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import (
|
|||||||
func TestGraphInputReverseDirection(t *testing.T) {
|
func TestGraphInputReverseDirection(t *testing.T) {
|
||||||
input := graphHandlerInput{
|
input := graphHandlerInput{
|
||||||
schema: schema.NewMock(t),
|
schema: schema.NewMock(t),
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: query.Columns{
|
Dimensions: query.Columns{
|
||||||
query.NewColumn("ExporterName"),
|
query.NewColumn("ExporterName"),
|
||||||
@@ -32,8 +32,8 @@ func TestGraphInputReverseDirection(t *testing.T) {
|
|||||||
}
|
}
|
||||||
original1 := fmt.Sprintf("%+v", input)
|
original1 := fmt.Sprintf("%+v", input)
|
||||||
expected := graphHandlerInput{
|
expected := graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: query.Columns{
|
Dimensions: query.Columns{
|
||||||
query.NewColumn("ExporterName"),
|
query.NewColumn("ExporterName"),
|
||||||
@@ -147,8 +147,8 @@ func TestGraphQuerySQL(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Description: "no dimensions, no filters, bps",
|
Description: "no dimensions, no filters, bps",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: []query.Column{},
|
Dimensions: []query.Column{},
|
||||||
Filter: query.Filter{},
|
Filter: query.Filter{},
|
||||||
@@ -173,8 +173,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no dimensions, no filters, l2 bps",
|
Description: "no dimensions, no filters, l2 bps",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: []query.Column{},
|
Dimensions: []query.Column{},
|
||||||
Filter: query.Filter{},
|
Filter: query.Filter{},
|
||||||
@@ -200,8 +200,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no dimensions, no filters, pps",
|
Description: "no dimensions, no filters, pps",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: []query.Column{},
|
Dimensions: []query.Column{},
|
||||||
Filter: query.Filter{},
|
Filter: query.Filter{},
|
||||||
@@ -226,8 +226,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no dimensions",
|
Description: "no dimensions",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: []query.Column{},
|
Dimensions: []query.Column{},
|
||||||
Filter: query.NewFilter("DstCountry = 'FR' AND SrcCountry = 'US'"),
|
Filter: query.NewFilter("DstCountry = 'FR' AND SrcCountry = 'US'"),
|
||||||
@@ -252,8 +252,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no dimensions, escaped filter",
|
Description: "no dimensions, escaped filter",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: []query.Column{},
|
Dimensions: []query.Column{},
|
||||||
Filter: query.NewFilter("InIfDescription = '{{ hello }}' AND SrcCountry = 'US'"),
|
Filter: query.NewFilter("InIfDescription = '{{ hello }}' AND SrcCountry = 'US'"),
|
||||||
@@ -278,8 +278,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no dimensions, reverse direction",
|
Description: "no dimensions, reverse direction",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: []query.Column{},
|
Dimensions: []query.Column{},
|
||||||
Filter: query.NewFilter("DstCountry = 'FR' AND SrcCountry = 'US'"),
|
Filter: query.NewFilter("DstCountry = 'FR' AND SrcCountry = 'US'"),
|
||||||
@@ -321,8 +321,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no dimensions, reverse direction, inl2%",
|
Description: "no dimensions, reverse direction, inl2%",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Dimensions: []query.Column{},
|
Dimensions: []query.Column{},
|
||||||
Filter: query.NewFilter("DstCountry = 'FR' AND SrcCountry = 'US'"),
|
Filter: query.NewFilter("DstCountry = 'FR' AND SrcCountry = 'US'"),
|
||||||
@@ -364,8 +364,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no filters",
|
Description: "no filters",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Limit: 20,
|
Limit: 20,
|
||||||
Dimensions: []query.Column{
|
Dimensions: []query.Column{
|
||||||
@@ -396,8 +396,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no filters, reverse",
|
Description: "no filters, reverse",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Limit: 20,
|
Limit: 20,
|
||||||
Dimensions: []query.Column{
|
Dimensions: []query.Column{
|
||||||
@@ -445,8 +445,8 @@ ORDER BY time WITH FILL
|
|||||||
}, {
|
}, {
|
||||||
Description: "no filters, previous period",
|
Description: "no filters, previous period",
|
||||||
Input: graphHandlerInput{
|
Input: graphHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Points: 100,
|
Points: 100,
|
||||||
Limit: 20,
|
Limit: 20,
|
||||||
Dimensions: []query.Column{
|
Dimensions: []query.Column{
|
||||||
@@ -624,8 +624,8 @@ func TestGraphHandler(t *testing.T) {
|
|||||||
Description: "single direction",
|
Description: "single direction",
|
||||||
URL: "/api/v0/console/graph",
|
URL: "/api/v0/console/graph",
|
||||||
JSONInput: gin.H{
|
JSONInput: gin.H{
|
||||||
"start": time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
"start": time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
"end": time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
"end": time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
"points": 100,
|
"points": 100,
|
||||||
"limit": 20,
|
"limit": 20,
|
||||||
"dimensions": []string{"ExporterName", "InIfProvider"},
|
"dimensions": []string{"ExporterName", "InIfProvider"},
|
||||||
@@ -699,8 +699,8 @@ func TestGraphHandler(t *testing.T) {
|
|||||||
Description: "bidirectional",
|
Description: "bidirectional",
|
||||||
URL: "/api/v0/console/graph",
|
URL: "/api/v0/console/graph",
|
||||||
JSONInput: gin.H{
|
JSONInput: gin.H{
|
||||||
"start": time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
"start": time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
"end": time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
"end": time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
"points": 100,
|
"points": 100,
|
||||||
"limit": 20,
|
"limit": 20,
|
||||||
"dimensions": []string{"ExporterName", "InIfProvider"},
|
"dimensions": []string{"ExporterName", "InIfProvider"},
|
||||||
@@ -818,8 +818,8 @@ func TestGraphHandler(t *testing.T) {
|
|||||||
Description: "previous period",
|
Description: "previous period",
|
||||||
URL: "/api/v0/console/graph",
|
URL: "/api/v0/console/graph",
|
||||||
JSONInput: gin.H{
|
JSONInput: gin.H{
|
||||||
"start": time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
"start": time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
"end": time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
"end": time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
"points": 100,
|
"points": 100,
|
||||||
"limit": 20,
|
"limit": 20,
|
||||||
"dimensions": []string{"ExporterName", "InIfProvider"},
|
"dimensions": []string{"ExporterName", "InIfProvider"},
|
||||||
|
|||||||
@@ -25,11 +25,12 @@ func TestSankeyQuerySQL(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Description: "two dimensions, no filters, l3 bps",
|
Description: "two dimensions, no filters, l3 bps",
|
||||||
Input: sankeyHandlerInput{
|
Input: sankeyHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Dimensions: []query.Column{
|
Dimensions: []query.Column{
|
||||||
query.NewColumn("SrcAS"),
|
query.NewColumn("SrcAS"),
|
||||||
query.NewColumn("ExporterName")},
|
query.NewColumn("ExporterName"),
|
||||||
|
},
|
||||||
Limit: 5,
|
Limit: 5,
|
||||||
Filter: query.Filter{},
|
Filter: query.Filter{},
|
||||||
Units: "l3bps",
|
Units: "l3bps",
|
||||||
@@ -51,11 +52,12 @@ ORDER BY xps DESC
|
|||||||
}, {
|
}, {
|
||||||
Description: "two dimensions, no filters, l2 bps",
|
Description: "two dimensions, no filters, l2 bps",
|
||||||
Input: sankeyHandlerInput{
|
Input: sankeyHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Dimensions: []query.Column{
|
Dimensions: []query.Column{
|
||||||
query.NewColumn("SrcAS"),
|
query.NewColumn("SrcAS"),
|
||||||
query.NewColumn("ExporterName")},
|
query.NewColumn("ExporterName"),
|
||||||
|
},
|
||||||
Limit: 5,
|
Limit: 5,
|
||||||
Filter: query.Filter{},
|
Filter: query.Filter{},
|
||||||
Units: "l2bps",
|
Units: "l2bps",
|
||||||
@@ -78,11 +80,12 @@ ORDER BY xps DESC
|
|||||||
}, {
|
}, {
|
||||||
Description: "two dimensions, no filters, pps",
|
Description: "two dimensions, no filters, pps",
|
||||||
Input: sankeyHandlerInput{
|
Input: sankeyHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Dimensions: []query.Column{
|
Dimensions: []query.Column{
|
||||||
query.NewColumn("SrcAS"),
|
query.NewColumn("SrcAS"),
|
||||||
query.NewColumn("ExporterName")},
|
query.NewColumn("ExporterName"),
|
||||||
|
},
|
||||||
Limit: 5,
|
Limit: 5,
|
||||||
Filter: query.Filter{},
|
Filter: query.Filter{},
|
||||||
Units: "pps",
|
Units: "pps",
|
||||||
@@ -104,11 +107,12 @@ ORDER BY xps DESC
|
|||||||
}, {
|
}, {
|
||||||
Description: "two dimensions, with filter",
|
Description: "two dimensions, with filter",
|
||||||
Input: sankeyHandlerInput{
|
Input: sankeyHandlerInput{
|
||||||
Start: time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
Start: time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
End: time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
End: time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
Dimensions: []query.Column{
|
Dimensions: []query.Column{
|
||||||
query.NewColumn("SrcAS"),
|
query.NewColumn("SrcAS"),
|
||||||
query.NewColumn("ExporterName")},
|
query.NewColumn("ExporterName"),
|
||||||
|
},
|
||||||
Limit: 10,
|
Limit: 10,
|
||||||
Filter: query.NewFilter("DstCountry = 'FR'"),
|
Filter: query.NewFilter("DstCountry = 'FR'"),
|
||||||
Units: "l3bps",
|
Units: "l3bps",
|
||||||
@@ -190,8 +194,8 @@ func TestSankeyHandler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
URL: "/api/v0/console/sankey",
|
URL: "/api/v0/console/sankey",
|
||||||
JSONInput: gin.H{
|
JSONInput: gin.H{
|
||||||
"start": time.Date(2022, 04, 10, 15, 45, 10, 0, time.UTC),
|
"start": time.Date(2022, 4, 10, 15, 45, 10, 0, time.UTC),
|
||||||
"end": time.Date(2022, 04, 11, 15, 45, 10, 0, time.UTC),
|
"end": time.Date(2022, 4, 11, 15, 45, 10, 0, time.UTC),
|
||||||
"dimensions": []string{"SrcAS", "InIfProvider", "ExporterName"},
|
"dimensions": []string{"SrcAS", "InIfProvider", "ExporterName"},
|
||||||
"limit": 10,
|
"limit": 10,
|
||||||
"filter": "DstCountry = 'FR'",
|
"filter": "DstCountry = 'FR'",
|
||||||
@@ -260,54 +264,102 @@ func TestSankeyHandler(t *testing.T) {
|
|||||||
"ExporterName: router2",
|
"ExporterName: router2",
|
||||||
},
|
},
|
||||||
"links": []gin.H{
|
"links": []gin.H{
|
||||||
{"source": "InIfProvider: provider1", "target": "ExporterName: Other",
|
{
|
||||||
"xps": 9472 + 7234 + 6006 + 5988},
|
"source": "InIfProvider: provider1", "target": "ExporterName: Other",
|
||||||
{"source": "InIfProvider: Other", "target": "ExporterName: router1",
|
"xps": 9472 + 7234 + 6006 + 5988,
|
||||||
"xps": 9677 + 3623 + 2915 + 1360},
|
},
|
||||||
{"source": "SrcAS: AS100", "target": "InIfProvider: Other",
|
{
|
||||||
"xps": 9677},
|
"source": "InIfProvider: Other", "target": "ExporterName: router1",
|
||||||
{"source": "SrcAS: AS300", "target": "InIfProvider: provider1",
|
"xps": 9677 + 3623 + 2915 + 1360,
|
||||||
"xps": 9472},
|
},
|
||||||
{"source": "InIfProvider: provider3", "target": "ExporterName: Other",
|
{
|
||||||
"xps": 4675 + 3999},
|
"source": "SrcAS: AS100", "target": "InIfProvider: Other",
|
||||||
{"source": "SrcAS: AS100", "target": "InIfProvider: provider1",
|
"xps": 9677,
|
||||||
"xps": 6006 + 2623},
|
},
|
||||||
{"source": "SrcAS: AS100", "target": "InIfProvider: provider3",
|
{
|
||||||
"xps": 3999 + 3978},
|
"source": "SrcAS: AS300", "target": "InIfProvider: provider1",
|
||||||
{"source": "InIfProvider: provider3", "target": "ExporterName: router2",
|
"xps": 9472,
|
||||||
"xps": 3978 + 3080 + 717},
|
},
|
||||||
{"source": "InIfProvider: provider2", "target": "ExporterName: router1",
|
{
|
||||||
"xps": 7593},
|
"source": "InIfProvider: provider3", "target": "ExporterName: Other",
|
||||||
{"source": "SrcAS: AS300", "target": "InIfProvider: provider2",
|
"xps": 4675 + 3999,
|
||||||
"xps": 7593},
|
},
|
||||||
{"source": "SrcAS: AS200", "target": "InIfProvider: provider1",
|
{
|
||||||
"xps": 7234},
|
"source": "SrcAS: AS100", "target": "InIfProvider: provider1",
|
||||||
{"source": "SrcAS: Other", "target": "InIfProvider: provider1",
|
"xps": 6006 + 2623,
|
||||||
"xps": 5988 + 159},
|
},
|
||||||
{"source": "SrcAS: AS200", "target": "InIfProvider: Other",
|
{
|
||||||
"xps": 4348 + 1360},
|
"source": "SrcAS: AS100", "target": "InIfProvider: provider3",
|
||||||
{"source": "SrcAS: AS200", "target": "InIfProvider: provider3",
|
"xps": 3999 + 3978,
|
||||||
"xps": 4675 + 717},
|
},
|
||||||
{"source": "InIfProvider: Other", "target": "ExporterName: router2",
|
{
|
||||||
"xps": 4348},
|
"source": "InIfProvider: provider3", "target": "ExporterName: router2",
|
||||||
{"source": "SrcAS: Other", "target": "InIfProvider: Other",
|
"xps": 3978 + 3080 + 717,
|
||||||
"xps": 3623 + 621},
|
},
|
||||||
{"source": "SrcAS: AS300", "target": "InIfProvider: Other",
|
{
|
||||||
"xps": 2915 + 975},
|
"source": "InIfProvider: provider2", "target": "ExporterName: router1",
|
||||||
{"source": "SrcAS: AS300", "target": "InIfProvider: provider3",
|
"xps": 7593,
|
||||||
"xps": 3080},
|
},
|
||||||
{"source": "InIfProvider: provider1", "target": "ExporterName: router1",
|
{
|
||||||
"xps": 2623 + 159},
|
"source": "SrcAS: AS300", "target": "InIfProvider: provider2",
|
||||||
{"source": "InIfProvider: provider2", "target": "ExporterName: router2",
|
"xps": 7593,
|
||||||
"xps": 2482},
|
},
|
||||||
{"source": "SrcAS: AS200", "target": "InIfProvider: provider2",
|
{
|
||||||
"xps": 2482},
|
"source": "SrcAS: AS200", "target": "InIfProvider: provider1",
|
||||||
{"source": "InIfProvider: provider2", "target": "ExporterName: Other",
|
"xps": 7234,
|
||||||
"xps": 2234},
|
},
|
||||||
{"source": "SrcAS: AS100", "target": "InIfProvider: provider2",
|
{
|
||||||
"xps": 2234},
|
"source": "SrcAS: Other", "target": "InIfProvider: provider1",
|
||||||
{"source": "InIfProvider: Other", "target": "ExporterName: Other",
|
"xps": 5988 + 159,
|
||||||
"xps": 975 + 621},
|
},
|
||||||
|
{
|
||||||
|
"source": "SrcAS: AS200", "target": "InIfProvider: Other",
|
||||||
|
"xps": 4348 + 1360,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "SrcAS: AS200", "target": "InIfProvider: provider3",
|
||||||
|
"xps": 4675 + 717,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "InIfProvider: Other", "target": "ExporterName: router2",
|
||||||
|
"xps": 4348,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "SrcAS: Other", "target": "InIfProvider: Other",
|
||||||
|
"xps": 3623 + 621,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "SrcAS: AS300", "target": "InIfProvider: Other",
|
||||||
|
"xps": 2915 + 975,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "SrcAS: AS300", "target": "InIfProvider: provider3",
|
||||||
|
"xps": 3080,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "InIfProvider: provider1", "target": "ExporterName: router1",
|
||||||
|
"xps": 2623 + 159,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "InIfProvider: provider2", "target": "ExporterName: router2",
|
||||||
|
"xps": 2482,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "SrcAS: AS200", "target": "InIfProvider: provider2",
|
||||||
|
"xps": 2482,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "InIfProvider: provider2", "target": "ExporterName: Other",
|
||||||
|
"xps": 2234,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "SrcAS: AS100", "target": "InIfProvider: provider2",
|
||||||
|
"xps": 2234,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "InIfProvider: Other", "target": "ExporterName: Other",
|
||||||
|
"xps": 975 + 621,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -195,28 +195,36 @@ func TestWidgetTop(t *testing.T) {
|
|||||||
"top": []gin.H{
|
"top": []gin.H{
|
||||||
{"name": "TCP/443", "percent": 51},
|
{"name": "TCP/443", "percent": 51},
|
||||||
{"name": "UDP/443", "percent": 20},
|
{"name": "UDP/443", "percent": 20},
|
||||||
{"name": "TCP/80", "percent": 18}}},
|
{"name": "TCP/80", "percent": 18},
|
||||||
|
},
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
URL: "/api/v0/console/widget/top/protocol",
|
URL: "/api/v0/console/widget/top/protocol",
|
||||||
JSONOutput: gin.H{
|
JSONOutput: gin.H{
|
||||||
"top": []gin.H{
|
"top": []gin.H{
|
||||||
{"name": "TCP", "percent": 75},
|
{"name": "TCP", "percent": 75},
|
||||||
{"name": "UDP", "percent": 24},
|
{"name": "UDP", "percent": 24},
|
||||||
{"name": "ESP", "percent": 1}}},
|
{"name": "ESP", "percent": 1},
|
||||||
|
},
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
URL: "/api/v0/console/widget/top/exporter",
|
URL: "/api/v0/console/widget/top/exporter",
|
||||||
JSONOutput: gin.H{
|
JSONOutput: gin.H{
|
||||||
"top": []gin.H{
|
"top": []gin.H{
|
||||||
{"name": "exporter1", "percent": 20},
|
{"name": "exporter1", "percent": 20},
|
||||||
{"name": "exporter3", "percent": 10},
|
{"name": "exporter3", "percent": 10},
|
||||||
{"name": "exporter5", "percent": 3}}},
|
{"name": "exporter5", "percent": 3},
|
||||||
|
},
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
URL: "/api/v0/console/widget/top/src-as",
|
URL: "/api/v0/console/widget/top/src-as",
|
||||||
JSONOutput: gin.H{
|
JSONOutput: gin.H{
|
||||||
"top": []gin.H{
|
"top": []gin.H{
|
||||||
{"name": "2906: Netflix", "percent": 12},
|
{"name": "2906: Netflix", "percent": 12},
|
||||||
{"name": "36040: Youtube", "percent": 10},
|
{"name": "36040: Youtube", "percent": 10},
|
||||||
{"name": "20940: Akamai", "percent": 9}}},
|
{"name": "20940: Akamai", "percent": 9},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -263,9 +271,9 @@ ORDER BY Time WITH FILL
|
|||||||
{"t": "2009-11-10T23:02:00Z", "gbps": 26.4},
|
{"t": "2009-11-10T23:02:00Z", "gbps": 26.4},
|
||||||
{"t": "2009-11-10T23:03:00Z", "gbps": 29.2},
|
{"t": "2009-11-10T23:03:00Z", "gbps": 29.2},
|
||||||
{"t": "2009-11-10T23:04:00Z", "gbps": 0},
|
{"t": "2009-11-10T23:04:00Z", "gbps": 0},
|
||||||
{"t": "2009-11-10T23:05:00Z", "gbps": 24.7}},
|
{"t": "2009-11-10T23:05:00Z", "gbps": 24.7},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
package demoexporter
|
package demoexporter
|
||||||
|
|
||||||
// Configuration describes the configuration for the demo exporter component.
|
// Configuration describes the configuration for the demo exporter component.
|
||||||
type Configuration struct {
|
type Configuration struct{}
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultConfiguration represents the default configuration for the demo exporter component.
|
// DefaultConfiguration represents the default configuration for the demo exporter component.
|
||||||
func DefaultConfiguration() Configuration {
|
func DefaultConfiguration() Configuration {
|
||||||
|
|||||||
@@ -25,12 +25,13 @@ func TestGetNetflowData(t *testing.T) {
|
|||||||
context.Background(),
|
context.Background(),
|
||||||
50,
|
50,
|
||||||
30000,
|
30000,
|
||||||
time.Date(2022, 03, 15, 14, 33, 0, 0, time.UTC),
|
time.Date(2022, 3, 15, 14, 33, 0, 0, time.UTC),
|
||||||
time.Date(2022, 03, 15, 15, 33, 0, 0, time.UTC))
|
time.Date(2022, 3, 15, 15, 33, 0, 0, time.UTC))
|
||||||
got := []interface{}{}
|
got := []interface{}{}
|
||||||
for payload := range ch {
|
for payload := range ch {
|
||||||
got = append(got, nfdecoder.Decode(decoder.RawFlow{
|
got = append(got, nfdecoder.Decode(decoder.RawFlow{
|
||||||
Payload: payload, Source: net.ParseIP("127.0.0.1")}))
|
Payload: payload, Source: net.ParseIP("127.0.0.1"),
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
ch = getNetflowData(
|
ch = getNetflowData(
|
||||||
@@ -93,11 +94,12 @@ func TestGetNetflowData(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
100,
|
100,
|
||||||
time.Date(2022, 03, 15, 14, 33, 0, 0, time.UTC),
|
time.Date(2022, 3, 15, 14, 33, 0, 0, time.UTC),
|
||||||
time.Date(2022, 03, 15, 16, 33, 0, 0, time.UTC))
|
time.Date(2022, 3, 15, 16, 33, 0, 0, time.UTC))
|
||||||
for payload := range ch {
|
for payload := range ch {
|
||||||
got = append(got, nfdecoder.Decode(decoder.RawFlow{
|
got = append(got, nfdecoder.Decode(decoder.RawFlow{
|
||||||
Payload: payload, Source: net.ParseIP("127.0.0.1")}))
|
Payload: payload, Source: net.ParseIP("127.0.0.1"),
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
expected := []interface{}{
|
expected := []interface{}{
|
||||||
[]interface{}{}, // templates
|
[]interface{}{}, // templates
|
||||||
|
|||||||
@@ -95,5 +95,4 @@ func TestSNMPServer(t *testing.T) {
|
|||||||
if diff := helpers.Diff(gotMetrics, expectedMetrics); diff != "" {
|
if diff := helpers.Diff(gotMetrics, expectedMetrics); diff != "" {
|
||||||
t.Fatalf("Metrics (-got, +want):\n%s", diff)
|
t.Fatalf("Metrics (-got, +want):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,79 +46,98 @@ func TestRTAEqual(t *testing.T) {
|
|||||||
routeAttributes{asn: 2038, asPath: []uint32{}},
|
routeAttributes{asn: 2038, asPath: []uint32{}},
|
||||||
routeAttributes{asn: 2038},
|
routeAttributes{asn: 2038},
|
||||||
true,
|
true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{}},
|
routeAttributes{asn: 2038, asPath: []uint32{}},
|
||||||
routeAttributes{asn: 2039},
|
routeAttributes{asn: 2039},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, communities: []uint32{}},
|
routeAttributes{asn: 2038, communities: []uint32{}},
|
||||||
routeAttributes{asn: 2038},
|
routeAttributes{asn: 2038},
|
||||||
true,
|
true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, communities: []uint32{}},
|
routeAttributes{asn: 2038, communities: []uint32{}},
|
||||||
routeAttributes{asn: 2039},
|
routeAttributes{asn: 2039},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{}},
|
||||||
routeAttributes{asn: 2038},
|
routeAttributes{asn: 2038},
|
||||||
true,
|
true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{}},
|
||||||
routeAttributes{asn: 2039},
|
routeAttributes{asn: 2039},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
||||||
true,
|
true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4}},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 0}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 0}},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3}},
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 4}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 4}},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4}},
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4}},
|
||||||
true,
|
true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}},
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}},
|
||||||
true,
|
true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}},
|
||||||
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35}},
|
routeAttributes{asn: 2038, asPath: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35}},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 400}},
|
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 400}},
|
||||||
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 400}},
|
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 400}},
|
||||||
true,
|
true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 400}},
|
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 400}},
|
||||||
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 402}},
|
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 402}},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300}},
|
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300}},
|
||||||
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 400}},
|
routeAttributes{asn: 2038, communities: []uint32{100, 200, 300, 400}},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
||||||
true,
|
true,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 8}}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 8}}},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 4}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 4}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
||||||
false,
|
false,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}}},
|
||||||
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
routeAttributes{asn: 2038, largeCommunities: []bgp.LargeCommunity{{ASN: 1, LocalData1: 2, LocalData2: 3}, {ASN: 3, LocalData1: 4, LocalData2: 5}, {ASN: 5, LocalData1: 6, LocalData2: 7}}},
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -1004,7 +1004,6 @@ func TestBMP(t *testing.T) {
|
|||||||
if diff := helpers.Diff(gotRIB, expectedRIB); diff != "" {
|
if diff := helpers.Diff(gotRIB, expectedRIB); diff != "" {
|
||||||
t.Errorf("RIB (-got, +want):\n%s", diff)
|
t.Errorf("RIB (-got, +want):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("init, peers up, eor, reach NLRI, conn down, immediate timeout", func(t *testing.T) {
|
t.Run("init, peers up, eor, reach NLRI, conn down, immediate timeout", func(t *testing.T) {
|
||||||
|
|||||||
@@ -40,8 +40,10 @@ type exporterClassification struct {
|
|||||||
Tenant string
|
Tenant string
|
||||||
}
|
}
|
||||||
|
|
||||||
type classifyStringFunc = func(string) bool
|
type (
|
||||||
type classifyStringRegexFunc = func(string, string, string) (bool, error)
|
classifyStringFunc = func(string) bool
|
||||||
|
classifyStringRegexFunc = func(string, string, string) (bool, error)
|
||||||
|
)
|
||||||
|
|
||||||
// exporterClassifierEnvironment defines the environment used by the exporter classifier
|
// exporterClassifierEnvironment defines the environment used by the exporter classifier
|
||||||
type exporterClassifierEnvironment struct {
|
type exporterClassifierEnvironment struct {
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ func (nd *Decoder) Decode(in decoder.RawFlow) []*schema.FlowMessage {
|
|||||||
ts := uint64(in.TimeReceived.UTC().Unix())
|
ts := uint64(in.TimeReceived.UTC().Unix())
|
||||||
buf := bytes.NewBuffer(in.Payload)
|
buf := bytes.NewBuffer(in.Payload)
|
||||||
msgDec, err := netflow.DecodeMessage(buf, templates)
|
msgDec, err := netflow.DecodeMessage(buf, templates)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case *netflow.ErrorTemplateNotFound:
|
case *netflow.ErrorTemplateNotFound:
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ func (nd *Decoder) Decode(in decoder.RawFlow) []*schema.FlowMessage {
|
|||||||
|
|
||||||
ts := uint64(in.TimeReceived.UTC().Unix())
|
ts := uint64(in.TimeReceived.UTC().Unix())
|
||||||
msgDec, err := sflow.DecodeMessage(buf)
|
msgDec, err := sflow.DecodeMessage(buf)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case *sflow.ErrorVersion:
|
case *sflow.ErrorVersion:
|
||||||
|
|||||||
@@ -302,7 +302,6 @@ func TestDecodeInterface(t *testing.T) {
|
|||||||
if diff := helpers.Diff(got, expectedFlows); diff != "" {
|
if diff := helpers.Diff(got, expectedFlows); diff != "" {
|
||||||
t.Fatalf("Decode() (-got, +want):\n%s", diff)
|
t.Fatalf("Decode() (-got, +want):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("flow sample with IPv4 data", func(t *testing.T) {
|
t.Run("flow sample with IPv4 data", func(t *testing.T) {
|
||||||
@@ -338,6 +337,5 @@ func TestDecodeInterface(t *testing.T) {
|
|||||||
if diff := helpers.Diff(got, expectedFlows); diff != "" {
|
if diff := helpers.Diff(got, expectedFlows); diff != "" {
|
||||||
t.Fatalf("Decode() (-got, +want):\n%s", diff)
|
t.Fatalf("Decode() (-got, +want):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,21 +16,19 @@ type oobMessage struct {
|
|||||||
Received time.Time
|
Received time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
// listenConfig configures a listening socket to reuse port and return overflows
|
||||||
// listenConfig configures a listening socket to reuse port and return overflows
|
var listenConfig = net.ListenConfig{
|
||||||
listenConfig = net.ListenConfig{
|
Control: func(network, address string, c syscall.RawConn) error {
|
||||||
Control: func(network, address string, c syscall.RawConn) error {
|
var err error
|
||||||
var err error
|
c.Control(func(fd uintptr) {
|
||||||
c.Control(func(fd uintptr) {
|
opts := udpSocketOptions
|
||||||
opts := udpSocketOptions
|
for _, opt := range opts {
|
||||||
for _, opt := range opts {
|
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, opt, 1)
|
||||||
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, opt, 1)
|
if err != nil {
|
||||||
if err != nil {
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
return err
|
})
|
||||||
},
|
return err
|
||||||
}
|
},
|
||||||
)
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func New(r *reporter.Reporter, configuration Configuration, dependencies Depende
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize decoders (at most once each)
|
// Initialize decoders (at most once each)
|
||||||
var alreadyInitialized = map[string]decoder.Decoder{}
|
alreadyInitialized := map[string]decoder.Decoder{}
|
||||||
decs := make([]decoder.Decoder, len(configuration.Inputs))
|
decs := make([]decoder.Decoder, len(configuration.Inputs))
|
||||||
for idx, input := range c.config.Inputs {
|
for idx, input := range c.config.Inputs {
|
||||||
dec, ok := alreadyInitialized[input.Decoder]
|
dec, ok := alreadyInitialized[input.Decoder]
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func TestFlow(t *testing.T) {
|
|||||||
"data-260.pcap", "data-260.pcap", "data-260.pcap", "data-260.pcap",
|
"data-260.pcap", "data-260.pcap", "data-260.pcap", "data-260.pcap",
|
||||||
} {
|
} {
|
||||||
outFile := path.Join(outDir, fmt.Sprintf("data-%d", idx))
|
outFile := path.Join(outDir, fmt.Sprintf("data-%d", idx))
|
||||||
err := os.WriteFile(outFile, helpers.ReadPcapPayload(t, path.Join(base, f)), 0666)
|
err := os.WriteFile(outFile, helpers.ReadPcapPayload(t, path.Join(base, f)), 0o666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("WriteFile(%q) error:\n%+v", outFile, err)
|
t.Fatalf("WriteFile(%q) error:\n%+v", outFile, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ func TestSimpleLookup(t *testing.T) {
|
|||||||
sc.Put(time.Now(), netip.MustParseAddr("::ffff:127.0.0.1"), "localhost", 676, Interface{Name: "Gi0/0/0/1", Description: "Transit", Speed: 1000})
|
sc.Put(time.Now(), netip.MustParseAddr("::ffff:127.0.0.1"), "localhost", 676, Interface{Name: "Gi0/0/0/1", Description: "Transit", Speed: 1000})
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{
|
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{
|
||||||
ExporterName: "localhost",
|
ExporterName: "localhost",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "Transit", Speed: 1000}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "Transit", Speed: 1000},
|
||||||
|
})
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 787, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.1", 787, answer{NOk: true})
|
||||||
expectCacheLookup(t, sc, "127.0.0.2", 676, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.2", 676, answer{NOk: true})
|
||||||
|
|
||||||
@@ -93,27 +94,33 @@ func TestExpire(t *testing.T) {
|
|||||||
sc.Expire(now.Add(-time.Hour))
|
sc.Expire(now.Add(-time.Hour))
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{
|
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{
|
||||||
ExporterName: "localhost",
|
ExporterName: "localhost",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "Transit"}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "Transit"},
|
||||||
|
})
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{
|
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{
|
||||||
ExporterName: "localhost2",
|
ExporterName: "localhost2",
|
||||||
Interface: Interface{Name: "Gi0/0/0/2", Description: "Peering"}})
|
Interface: Interface{Name: "Gi0/0/0/2", Description: "Peering"},
|
||||||
|
})
|
||||||
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
||||||
ExporterName: "localhost3",
|
ExporterName: "localhost3",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX"}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX"},
|
||||||
|
})
|
||||||
sc.Expire(now.Add(-29 * time.Minute))
|
sc.Expire(now.Add(-29 * time.Minute))
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{NOk: true})
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{
|
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{
|
||||||
ExporterName: "localhost2",
|
ExporterName: "localhost2",
|
||||||
Interface: Interface{Name: "Gi0/0/0/2", Description: "Peering"}})
|
Interface: Interface{Name: "Gi0/0/0/2", Description: "Peering"},
|
||||||
|
})
|
||||||
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
||||||
ExporterName: "localhost3",
|
ExporterName: "localhost3",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX"}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX"},
|
||||||
|
})
|
||||||
sc.Expire(now.Add(-19 * time.Minute))
|
sc.Expire(now.Add(-19 * time.Minute))
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{NOk: true})
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{NOk: true})
|
||||||
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
||||||
ExporterName: "localhost3",
|
ExporterName: "localhost3",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX"}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX"},
|
||||||
|
})
|
||||||
sc.Expire(now.Add(-9 * time.Minute))
|
sc.Expire(now.Add(-9 * time.Minute))
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{NOk: true})
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{NOk: true})
|
||||||
@@ -123,7 +130,8 @@ func TestExpire(t *testing.T) {
|
|||||||
sc.Expire(now.Add(-19 * time.Minute))
|
sc.Expire(now.Add(-19 * time.Minute))
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{
|
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{
|
||||||
ExporterName: "localhost",
|
ExporterName: "localhost",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "Transit"}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "Transit"},
|
||||||
|
})
|
||||||
|
|
||||||
gotMetrics := r.GetMetrics("akvorado_inlet_snmp_cache_")
|
gotMetrics := r.GetMetrics("akvorado_inlet_snmp_cache_")
|
||||||
expectedMetrics := map[string]string{
|
expectedMetrics := map[string]string{
|
||||||
@@ -154,11 +162,13 @@ func TestExpireRefresh(t *testing.T) {
|
|||||||
sc.Expire(now.Add(-29 * time.Minute))
|
sc.Expire(now.Add(-29 * time.Minute))
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{
|
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{
|
||||||
ExporterName: "localhost",
|
ExporterName: "localhost",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "Transit"}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "Transit"},
|
||||||
|
})
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{NOk: true})
|
||||||
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
||||||
ExporterName: "localhost2",
|
ExporterName: "localhost2",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX"}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX"},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNeedUpdates(t *testing.T) {
|
func TestNeedUpdates(t *testing.T) {
|
||||||
@@ -244,10 +254,12 @@ func TestSaveLoad(t *testing.T) {
|
|||||||
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{NOk: true})
|
expectCacheLookup(t, sc, "127.0.0.1", 676, answer{NOk: true})
|
||||||
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{
|
expectCacheLookup(t, sc, "127.0.0.1", 678, answer{
|
||||||
ExporterName: "localhost",
|
ExporterName: "localhost",
|
||||||
Interface: Interface{Name: "Gi0/0/0/2", Description: "Peering"}})
|
Interface: Interface{Name: "Gi0/0/0/2", Description: "Peering"},
|
||||||
|
})
|
||||||
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
expectCacheLookup(t, sc, "127.0.0.2", 678, answer{
|
||||||
ExporterName: "localhost2",
|
ExporterName: "localhost2",
|
||||||
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX", Speed: 1000}})
|
Interface: Interface{Name: "Gi0/0/0/1", Description: "IX", Speed: 1000},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConcurrentOperations(t *testing.T) {
|
func TestConcurrentOperations(t *testing.T) {
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ func (l *goSNMPLogger) Print(v ...interface{}) {
|
|||||||
e.Msg(fmt.Sprint(v...))
|
e.Msg(fmt.Sprint(v...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *goSNMPLogger) Printf(format string, v ...interface{}) {
|
func (l *goSNMPLogger) Printf(format string, v ...interface{}) {
|
||||||
if e := l.r.Debug(); e.Enabled() {
|
if e := l.r.Debug(); e.Enabled() {
|
||||||
e.Msg(fmt.Sprintf(format, v...))
|
e.Msg(fmt.Sprintf(format, v...))
|
||||||
|
|||||||
@@ -211,7 +211,6 @@ func TestCoalescing(t *testing.T) {
|
|||||||
expectSNMPLookup(t, c, "127.0.0.1", 767, answer{NOk: true})
|
expectSNMPLookup(t, c, "127.0.0.1", 767, answer{NOk: true})
|
||||||
expectSNMPLookup(t, c, "127.0.0.1", 768, answer{NOk: true})
|
expectSNMPLookup(t, c, "127.0.0.1", 768, answer{NOk: true})
|
||||||
expectSNMPLookup(t, c, "127.0.0.1", 769, answer{NOk: true})
|
expectSNMPLookup(t, c, "127.0.0.1", 769, answer{NOk: true})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
gotMetrics := r.GetMetrics("akvorado_inlet_snmp_poller_", "coalesced_count")
|
gotMetrics := r.GetMetrics("akvorado_inlet_snmp_poller_", "coalesced_count")
|
||||||
|
|||||||
@@ -106,8 +106,10 @@ func (c *Component) registerHTTPHandlers() error {
|
|||||||
defer c.networkSourcesLock.RUnlock()
|
defer c.networkSourcesLock.RUnlock()
|
||||||
for _, ss := range c.networkSources {
|
for _, ss := range c.networkSources {
|
||||||
for _, v := range ss {
|
for _, v := range ss {
|
||||||
wr.Write([]string{v.Prefix.String(),
|
wr.Write([]string{
|
||||||
v.Name, v.Role, v.Site, v.Region, v.Tenant})
|
v.Prefix.String(),
|
||||||
|
v.Name, v.Role, v.Site, v.Region, v.Tenant,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.config.Networks != nil {
|
if c.config.Networks != nil {
|
||||||
|
|||||||
@@ -217,5 +217,4 @@ func TestNetworkSources(t *testing.T) {
|
|||||||
if diff := helpers.Diff(gotMetrics, expectedMetrics); diff != "" {
|
if diff := helpers.Diff(gotMetrics, expectedMetrics); diff != "" {
|
||||||
t.Fatalf("Metrics (-got, +want):\n%s", diff)
|
t.Fatalf("Metrics (-got, +want):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
package orchestrator
|
package orchestrator
|
||||||
|
|
||||||
// Configuration describes the configuration for the broker.
|
// Configuration describes the configuration for the broker.
|
||||||
type Configuration struct {
|
type Configuration struct{}
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultConfiguration represents the default configuration for the broker.
|
// DefaultConfiguration represents the default configuration for the broker.
|
||||||
func DefaultConfiguration() Configuration {
|
func DefaultConfiguration() Configuration {
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ func TestTopicCreation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTopicMorePartitions(t *testing.T) {
|
func TestTopicMorePartitions(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user