test(coderd): enable dbrollup service for insights tests (#12673)

This commit is contained in:
Mathias Fredriksson
2024-03-22 20:18:20 +02:00
committed by GitHub
parent 12e6fbf11e
commit b4fd819f0d
3 changed files with 83 additions and 16 deletions

View File

@ -21,7 +21,8 @@ const (
)
type Event struct {
TemplateUsageStats bool
Init bool `json:"-"`
TemplateUsageStats bool `json:"template_usage_stats"`
}
type Rolluper struct {
@ -138,6 +139,15 @@ func (r *Rolluper) start(ctx context.Context) {
}
}
// For testing.
if r.event != nil {
select {
case <-ctx.Done():
return
case r.event <- Event{Init: true}:
}
}
// Perform do immediately and on every tick of the ticker,
// disregarding the execution time of do. This ensure that
// the rollup is performed every interval assuming do does