You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ca...@apache.org on 2022/09/07 06:15:21 UTC

[incubator-linkis] branch dev-1.3.1 updated: [ISSUE-3270][linkis-instance-label-server]Unit test configuration (#3271)

This is an automated email from the ASF dual-hosted git repository.

casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new e6f6d3214 [ISSUE-3270][linkis-instance-label-server]Unit test configuration (#3271)
e6f6d3214 is described below

commit e6f6d3214cfee6752689827407944524bc851e25
Author: 成彬彬 <10...@users.noreply.github.com>
AuthorDate: Wed Sep 7 14:15:15 2022 +0800

    [ISSUE-3270][linkis-instance-label-server]Unit test configuration (#3271)
    
    * linkis-instance-label-server test
    * Unit test configuration
---
 .../org/apache/linkis/instance/label/Scan.java     | 26 +++++++++
 .../instance/label/WebApplicationServer.java       | 34 ++++++++++++
 .../linkis/instance/label/dao/BaseDaoTest.java     | 31 +++++++++++
 .../src/test/resources/application.properties      | 42 ++++++++++++++
 .../src/test/resources/create.sql                  | 64 ++++++++++++++++++++++
 5 files changed, 197 insertions(+)

diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/Scan.java b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/Scan.java
new file mode 100644
index 000000000..42e408c13
--- /dev/null
+++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/Scan.java
@@ -0,0 +1,26 @@
+/*
+ * 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.linkis.instance.label;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+
+import org.mybatis.spring.annotation.MapperScan;
+
+@EnableAutoConfiguration
+@MapperScan("org.apache.linkis.instance.label.dao")
+public class Scan {}
diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/WebApplicationServer.java b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/WebApplicationServer.java
new file mode 100644
index 000000000..2c843b99c
--- /dev/null
+++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/WebApplicationServer.java
@@ -0,0 +1,34 @@
+/*
+ * 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.linkis.instance.label;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.annotation.ComponentScan;
+
+@EnableAutoConfiguration
+@ServletComponentScan
+@ComponentScan
+public class WebApplicationServer extends SpringBootServletInitializer {
+
+  public static void main(String[] args) {
+    new SpringApplicationBuilder(WebApplicationServer.class).run(args);
+  }
+}
diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/dao/BaseDaoTest.java b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/dao/BaseDaoTest.java
new file mode 100644
index 000000000..89c50fafd
--- /dev/null
+++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/java/org/apache/linkis/instance/label/dao/BaseDaoTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.linkis.instance.label.dao;
+
+import org.apache.linkis.instance.label.Scan;
+
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.transaction.annotation.Transactional;
+
+@SpringBootTest(classes = Scan.class)
+@Transactional
+@Rollback(true)
+@EnableTransactionManagement
+public abstract class BaseDaoTest {}
diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/resources/application.properties b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/resources/application.properties
new file mode 100644
index 000000000..df2c75307
--- /dev/null
+++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/resources/application.properties
@@ -0,0 +1,42 @@
+#
+# 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.
+#
+
+
+
+#h2 database config
+spring.datasource.driver-class-name=org.h2.Driver
+#init
+spring.datasource.url=jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;INIT=runscript from 'classpath:create.sql'
+spring.datasource.username=sa
+spring.datasource.password=
+spring.datasource.hikari.connection-test-query=select 1
+spring.datasource.hikari.minimum-idle=5
+spring.datasource.hikari.auto-commit=true
+spring.datasource.hikari.validation-timeout=3000
+spring.datasource.hikari.pool-name=linkis-test
+spring.datasource.hikari.maximum-pool-size=50
+spring.datasource.hikari.connection-timeout=30000
+spring.datasource.hikari.idle-timeout=600000
+spring.datasource.hikari.leak-detection-threshold=0
+spring.datasource.hikari.initialization-fail-timeout=1
+
+mybatis-plus.mapper-locations=classpath:org/apache/linkis/instance/label/dao/impl/*.xml
+mybatis-plus.type-aliases-package=org.apache.linkis.instance.label.entity
+mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+
+#disable eureka discovery client
+spring.cloud.service-registry.auto-registration.enabled=false
+eureka.client.enabled=false
+eureka.client.serviceUrl.registerWithEureka=false
\ No newline at end of file
diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/resources/create.sql b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/resources/create.sql
new file mode 100644
index 000000000..3b1959510
--- /dev/null
+++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/test/resources/create.sql
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+ 
+SET FOREIGN_KEY_CHECKS = 0;
+SET REFERENTIAL_INTEGRITY FALSE;
+
+DROP TABLE IF EXISTS linkis_ps_instance_info;
+CREATE TABLE linkis_ps_instance_info (
+  id int(11) NOT NULL AUTO_INCREMENT,
+  instance varchar(128) DEFAULT NULL ,
+  name varchar(128)   DEFAULT NULL,
+  update_time datetime(3)  DEFAULT CURRENT_TIMESTAMP,
+  create_time datetime(3) DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (id)
+) ;
+
+
+DROP TABLE IF EXISTS linkis_ps_instance_label;
+CREATE TABLE linkis_ps_instance_label (
+  id int(20) NOT NULL AUTO_INCREMENT,
+  label_key varchar(32)     NOT NULL,
+  label_value varchar(255)     NOT NULL,
+  label_feature varchar(16)  NOT NULL,
+  label_value_size int(20) NOT NULL,
+  update_time datetime(3)  NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  create_time datetime(3)  NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (id)
+) ;
+
+DROP TABLE IF EXISTS linkis_ps_instance_label_relation;
+CREATE TABLE linkis_ps_instance_label_relation (
+  id int(20) NOT NULL AUTO_INCREMENT,
+  label_id int(20) DEFAULT NULL ,
+  service_instance varchar(128)  NOT NULL ,
+  update_time datetime(3)  DEFAULT CURRENT_TIMESTAMP   ,
+  create_time datetime(3) DEFAULT CURRENT_TIMESTAMP ,
+  PRIMARY KEY (id)
+) ;
+
+
+DROP TABLE IF EXISTS linkis_ps_instance_label_value_relation;
+CREATE TABLE linkis_ps_instance_label_value_relation (
+  id int(20) NOT NULL AUTO_INCREMENT,
+  label_value_key varchar(255)  NOT NULL    ,
+  label_value_content varchar(255)  DEFAULT NULL ,
+  label_id int(20) DEFAULT NULL ,
+  update_time datetime DEFAULT CURRENT_TIMESTAMP ,
+  create_time datetime DEFAULT CURRENT_TIMESTAMP ,
+  PRIMARY KEY (id)
+) ;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org