Wenjun Ruan
1 year ago
committed by
GitHub
19 changed files with 4425 additions and 8 deletions
@ -0,0 +1,30 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.tools.datasource; |
||||
|
||||
import org.apache.dolphinscheduler.dao.DaoConfiguration; |
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.testcontainers.containers.Network; |
||||
|
||||
@SpringBootTest(classes = {UpgradeDolphinScheduler.class, DaoConfiguration.class}) |
||||
public abstract class BaseDolphinSchedulerManagerIT { |
||||
|
||||
protected static final Network NETWORK = Network.newNetwork(); |
||||
|
||||
} |
@ -0,0 +1,81 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.tools.datasource.mysql; |
||||
|
||||
import org.apache.dolphinscheduler.tools.datasource.BaseDolphinSchedulerManagerIT; |
||||
import org.apache.dolphinscheduler.tools.datasource.DolphinSchedulerManager; |
||||
|
||||
import java.util.stream.Stream; |
||||
|
||||
import javax.sql.DataSource; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import org.junit.jupiter.api.AfterAll; |
||||
import org.junit.jupiter.api.BeforeAll; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.test.context.ActiveProfiles; |
||||
import org.testcontainers.containers.GenericContainer; |
||||
import org.testcontainers.containers.MySQLContainer; |
||||
import org.testcontainers.containers.wait.strategy.Wait; |
||||
import org.testcontainers.lifecycle.Startables; |
||||
import org.testcontainers.utility.DockerImageName; |
||||
|
||||
import com.google.common.collect.Lists; |
||||
|
||||
// todo: use TestTemplate to test multiple mysql version
|
||||
@Slf4j |
||||
@ActiveProfiles("mysql") |
||||
public class BaseDolphinSchedulerDatabaseWithMysqlIT extends BaseDolphinSchedulerManagerIT { |
||||
|
||||
@Autowired |
||||
protected DolphinSchedulerManager dolphinSchedulerManager; |
||||
|
||||
@Autowired |
||||
protected DataSource dataSource; |
||||
|
||||
protected static GenericContainer databaseContainer; |
||||
|
||||
@BeforeAll |
||||
public static void initializeContainer() { |
||||
// todo: test with multiple mysql version
|
||||
databaseContainer = new MySQLContainer(DockerImageName.parse("mysql:8.0")) |
||||
.withUsername("root") |
||||
.withPassword("root") |
||||
.withDatabaseName("dolphinscheduler") |
||||
.withNetwork(NETWORK) |
||||
.withExposedPorts(3306) |
||||
.waitingFor(Wait.forHealthcheck()); |
||||
databaseContainer.setPortBindings(Lists.newArrayList("3306:3306")); |
||||
|
||||
log.info("Create MySQLContainer successfully."); |
||||
databaseContainer.start(); |
||||
|
||||
log.info("Starting MySQLContainer..."); |
||||
Startables.deepStart(Stream.of(databaseContainer)).join(); |
||||
log.info("MySQLContainer started"); |
||||
} |
||||
|
||||
@AfterAll |
||||
public static void closeContainer() { |
||||
if (databaseContainer != null) { |
||||
databaseContainer.stop(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.tools.datasource.mysql; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import org.junit.jupiter.api.Assertions; |
||||
import org.junit.jupiter.api.DisplayName; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.test.context.ActiveProfiles; |
||||
|
||||
@Slf4j |
||||
@ActiveProfiles("mysql") |
||||
class DolphinSchedulerDatabaseInitializeWithMysqlIT extends BaseDolphinSchedulerDatabaseWithMysqlIT { |
||||
|
||||
@Test |
||||
@DisplayName("Test Initialize DolphinScheduler database in MySQL") |
||||
void testInitializeWithMysqlProfile() { |
||||
Assertions.assertDoesNotThrow(() -> dolphinSchedulerManager.initDolphinScheduler()); |
||||
// todo: Assert table count
|
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,48 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.tools.datasource.mysql; |
||||
|
||||
import org.apache.dolphinscheduler.common.sql.SqlScriptRunner; |
||||
|
||||
import java.io.IOException; |
||||
import java.sql.SQLException; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import org.junit.jupiter.api.Assertions; |
||||
import org.junit.jupiter.api.DisplayName; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
@Slf4j |
||||
class DolphinSchedulerDatabaseUpgradeWithMysqlIT extends BaseDolphinSchedulerDatabaseWithMysqlIT { |
||||
|
||||
@Test |
||||
@DisplayName("Test Upgrade DolphinScheduler database in MySQL") |
||||
void testUpgradeWithMysqlProfile() throws SQLException, IOException { |
||||
|
||||
// initialize the 3.0.0 schema
|
||||
SqlScriptRunner sqlScriptRunner = new SqlScriptRunner(dataSource, "3.0.0_schema/mysql_3.0.0.sql"); |
||||
sqlScriptRunner.execute(); |
||||
log.info("Initialize the 3.0.0 schema successfully."); |
||||
|
||||
Assertions.assertDoesNotThrow(() -> dolphinSchedulerManager.upgradeDolphinScheduler()); |
||||
// todo: Assert table count
|
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,78 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.tools.datasource.postgresql; |
||||
|
||||
import org.apache.dolphinscheduler.tools.datasource.BaseDolphinSchedulerManagerIT; |
||||
import org.apache.dolphinscheduler.tools.datasource.DolphinSchedulerManager; |
||||
|
||||
import java.util.stream.Stream; |
||||
|
||||
import javax.sql.DataSource; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import org.junit.jupiter.api.AfterAll; |
||||
import org.junit.jupiter.api.BeforeAll; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.test.context.ActiveProfiles; |
||||
import org.testcontainers.containers.GenericContainer; |
||||
import org.testcontainers.containers.PostgreSQLContainer; |
||||
import org.testcontainers.lifecycle.Startables; |
||||
import org.testcontainers.utility.DockerImageName; |
||||
|
||||
import com.google.common.collect.Lists; |
||||
|
||||
// todo: use TestTemplate to test multiple PG version
|
||||
@Slf4j |
||||
@ActiveProfiles("postgresql") |
||||
public class BaseDolphinSchedulerManagerWithPostgresqlIT extends BaseDolphinSchedulerManagerIT { |
||||
|
||||
@Autowired |
||||
protected DolphinSchedulerManager dolphinSchedulerManager; |
||||
|
||||
@Autowired |
||||
protected DataSource dataSource; |
||||
|
||||
protected static GenericContainer databaseContainer; |
||||
|
||||
@BeforeAll |
||||
public static void initializeContainer() { |
||||
// todo: test with multiple pg version
|
||||
databaseContainer = new PostgreSQLContainer(DockerImageName.parse("postgres:11.1")) |
||||
.withUsername("root") |
||||
.withPassword("root") |
||||
.withDatabaseName("dolphinscheduler") |
||||
.withNetwork(NETWORK) |
||||
.withExposedPorts(5432); |
||||
databaseContainer.setPortBindings(Lists.newArrayList("5432:5432")); |
||||
|
||||
log.info("Create PostgreSQLContainer successfully."); |
||||
databaseContainer.start(); |
||||
|
||||
log.info("Starting PostgreSQLContainer..."); |
||||
Startables.deepStart(Stream.of(databaseContainer)).join(); |
||||
log.info("PostgreSQLContainer started"); |
||||
} |
||||
|
||||
@AfterAll |
||||
public static void closeContainer() { |
||||
if (databaseContainer != null) { |
||||
databaseContainer.stop(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.tools.datasource.postgresql; |
||||
|
||||
import org.apache.dolphinscheduler.common.sql.SqlScriptRunner; |
||||
|
||||
import lombok.SneakyThrows; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import org.junit.jupiter.api.Assertions; |
||||
import org.junit.jupiter.api.DisplayName; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
@Slf4j |
||||
class DolphinSchedulerDatabaseUpgradeWithPostgresqlIT extends BaseDolphinSchedulerManagerWithPostgresqlIT { |
||||
|
||||
@Test |
||||
@SneakyThrows |
||||
@DisplayName("Test Upgrade DolphinScheduler database in PostgreSQL") |
||||
void testUpgradeWithPostgreSQLProfile() { |
||||
// initialize the 3.0.0 schema
|
||||
SqlScriptRunner sqlScriptRunner = new SqlScriptRunner(dataSource, "3.0.0_schema/postgresql_3.0.0.sql"); |
||||
sqlScriptRunner.execute(); |
||||
log.info("Initialize the 3.0.0 schema successfully."); |
||||
|
||||
Assertions.assertDoesNotThrow(() -> dolphinSchedulerManager.upgradeDolphinScheduler()); |
||||
// todo: Assert table count
|
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.tools.datasource.postgresql; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import org.junit.jupiter.api.Assertions; |
||||
import org.junit.jupiter.api.DisplayName; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
@Slf4j |
||||
class DolphinSchedulerInitializeWithPostgresqlIT extends BaseDolphinSchedulerManagerWithPostgresqlIT { |
||||
|
||||
@Test |
||||
@DisplayName("Test initDolphinScheduler database in PostgreSQL") |
||||
void testInitializeWithPostgreSQLProfile() { |
||||
Assertions.assertDoesNotThrow(() -> { |
||||
dolphinSchedulerManager.initDolphinScheduler(); |
||||
}); |
||||
// todo: Assert table count
|
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@
|
||||
# |
||||
# Licensed to the Apache Software Foundation (ASF) under one or more |
||||
# contributor license agreements. See the NOTICE file distributed with |
||||
# this work for additional information regarding copyright ownership. |
||||
# The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
# (the "License"); you may not use this file except in compliance with |
||||
# the License. You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
# |
||||
spring: |
||||
main: |
||||
banner-mode: off |
||||
datasource: |
||||
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
url: jdbc:mysql://localhost:3306/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8 |
||||
username: root |
||||
password: root |
||||
hikari: |
||||
connection-test-query: select 1 |
||||
minimum-idle: 5 |
||||
auto-commit: true |
||||
validation-timeout: 3000 |
||||
pool-name: DolphinScheduler |
||||
maximum-pool-size: 50 |
||||
connection-timeout: 30000 |
||||
idle-timeout: 600000 |
||||
leak-detection-threshold: 0 |
||||
initialization-fail-timeout: 1 |
||||
|
||||
demo: |
||||
tenant-code: default |
||||
domain-name: localhost |
||||
api-server-port: 5173 |
||||
|
||||
# Override by profile |
||||
|
@ -0,0 +1,43 @@
|
||||
# |
||||
# Licensed to the Apache Software Foundation (ASF) under one or more |
||||
# contributor license agreements. See the NOTICE file distributed with |
||||
# this work for additional information regarding copyright ownership. |
||||
# The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
# (the "License"); you may not use this file except in compliance with |
||||
# the License. You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
# |
||||
spring: |
||||
main: |
||||
banner-mode: off |
||||
datasource: |
||||
driver-class-name: org.postgresql.Driver |
||||
url: jdbc:postgresql://localhost:5432/dolphinscheduler |
||||
username: root |
||||
password: root |
||||
hikari: |
||||
connection-test-query: select 1 |
||||
minimum-idle: 5 |
||||
auto-commit: true |
||||
validation-timeout: 3000 |
||||
pool-name: DolphinScheduler |
||||
maximum-pool-size: 50 |
||||
connection-timeout: 30000 |
||||
idle-timeout: 600000 |
||||
leak-detection-threshold: 0 |
||||
initialization-fail-timeout: 1 |
||||
|
||||
demo: |
||||
tenant-code: default |
||||
domain-name: localhost |
||||
api-server-port: 5173 |
||||
|
||||
# Override by profile |
||||
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more |
||||
~ contributor license agreements. See the NOTICE file distributed with |
||||
~ this work for additional information regarding copyright ownership. |
||||
~ The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
~ (the "License"); you may not use this file except in compliance with |
||||
~ the License. You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
--> |
||||
|
||||
<configuration scan="true" scanPeriod="120 seconds"> |
||||
<property name="log.base" value="logs"/> |
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
||||
<encoder> |
||||
<pattern> |
||||
[%level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} %logger{96}:[%line] - [WorkflowInstance-%X{workflowInstanceId:-0}][TaskInstance-%X{taskInstanceId:-0}] - %msg%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> |
||||
</encoder> |
||||
</appender> |
||||
|
||||
|
||||
<root level="INFO"> |
||||
<appender-ref ref="STDOUT"/> |
||||
</root> |
||||
</configuration> |
Loading…
Reference in new issue