Skip to content

Commit

Permalink
fix receivers config unit tests (#594)
Browse files Browse the repository at this point in the history
Signed-off-by: fuwx <[email protected]>
  • Loading branch information
fuwx295 authored Nov 27, 2023
1 parent 21b9dc9 commit 397ddeb
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 3 deletions.
84 changes: 82 additions & 2 deletions collector/internal/application/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import (

"github.com/Kindling-project/kindling/collector/pkg/component/analyzer/network"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer/processor/k8sprocessor"
"github.com/Kindling-project/kindling/collector/pkg/component/receiver/cgoreceiver"
"github.com/Kindling-project/kindling/collector/pkg/metadata/kubernetes"
)

func TestConstructConfig(t *testing.T) {
factory := NewComponentsFactory()
factory.RegisterProcessor(k8sprocessor.K8sMetadata, k8sprocessor.NewKubernetesProcessor, &k8sprocessor.DefaultConfig)
factory.RegisterAnalyzer(network.Network.String(), network.NewNetworkAnalyzer, network.NewDefaultConfig())
factory.RegisterReceiver(cgoreceiver.Cgo, cgoreceiver.NewCgoReceiver, cgoreceiver.NewDefaultConfig())

// Construct the config from the yaml file
v := viper.New()
Expand All @@ -34,12 +37,18 @@ func TestConstructConfig(t *testing.T) {
KubeConfigDir: "/opt/.kube/config",
GraceDeletePeriod: 30,
EnableFetchReplicaSet: true,
MetaDataProviderConfig: &kubernetes.MetaDataProviderConfig{
Enable: false,
EnableTrace: false,
Endpoint: "",
},
}
assert.Equal(t, expectedCfg, k8sCfg)

networkAnalyzerFactory := factory.Analyzers[network.Network.String()]
networkConfig := networkAnalyzerFactory.Config
expectedNetworkConfig := &network.Config{
EventChannelSize: 10000,
EnableTimeoutCheck: true,
ConnectTimeout: 100,
FdReuseTimeout: 15,
Expand All @@ -61,8 +70,79 @@ func TestConstructConfig(t *testing.T) {
},
},
UrlClusteringMethod: "blank",
IgnoreDnsRcode3Error: false,

IgnoreDnsRcode3Error: true,
}
assert.Equal(t, expectedNetworkConfig, networkConfig)

cgoreceiverFactory := factory.Receivers[cgoreceiver.Cgo]
cgoreceiverConfig := cgoreceiverFactory.Config
expectedCgoreceiverConfig := &cgoreceiver.Config{
SubscribeInfo: []cgoreceiver.SubEvent{
{
Name: "syscall_exit-writev",
Category: "net",
},
{
Name: "syscall_exit-readv",
Category: "net",
},
{
Name: "syscall_exit-write",
Category: "net",
},
{
Name: "syscall_exit-read",
Category: "net",
},
{
Name: "syscall_exit-sendto",
Category: "net",
},
{
Name: "syscall_exit-recvfrom",
Category: "net",
},
{
Name: "syscall_exit-sendmsg",
Category: "net",
},
{
Name: "syscall_exit-recvmsg",
Category: "net",
},
{
Name: "syscall_exit-sendmmsg",
Category: "net",
},
{
Name: "kprobe-tcp_close",
},
{
Name: "kprobe-tcp_rcv_established",
},
{
Name: "kprobe-tcp_drop",
},
{
Name: "kprobe-tcp_retransmit_skb",
},
{
Name: "syscall_exit-connect",
},
{
Name: "kretprobe-tcp_connect",
},
{
Name: "kprobe-tcp_set_state",
},
{
Name: "tracepoint-procexit",
},
},
ProcessFilterInfo: cgoreceiver.ProcessFilter{
Comms: []string{"kindling-collec", "containerd", "dockerd", "containerd-shim", "filebeat", "java"},
},
}
assert.Equal(t, expectedCgoreceiverConfig, cgoreceiverConfig)
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,42 @@ processors:
# The default value is false. It should be enabled if the ReplicaSet
# is used to control pods in the third-party CRD except for Deployment.
enable_fetch_replicaset: true
nodemetricprocessor:
nodemetricprocessor:
receivers:
cgoreceiver:
subscribe:
- name: syscall_exit-writev
category: net
- name: syscall_exit-readv
category: net
- name: syscall_exit-write
category: net
- name: syscall_exit-read
category: net
- name: syscall_exit-sendto
category: net
- name: syscall_exit-recvfrom
category: net
- name: syscall_exit-sendmsg
category: net
- name: syscall_exit-recvmsg
category: net
- name: syscall_exit-sendmmsg
category: net
- name: kprobe-tcp_close
- name: kprobe-tcp_rcv_established
- name: kprobe-tcp_drop
- name: kprobe-tcp_retransmit_skb
- name: syscall_exit-connect
- name: kretprobe-tcp_connect
- name: kprobe-tcp_set_state
- name: tracepoint-procexit
process_filter:
# the length of a comm should be no more than 16
comms:
- "kindling-collec"
- "containerd"
- "dockerd"
- "containerd-shim"
- "filebeat"
- "java"

0 comments on commit 397ddeb

Please sign in to comment.