diff --git a/seatunnel-server/seatunnel-app/src/main/resources/org/apache/seatunnel/app/dal/mapper/UserMapper.xml b/seatunnel-server/seatunnel-app/src/main/resources/org/apache/seatunnel/app/dal/mapper/UserMapper.xml index f41150718..0539f9cc7 100644 --- a/seatunnel-server/seatunnel-app/src/main/resources/org/apache/seatunnel/app/dal/mapper/UserMapper.xml +++ b/seatunnel-server/seatunnel-app/src/main/resources/org/apache/seatunnel/app/dal/mapper/UserMapper.xml @@ -36,7 +36,7 @@ insert into `user` (username, password, status, type) - value (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, + values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{type,jdbcType=TINYINT}) @@ -99,7 +99,7 @@ diff --git a/seatunnel-server/seatunnel-app/src/main/resources/script/seatunnel_server_h2.sql b/seatunnel-server/seatunnel-app/src/main/resources/script/seatunnel_server_h2.sql index c85527f2f..f9bfb51af 100644 --- a/seatunnel-server/seatunnel-app/src/main/resources/script/seatunnel_server_h2.sql +++ b/seatunnel-server/seatunnel-app/src/main/resources/script/seatunnel_server_h2.sql @@ -39,6 +39,12 @@ CREATE TABLE role ( update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); +-- ---------------------------- +-- Records of role +-- ---------------------------- +INSERT INTO role (type, role_name, description) VALUES (0, 'ADMIN_ROLE', 'Admin User'); +INSERT INTO role (type, role_name, description) VALUES (1, 'NORMAL_ROLE', 'Normal User'); + -- ---------------------------- -- Table structure for role_user_relation -- ---------------------------- diff --git a/seatunnel-web-it/README.md b/seatunnel-web-it/README.md index 97e057017..373ec96b3 100644 --- a/seatunnel-web-it/README.md +++ b/seatunnel-web-it/README.md @@ -1,13 +1,16 @@ Build seatunnel-web ./mvnw clean install -DskipTests -Update mysql database details in src/test/resources/application.yml and Run the seatunnel-web-it integration tests -./mvnw -T 1C -B verify -DskipUT=true -DskipIT=false -DSEATUNNEL_HOME=/some/path/apache-seatunnel-2.3.7 -DST_WEB_BASEDIR_PATH=seatunnel-web-dist/target/apache-seatunnel-web-1.0.0-SNAPSHOT/apache-seatunnel-web-1.0.0-SNAPSHOT +Run seatunnel-web-it integration tests +./mvnw -T 1C -B verify -DskipUT=true -DskipIT=false -DSEATUNNEL_HOME=/some/path/apache-seatunnel-2.3.7 -DST_WEB_BASEDIR_PATH=seatunnel-web-dist/target/apache-seatunnel-web-1.0.2-SNAPSHOT/apache-seatunnel-web-1.0.2-SNAPSHOT NOTE: Please remember to update the versions according to the latest supported versions. If you're using a version of Java higher than Java 8 for running the tests, add the following VM options: --DitJvmArgs="--add-opens java.base/java.lang.invoke=ALL-UNNAMED". +-DitJvmArgs="-Xmx1024m --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED" While running integrations tests from IDE, ensure following VM options are set SEATUNNEL_HOME=/some/path/apache-seatunnel-2.3.7 -ST_WEB_BASEDIR_PATH=/some/path/seatunnel-web-dist/target/apache-seatunnel-web-1.0.0-SNAPSHOT/apache-seatunnel-web-1.0.0-SNAPSHOT +ST_WEB_BASEDIR_PATH=/some/path/seatunnel-web-dist/target/apache-seatunnel-web-1.0.2-SNAPSHOT/apache-seatunnel-web-1.0.2-SNAPSHOT + +By default, integration tests use the H2 database. If you want to use the MySQL database, update the MySQL database details in src/test/resources/application.yml and run the seatunnel-web-it integration tests with the -DdbType=mysql option as shown below: +./mvnw -T 1C -B verify -DskipUT=true -DskipIT=false -DdbType=mysql -DSEATUNNEL_HOME=/some/path/apache-seatunnel-2.3.7 -DST_WEB_BASEDIR_PATH=seatunnel-web-dist/target/apache-seatunnel-web-1.0.2-SNAPSHOT/apache-seatunnel-web-1.0.2-SNAPSHOT diff --git a/seatunnel-web-it/src/test/java/org/apache/seatunnel/app/common/SeaTunnelWebCluster.java b/seatunnel-web-it/src/test/java/org/apache/seatunnel/app/common/SeaTunnelWebCluster.java index a5b630a90..df4127dab 100644 --- a/seatunnel-web-it/src/test/java/org/apache/seatunnel/app/common/SeaTunnelWebCluster.java +++ b/seatunnel-web-it/src/test/java/org/apache/seatunnel/app/common/SeaTunnelWebCluster.java @@ -32,11 +32,19 @@ import lombok.extern.slf4j.Slf4j; import java.io.File; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import static org.junit.jupiter.api.Assertions.assertTrue; @Slf4j public class SeaTunnelWebCluster { + private static final String DB_TYPE_H2 = "h2"; + private static final String DB_TYPE_MYSQL = "mysql"; + private static final Set SUPPORTED_DB_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DB_TYPE_H2, DB_TYPE_MYSQL))); private SeaTunnelServer server; private HazelcastInstanceImpl instance; private ConfigurableApplicationContext applicationContext; @@ -59,8 +67,16 @@ public void start() { server = instance.node.nodeEngine.getService(SeaTunnelServer.SERVICE_NAME); ILogger LOGGER = instance.node.nodeEngine.getLogger(SeaTunnelWebCluster.class); - // String[] args = {"--spring.profiles.active=h2"}; - String[] args = {}; + // For integration tests, default database is H2, so the default spring profile is h2 + String dbType = System.getProperty("dbType", DB_TYPE_H2); + if (!SUPPORTED_DB_TYPES.contains(dbType)) { + throw new IllegalArgumentException( + "Invalid dbType: " + dbType + ". Supported values are: " + SUPPORTED_DB_TYPES); + } + + String springProfile = dbType.equals(DB_TYPE_MYSQL) ? "default" : "h2"; + String[] args = {"--spring.profiles.active=" + springProfile}; + applicationContext = SpringApplication.run(SeatunnelApplication.class, args); LOGGER.info("SeaTunnel-web server started."); assertTrue(isRunning()); diff --git a/seatunnel-web-it/src/test/resources/application.yml b/seatunnel-web-it/src/test/resources/application.yml index 3b49d2a32..276983f36 100644 --- a/seatunnel-web-it/src/test/resources/application.yml +++ b/seatunnel-web-it/src/test/resources/application.yml @@ -40,6 +40,10 @@ jwt: --- spring: + application: + name: seatunnel + jackson: + date-format: yyyy-MM-dd HH:mm:ss config: activate: on-profile: h2 @@ -57,4 +61,9 @@ spring: path: /h2 settings: trace: false - web-allow-others: false \ No newline at end of file + web-allow-others: false +jwt: + expireTime: 86400 + # please add key when deploy + secretKey: https://github.com/apache/seatunnel + algorithm: HS256 \ No newline at end of file