Skip to content

Commit 2fb80f2

Browse files
authored
Enable SDKFlagBlockedSelectorSignalReceive by default (#1762)
* enable flag by default * Fix tests * Fix integration test I missed * Add comment to unblockSelectorSignal
1 parent 918fea8 commit 2fb80f2

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

internal/internal_coroutines_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ func TestSelectBlockingDefault(t *testing.T) {
541541
}
542542
// Verify that the flag is not set
543543
require.False(t, env.GetFlag(SDKFlagBlockedSelectorSignalReceive))
544+
unblockSelectorSignal = false
545+
defer func() { unblockSelectorSignal = true }()
546+
544547
interceptor, ctx, err := newWorkflowContext(env, nil)
545548
require.NoError(t, err, "newWorkflowContext failed")
546549
d, _ := newDispatcher(ctx, interceptor, func(ctx Context) {
@@ -608,7 +611,9 @@ func TestSelectBlockingDefaultWithFlag(t *testing.T) {
608611
TaskQueueName: "taskqueue:" + t.Name(),
609612
},
610613
}
614+
require.True(t, unblockSelectorSignal)
611615
require.True(t, env.TryUse(SDKFlagBlockedSelectorSignalReceive))
616+
612617
interceptor, ctx, err := newWorkflowContext(env, nil)
613618
require.NoError(t, err, "newWorkflowContext failed")
614619
d, _ := newDispatcher(ctx, interceptor, func(ctx Context) {

internal/internal_flags.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const (
3131
SDKFlagUnknown = math.MaxUint32
3232
)
3333

34-
var unblockSelectorSignal bool
34+
// unblockSelectorSignal exists to allow us to configure the default behavior of
35+
// SDKFlagBlockedSelectorSignalReceive. This is primarily useful with tests.
36+
var unblockSelectorSignal = true
3537

3638
func sdkFlagFromUint(value uint32) sdkFlag {
3739
switch value {

internal/internal_workflow_testsuite_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,7 +4217,7 @@ func (s *WorkflowTestSuiteUnitTest) Test_SameWorkflowAndActivityNames() {
42174217
s.Require().NoError(env.GetWorkflowError())
42184218
}
42194219

4220-
func (s *WorkflowTestSuiteUnitTest) Test_SignalLoss() {
4220+
func (s *WorkflowTestSuiteUnitTest) Test_SignalNotLost() {
42214221
workflowFn := func(ctx Context) error {
42224222
ch1 := GetSignalChannel(ctx, "test-signal")
42234223
ch2 := GetSignalChannel(ctx, "test-signal-2")
@@ -4230,8 +4230,11 @@ func (s *WorkflowTestSuiteUnitTest) Test_SignalLoss() {
42304230
ch2.Receive(ctx, &v)
42314231
})
42324232
selector.Select(ctx)
4233-
s.Require().True(ch1.Len() == 0 && v == "s2")
4233+
s.Require().Equal(ch1.Len(), 1)
4234+
s.Require().Equal(v, "s2")
42344235
selector.Select(ctx)
4236+
s.Require().Equal(ch1.Len(), 0)
4237+
s.Require().Equal(v, "s1")
42354238

42364239
return nil
42374240
}
@@ -4245,8 +4248,5 @@ func (s *WorkflowTestSuiteUnitTest) Test_SignalLoss() {
42454248
env.ExecuteWorkflow(workflowFn)
42464249
s.True(env.IsWorkflowCompleted())
42474250
err := env.GetWorkflowError()
4248-
s.Error(err)
4249-
var workflowErr *WorkflowExecutionError
4250-
s.True(errors.As(err, &workflowErr))
4251-
s.Equal("deadline exceeded (type: ScheduleToClose)", workflowErr.cause.Error())
4251+
s.NoError(err)
42524252
}

test/integration_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7336,6 +7336,10 @@ func (ts *IntegrationTestSuite) TestSelectorBlock() {
73367336
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
73377337
defer cancel()
73387338
options := ts.startWorkflowOptions("test-selector-block")
7339+
7340+
internal.SetUnblockSelectorSignal(false)
7341+
defer internal.SetUnblockSelectorSignal(true)
7342+
73397343
run, err := ts.client.ExecuteWorkflow(ctx, options, ts.workflows.SelectorBlockSignal)
73407344
ts.NoError(err)
73417345
var result string
@@ -7348,9 +7352,6 @@ func (ts *IntegrationTestSuite) TestSelectorNoBlock() {
73487352
defer cancel()
73497353
options := ts.startWorkflowOptions("test-selector-block")
73507354

7351-
internal.SetUnblockSelectorSignal(true)
7352-
defer internal.SetUnblockSelectorSignal(false)
7353-
73547355
run, err := ts.client.ExecuteWorkflow(ctx, options, ts.workflows.SelectorBlockSignal)
73557356
ts.NoError(err)
73567357
var result string

0 commit comments

Comments
 (0)