This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 06071e2037a Simplify MCP functionality E2E transport cases (#39287)
06071e2037a is described below
commit 06071e2037a9d8ab50ebb50a665cf51028f5af74
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jul 31 14:29:23 2026 +0800
Simplify MCP functionality E2E transport cases (#39287)
---
.../functionality/AbstractMySQLRuntimeE2ETest.java | 4 --
.../AbstractTransportParameterizedE2ETest.java | 9 +--
.../functionality/FunctionalityTransportCases.java | 52 +++++++-----------
.../mcp/functionality/MySQLMetadataE2ETest.java | 64 +++++++---------------
.../mcp/functionality/MySQLReadOnlySQLE2ETest.java | 31 ++++-------
.../functionality/MySQLSQLExecutionE2ETest.java | 58 +++++++-------------
.../PostgreSQLDatabaseGatewayE2ETest.java | 16 +-----
7 files changed, 76 insertions(+), 158 deletions(-)
diff --git
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/AbstractMySQLRuntimeE2ETest.java
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/AbstractMySQLRuntimeE2ETest.java
index b7c5ba16261..487d492589a 100644
---
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/AbstractMySQLRuntimeE2ETest.java
+++
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/AbstractMySQLRuntimeE2ETest.java
@@ -152,10 +152,6 @@ abstract class AbstractMySQLRuntimeE2ETest extends
AbstractTransportParameterize
return FunctionalityTransportCases.allTransportCases();
}
- protected static Stream<Arguments> httpTransportCase() {
- return FunctionalityTransportCases.httpTransportCase();
- }
-
protected static Stream<Arguments> singleMetadataResourceCases() {
return
FunctionalityTransportCases.singleMetadataResourceCases(LOGICAL_DATABASE_NAME);
}
diff --git
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/AbstractTransportParameterizedE2ETest.java
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/AbstractTransportParameterizedE2ETest.java
index 7b69bae0e91..f8abeaec543 100644
---
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/AbstractTransportParameterizedE2ETest.java
+++
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/AbstractTransportParameterizedE2ETest.java
@@ -22,22 +22,19 @@ import org.junit.jupiter.api.AfterEach;
abstract class AbstractTransportParameterizedE2ETest extends
AbstractFunctionalityE2ETest {
- private RuntimeTransport transport;
+ private RuntimeTransport transport = RuntimeTransport.HTTP;
protected final void useTransport(final RuntimeTransport transport) {
this.transport = transport;
}
@AfterEach
- void clearTransport() {
- transport = null;
+ void resetTransport() {
+ transport = RuntimeTransport.HTTP;
}
@Override
protected final RuntimeTransport getTransport() {
- if (null == transport) {
- throw new IllegalStateException("Runtime transport is not selected
for current MCP Functionality E2E test.");
- }
return transport;
}
}
diff --git
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/FunctionalityTransportCases.java
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/FunctionalityTransportCases.java
index f3a1fd8410d..43d5796f167 100644
---
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/FunctionalityTransportCases.java
+++
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/FunctionalityTransportCases.java
@@ -32,49 +32,35 @@ final class FunctionalityTransportCases {
return allTransports().map(each ->
Arguments.of(getTransportName(each), each));
}
- static Stream<Arguments> httpTransportCase() {
- return httpTransports().map(each ->
Arguments.of(getTransportName(each), each));
- }
-
static Stream<Arguments> singleMetadataResourceCases(final String
logicalDatabaseName) {
- return httpTransports().flatMap(each ->
createSingleMetadataResourceCases(logicalDatabaseName, each));
+ return Stream.of(
+ Arguments.of("database detail", "shardingsphere://databases/"
+ logicalDatabaseName, "database", logicalDatabaseName),
+ Arguments.of("schema detail", "shardingsphere://databases/" +
logicalDatabaseName + "/schemas/" + logicalDatabaseName, "schema",
logicalDatabaseName),
+ Arguments.of("table column detail",
+ "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/tables/orders/columns/status", "column",
"status"),
+ Arguments.of("view detail", "shardingsphere://databases/" +
logicalDatabaseName + "/schemas/" + logicalDatabaseName +
"/views/active_orders", "view", "active_orders"),
+ Arguments.of("view column detail",
+ "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/views/active_orders/columns/status",
"column", "status"),
+ Arguments.of("index detail",
+ "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/tables/orders/indexes/idx_orders_status",
"index", "idx_orders_status"));
}
static Stream<Arguments> collectionMetadataResourceCases(final String
logicalDatabaseName) {
- return httpTransports().flatMap(each -> Stream.of(
- Arguments.of(getTransportName(each) + " schemas list", each,
"shardingsphere://databases/" + logicalDatabaseName + "/schemas", "schema",
List.of(logicalDatabaseName)),
- Arguments.of(getTransportName(each) + " tables list", each,
- "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/tables", "table", List.of("order_items",
"orders")),
- Arguments.of(getTransportName(each) + " table columns list",
each,
- "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/tables/orders/columns", "column",
List.of("amount", "order_id", "status")),
- Arguments.of(getTransportName(each) + " view columns list",
each,
- "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/views/active_orders/columns", "column",
List.of("order_id", "status"))));
+ return Stream.of(
+ Arguments.of("schemas list", "shardingsphere://databases/" +
logicalDatabaseName + "/schemas", "schema", List.of(logicalDatabaseName)),
+ Arguments.of("tables list", "shardingsphere://databases/" +
logicalDatabaseName + "/schemas/" + logicalDatabaseName + "/tables", "table",
List.of("order_items", "orders")),
+ Arguments.of("table columns list",
"shardingsphere://databases/" + logicalDatabaseName + "/schemas/" +
logicalDatabaseName + "/tables/orders/columns", "column",
+ List.of("amount", "order_id", "status")),
+ Arguments.of("view columns list",
"shardingsphere://databases/" + logicalDatabaseName + "/schemas/" +
logicalDatabaseName + "/views/active_orders/columns", "column",
+ List.of("order_id", "status")));
}
- static Stream<RuntimeTransport> allTransports() {
+ private static Stream<RuntimeTransport> allTransports() {
return Stream.of(RuntimeTransport.HTTP, RuntimeTransport.STDIO);
}
- static String getTransportName(final RuntimeTransport transport) {
+ private static String getTransportName(final RuntimeTransport transport) {
return RuntimeTransport.HTTP == transport ? "http" : "stdio";
}
- private static Stream<RuntimeTransport> httpTransports() {
- return Stream.of(RuntimeTransport.HTTP);
- }
-
- private static Stream<Arguments> createSingleMetadataResourceCases(final
String logicalDatabaseName, final RuntimeTransport transport) {
- return Stream.of(
- Arguments.of(getTransportName(transport) + " database detail",
transport, "shardingsphere://databases/" + logicalDatabaseName, "database",
logicalDatabaseName),
- Arguments.of(getTransportName(transport) + " schema detail",
transport, "shardingsphere://databases/" + logicalDatabaseName + "/schemas/" +
logicalDatabaseName, "schema",
- logicalDatabaseName),
- Arguments.of(getTransportName(transport) + " table column
detail", transport,
- "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/tables/orders/columns/status", "column",
"status"),
- Arguments.of(getTransportName(transport) + " view detail",
transport,
- "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/views/active_orders", "view",
"active_orders"),
- Arguments.of(getTransportName(transport) + " view column
detail", transport,
- "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/views/active_orders/columns/status",
"column", "status"),
- Arguments.of(getTransportName(transport) + " index detail",
transport,
- "shardingsphere://databases/" + logicalDatabaseName +
"/schemas/" + logicalDatabaseName + "/tables/orders/indexes/idx_orders_status",
"index", "idx_orders_status"));
- }
}
diff --git
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLMetadataE2ETest.java
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLMetadataE2ETest.java
index 880b05e477f..deac7ff536a 100644
---
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLMetadataE2ETest.java
+++
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLMetadataE2ETest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.test.e2e.mcp.functionality;
-import org.apache.shardingsphere.test.e2e.mcp.support.runtime.RuntimeTransport;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.MCPPayloadAssertions;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.client.MCPInteractionClient;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -43,10 +43,8 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
return true;
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertReadCapabilities(final String name, final RuntimeTransport
transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertReadCapabilities() throws IOException, InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual =
interactionClient.readResource("shardingsphere://databases/logic_db/capabilities");
assertThat(String.valueOf(actual.get("databaseType")),
is("MySQL"));
@@ -54,19 +52,15 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertReadDatabasesResource(final String name, final RuntimeTransport
transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertReadDatabasesResource() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
MCPPayloadAssertions.assertSingleItemValue(interactionClient.readResource("shardingsphere://databases"),
"database", LOGICAL_DATABASE_NAME);
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertReadUnknownDatabaseRecovery(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertReadUnknownDatabaseRecovery() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual =
interactionClient.readResource("shardingsphere://databases/missing_db");
assertTrue(getPayloadItems(actual).isEmpty());
@@ -80,9 +74,7 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
@ParameterizedTest(name = "{0}")
@MethodSource("singleMetadataResourceCases")
- void assertReadSingleMetadataResource(final String name, final
RuntimeTransport transport,
- final String resourceUri, final
String key, final String expectedValue) throws IOException,
InterruptedException {
- useTransport(transport);
+ void assertReadSingleMetadataResource(final String name, final String
resourceUri, final String key, final String expectedValue) throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
MCPPayloadAssertions.assertSingleItemValue(interactionClient.readResource(resourceUri),
key, expectedValue);
}
@@ -90,18 +82,14 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
@ParameterizedTest(name = "{0}")
@MethodSource("collectionMetadataResourceCases")
- void assertReadCollectionMetadataResource(final String name, final
RuntimeTransport transport,
- final String resourceUri, final
String key, final List<String> expectedNames) throws IOException,
InterruptedException {
- useTransport(transport);
+ void assertReadCollectionMetadataResource(final String name, final String
resourceUri, final String key, final List<String> expectedNames) throws
IOException, InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
MCPPayloadAssertions.assertItemValues(interactionClient.readResource(resourceUri),
key, expectedNames);
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertReadTableDetail(final String name, final RuntimeTransport
transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertReadTableDetail() throws IOException, InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
List<Map<String, Object>> items =
getPayloadItems(interactionClient.readResource(
String.format("shardingsphere://databases/%s/schemas/%s/tables/orders",
LOGICAL_DATABASE_NAME, LOGICAL_DATABASE_NAME)));
@@ -113,10 +101,8 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertSearchMetadataTablesAndViews(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertSearchMetadataTablesAndViews() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
List<Map<String, Object>> items =
getPayloadItems(interactionClient.call("database_gateway_search_metadata",
Map.of("database", LOGICAL_DATABASE_NAME, "schema",
LOGICAL_DATABASE_NAME, "query", "order", "object_types", List.of("table",
"view"))));
@@ -124,10 +110,8 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertValidateRuntimeDatabase(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertValidateRuntimeDatabase() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual = interactionClient.call(
"database_gateway_validate_runtime_database",
Map.of("database", LOGICAL_DATABASE_NAME));
@@ -140,10 +124,8 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertSearchMetadataPagination(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertSearchMetadataPagination() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> firstPage =
interactionClient.call("database_gateway_search_metadata",
Map.of("database", LOGICAL_DATABASE_NAME, "schema",
LOGICAL_DATABASE_NAME, "query", "order",
@@ -160,10 +142,8 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertReadViews(final String name, final RuntimeTransport transport)
throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertReadViews() throws IOException, InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
List<Map<String, Object>> items =
getPayloadItems(interactionClient.readResource(
String.format("shardingsphere://databases/%s/schemas/%s/views",
LOGICAL_DATABASE_NAME, LOGICAL_DATABASE_NAME)));
@@ -172,10 +152,8 @@ class MySQLMetadataE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertReadIndexes(final String name, final RuntimeTransport
transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertReadIndexes() throws IOException, InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
List<String> actualIndexNames =
getPayloadItems(interactionClient.readResource(
String.format("shardingsphere://databases/%s/schemas/%s/tables/orders/indexes",
LOGICAL_DATABASE_NAME, LOGICAL_DATABASE_NAME)))
diff --git
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLReadOnlySQLE2ETest.java
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLReadOnlySQLE2ETest.java
index 02364479502..a512582a2e3 100644
---
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLReadOnlySQLE2ETest.java
+++
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLReadOnlySQLE2ETest.java
@@ -23,6 +23,7 @@ import
org.apache.shardingsphere.test.e2e.mcp.support.runtime.RuntimeTransport;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.MCPInteractionPayloads;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.MCPPayloadAssertions;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.client.MCPInteractionClient;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -45,10 +46,8 @@ class MySQLReadOnlySQLE2ETest extends
AbstractMySQLRuntimeE2ETest {
return true;
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteSelect(final String name, final RuntimeTransport
transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteSelect() throws IOException, InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual =
interactionClient.call("database_gateway_execute_query",
Map.of("database", LOGICAL_DATABASE_NAME, "schema",
LOGICAL_DATABASE_NAME, "sql", "SELECT status FROM orders ORDER BY order_id",
"max_rows", 10));
@@ -56,10 +55,8 @@ class MySQLReadOnlySQLE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteSelectWithTruncation(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteSelectWithTruncation() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual =
interactionClient.call("database_gateway_execute_query",
Map.of("database", LOGICAL_DATABASE_NAME, "schema",
LOGICAL_DATABASE_NAME, "sql", "SELECT order_id, status FROM orders ORDER BY
order_id", "max_rows", 1));
@@ -69,10 +66,8 @@ class MySQLReadOnlySQLE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteExplainSelect(final String name, final RuntimeTransport
transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteExplainSelect() throws IOException, InterruptedException
{
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual =
interactionClient.call("database_gateway_execute_explain_query",
Map.of("database", LOGICAL_DATABASE_NAME, "schema",
LOGICAL_DATABASE_NAME, "sql", "SELECT * FROM orders WHERE order_id = 1",
@@ -83,10 +78,8 @@ class MySQLReadOnlySQLE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteQueryTimeout(final String name, final RuntimeTransport
transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteQueryTimeout() throws IOException, InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual =
interactionClient.call("database_gateway_execute_query",
Map.of("database", LOGICAL_DATABASE_NAME, "schema",
LOGICAL_DATABASE_NAME, "sql", "SELECT SLEEP(2)", "timeout_ms", 1));
@@ -125,10 +118,8 @@ class MySQLReadOnlySQLE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertRejectSequenceResource(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertRejectSequenceResource() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual = interactionClient.readResource(
String.format("shardingsphere://databases/%s/schemas/%s/sequences",
LOGICAL_DATABASE_NAME, LOGICAL_DATABASE_NAME));
diff --git
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLSQLExecutionE2ETest.java
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLSQLExecutionE2ETest.java
index e50beeb2fdb..f10b5fa63ea 100644
---
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLSQLExecutionE2ETest.java
+++
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/MySQLSQLExecutionE2ETest.java
@@ -18,12 +18,10 @@
package org.apache.shardingsphere.test.e2e.mcp.functionality;
import
org.apache.shardingsphere.test.e2e.mcp.support.runtime.MySQLRuntimeTestSupport;
-import org.apache.shardingsphere.test.e2e.mcp.support.runtime.RuntimeTransport;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.MCPPayloadAssertions;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.client.MCPInteractionClient;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.sql.SQLException;
@@ -39,10 +37,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@EnabledIf("org.apache.shardingsphere.test.e2e.mcp.env.MCPE2ECondition#isDockerEnabled")
class MySQLSQLExecutionE2ETest extends AbstractMySQLRuntimeE2ETest {
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteUpdate(final String name, final RuntimeTransport
transport) throws SQLException, IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteUpdate() throws SQLException, IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> actual =
interactionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments("UPDATE orders SET status =
'PENDING' WHERE order_id = 1"));
@@ -52,10 +48,8 @@ class MySQLSQLExecutionE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteRollback(final String name, final RuntimeTransport
transport) throws SQLException, IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteRollback() throws SQLException, IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> beginResponse =
interactionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments("BEGIN"));
interactionClient.call("database_gateway_execute_update",
@@ -67,10 +61,8 @@ class MySQLSQLExecutionE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteSavepointFlow(final String name, final RuntimeTransport
transport) throws SQLException, IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteSavepointFlow() throws SQLException, IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
interactionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments("BEGIN"));
interactionClient.call("database_gateway_execute_update",
@@ -87,10 +79,8 @@ class MySQLSQLExecutionE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteReleaseSavepoint(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteReleaseSavepoint() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
interactionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments("BEGIN"));
Map<String, Object> savepointResponse =
interactionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments("SAVEPOINT sp_release"));
@@ -102,10 +92,8 @@ class MySQLSQLExecutionE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertExecuteDdlRefreshesMetadata(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertExecuteDdlRefreshesMetadata() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
Map<String, Object> executeResponse =
interactionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments("CREATE TABLE orders_archive
(order_id INT PRIMARY KEY)"));
@@ -116,10 +104,8 @@ class MySQLSQLExecutionE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertCloseRollsBackPendingTransaction(final String name, final
RuntimeTransport transport) throws SQLException, IOException,
InterruptedException {
- useTransport(transport);
+ @Test
+ void assertCloseRollsBackPendingTransaction() throws SQLException,
IOException, InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
interactionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments("BEGIN"));
interactionClient.call("database_gateway_execute_update",
@@ -129,10 +115,8 @@ class MySQLSQLExecutionE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertListDatabasesWithMultipleRuntimeDatabases(final String name,
final RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertListDatabasesWithMultipleRuntimeDatabases() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient(createPreparedProgrammaticRuntimeDatabases())) {
List<String> actualDatabaseNames =
getPayloadItems(interactionClient.readResource("shardingsphere://databases")).stream()
.map(each ->
String.valueOf(each.get("database"))).toList();
@@ -140,10 +124,8 @@ class MySQLSQLExecutionE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertRefreshMetadataVisibleForTargetDatabaseOnly(final String name,
final RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertRefreshMetadataVisibleForTargetDatabaseOnly() throws
IOException, InterruptedException {
try (MCPInteractionClient firstInteractionClient =
createOpenedInteractionClient(createPreparedProgrammaticRuntimeDatabases())) {
firstInteractionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments(LOGICAL_DATABASE_NAME,
"CREATE TABLE orders_archive (order_id INT PRIMARY KEY)"));
@@ -159,10 +141,8 @@ class MySQLSQLExecutionE2ETest extends
AbstractMySQLRuntimeE2ETest {
}
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertRejectCrossDatabaseTransactionSwitch(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertRejectCrossDatabaseTransactionSwitch() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient(createPreparedProgrammaticRuntimeDatabases())) {
interactionClient.call("database_gateway_execute_update",
createExecuteUpdateArguments(LOGICAL_DATABASE_NAME, "BEGIN"));
Map<String, Object> actual =
interactionClient.call("database_gateway_execute_query",
diff --git
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/PostgreSQLDatabaseGatewayE2ETest.java
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/PostgreSQLDatabaseGatewayE2ETest.java
index 5e0d9cdd350..872b699600a 100644
---
a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/PostgreSQLDatabaseGatewayE2ETest.java
+++
b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/functionality/PostgreSQLDatabaseGatewayE2ETest.java
@@ -19,16 +19,13 @@ package
org.apache.shardingsphere.test.e2e.mcp.functionality;
import
org.apache.shardingsphere.mcp.support.database.metadata.jdbc.RuntimeDatabaseConfiguration;
import
org.apache.shardingsphere.test.e2e.mcp.support.runtime.PostgreSQLRuntimeTestSupport;
-import org.apache.shardingsphere.test.e2e.mcp.support.runtime.RuntimeTransport;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.MCPInteractionPayloads;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.MCPPayloadAssertions;
import
org.apache.shardingsphere.test.e2e.mcp.support.transport.client.MCPInteractionClient;
import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.condition.EnabledIf;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
import org.testcontainers.containers.GenericContainer;
import java.io.IOException;
@@ -36,7 +33,6 @@ import java.sql.SQLException;
import java.sql.Types;
import java.util.List;
import java.util.Map;
-import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -88,10 +84,8 @@ class PostgreSQLDatabaseGatewayE2ETest extends
AbstractTransportParameterizedE2E
return PostgreSQLRuntimeTestSupport.createRuntimeDatabases(container,
LOGICAL_DATABASE_NAME);
}
- @ParameterizedTest(name = "{0}")
- @MethodSource("httpTransportCase")
- void assertDatabaseGatewayContract(final String name, final
RuntimeTransport transport) throws IOException, InterruptedException {
- useTransport(transport);
+ @Test
+ void assertDatabaseGatewayContract() throws IOException,
InterruptedException {
try (MCPInteractionClient interactionClient =
createOpenedInteractionClient()) {
assertMetadata(interactionClient);
assertQueries(interactionClient);
@@ -159,10 +153,6 @@ class PostgreSQLDatabaseGatewayE2ETest extends
AbstractTransportParameterizedE2E
return Map.of("database", LOGICAL_DATABASE_NAME, "schema", schema,
"sql", sql, "execution_mode", "execute");
}
- private static Stream<Arguments> httpTransportCase() {
- return FunctionalityTransportCases.httpTransportCase();
- }
-
private Map<String, Object> findNested(final Map<String, Object> payload,
final String collectionName, final String fieldName, final String
expectedValue) {
return ((List<?>) payload.get(collectionName)).stream().map(each ->
MCPInteractionPayloads.getRequiredObjectValue(each, collectionName))
.filter(each ->
expectedValue.equals(each.get(fieldName))).findFirst().orElseThrow();