Skip to content

Commit 02df343

Browse files
Make a copy of the test case for parallel test to work
1 parent 199f026 commit 02df343

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

common/dynamicconfig/constants.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,10 @@ const (
573573
ReplicatorProcessorUpdateAckIntervalJitterCoefficient = "history.replicatorProcessorUpdateAckIntervalJitterCoefficient"
574574
// ReplicatorProcessorEnablePriorityTaskProcessor indicates whether priority task processor should be used for ReplicatorProcessor
575575
ReplicatorProcessorEnablePriorityTaskProcessor = "history.replicatorProcessorEnablePriorityTaskProcessor"
576-
// MaximumBufferedEventsBatch is max number of buffer event in mutable state.
577-
// This limit is exclusive, so the number of buffered events must be less than this amount.
576+
// MaximumBufferedEventsBatch is the maximum permissible number of buffered events for any given mutable state.
578577
MaximumBufferedEventsBatch = "history.maximumBufferedEventsBatch"
579-
// MaximumBufferedEventsSizeInBytes is the maximum total size of all buffered events for a workflow execution.
580-
// The total size is determined by the sum of the size, in bytes, of each HistoryEvent proto.
581-
// This limit is inclusive, so the size of the buffered events must be less than or equal to this amount.
578+
// MaximumBufferedEventsSizeInBytes is the maximum permissible size of all buffered events for any given mutable
579+
// state. The total size is determined by the sum of the size, in bytes, of each HistoryEvent proto.
582580
MaximumBufferedEventsSizeInBytes = "history.maximumBufferedEventsSizeInBytes"
583581
// MaximumSignalsPerExecution is max number of signals supported by single execution
584582
MaximumSignalsPerExecution = "history.maximumSignalsPerExecution"

service/history/workflow/mutable_state_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4602,7 +4602,7 @@ func (ms *MutableStateImpl) closeTransactionWithPolicyCheck(
46024602
}
46034603

46044604
func (ms *MutableStateImpl) BufferSizeAcceptable() bool {
4605-
if ms.hBuilder.NumBufferedEvents() >= ms.config.MaximumBufferedEventsBatch() {
4605+
if ms.hBuilder.NumBufferedEvents() > ms.config.MaximumBufferedEventsBatch() {
46064606
return false
46074607
}
46084608

service/history/workflow/workflow_test/mutable_state_impl_test.go

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,38 +60,39 @@ func TestMutableStateImpl_ForceFlushBufferedEvents(t *testing.T) {
6060

6161
for _, tc := range []mutationTestCase{
6262
{
63-
name: "Number of events acceptable",
63+
name: "Number of events ok",
6464
transactionPolicy: workflow.TransactionPolicyActive,
65-
signals: 1,
65+
signals: 2,
6666
maxEvents: 2,
6767
maxSizeInBytes: math.MaxInt,
6868
expectFlush: false,
6969
},
7070
{
71-
name: "Number of events has reached limit",
71+
name: "Max number of events exceeded",
7272
transactionPolicy: workflow.TransactionPolicyActive,
73-
signals: 2,
73+
signals: 3,
7474
maxEvents: 2,
7575
maxSizeInBytes: math.MaxInt,
7676
expectFlush: true,
7777
},
7878
{
79-
name: "Number of events acceptable but byte size limit exceeded",
79+
name: "Number of events ok but byte size limit exceeded",
8080
transactionPolicy: workflow.TransactionPolicyActive,
81-
signals: 1,
81+
signals: 2,
8282
maxEvents: 2,
83-
maxSizeInBytes: 0,
83+
maxSizeInBytes: 25,
8484
expectFlush: true,
8585
},
8686
{
87-
name: "Number of events limit reached and byte size limit exceeded",
87+
name: "Max number of events and size of events both exceeded",
8888
transactionPolicy: workflow.TransactionPolicyActive,
89-
signals: 2,
89+
signals: 3,
9090
maxEvents: 2,
91-
maxSizeInBytes: 0,
91+
maxSizeInBytes: 25,
9292
expectFlush: true,
9393
},
9494
} {
95+
tc := tc
9596
t.Run(tc.name, tc.Run)
9697
}
9798
}
@@ -105,7 +106,7 @@ type mutationTestCase struct {
105106
maxSizeInBytes int
106107
}
107108

108-
func (c mutationTestCase) Run(t *testing.T) {
109+
func (c *mutationTestCase) Run(t *testing.T) {
109110
t.Parallel()
110111

111112
nsEntry := tests.LocalNamespaceEntry
@@ -131,7 +132,7 @@ func (c mutationTestCase) Run(t *testing.T) {
131132
}
132133
}
133134

134-
func (c mutationTestCase) startWFT(
135+
func (c *mutationTestCase) startWFT(
135136
t *testing.T,
136137
ms *workflow.MutableStateImpl,
137138
) *workflow.WorkflowTaskInfo {
@@ -150,7 +151,7 @@ func (c mutationTestCase) startWFT(
150151
return wft
151152
}
152153

153-
func (c mutationTestCase) startWorkflowExecution(
154+
func (c *mutationTestCase) startWorkflowExecution(
154155
t *testing.T,
155156
ms *workflow.MutableStateImpl,
156157
nsEntry *namespace.Namespace,
@@ -178,7 +179,7 @@ func (c mutationTestCase) startWorkflowExecution(
178179
}
179180
}
180181

181-
func (c mutationTestCase) addWorkflowExecutionSignaled(t *testing.T, i int, ms *workflow.MutableStateImpl) {
182+
func (c *mutationTestCase) addWorkflowExecutionSignaled(t *testing.T, i int, ms *workflow.MutableStateImpl) {
182183
t.Helper()
183184

184185
payload := &commonpb.Payloads{}
@@ -197,7 +198,7 @@ func (c mutationTestCase) addWorkflowExecutionSignaled(t *testing.T, i int, ms *
197198
}
198199
}
199200

200-
func (c mutationTestCase) createMutableState(t *testing.T, nsEntry *namespace.Namespace) *workflow.MutableStateImpl {
201+
func (c *mutationTestCase) createMutableState(t *testing.T, nsEntry *namespace.Namespace) *workflow.MutableStateImpl {
201202
t.Helper()
202203

203204
ctrl := gomock.NewController(t)
@@ -236,23 +237,23 @@ func (c mutationTestCase) createMutableState(t *testing.T, nsEntry *namespace.Na
236237
return ms
237238
}
238239

239-
func (c mutationTestCase) createConfig() *configs.Config {
240+
func (c *mutationTestCase) createConfig() *configs.Config {
240241
cfg := tests.NewDynamicConfig()
241242
cfg.MaximumBufferedEventsBatch = c.getMaxEvents
242243
cfg.MaximumBufferedEventsSizeInBytes = c.getMaxSizeInBytes
243244

244245
return cfg
245246
}
246247

247-
func (c mutationTestCase) getMaxEvents() int {
248+
func (c *mutationTestCase) getMaxEvents() int {
248249
return c.maxEvents
249250
}
250251

251-
func (c mutationTestCase) getMaxSizeInBytes() int {
252+
func (c *mutationTestCase) getMaxSizeInBytes() int {
252253
return c.maxSizeInBytes
253254
}
254255

255-
func (c mutationTestCase) testWFTFailedEvent(
256+
func (c *mutationTestCase) testWFTFailedEvent(
256257
t *testing.T,
257258
wft *workflow.WorkflowTaskInfo,
258259
event *history.HistoryEvent,
@@ -276,7 +277,7 @@ func (c mutationTestCase) testWFTFailedEvent(
276277
}
277278
}
278279

279-
func (c mutationTestCase) findWFTEvent(eventType enumspb.EventType, workflowEvents []*persistence.WorkflowEvents) (
280+
func (c *mutationTestCase) findWFTEvent(eventType enumspb.EventType, workflowEvents []*persistence.WorkflowEvents) (
280281
*history.HistoryEvent,
281282
bool,
282283
) {
@@ -291,7 +292,7 @@ func (c mutationTestCase) findWFTEvent(eventType enumspb.EventType, workflowEven
291292
return nil, false
292293
}
293294

294-
func (c mutationTestCase) testFailure(
295+
func (c *mutationTestCase) testFailure(
295296
t *testing.T,
296297
ms *workflow.MutableStateImpl,
297298
wft *workflow.WorkflowTaskInfo,
@@ -330,7 +331,7 @@ func (c mutationTestCase) testFailure(
330331
c.testWFTFailedEvent(t, wft, event)
331332
}
332333

333-
func (c mutationTestCase) testSuccess(
334+
func (c *mutationTestCase) testSuccess(
334335
t *testing.T,
335336
ms *workflow.MutableStateImpl,
336337
workflowEvents []*persistence.WorkflowEvents,

0 commit comments

Comments
 (0)