-
Notifications
You must be signed in to change notification settings - Fork 454
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
Integrate Redis streams in to Nitro's validation #2241
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8f0729d
Second draft of pubsub in nitro
anodar 4674992
Move RedisValidationServer to ValidationNode
anodar 51d4666
Move redisURL and redisStream out from producer and consumer, pass it…
anodar 8496679
Implement system tests
anodar db855d5
Move moduleRoot to common_test since block_validator_test isn't compi…
anodar 2f9cc14
Fix linter error
anodar b990e16
Drop RedisStream from RedisValidationClientConfig, it's dereived from…
anodar 5b98d6f
Error out when currentModuleRoot is latest and execSpanner isn't init…
anodar fb897bb
Set rootModule dynamically
anodar 738f04d
Introduce ExecutionServerConfig to BlockValidatorConfig, restructure …
anodar 005f441
Fix TestChallengeManagerFullAsserterCorrect test
anodar a0268fe
Add config validation
anodar 4e83750
Fix config defaults
anodar 123023e
drop moduleRoots from config and initialize from block_validator instead
anodar 9dfe3d1
Factor out redisproducer and redisconumer
anodar db2eaf0
valnode: only start redis validation if enabled
tsahee 5709b50
Merge branch 'master' into nitro-pubsub
tsahee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -28,16 +28,17 @@ type testResponse struct { | |
Response string | ||
} | ||
|
||
func createGroup(ctx context.Context, t *testing.T, streamName, groupName string, client redis.UniversalClient) { | ||
func createRedisGroup(ctx context.Context, t *testing.T, streamName string, client redis.UniversalClient) { | ||
t.Helper() | ||
if _, err := client.XGroupCreateMkStream(ctx, streamName, groupName, "$").Result(); err != nil { | ||
// Stream name and group name are the same. | ||
if _, err := client.XGroupCreateMkStream(ctx, streamName, streamName, "$").Result(); err != nil { | ||
t.Fatalf("Error creating stream group: %v", err) | ||
} | ||
} | ||
|
||
func destroyGroup(ctx context.Context, t *testing.T, streamName, groupName string, client redis.UniversalClient) { | ||
func destroyRedisGroup(ctx context.Context, t *testing.T, streamName string, client redis.UniversalClient) { | ||
t.Helper() | ||
if _, err := client.XGroupDestroy(ctx, streamName, groupName).Result(); err != nil { | ||
if _, err := client.XGroupDestroy(ctx, streamName, streamName).Result(); err != nil { | ||
log.Debug("Error destroying a stream group", "error", err) | ||
} | ||
} | ||
|
@@ -54,49 +55,48 @@ func (e *disableReproduce) apply(_ *ConsumerConfig, prodCfg *ProducerConfig) { | |
|
||
func producerCfg() *ProducerConfig { | ||
return &ProducerConfig{ | ||
EnableReproduce: DefaultTestProducerConfig.EnableReproduce, | ||
CheckPendingInterval: DefaultTestProducerConfig.CheckPendingInterval, | ||
KeepAliveTimeout: DefaultTestProducerConfig.KeepAliveTimeout, | ||
CheckResultInterval: DefaultTestProducerConfig.CheckResultInterval, | ||
EnableReproduce: TestProducerConfig.EnableReproduce, | ||
CheckPendingInterval: TestProducerConfig.CheckPendingInterval, | ||
KeepAliveTimeout: TestProducerConfig.KeepAliveTimeout, | ||
CheckResultInterval: TestProducerConfig.CheckResultInterval, | ||
} | ||
} | ||
|
||
func consumerCfg() *ConsumerConfig { | ||
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. (same as producerCfg) 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. Same as above (technically we don't change consumer config, but just to follow the pattern). |
||
return &ConsumerConfig{ | ||
ResponseEntryTimeout: DefaultTestConsumerConfig.ResponseEntryTimeout, | ||
KeepAliveTimeout: DefaultTestConsumerConfig.KeepAliveTimeout, | ||
ResponseEntryTimeout: TestConsumerConfig.ResponseEntryTimeout, | ||
KeepAliveTimeout: TestConsumerConfig.KeepAliveTimeout, | ||
} | ||
} | ||
|
||
func newProducerConsumers(ctx context.Context, t *testing.T, opts ...configOpt) (*Producer[testRequest, testResponse], []*Consumer[testRequest, testResponse]) { | ||
t.Helper() | ||
redisURL := redisutil.CreateTestRedis(ctx, t) | ||
redisClient, err := redisutil.RedisClientFromURL(redisutil.CreateTestRedis(ctx, t)) | ||
if err != nil { | ||
t.Fatalf("RedisClientFromURL() unexpected error: %v", err) | ||
} | ||
prodCfg, consCfg := producerCfg(), consumerCfg() | ||
prodCfg.RedisURL, consCfg.RedisURL = redisURL, redisURL | ||
streamName := uuid.NewString() | ||
groupName := fmt.Sprintf("group_%s", streamName) | ||
prodCfg.RedisGroup, consCfg.RedisGroup = groupName, groupName | ||
prodCfg.RedisStream, consCfg.RedisStream = streamName, streamName | ||
streamName := fmt.Sprintf("stream:%s", uuid.NewString()) | ||
for _, o := range opts { | ||
o.apply(consCfg, prodCfg) | ||
} | ||
producer, err := NewProducer[testRequest, testResponse](prodCfg) | ||
producer, err := NewProducer[testRequest, testResponse](redisClient, streamName, prodCfg) | ||
if err != nil { | ||
t.Fatalf("Error creating new producer: %v", err) | ||
} | ||
|
||
var consumers []*Consumer[testRequest, testResponse] | ||
for i := 0; i < consumersCount; i++ { | ||
c, err := NewConsumer[testRequest, testResponse](ctx, consCfg) | ||
c, err := NewConsumer[testRequest, testResponse](redisClient, streamName, consCfg) | ||
if err != nil { | ||
t.Fatalf("Error creating new consumer: %v", err) | ||
} | ||
consumers = append(consumers, c) | ||
} | ||
createGroup(ctx, t, streamName, groupName, producer.client) | ||
createRedisGroup(ctx, t, streamName, producer.client) | ||
t.Cleanup(func() { | ||
ctx := context.Background() | ||
destroyGroup(ctx, t, streamName, groupName, producer.client) | ||
destroyRedisGroup(ctx, t, streamName, producer.client) | ||
var keys []string | ||
for _, c := range consumers { | ||
keys = append(keys, c.heartBeatKey()) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
cant you just return &TestProducerConfig?
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.
We run tests in parallel and some of them change property on it, e.g. set EnableReproduce to false. If you use same instance for concurrently running tests, tests will become flaky.