Skip to content

Commit

Permalink
[case](restart_fe) add demo case for restart_fe test (apache#37091)
Browse files Browse the repository at this point in the history
Issue Number: close #xxx

<!--Describe your changes.-->

---------

Co-authored-by: stephen <[email protected]>
  • Loading branch information
hello-stephen and stephen committed Jul 14, 2024
1 parent 791566c commit f8f97e3
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 74 deletions.
11 changes: 11 additions & 0 deletions regression-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ under the License.

# 新加case注意事项

## 常规 case
1. 变量名前要写 def,否则是全局变量,并行跑的 case 的时候可能被其他 case 影响。

Problematic code:
Expand Down Expand Up @@ -65,3 +66,13 @@ under the License.
sql """sync"""
sql """select count(*) from table """
```

6. UDF 的 case,需要把对应的 jar 包拷贝到所有 BE 机器上。

[示例](https://github.com/apache/doris/blob/master/regression-test/suites/javaudf_p0/test_javaudf_case.groovy#L27)


## 兼容性 case
指重启 FE 测试或升级测试中,在初始集群上创建的资源或规则,在集群重启或升级后也能正常使用,比如权限、UDF等。
这些 case 需要拆分成两个文件,load.groovy 和 xxxx.groovy,放到一个文件夹中并加上 `restart_fe` 组标签,[示例](https://github.com/apache/doris/pull/37118)

26 changes: 26 additions & 0 deletions regression-test/data/javaudf_p0/null/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select_default --
1
2
3
4
5
6
7
8
9

-- !select --
\N

-- !select --
\N
\N
\N
\N
\N
\N
\N
\N
\N

3 changes: 1 addition & 2 deletions regression-test/suites/auth_up_down_p0/load.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

suite("test_upgrade_downgrade_prepare_auth","p0,auth") {
suite("test_upgrade_downgrade_prepare_auth","p0,auth,restart_fe") {

String user1 = 'test_upgrade_downgrade_compatibility_auth_user1'
String user2 = 'test_upgrade_downgrade_compatibility_auth_user2'
Expand Down Expand Up @@ -45,7 +45,6 @@ suite("test_upgrade_downgrade_prepare_auth","p0,auth") {
sql """CREATE ROLE ${role1}"""
sql """CREATE ROLE ${role2}"""


try_sql """drop table if exists ${dbName}.${tableName1}"""
sql """drop database if exists ${dbName}"""
sql """create database ${dbName}"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

suite("test_upgrade_downgrade_compatibility_auth","p0,auth") {
suite("test_upgrade_downgrade_compatibility_auth","p0,auth,restart_fe") {

sql """ADMIN SET FRONTEND CONFIG ('experimental_enable_workload_group' = 'true');"""
sql """set experimental_enable_pipeline_engine = true;"""
Expand Down
66 changes: 66 additions & 0 deletions regression-test/suites/javaudf_p0/null/load.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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.

import org.codehaus.groovy.runtime.IOGroovyMethods

import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Paths

suite('test_javaudf_null_load', 'p0,restart_fe') {
// In order to cover the scenario that udf can be used normally after fe restart.
// We devided the origin case test_javaudf_null.groovy into two parts, load and query, this case is the first part.
// run load and query -> restart fe -> run query again,
// by this way, we can cover the scenario.
def tableName = 'test_javaudf_null'
def jarPath = """${context.file.parent}/../jars/java-udf-case-jar-with-dependencies.jar"""
scp_udf_file_to_all_be(jarPath)

log.info("Jar path: ${jarPath}".toString())
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """DROP FUNCTION IF EXISTS java_udf_null_test(int);"""
sql """
CREATE TABLE IF NOT EXISTS ${tableName} (
`user_id` INT NOT NULL COMMENT ""
)
DISTRIBUTED BY HASH(user_id) PROPERTIES("replication_num" = "1");
"""
StringBuilder sb = new StringBuilder()
int i = 1
for (; i < 9; i ++) {
sb.append("""
(${i}),
""")
}
sb.append("""
(${i})
""")
sql """ INSERT INTO ${tableName} VALUES
${sb.toString()}
"""

File path = new File(jarPath)
if (!path.exists()) {
throw new IllegalStateException("""${jarPath} doesn't exist! """)
}

sql """ CREATE FUNCTION java_udf_null_test(int) RETURNS int PROPERTIES (
"file"="file://${jarPath}",
"symbol"="org.apache.doris.udf.NullTest",
"type"="JAVA_UDF"
); """
}
24 changes: 24 additions & 0 deletions regression-test/suites/javaudf_p0/null/test.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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.

suite('test_javaudf_null_query', 'p0,restart_fe') {
def tableName = 'test_javaudf_null'
qt_select_default """ SELECT * FROM ${tableName} t ORDER BY user_id; """

qt_select ''' SELECT java_udf_null_test(1) result; '''
qt_select """ SELECT java_udf_null_test(user_id) result FROM ${tableName} ORDER BY result; """
}
71 changes: 0 additions & 71 deletions regression-test/suites/javaudf_p0/test_javaudf_null.groovy

This file was deleted.

0 comments on commit f8f97e3

Please sign in to comment.