(t *testing.T)
| 107 | } |
| 108 | |
| 109 | func TestShutdownBuckets(t *testing.T) { |
| 110 | var ( |
| 111 | bucketStore = NewBucketStore() |
| 112 | Holders = []BucketFactory{ |
| 113 | // one long counter |
| 114 | { |
| 115 | Spec: BucketSpec{ |
| 116 | Name: "test_counter_slow", |
| 117 | Description: "test_counter_slow", |
| 118 | Debug: true, |
| 119 | Type: "counter", |
| 120 | Capacity: -1, |
| 121 | Duration: "10m", |
| 122 | Filter: "true", |
| 123 | }, |
| 124 | }, |
| 125 | // slow leaky |
| 126 | { |
| 127 | Spec: BucketSpec{ |
| 128 | Name: "test_leaky_slow", |
| 129 | Description: "test_leaky_slow", |
| 130 | Debug: true, |
| 131 | Type: "leaky", |
| 132 | Capacity: 5, |
| 133 | LeakSpeed: "10m", |
| 134 | Filter: "true", |
| 135 | }, |
| 136 | }, |
| 137 | } |
| 138 | ) |
| 139 | |
| 140 | for idx := range Holders { |
| 141 | if err := Holders[idx].LoadBucket(); err != nil { |
| 142 | t.Fatalf("while loading (%d/%d): %s", idx, len(Holders), err) |
| 143 | } |
| 144 | |
| 145 | if err := Holders[idx].Validate(); err != nil { |
| 146 | t.Fatalf("while validating (%d/%d): %s", idx, len(Holders), err) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | log.Info("Pouring to bucket") |
| 151 | |
| 152 | in := pipeline.Event{Parsed: map[string]string{"something": "something"}} |
| 153 | // pour an item that will go to leaky + counter |
| 154 | ctx, cancel := context.WithCancel(t.Context()) |
| 155 | ok, err := PourItemToHolders(ctx, in, Holders, bucketStore, nil) |
| 156 | if err != nil { |
| 157 | t.Fatalf("while pouring item : %s", err) |
| 158 | } |
| 159 | |
| 160 | if !ok { |
| 161 | t.Fatal("didn't pour item") |
| 162 | } |
| 163 | |
| 164 | time.Sleep(1 * time.Second) |
| 165 | |
| 166 | if err := expectBucketCount(bucketStore, 2); err != nil { |
nothing calls this directly
no test coverage detected
searching dependent graphs…