Skip to content

Commit

Permalink
Merge branch 'release/v0.3.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
pojol committed Jul 2, 2023
2 parents cb8889d + ca32d75 commit aabd666
Show file tree
Hide file tree
Showing 32 changed files with 3,187 additions and 2,012 deletions.
84 changes: 84 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# v0.3.6 (pre
* feature
- The way of previewing report has been changed from clicking tags to displaying directly at the bottom, with tab switching for charts (more intuitive)
- Replaced the implementation library of codemirror to provide a better code writing experience
- Added share feature, by selecting bot in bots panel and clicking share can copy the bot's address to clipboard for others to access directly the bot's editing view
- Added automatic refresh for running (default 10s)
- Changed the storage implementation of batch, now it will be stored in the db so that it can continue executing after an abnormal interruption
* fix
- It will directly panic if the database cannot connect (encounter errors should terminate immediately)
- Replaced the clipboard implementation of share button to an earlier api (can adapt to more browsers)
- Fixed the problem that report was not sorted by time
- Fixed the issue of wrong click event in bots

# v0.3.5 (pre
Major adjustments are nearing completion. Version 0.3 will only fix bugs next.
* Feature
- Added a queue delay configuration to control the scheduling frequency of the robot
- Optimized the CSS implementation of nodes in the sideplane
- Added HTTP query params as input
* Fix
- The code input box has disordered input logic after switching input methods
- Clicking inputnumber in bots will lose focus
- When zooming and resizing the window, the editor window is not enlarged or reduced proportionally

# v0.3.1 (pre
* Feature
- Added a button to erase the behavior tree
- The drawing of the graph now depends entirely on the data in model/tree
* Fix
- Clicking too fast caused the current node to draw incorrectly
- Some jumps in the debugging window are fixed
- When zooming and resizing the window, the editor window is not enlarged or reduced proportionally
# v0.3.0 (pre

