-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49df920
commit 74133e7
Showing
4 changed files
with
90 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package curator | ||
|
||
type parallelRunnerImpl struct { | ||
runners []SessionRunner | ||
} | ||
|
||
func NewParallelRunner(runners ...SessionRunner) SessionRunner { | ||
return ¶llelRunnerImpl{ | ||
runners: runners, | ||
} | ||
} | ||
|
||
func (r *parallelRunnerImpl) Begin(client Client) { | ||
for _, runner := range r.runners { | ||
runner.Begin(client) | ||
} | ||
} | ||
|
||
func (r *parallelRunnerImpl) Retry() { | ||
for _, runner := range r.runners { | ||
runner.Retry() | ||
} | ||
} | ||
|
||
func (r *parallelRunnerImpl) End() { | ||
for _, runner := range r.runners { | ||
runner.End() | ||
} | ||
} |
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,59 @@ | ||
package curator | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParallelRunner(t *testing.T) { | ||
t.Run("normal", func(t *testing.T) { | ||
var steps []string | ||
r := NewParallelRunner( | ||
New(func(sess *Session) { | ||
steps = append(steps, "init01") | ||
sess.Run(func(client Client) { | ||
sess.AddRetry(func(sess *Session) { | ||
steps = append(steps, "retry01") | ||
}) | ||
}) | ||
}), | ||
New(func(sess *Session) { | ||
steps = append(steps, "init02") | ||
}), | ||
) | ||
|
||
assert.Equal(t, 0, len(steps)) | ||
|
||
r.Begin(nil) | ||
assert.Equal(t, []string{ | ||
"init01", | ||
"init02", | ||
}, steps) | ||
|
||
r.Retry() | ||
assert.Equal(t, []string{ | ||
"init01", | ||
"init02", | ||
"retry01", | ||
}, steps) | ||
|
||
r.End() | ||
assert.Equal(t, []string{ | ||
"init01", | ||
"init02", | ||
"retry01", | ||
}, steps) | ||
|
||
// Session Begin Again | ||
r.Begin(nil) | ||
assert.Equal(t, []string{ | ||
"init01", | ||
"init02", | ||
"retry01", | ||
"init01", | ||
"init02", | ||
}, steps) | ||
}) | ||
|
||
} |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
*) Test Retry When Leader Expired (when Error = Session Expired) | ||
*) Add CI Pipeline for Integration Tests | ||
*) Batching Read & Write to TCP | ||
*) Test Zookeeper with Clusters and IPTables | ||
*) Stress Tests with Race Detector | ||
*) Add Multi-Ops Transactions |