-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: pending waiter #497
Changes from all commits
434e7cd
73b0a83
36d4eb3
026c91e
05fde35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*.dylib | ||
debug | ||
bin/ | ||
logs/ | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"context" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/goccy/go-json" | ||
"github.com/pkg/errors" | ||
|
@@ -213,7 +214,7 @@ func TestState_SessionVariables(t *testing.T) { | |
func setupStateForCLTest() (*State, *eventCounter, *eventCounter, *eventCounter, *eventCounter) { | ||
counters := &statistics.ExecutionCounters{} | ||
state := New(context.Background(), "", 60, nil, 1, 1, "", false, counters) | ||
state.Rest = NewRestHandler(state.ctx, state.trafficLogger, state.HeaderJar, state.VirtualProxy, state.Timeout) | ||
state.Rest = NewRestHandler(state.ctx, state.trafficLogger, state.HeaderJar, state.VirtualProxy, state.Timeout, &state.Pending) | ||
|
||
event0 := registerEvent(state, 0) | ||
event1 := registerEvent(state, 1) | ||
|
@@ -403,3 +404,42 @@ func TestStateTemplateArtifactMap(t *testing.T) { | |
}) | ||
|
||
} | ||
|
||
func TestPendingWaiter(t *testing.T) { | ||
counters := &statistics.ExecutionCounters{} | ||
state := New(context.Background(), "", 120, nil, 1, 1, "", false, counters) | ||
Comment on lines
+408
to
+410
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this simple test break the old one? If so, good! If not it would be a good idea to create such a test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes I created it as a failing test with old one, and doesn't fail with new implementation |
||
state.Rest = NewRestHandler(state.ctx, state.trafficLogger, state.HeaderJar, state.VirtualProxy, state.Timeout, &state.Pending) | ||
actionState := &action.State{} | ||
|
||
firstDone := false | ||
secondDone := false | ||
thirdDone := false | ||
|
||
state.QueueRequest(func(ctx context.Context) error { | ||
<-time.After(50 * time.Millisecond) | ||
firstDone = true | ||
return nil | ||
}, actionState, true, "") | ||
|
||
state.Rest.QueueRequestWithCallback(actionState, true, nil, state.LogEntry, func(err error, req *RestRequest) { | ||
<-time.After(100 * time.Millisecond) | ||
secondDone = true | ||
state.QueueRequest(func(ctx context.Context) error { | ||
<-time.After(500 * time.Millisecond) | ||
thirdDone = true | ||
return nil | ||
}, actionState, true, "") | ||
}) | ||
|
||
state.Wait(actionState) | ||
|
||
if !firstDone { | ||
t.Error("first request not waited for") | ||
} | ||
if !secondDone { | ||
t.Error("second request not waited for") | ||
} | ||
if !thirdDone { | ||
t.Error("third request not waited for") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size
does not matter 😉