zoudan commented on code in PR #23849: URL: https://github.com/apache/flink/pull/23849#discussion_r1416957349
########## flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/service/SqlGatewayServiceStatementITCase.java: ########## @@ -52,18 +59,49 @@ /** Test {@link SqlGatewayService}#executeStatement. */ public class SqlGatewayServiceStatementITCase extends AbstractSqlGatewayStatementITCase { - private final SessionEnvironment defaultSessionEnvironment = + private static final SessionEnvironment DEFAULT_SESSION_ENVIRONMENT = + SessionEnvironment.newBuilder() + .setSessionEndpointVersion(MockedEndpointVersion.V1) + .build(); + + private static final SessionEnvironment SESSION_ENVIRONMENT_WITH_PLAN_CACHE_ENABLED = SessionEnvironment.newBuilder() .setSessionEndpointVersion(MockedEndpointVersion.V1) + .addSessionConfig( + Collections.singletonMap( + SQL_GATEWAY_SESSION_PLAN_CACHE_ENABLED.key(), "true")) .build(); private SessionHandle sessionHandle; + @Parameters(name = "parameters={0}") + public static List<TestParameters> parameters() throws Exception { + return listFlinkSqlTests().stream() + .map(path -> new StatementTestParameters(path, path.endsWith("repeated_dql.q"))) + .collect(Collectors.toList()); + } + @BeforeEach @Override public void before(@TempDir Path temporaryFolder) throws Exception { super.before(temporaryFolder); - sessionHandle = service.openSession(defaultSessionEnvironment); + SessionEnvironment sessionEnvironment = + isPlanCacheEnabled() + ? SESSION_ENVIRONMENT_WITH_PLAN_CACHE_ENABLED + : DEFAULT_SESSION_ENVIRONMENT; + sessionHandle = service.openSession(sessionEnvironment); + } + + @AfterEach + public void after() { + if (isPlanCacheEnabled()) { + CacheStats cacheStats = + ((SqlGatewayServiceImpl) service) + .getSession(sessionHandle) + .getPlanCacheManager() + .getCacheStats(); + assertThat(cacheStats).isEqualTo(new CacheStats(4, 14, 0, 0, 0, 0)); Review Comment: How about we just check the value of hitCount? Then we only have to modify the expected value when we add/delete/modify a query which has an impact on cache hits. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org