git-hulk commented on code in PR #1855:
URL: https://github.com/apache/kvrocks/pull/1855#discussion_r1375341120


##########
tests/gocase/unit/config/config_test.go:
##########
@@ -141,3 +144,92 @@ func TestStartWithoutConfigurationFile(t *testing.T) {
        require.NoError(t, rdb.Do(ctx, "SET", "foo", "bar").Err())
        require.Equal(t, "bar", rdb.Do(ctx, "GET", "foo").Val())
 }
+
+func TestDynamicChangeWorkerThread(t *testing.T) {
+       configs := map[string]string{}
+       srv := util.StartServer(t, configs)
+       defer srv.Close()
+
+       ctx := context.Background()
+       rdb := srv.NewClientWithOption(&redis.Options{
+               MaxIdleConns: 20,
+               MaxRetries:   -1, // Disable retry to check connections are 
alive after config change
+       })
+       defer func() { require.NoError(t, rdb.Close()) }()
+
+       t.Run("Test dynamic change worker thread", func(t *testing.T) {
+               runCommands := func(workers int) {
+                       var wg sync.WaitGroup
+                       require.NoError(t, rdb.Do(ctx, "CONFIG", "SET", 
"workers", strconv.Itoa(workers)).Err())
+                       for i := 0; i < 10; i++ {
+                               wg.Add(1)
+                               go func() {
+                                       defer wg.Done()
+                                       for j := 0; j < 10; j++ {
+                                               require.NoError(t, rdb.Set(ctx, 
"foo", "bar", 0).Err())
+                                       }
+                               }()
+                       }
+                       wg.Wait()
+               }
+               // Reduce worker threads to 4
+               runCommands(4)
+
+               // Reduce worker threads to 1
+               runCommands(1)
+
+               // Reduce worker threads to 12

Review Comment:
   Good catch, thank you!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to