Add test for splitting post payload.
@@ -207,7 +207,6 @@ func newFixture(t *testing.T, config Config) *fixture {
if err != nil {
t.Fatal(err)
}
-
f.ddmetrics <- ddmetrics
w.WriteHeader(http.StatusAccepted)
}))
@@ -259,6 +258,37 @@ func TestLocalServerUnaggregatedMetrics(t *testing.T) {
assertMetrics(t, ddmetrics, expectedMetrics)
}
+// TestFlushMaxSize tests the behavior of
+// the veneur client splitting a post across multiple requests.
+func TestFlushMaxSize(t *testing.T) {
+ metricValues, _ := generateMetrics()
+ config := localConfig()
+ config.FlushMaxPerBody = 2
+ f := newFixture(t, config)
+ defer f.Close()
+
+ for _, value := range metricValues {
+ f.server.Workers[0].ProcessMetric(&samplers.UDPMetric{
+ MetricKey: samplers.MetricKey{
+ Name: "a.b.c",
+ Type: "histogram",
+ },
+ Value: value,
+ Digest: 12345,
+ SampleRate: 1.0,
+ Scope: samplers.LocalOnly,
+ })
+ }
+
+ f.server.Flush()
+
+ // Verify we get 3 sets of 2, other tests can verify the internals
+ for i := 1; i <= 3; i++ {
+ ddmetrics := <-f.ddmetrics
+ assert.Equal(t, 2, len(ddmetrics.Series), "incorrect number of elements in the flushed series on the remote server")
+ }
+}
+
func TestGlobalServerFlush(t *testing.T) {
metricValues, expectedMetrics := generateMetrics()
config := globalConfig()