* Feature
- Rewrote the entire editor using the umi framework and ts (type safe, supports dark mode switching
- Replaced components with functions, wrote code using hooks + redux (stateless mode (optimized loading time and drawing efficiency
- Added a new bot loading method that can load a bot by accessing the URL (easier to spread
- Introduced the SQLite in-memory database (easy to try, can be deployed locally quickly
* Fix
- Fixed the loss of tail node information
- Fixed the problem that batches could not exit accurately during pressure testing

# v0.2.5
* Feature
- Rewrote the sidebar to provide a better filtering method
- Prefab is displayed separately as a page and provides search and editing functions
- Optimized connection points (shrink when there is no mouse movein)
- Added time sorting to the report page

## v0.2.1
* Feature
- Added new parallel nodes
- Deleted the original assert node type
- Added a runtime err column to output runtime error information
- Refactored the runtime logic of bots
- Introduced the logic to display thread information in the response column (parallel nodes will create new threads)
- Added a small animation when running to the node (optimization prompt

## v0.1.17
* Feature
* Fix
- Fixed logic errors in asynchronous loading of behavior trees

## v0.1.16
* Feature
- Provides fmt function for lua code
- Leave enough space for prefab and move change to overlap with meta window
- Add step shortcut [F10]
* Fix
- Error deleting configuration file failed
- Root node position correction
- Fix health check not performed after initializing server address

## v0.1.15
* Feature
- Removed the debug button in the edit interface and automatically created when clicking step
- Added a delay for step on the last node (to prevent continuous clicking
- Added a reset button to prevent the user from not wanting to execute down
- Removed the utils in the script module (changed to an independent uuid and random interface displayed at the first level directory for easy reference
- Added node "prefab" function (now users can define and reuse their own script nodes in the config panel
- Added connection status prompt
* Fix
- step api does not return correct error information
16 changes: 14 additions & 2 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# v0.3.6 (pre
* feature
- 将 report 中的预览方式从通过点击 tag 的形式换为直接显示在下方,通过tab 进行图表的切换(更直观
- 替换了 codemirror 的实现库,使代码的编写体验更好
- 添加 share 功能,在 bots 面板中选中 bot 点击 share 能将 bot 的地址复制在剪贴板中,别人可以直接访问这个地址打开 bot 的编辑视窗
- 添加了 running 的自动刷新(默认 10s
- 更换了 batch 的存储实现,现在将存储在 db 中,以便于在异常中断后还能继续执行

* fix
- 如果数据库无法连接则会直接panic(遇到错误应该立即终止
- share 按钮,剪贴板的实现替换为更早的 api(能适配更多的浏览器
- 解决的 report 没有按时间排序的问题
- 解决了 bots 中控件点击事件错乱的问题

# v0.3.5 (pre
> 大的调整已经接近完成,接下来0.3版本将只修复bug
* feature
- 添加了一个入队延迟的配置,用于控制机器人的调度频率
- 优化了 sideplane 中节点的 css 实现
Expand All @@ -11,7 +24,6 @@


# v0.3.1 (pre
> 大的调整已经接近完成,接下来0.3版本将只修复bug
* feature
- 添加擦除行为树的按钮
- graph 的绘制现在完全居于 model/tree 中的数据进行
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gobot is a powerful stateful API testing robot. It provides a graphical interfac
1. Download the specified version of the editor and driver on the release page.
2. Execute the driver end in memory mode on the command line `./gobot-driver-win32-v0.3.x.exe --no_database --mock`
3. Start gobot_editor_win_x64_v0.3.x and fill in the driver address http://127.0.0.1:8888
4. If using for the first time, you can find sample robots in the /demos directory and load them on the bots page.
4. If using for the first time, you can find sample robots in the /sample directory and load them on the bots page.


## Feature
Expand Down Expand Up @@ -51,6 +51,11 @@ function execute()
-- Here, users can define the execution logic of nodes themselves (for example, sending an HTTP request)
res, err = http.post("url", req)

-- todo

-- state - State code
-- res - Information displayed in the Response panel
return state.Succ, res
end
```

Expand Down
15 changes: 11 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gobot是一个功能强大的有状态API测试机器人。它提供图形界面
1. 在 release 页面下载指定版本的 编辑端(editor 以及 驱动端(driver
2. 在命令行以内存模式执行驱动端 `./gobot-driver-win32-v0.3.x.exe --no_database --mock`
3. 启动 gobot_editor_win_x64_v0.3.x ,并将 driver 地址填入 http://127.0.0.1:8888
4. 如果是初次使用,可以在 /demos 目录中找到示例机器人,在bots页面中载入使用
4. 如果是初次使用,可以在 /sample 目录中找到示例机器人,在bots页面中载入使用

## 特性
* 使用`行为树`控制机器人的运行逻辑,使用`脚本`控制节点的具体行为(比如发起一次http请求
Expand Down Expand Up @@ -44,7 +44,13 @@ function execute()

-- 用户可以在这里自行定义节点的执行逻辑(例如发送一次http请求
res, err = http.post("url", req)


-- todo

-- 返回值
-- state 状态码
-- res 显示在 Response 面板的信息
return state.Succ, res
end
```

Expand All @@ -54,9 +60,10 @@ end
|`base64`|`http`|`protobuf`|`mongoDB`|`json`|
|`md5`|`uuid`|`random`|...|

## [在线试用](http://123.60.17.61:7777) <--
## [文档](https://pojol.gitee.io/gobot/#/) <--
## [在线试用](http://123.60.17.61:7777)
## [文档](https://pojol.gitee.io/gobot/#/)

## [视频演示](https://www.bilibili.com/video/BV1sS4y1z7Dg/?vd_source=7c2dfd750914fd5f8a9811b19f0bf447)

## 编辑器预览
[![image.png](https://i.postimg.cc/t4jMVjp1/image.png)](https://postimg.cc/PPS4B0Lh)
5 changes: 5 additions & 0 deletions bot/behavior/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ func (t *Tick) Do() (state string, end bool) {

if err != nil {
threadInfo.ErrMsg = fmt.Sprintf("tick err %v", err.Error())
fmt.Println("tick err", threadInfo.ErrMsg)
}
if parseerr != nil {
threadInfo.ErrMsg = fmt.Sprintf("%v parse err %v", threadInfo.ErrMsg, parseerr.Error())
fmt.Println("tick parse err", threadInfo.ErrMsg)
}

if state != Succ {
Expand All @@ -114,9 +116,11 @@ func (t *Tick) Do() (state string, end bool) {
} else if state == Break {
end = true
threadInfo.ErrMsg = fmt.Sprintf("script break err %v", msg)
fmt.Println("tick break err", threadInfo.ErrMsg)
} else if state == Error {
// 节点脚本出错,脚本逻辑自行抛出的错误
threadInfo.ErrMsg = fmt.Sprintf("script err %v", msg)
fmt.Println("tick script err", threadInfo.ErrMsg)
}
}

Expand All @@ -134,6 +138,7 @@ func (t *Tick) Do() (state string, end bool) {

if t.blackboard.end {
state = Exit
end = true
goto ext
}

Expand Down
2 changes: 1 addition & 1 deletion bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (b *Bot) loopThread(doneCh chan<- string, errch chan<- ErrInfo) {
goto ext
}

if state == behavior.Break || state == behavior.Exit {
if state == behavior.Break || state == behavior.Error {
errch <- ErrInfo{
ID: b.id,
Err: nil,
Expand Down
106 changes: 54 additions & 52 deletions database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"os"
"sync"

"github.com/glebarez/sqlite"
"gorm.io/driver/mysql"
Expand All @@ -24,12 +23,12 @@ type Cache struct {
behavior *Behavior
prefab *Prefab
report *Report
task *Task

mysqlptr *gorm.DB
}

var db *Cache
var once sync.Once

func GetConfig() *Conf {
return db.conf
Expand All @@ -47,62 +46,65 @@ func GetBehavior() *Behavior {
return db.behavior
}

func Init(NoDBMode bool) *Cache {
once.Do(func() {

var sqlptr *gorm.DB
var err error

if NoDBMode {
sqlptr, err = gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
} else {
pwd := os.Getenv("MYSQL_PASSWORD")
if pwd == "" {
panic(errors.New("mysql password is not defined"))
}

name := os.Getenv("MYSQL_DATABASE")
if name == "" {
panic(errors.New("mysql database is not defined"))
}

host := os.Getenv("MYSQL_HOST")
if host == "" {
panic(errors.New("mysql host is not defined"))
}

user := os.Getenv("MYSQL_USER")
if user == "" {
panic(errors.New("mysql user is not defined"))
}

dsn := user + ":" + pwd + "@tcp(" + host + ")/" + name + "?charset=utf8&parseTime=True&loc=Local"

sqlptr, err = gorm.Open(mysql.New(mysql.Config{
DSN: dsn, // data source name
DefaultStringSize: 256, // default size for string fields
DisableDatetimePrecision: true, // disable datetime precision, which not supported before MySQL 5.6
DontSupportRenameIndex: true, // drop & create when rename index, rename index not supported before MySQL 5.7, MariaDB
DontSupportRenameColumn: true, // `change` when rename column, rename column not supported before MySQL 8, MariaDB
SkipInitializeWithVersion: false, // auto configure based on currently MySQL version
}), &gorm.Config{})
func GetTask() *Task {
return db.task
}

func Init(NoDBMode bool) (*Cache, error) {

var sqlptr *gorm.DB
var err error

if NoDBMode {
sqlptr, err = gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
} else {
pwd := os.Getenv("MYSQL_PASSWORD")
if pwd == "" {
panic(errors.New("mysql password is not defined"))
}

if err != nil {
fmt.Println("open mysql err", err.Error())
return
name := os.Getenv("MYSQL_DATABASE")
if name == "" {
panic(errors.New("mysql database is not defined"))
}

db = &Cache{
mysqlptr: sqlptr,
conf: CreateConfig(sqlptr),
prefab: CreatePrefab(sqlptr),
behavior: CreateBehavior(sqlptr),
report: CreateReport(sqlptr),
host := os.Getenv("MYSQL_HOST")
if host == "" {
panic(errors.New("mysql host is not defined"))
}
})

return db
user := os.Getenv("MYSQL_USER")
if user == "" {
panic(errors.New("mysql user is not defined"))
}

dsn := user + ":" + pwd + "@tcp(" + host + ")/" + name + "?charset=utf8&parseTime=True&loc=Local"

sqlptr, err = gorm.Open(mysql.New(mysql.Config{
DSN: dsn, // data source name
DefaultStringSize: 256, // default size for string fields
DisableDatetimePrecision: true, // disable datetime precision, which not supported before MySQL 5.6
DontSupportRenameIndex: true, // drop & create when rename index, rename index not supported before MySQL 5.7, MariaDB
DontSupportRenameColumn: true, // `change` when rename column, rename column not supported before MySQL 8, MariaDB
SkipInitializeWithVersion: false, // auto configure based on currently MySQL version
}), &gorm.Config{})
}

if err != nil {
fmt.Println("gorm open err", err.Error())
return nil, err
}

db = &Cache{
mysqlptr: sqlptr,
conf: CreateConfig(sqlptr),
prefab: CreatePrefab(sqlptr),
behavior: CreateBehavior(sqlptr),
report: CreateReport(sqlptr),
task: CreateTask(sqlptr),
}

return db, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion database/db_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *Report) Append(info ReportDetail) error {
func (r *Report) List() ([]ReportTable, error) {
var lst []ReportTable

res := r.db.Find(&lst).Limit(100)
res := r.db.Order("begin_time desc").Limit(100).Find(&lst)

return lst, res.Error
}
Loading

0 comments on commit aabd666

Please sign in to comment.