This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new fec3f8c1b3b Add more test cases on SetDistVariableExecutorTest (#38037)
fec3f8c1b3b is described below

commit fec3f8c1b3bd0f48ffa0f55fdce07f8aa9bec7cb
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Feb 14 10:52:20 2026 +0800

    Add more test cases on SetDistVariableExecutorTest (#38037)
    
    * Add more test cases on SetDistVariableExecutorTest
    
    * Add more test cases on SetDistVariableExecutorTest
    
    * Add more test cases on SetDistVariableExecutorTest
---
 .github/workflows/e2e-agent.yml                    |  2 +
 .github/workflows/e2e-operation.yml                |  2 +
 .github/workflows/e2e-sql.yml                      |  2 +
 .github/workflows/nightly-e2e-agent.yml            |  2 +
 .github/workflows/nightly-e2e-operation.yml        |  2 +
 .github/workflows/nightly-e2e-sql.yml              |  2 +
 .../variable/SetDistVariableExecutorTest.java      | 91 ++++++++++------------
 7 files changed, 51 insertions(+), 52 deletions(-)

diff --git a/.github/workflows/e2e-agent.yml b/.github/workflows/e2e-agent.yml
index b45b0f96b2b..2a7aafc7e8d 100644
--- a/.github/workflows/e2e-agent.yml
+++ b/.github/workflows/e2e-agent.yml
@@ -61,6 +61,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - uses: actions/[email protected]
         with:
           path: |
@@ -136,6 +137,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - uses: actions/[email protected]
         with:
           path: |
diff --git a/.github/workflows/e2e-operation.yml 
b/.github/workflows/e2e-operation.yml
index e2441fdd245..b7c355c4590 100644
--- a/.github/workflows/e2e-operation.yml
+++ b/.github/workflows/e2e-operation.yml
@@ -65,6 +65,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - name: Maven Install
         env:
           PREFIX: "test/e2e/operation/"
@@ -124,6 +125,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - name: Download Build Artifacts
         uses: actions/download-artifact@v4
         with:
diff --git a/.github/workflows/e2e-sql.yml b/.github/workflows/e2e-sql.yml
index 0935192317c..b1d3f897011 100644
--- a/.github/workflows/e2e-sql.yml
+++ b/.github/workflows/e2e-sql.yml
@@ -65,6 +65,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - uses: actions/[email protected]
         with:
           path: |
@@ -135,6 +136,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - name: Download E2E Image
         if: matrix.adapter == 'proxy'
         uses: actions/download-artifact@v4
diff --git a/.github/workflows/nightly-e2e-agent.yml 
b/.github/workflows/nightly-e2e-agent.yml
index 67126fec955..361b982563a 100644
--- a/.github/workflows/nightly-e2e-agent.yml
+++ b/.github/workflows/nightly-e2e-agent.yml
@@ -49,6 +49,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - uses: actions/[email protected]
         with:
           path: |
@@ -124,6 +125,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - uses: actions/[email protected]
         with:
           path: |
diff --git a/.github/workflows/nightly-e2e-operation.yml 
b/.github/workflows/nightly-e2e-operation.yml
index 898f929536b..6c828c7c502 100644
--- a/.github/workflows/nightly-e2e-operation.yml
+++ b/.github/workflows/nightly-e2e-operation.yml
@@ -55,6 +55,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - name: Maven Install
         env:
           PREFIX: "test/e2e/operation/"
@@ -119,6 +120,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - name: Download Build Artifacts
         uses: actions/download-artifact@v4
         with:
diff --git a/.github/workflows/nightly-e2e-sql.yml 
b/.github/workflows/nightly-e2e-sql.yml
index 12aae7ffba5..8aa0f37f129 100644
--- a/.github/workflows/nightly-e2e-sql.yml
+++ b/.github/workflows/nightly-e2e-sql.yml
@@ -49,6 +49,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - uses: actions/[email protected]
         with:
           path: |
@@ -125,6 +126,7 @@ jobs:
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
+          set-host: true
       - name: Download E2E Image
         if: matrix.adapter == 'proxy'
         uses: actions/download-artifact@v4
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
index 00e982adfae..91256f33e85 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
@@ -17,7 +17,6 @@
 
 package 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.variable;
 
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
 import 
org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecutor;
 import 
org.apache.shardingsphere.distsql.statement.type.ral.updatable.SetDistVariableStatement;
 import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
@@ -31,87 +30,75 @@ import 
org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext;
 import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData;
 import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import 
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
 import 
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatistics;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistFacade;
-import 
org.apache.shardingsphere.mode.metadata.persist.config.global.PropertiesPersistService;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 import java.util.Collections;
 import java.util.Properties;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 class SetDistVariableExecutorTest {
     
     private final SetDistVariableExecutor executor = (SetDistVariableExecutor) 
TypedSPILoader.getService(DistSQLUpdateExecutor.class, 
SetDistVariableStatement.class);
     
-    @Test
-    void assertExecuteWithConfigurationKey() {
-        SetDistVariableStatement statement = new 
SetDistVariableStatement("proxy_frontend_flush_threshold", "1024");
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("assertExecuteUpdateSuccessArguments")
+    void assertExecuteUpdateSuccess(final String caseName, final 
SetDistVariableStatement statement, final Consumer<ContextManager> assertion) {
         ContextManager contextManager = mockContextManager();
         executor.executeUpdate(statement, contextManager);
-        
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD),
 is(1024));
+        assertDoesNotThrow(() -> assertion.accept(contextManager));
     }
     
-    @Test
-    void assertExecuteWithTemporaryConfigurationKey() {
-        SetDistVariableStatement statement = new 
SetDistVariableStatement("proxy_meta_data_collector_enabled", "false");
-        ContextManager contextManager = mockContextManager();
-        executor.executeUpdate(statement, contextManager);
-        assertFalse((Boolean) 
contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getValue(TemporaryConfigurationPropertyKey.PROXY_META_DATA_COLLECTOR_ENABLED));
-    }
-    
-    @Test
-    void assertExecuteWithTypedSPI() {
-        SetDistVariableStatement statement = new 
SetDistVariableStatement("proxy_frontend_database_protocol_type", "Fixture");
-        ContextManager contextManager = mockContextManager();
-        executor.executeUpdate(statement, contextManager);
-        
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getProps().getProperty("proxy-frontend-database-protocol-type"),
 is("FIXTURE"));
-        assertThat(((DatabaseType) 
contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_FRONTEND_DATABASE_PROTOCOL_TYPE)).getType(),
 is("FIXTURE"));
-    }
-    
-    @Test
-    void assertExecuteWithUnsupportedVariable() {
-        assertThrows(UnsupportedVariableException.class, () -> 
executor.executeUpdate(new SetDistVariableStatement("unknown", "1"), 
mockContextManager()));
+    private static Stream<Arguments> assertExecuteUpdateSuccessArguments() {
+        return Stream.of(
+                Arguments.of("configuration key", new 
SetDistVariableStatement("proxy_frontend_flush_threshold", "1024"),
+                        (Consumer<ContextManager>) contextManager -> 
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps()
+                                
.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD), is(1024))),
+                Arguments.of("temporary configuration key", new 
SetDistVariableStatement("proxy_meta_data_collector_enabled", "false"),
+                        (Consumer<ContextManager>) contextManager -> 
assertFalse(
+                                (Boolean) 
contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getValue(TemporaryConfigurationPropertyKey.PROXY_META_DATA_COLLECTOR_ENABLED))),
+                Arguments.of("typed spi property", new 
SetDistVariableStatement("proxy_frontend_database_protocol_type", "Fixture"),
+                        (Consumer<ContextManager>) contextManager -> 
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getProps()
+                                
.getProperty("proxy-frontend-database-protocol-type"), is("FIXTURE"))),
+                Arguments.of("valid cron property", new 
SetDistVariableStatement("proxy_meta_data_collector_cron", "0 0/5 * * * ?"),
+                        (Consumer<ContextManager>) contextManager -> 
assertThat(contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getProps()
+                                
.getProperty("proxy-meta-data-collector-cron"), is("0 0/5 * * * ?"))));
     }
     
