MCPcopy
hub / github.com/crowdsecurity/crowdsec / TestGCandDump

Function TestGCandDump

pkg/leakybucket/manager_run_test.go:24–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func TestGCandDump(t *testing.T) {
25 var (
26 bucketStore = NewBucketStore()
27 ctx = t.Context()
28 )
29
30 Holders := []BucketFactory{
31 // one overflowing soon + bh
32 {
33 Spec: BucketSpec{
34 Name: "test_counter_fast",
35 Description: "test_counter_fast",
36 Debug: true,
37 Type: "counter",
38 Capacity: -1,
39 Duration: "0.5s",
40 Blackhole: "1m",
41 Filter: "true",
42 },
43 },
44 // one long counter
45 {
46 Spec: BucketSpec{
47 Name: "test_counter_slow",
48 Description: "test_counter_slow",
49 Debug: true,
50 Type: "counter",
51 Capacity: -1,
52 Duration: "10m",
53 Filter: "true",
54 },
55 },
56 // slow leaky
57 {
58 Spec: BucketSpec{
59 Name: "test_leaky_slow",
60 Description: "test_leaky_slow",
61 Debug: true,
62 Type: "leaky",
63 Capacity: 5,
64 LeakSpeed: "10m",
65 Filter: "true",
66 },
67 },
68 }
69
70 for idx := range Holders {
71 if err := Holders[idx].LoadBucket(); err != nil {
72 t.Fatalf("while loading (%d/%d): %s", idx, len(Holders), err)
73 }
74
75 if err := Holders[idx].Validate(); err != nil {
76 t.Fatalf("while validating (%d/%d): %s", idx, len(Holders), err)
77 }
78 }
79
80 log.Info("Pouring to bucket")
81

Callers

nothing calls this directly

Calls 7

NewBucketStoreFunction · 0.85
PourItemToHoldersFunction · 0.85
expectBucketCountFunction · 0.85
GarbageCollectBucketsFunction · 0.85
LoadBucketMethod · 0.80
ValidateMethod · 0.65
InfoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…