-
Notifications
You must be signed in to change notification settings - Fork 1
/
perf_test.go
65 lines (58 loc) · 1.42 KB
/
perf_test.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package exporter
import (
"io/ioutil"
"strconv"
"strings"
"testing"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/viper"
)
func TestPerfExporter(t *testing.T) {
paranoidBytes, err := ioutil.ReadFile("/proc/sys/kernel/perf_event_paranoid")
if err != nil {
t.Skip("Procfs not mounted, skipping perf tests")
}
paranoidStr := strings.Replace(string(paranoidBytes), "\n", "", -1)
paranoid, err := strconv.Atoi(paranoidStr)
if err != nil {
t.Fatalf("Expected perf_event_paranoid to be an int, got: %s", paranoidStr)
}
if paranoid >= 1 {
t.Skip("Skipping perf tests, set perf_event_paranoid to 0")
}
t.Skip()
config := viper.GetViper()
config.SetDefault("raw_syscalls.events", []string{"sys_enter", "sys_exit"})
collector, err := NewPerfCollector(config)
if err != nil {
t.Fatal(err)
}
defer func() {
if err := collector.Stop(); err != nil {
t.Fatal(err)
}
}()
desc := make(chan *prometheus.Desc)
collector.Describe(desc)
}
func TestPerfExporterCollect(t *testing.T) {
t.Skip()
config := viper.GetViper()
config.SetDefault("raw_syscalls.events", []string{"sys_enter", "sys_exit"})
collector, err := NewPerfCollector(config)
if err != nil {
t.Fatal(err)
}
defer func() {
if err := collector.Stop(); err != nil {
t.Fatal(err)
}
}()
go func() {
if err := collector.Start(); err != nil {
t.Fatal(err)
}
}()
ch := make(chan prometheus.Metric)
collector.Collect(ch)
}