MCPcopy Create free account
hub / github.com/AdRoll/baker / TestStatsDumper

Function TestStatsDumper

stats_test.go:91–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestStatsDumper(t *testing.T) {
92 // Check that the StatsDumper correctly reports the metrics gathered from
93 // the components. The tests check both the reports printed to the standard
94 // output and metrics published to the MetricClient.
95 toml := `
96[input]
97name="statsInput"
98
99[[filter]]
100name="statsFilter"
101
102[[filter]]
103name="statsFilter"
104
105[[filter]]
106name="statsFilter"
107
108[output]
109name="statsOutput"
110procs=2
111fields=["field0"]
112
113[upload]
114name="statsUpload"
115
116[metrics]
117name="MockMetrics"
118`
119 components := baker.Components{
120 Inputs: []baker.InputDesc{{Name: "statsInput",
121 Config: &struct{}{},
122 New: func(baker.InputParams) (baker.Input, error) { return statsInput{}, nil },
123 }},
124 Filters: []baker.FilterDesc{{Name: "statsFilter",
125 Config: &struct{}{},
126 New: func(baker.FilterParams) (baker.Filter, error) { return statsFilter{}, nil },
127 }},
128 Outputs: []baker.OutputDesc{{Name: "statsOutput",
129 Config: &struct{}{},
130 New: func(baker.OutputParams) (baker.Output, error) { return statsOutput{}, nil },
131 }},
132 Uploads: []baker.UploadDesc{{Name: "statsUpload",
133 Config: &struct{}{},
134 New: func(baker.UploadParams) (baker.Upload, error) { return statsUpload{}, nil },
135 }},
136 Metrics: []baker.MetricsDesc{testutil.MockMetricsDesc},
137 FieldByName: func(n string) (baker.FieldIndex, bool) { return 0, true },
138 FieldNames: []string{"foo", "bar"},
139 }
140
141 cfg, err := baker.NewConfigFromToml(strings.NewReader(toml), components)
142 if err != nil {
143 t.Fatal(err)
144 }
145
146 tp, err := baker.NewTopologyFromConfig(cfg)
147 if err != nil {
148 t.Fatal(err)

Callers

nothing calls this directly

Calls 7

SetWriterMethod · 0.95
RunMethod · 0.95
NewConfigFromTomlFunction · 0.92
NewTopologyFromConfigFunction · 0.92
NewStatsDumperFunction · 0.92
DiffWithGoldenFunction · 0.92
PublishedMetricsMethod · 0.80

Tested by

no test coverage detected