ruanwenjun commented on a change in pull request #6500:
URL: https://github.com/apache/dolphinscheduler/pull/6500#discussion_r727686337
##########
File path:
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java
##########
@@ -106,17 +115,30 @@ public DruidDataSource dataSource() throws SQLException {
//auto commit
druidDataSource.setDefaultAutoCommit(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_DEFAULT_AUTO_COMMIT,
true));
druidDataSource.init();
+ logger.info("Initialize Druid DataSource success");
return druidDataSource;
}
+ @Bean(name = "datasource")
+ @Profile(value = {ProfileType.UNIT_TEST})
+ public DataSource h2DataSource() {
+ EmbeddedDatabaseBuilder embeddedDatabaseBuilder = new
EmbeddedDatabaseBuilder(new FileSystemResourceLoader());
+ EmbeddedDatabase datasource =
embeddedDatabaseBuilder.setType(EmbeddedDatabaseType.H2)
+ .setName("DolphinSchedulerUT;MODE=MySQL")
+ .addScript("file:../sql/dolphinscheduler_h2.sql")
+ .build();
+ logger.info("Initialize H2 DataSource success");
+ return datasource;
+ }
Review comment:
Yes, it's better to add multiple profiles.
##########
File path:
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java
##########
@@ -106,17 +115,30 @@ public DruidDataSource dataSource() throws SQLException {
//auto commit
druidDataSource.setDefaultAutoCommit(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_DEFAULT_AUTO_COMMIT,
true));
druidDataSource.init();
+ logger.info("Initialize Druid DataSource success");
return druidDataSource;
}
+ @Bean(name = "datasource")
+ @Profile(value = {ProfileType.UNIT_TEST})
+ public DataSource h2DataSource() {
+ EmbeddedDatabaseBuilder embeddedDatabaseBuilder = new
EmbeddedDatabaseBuilder(new FileSystemResourceLoader());
+ EmbeddedDatabase datasource =
embeddedDatabaseBuilder.setType(EmbeddedDatabaseType.H2)
+ .setName("DolphinSchedulerUT;MODE=MySQL")
+ .addScript("file:../sql/dolphinscheduler_h2.sql")
+ .build();
+ logger.info("Initialize H2 DataSource success");
+ return datasource;
+ }
Review comment:
Yes, it's better to add multiple profile files.
--
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]