Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #553 from mirackara/CustomEventsHarvestIncrease
Default Custom Event Harvest Increase from 10,000 to 30,000
- Loading branch information
Showing
4 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright 2020 New Relic Corporation. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package newrelic | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/newrelic/go-agent/v3/internal" | ||
) | ||
|
||
// Check Default Value | ||
func TestCustomLimitsBasic(t *testing.T) { | ||
limit := internal.MaxCustomEvents | ||
limits := &internal.RequestEventLimits{ | ||
CustomEvents: limit, | ||
} | ||
// This function will mock a connect reply from the server | ||
mockReplyFunction := func(reply *internal.ConnectReply) { | ||
reply.MockConnectReplyEventLimits(limits) | ||
} | ||
testApp := newTestApp( | ||
mockReplyFunction, | ||
ConfigCustomInsightsEventsMaxSamplesStored(limit), | ||
) | ||
|
||
customEventRate := limit / (60 / internal.CustomEventHarvestsPerMinute) | ||
|
||
// Check if custom event queue capacity == rate | ||
if customEventRate != testApp.app.testHarvest.CustomEvents.capacity() { | ||
t.Errorf("Custom Events Rate is not equal to harvest: expected %d, actual %d", customEventRate, testApp.app.testHarvest.CustomEvents.capacity()) | ||
} | ||
} | ||
func TestCustomEventLimitUserSet(t *testing.T) { | ||
limit := 7000 | ||
limits := &internal.RequestEventLimits{ | ||
CustomEvents: limit, | ||
} | ||
mockReplyFunction := func(reply *internal.ConnectReply) { | ||
reply.MockConnectReplyEventLimits(limits) | ||
} | ||
testApp := newTestApp( | ||
mockReplyFunction, | ||
ConfigCustomInsightsEventsMaxSamplesStored(limit), | ||
) | ||
|
||
customEventRate := limit / (60 / internal.CustomEventHarvestsPerMinute) | ||
|
||
if customEventRate != testApp.app.testHarvest.CustomEvents.capacity() { | ||
t.Errorf("Custom Events Rate is not equal to harvest: expected %d, actual %d", customEventRate, testApp.app.testHarvest.CustomEvents.capacity()) | ||
} | ||
} | ||
|
||
func TestCustomLimitEnthusiast(t *testing.T) { | ||
limit := 100000 | ||
limits := &internal.RequestEventLimits{ | ||
CustomEvents: limit, | ||
} | ||
// This function will mock a connect reply from the server | ||
mockReplyFunction := func(reply *internal.ConnectReply) { | ||
reply.MockConnectReplyEventLimits(limits) | ||
} | ||
testApp := newTestApp( | ||
mockReplyFunction, | ||
ConfigCustomInsightsEventsMaxSamplesStored(limit), | ||
) | ||
|
||
customEventRate := limit / (60 / internal.CustomEventHarvestsPerMinute) | ||
|
||
// Check if custom event queue capacity == rate | ||
if customEventRate != testApp.app.testHarvest.CustomEvents.capacity() { | ||
t.Errorf("Custom Events Rate is not equal to harvest: expected %d, actual %d", customEventRate, testApp.app.testHarvest.CustomEvents.capacity()) | ||
} | ||
} | ||
|
||
func TestCustomLimitsTypo(t *testing.T) { | ||
limit := 1000000 | ||
limits := &internal.RequestEventLimits{ | ||
CustomEvents: limit, | ||
} | ||
// This function will mock a connect reply from the server | ||
mockReplyFunction := func(reply *internal.ConnectReply) { | ||
reply.MockConnectReplyEventLimits(limits) | ||
} | ||
testApp := newTestApp( | ||
mockReplyFunction, | ||
ConfigCustomInsightsEventsMaxSamplesStored(limit), | ||
) | ||
|
||
customEventRate := 100000 / (60 / internal.CustomEventHarvestsPerMinute) | ||
|
||
// Check if custom event queue capacity == rate | ||
if customEventRate != testApp.app.testHarvest.CustomEvents.capacity() { | ||
t.Errorf("Custom Events Rate is not equal to harvest: expected %d, actual %d", 8333, testApp.app.testHarvest.CustomEvents.capacity()) | ||
} | ||
} | ||
|
||
func TestCustomLimitZero(t *testing.T) { | ||
limit := 0 | ||
limits := &internal.RequestEventLimits{ | ||
CustomEvents: limit, | ||
} | ||
// This function will mock a connect reply from the server | ||
mockReplyFunction := func(reply *internal.ConnectReply) { | ||
reply.MockConnectReplyEventLimits(limits) | ||
} | ||
testApp := newTestApp( | ||
mockReplyFunction, | ||
ConfigCustomInsightsEventsMaxSamplesStored(limit), | ||
) | ||
|
||
customEventRate := limit / (60 / internal.CustomEventHarvestsPerMinute) | ||
|
||
// Check if custom event queue capacity == rate | ||
if customEventRate != testApp.app.testHarvest.CustomEvents.capacity() { | ||
t.Errorf("Custom Events Rate is not equal to harvest: expected %d, actual %d", customEventRate, testApp.app.testHarvest.CustomEvents.capacity()) | ||
} | ||
} |