@@ -41,7 +41,6 @@ import (
4141 taskqueuepb "go.temporal.io/api/taskqueue/v1"
4242 workflowpb "go.temporal.io/api/workflow/v1"
4343 "go.temporal.io/api/workflowservice/v1"
44-
4544 "go.temporal.io/server/api/historyservice/v1"
4645 workflowspb "go.temporal.io/server/api/workflow/v1"
4746 "go.temporal.io/server/common"
@@ -2315,6 +2314,41 @@ func (s *historyBuilderSuite) TestReorder() {
23152314 )
23162315}
23172316
2317+ func (s * historyBuilderSuite ) TestBufferSize_Memory () {
2318+ s .Assert ().Zero (s .historyBuilder .NumBufferedEvents ())
2319+ s .Assert ().Zero (s .historyBuilder .SizeInBytesOfBufferedEvents ())
2320+ s .historyBuilder .AddWorkflowExecutionSignaledEvent (
2321+ "signal-name" ,
2322+ & commonpb.Payloads {},
2323+ "identity" ,
2324+ & commonpb.Header {},
2325+ )
2326+ s .Assert ().Equal (1 , s .historyBuilder .NumBufferedEvents ())
2327+ // the size of the proto is non-deterministic, so just assert that it's non-zero, and it isn't really high
2328+ s .Assert ().Greater (s .historyBuilder .SizeInBytesOfBufferedEvents (), 0 )
2329+ s .Assert ().Less (s .historyBuilder .SizeInBytesOfBufferedEvents (), 100 )
2330+ s .flush ()
2331+ s .Assert ().Zero (s .historyBuilder .NumBufferedEvents ())
2332+ s .Assert ().Zero (s .historyBuilder .SizeInBytesOfBufferedEvents ())
2333+ }
2334+
2335+ func (s * historyBuilderSuite ) TestBufferSize_DB () {
2336+ s .Assert ().Zero (s .historyBuilder .NumBufferedEvents ())
2337+ s .Assert ().Zero (s .historyBuilder .SizeInBytesOfBufferedEvents ())
2338+ s .historyBuilder .dbBufferBatch = []* historypb.HistoryEvent {{
2339+ EventType : enumspb .EVENT_TYPE_TIMER_FIRED ,
2340+ EventId : common .BufferedEventID ,
2341+ TaskId : common .EmptyEventTaskID ,
2342+ }}
2343+ s .Assert ().Equal (1 , s .historyBuilder .NumBufferedEvents ())
2344+ // the size of the proto is non-deterministic, so just assert that it's non-zero, and it isn't really high
2345+ s .Assert ().Greater (s .historyBuilder .SizeInBytesOfBufferedEvents (), 0 )
2346+ s .Assert ().Less (s .historyBuilder .SizeInBytesOfBufferedEvents (), 100 )
2347+ s .flush ()
2348+ s .Assert ().Zero (s .historyBuilder .NumBufferedEvents ())
2349+ s .Assert ().Zero (s .historyBuilder .SizeInBytesOfBufferedEvents ())
2350+ }
2351+
23182352func (s * historyBuilderSuite ) assertEventIDTaskID (
23192353 historyMutation * HistoryMutation ,
23202354) {
0 commit comments