-    @Test
-    void assertExecuteWithInvalidValue() {
-        assertThrows(InvalidVariableValueException.class, () -> 
executor.executeUpdate(new 
SetDistVariableStatement("proxy_frontend_flush_threshold", "invalid"), 
mockContextManager()));
-    }
-    
-    @Test
-    void assertExecuteWithCronVariable() {
-        ContextManager contextManager = mockContextManager();
-        SetDistVariableStatement statement = new 
SetDistVariableStatement("proxy_meta_data_collector_cron", "0 0/5 * * * ?");
-        executor.executeUpdate(statement, contextManager);
-        
assertThat(contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getProps().getProperty("proxy-meta-data-collector-cron"),
 is("0 0/5 * * * ?"));
-    }
-    
-    @Test
-    void assertExecuteWithInvalidCronVariable() {
-        assertThrows(InvalidVariableValueException.class, () -> 
executor.executeUpdate(new 
SetDistVariableStatement("proxy_meta_data_collector_cron", "invalid"), 
mockContextManager()));
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("assertExecuteUpdateFailureArguments")
+    void assertExecuteUpdateFailure(final String caseName, final 
SetDistVariableStatement statement, final Class<? extends Throwable> 
expectedExceptionType) {
+        assertThrows(expectedExceptionType, () -> 
executor.executeUpdate(statement, mockContextManager()));
     }
     
     private ContextManager mockContextManager() {
-        MetaDataPersistFacade metaDataPersistFacade = 
mock(MetaDataPersistFacade.class, RETURNS_DEEP_STUBS);
-        
when(metaDataPersistFacade.getPropsService()).thenReturn(mock(PropertiesPersistService.class));
         ComputeNodeInstanceContext computeNodeInstanceContext = new 
ComputeNodeInstanceContext(
                 new ComputeNodeInstance(mock(InstanceMetaData.class)), new 
ModeConfiguration("Standalone", null), new EventBusContext());
         computeNodeInstanceContext.init(mock(WorkerIdGenerator.class));
-        return new ContextManager(new MetaDataContexts(new 
ShardingSphereMetaData(Collections.emptyList(), new 
ResourceMetaData(Collections.emptyMap()),
-                new RuleMetaData(Collections.emptyList()), new 
ConfigurationProperties(new Properties())), new ShardingSphereStatistics()), 
computeNodeInstanceContext, mock(), mock());
+        return new ContextManager(new MetaDataContexts(
+                new ShardingSphereMetaData(Collections.emptyList(), mock(), 
mock(), new ConfigurationProperties(new Properties())), new 
ShardingSphereStatistics()),
+                computeNodeInstanceContext, mock(), mock());
+    }
+    
+    private static Stream<Arguments> assertExecuteUpdateFailureArguments() {
+        return Stream.of(
+                Arguments.of("unsupported variable", new 
SetDistVariableStatement("unknown", "1"), UnsupportedVariableException.class),
+                Arguments.of("invalid numeric value", new 
SetDistVariableStatement("proxy_frontend_flush_threshold", "invalid"), 
InvalidVariableValueException.class),
+                Arguments.of("invalid cron expression", new 
SetDistVariableStatement("proxy_meta_data_collector_cron", "invalid"), 
InvalidVariableValueException.class),
+                Arguments.of("empty cron expression", new 
SetDistVariableStatement("proxy_meta_data_collector_cron", ""), 
InvalidVariableValueException.class));
     }
 }

Reply via email to