-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add task template * add unit tests --------- Co-authored-by: zeyu10 <[email protected]>
- Loading branch information
1 parent
0007151
commit e257c7e
Showing
57 changed files
with
2,512 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2021-2023 Weibo, Inc. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
CREATE DATABASE IF NOT EXISTS rill_flow; | ||
USE rill_flow; | ||
CREATE TABLE IF NOT EXISTS `task_template` ( | ||
`id` bigint NOT NULL AUTO_INCREMENT, | ||
`name` varchar(64) NOT NULL DEFAULT '' COMMENT 'template name', | ||
`type` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'template type: 0. function,1. plugin,2. logic', | ||
`category` varchar(64) NOT NULL DEFAULT '' COMMENT 'template category: function, foreach, etc.', | ||
`icon` TEXT NOT NULL COMMENT 'icon base64 string', | ||
`task_yaml` TEXT NOT NULL COMMENT 'default task yaml configurations in dag', | ||
`schema` TEXT NOT NULL COMMENT 'json schema for input', | ||
`output` TEXT NOT NULL COMMENT 'json schema to describe the output of the task', | ||
`enable` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'whether it is enabled: 0. disabled, 1. enabled', | ||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time of this record', | ||
`update_time` datetime NOT NULL DEFAULT '1970-01-01 08:00:00' COMMENT 'newly update time of this record', | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `name` (`name`), | ||
KEY `idx_type_category` (`type`, `category`), | ||
KEY `idx_update_time` (`update_time`), | ||
KEY `idx_create_time` (`create_time`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Rill Flow task template table'; | ||
|
||
grant all on *.* to 'root'@'%' identified by 'secret'; | ||
flush privileges; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.addLombokGeneratedAnnotation = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...re/src/test/groovy/com/weibo/rill/flow/olympicene/core/model/task/TaskCategoryTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright 2021-2023 Weibo, Inc. | ||
* | ||
* Licensed 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 com.weibo.rill.flow.olympicene.core.model.task | ||
|
||
|
||
import spock.lang.Specification | ||
|
||
/*** | ||
* test for this class: | ||
package com.weibo.rill.flow.olympicene.core.model.task; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
@AllArgsConstructor | ||
@Getter | ||
public enum TaskCategory { | ||
// 调用函数服务的Task | ||
FUNCTION("function", 0), | ||
// 流程控制Task,执行分支语句 | ||
CHOICE("choice", 1), | ||
// 流程控制Task,执行循环语句 | ||
FOREACH("foreach", 1), | ||
// 本身无处理逻辑,等待外部通知,然后执行 output 更新数据, 兼容olympiadane1.0 | ||
SUSPENSE("suspense", 2), | ||
// 空 task | ||
PASS("pass", 2), | ||
// return task | ||
RETURN("return", 2), | ||
; | ||
private final String value; | ||
private final int type; | ||
public static com.weibo.rill.flow.olympicene.core.model.task.TaskCategory getEnumByValue(String category) { | ||
if (category == null) { | ||
return null; | ||
} | ||
return switch (category) { | ||
case "function" -> FUNCTION; | ||
case "choice" -> CHOICE; | ||
case "foreach" -> FOREACH; | ||
case "suspense" -> SUSPENSE; | ||
case "pass" -> PASS; | ||
case "return" -> RETURN; | ||
default -> null; | ||
}; | ||
} | ||
} | ||
*/ | ||
class TaskCategoryTest extends Specification { | ||
/** | ||
* test enum | ||
* @return | ||
*/ | ||
def "test getEnumByValue"() { | ||
when: | ||
TaskCategory taskCategory = TaskCategory.getEnumByValue(category) | ||
then: | ||
taskCategory == expected | ||
where: | ||
category | expected | ||
null | null | ||
"choice" | TaskCategory.CHOICE | ||
"foreach" | TaskCategory.FOREACH | ||
"function" | TaskCategory.FUNCTION | ||
"pass" | TaskCategory.PASS | ||
"suspense" | TaskCategory.SUSPENSE | ||
"return" | TaskCategory.RETURN | ||
"break" | null | ||
} | ||
|
||
def "test getType"() { | ||
when: | ||
var category = given | ||
then: | ||
category.getType() == expected | ||
where: | ||
given | expected | ||
TaskCategory.FUNCTION | 0 | ||
TaskCategory.FOREACH | 1 | ||
TaskCategory.CHOICE | 1 | ||
TaskCategory.SUSPENSE | 2 | ||
TaskCategory.RETURN | 2 | ||
TaskCategory.PASS | 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.