Skip to content

Commit

Permalink
v0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
brookshi committed Mar 12, 2018
1 parent 09f210c commit 70d712a
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 25 deletions.
4 changes: 2 additions & 2 deletions api/mail/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ export class Mail {
};
return new Promise((resolve, reject) => Mail.transporter.sendMail(mailOptions, (err, info) => {
if (err) {
Log.error(err.message);
Log.error(`mail: ${err.message}`);
reject(err);
} else {
Log.info('send mail success');
Log.info('mail: send mail success');
resolve();
}
}));
Expand Down
2 changes: 1 addition & 1 deletion api/utils/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Setting {
files.forEach(file => {
const filePath = path.join(frontEndJSFolder, file);
let content = fs.readFileSync(filePath, 'utf8');
content = content.replace('HITCHHIKER_APP_HOST', this.appHost).replace('hitchhiker_zh', `hitchhiker_${this.appLanguage}`);
content = content.replace('HITCHHIKER_APP_HOST', this.appHost).replace(/hitchhiker_(?:zh|en)/g, `hitchhiker_${this.appLanguage}`);
fs.writeFileSync(filePath, content, { encoding: 'utf8' });
});
}
Expand Down
7 changes: 4 additions & 3 deletions cn/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

* [Introduction](README.md)
* [1. 介绍](introduction.md)
* [2. 安装](installation/README.md)
* [2.1 Docker](installation/docker.md)
* [2.2 安装包](installation/StepByStep.md)
* [2. 安装:两种安装方式](installation/README.md)
* [2.1 使用Docker安装](installation/docker.md)
* [2.2 使用安装包安装](installation/StepByStep.md)
* [2.3 配置](installation/configuration.md)
* [2.4 自定义邮件接口](installation/Mail_Interface.md)
* [3. 简易教程](Simple_Tutorial/README.md)
Expand All @@ -13,6 +13,7 @@
* [3.3 创建一个Request并使用](Simple_Tutorial/Create_Request.md)
* [3.4 使用环境变量](Simple_Tutorial/Use_Env_Var.md)
* [3.5 使用Parameters](Simple_Tutorial/Use_Param.md)
* [3.6 基于UI的断言](Simple_Tutorial/Assert_Base_On_UI.md)
* [4. 变量](Variable/README.md)
* [4.1 环境变量](Variable/Env_Var.md)
* [4.2 Parameter变量](Variable/Param_Var.md)
Expand Down
11 changes: 11 additions & 0 deletions cn/Simple_Tutorial/Assert_Base_On_UI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#### 基于UI的断言

断言可以帮忙测试更好的测出返回数据的正确性问题,一般来说通过脚本来创建断言会更灵活,但是对于QA来说,对脚本可能不太熟悉,或者说熟悉其他脚本但不熟悉js,写起来就不太容易了。

针对这种情况推出了基于UI的断言,只需要用鼠标点点,写写目标值就可以了。

![](https://raw.githubusercontent.com/brookshi/images/master/Hitchhiker/assert.PNG)

#### 如何创建

![](https://raw.githubusercontent.com/brookshi/images/master/Hitchhiker/assert.gif)
4 changes: 3 additions & 1 deletion cn/Simple_Tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ Collection, Project, Schedule, Stress Test

4. [使用环境变量](Use_Env_Var.md)

5. [使用Parameters](Use_Param.md)
5. [使用Parameters](Use_Param.md)

6. [基于UI的断言](Assert_Base_On_UI.md)
2 changes: 1 addition & 1 deletion cn/installation/StepByStep.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
> 创建DB的脚本: CREATE DATABASE IF NOT EXISTS \`hitchhiker-prod\` default charset utf8 COLLATE utf8_general_ci;
> 修改变量需要把`max_allowed_packet=200M`加到 my.ini 文件[mysqld] Section下,具体参考:[change max_allowed_packet](https://stackoverflow.com/questions/8062496/how-to-change-max-allowed-packet-size)
1. 下载安装包 [https://github.com/brookshi/Hitchhiker/releases/download/v0.9/Hitchhiker.zip](https://github.com/brookshi/Hitchhiker/releases/download/v0.9/Hitchhiker.zip);
1. 下载安装包 [https://github.com/brookshi/Hitchhiker/releases/download/v0.10/Hitchhiker.zip](https://github.com/brookshi/Hitchhiker/releases/download/v0.10/Hitchhiker.zip);
下载速度慢的可以去阿里云下载 http://hitchhiker.oss-cn-hongkong.aliyuncs.com/Hitchhiker.zip

2. 解压并在build目录下(即setup.js的目录)执行命令`node setup.js`(windows), `sudo node setup.js`(linux);
Expand Down
5 changes: 3 additions & 2 deletions cn/installation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Hitchhiker的很多设置可以在appconfig.json里设置,也有对应的环
"host": "http://localhost:3000/", // 设置运行的ip和端口, 环境变量:HITCHHIKER_APP_HOST
"port": 8080, // 使用nginx做代理时可以使用这个端口 HITCHHIKER_APP_PORT
"api": "http://localhost:81/api/", // API接口,调试用, 环境变量使用上面的
"language": "en", // 语言,目前只对邮件内容起作用, HITCHHIKER_APP_LANG
"language": "en", // 语言,中文:zh, 英文:en, HITCHHIKER_APP_LANG
"encryptKey": "hitchhikerapi",
"defaultPassword": "123456", // 新帐号的默认密码
"tempUser": "test@test.test", // use without login时使用的用户账号
Expand All @@ -19,6 +19,7 @@ Hitchhiker的很多设置可以在appconfig.json里设置,也有对应的环
"User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36",
"Cache-Control:no-cache"
],
"requestTimeout": 1800000, // 请求超时时间 (ms), HITCHHIKER_APP_SCRIPT_TIMEOUT
"scriptTimeout": 60000, // 脚本执行时间(毫秒) HITCHHIKER_SCRIPT_TIMEOUT
"safeVM": false, // 是否使用安全脚本,如require HITCHHIKER_SAFE_VM
"enableUpload": true, // 是否支持上传脚本和数据, HITCHHIKER_ENABLE_UPLOAD
Expand Down Expand Up @@ -50,7 +51,7 @@ Hitchhiker的很多设置可以在appconfig.json里设置,也有对应的环
},
"mail": {
"host": "http://email.hitchhiker-api.com/api/mail/", // mail默认接口
"custom": "none", // 是否需要自定义mail,可以使用 "api" 或 "smtp", HITCHHIKER_MAIL_CUSTOM
"customType": "none", // 是否需要自定义mail,可以使用 "api" 或 "smtp", HITCHHIKER_MAIL_CUSTOM_TYPE
"customApi": "http://", // custom为"api"时会使用这个mail接口, Hitchhiker会post {target, subject, content}到这个接口 HITCHHIKER_MAIL_API
"smtp": { // custom为"smtp"时使用这块,下面是qq的一个例子作为参考,注意:有的公司内部邮件不需要用户名或密码验证则 user和pass需要空掉不写,否则会报错
"host": "smtp.qq.com", // HITCHHIKER_MAIL_SMTP_HOST
Expand Down
16 changes: 10 additions & 6 deletions cn/installation/docker.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
docker使用的是docker-compose来安装,会自动下载两个image:hitchhiker和mysql,基本上按命令执行即可,如果需要配置,可以参考:[配置文件](configuration.md), 环境变量可以写到docker-compose.yml里

国内用户请使用阿里云的镜像 hitchhiker-cn:registry.cn-hangzhou.aliyuncs.com/brook/hitchhiker-cn:v0.9
国内用户请使用阿里云的镜像 hitchhiker-cn:registry.cn-hangzhou.aliyuncs.com/brook/hitchhiker-cn:v0.10

#### 参考下面命令,一步一步部署 (基于ubuntu,其他系统类似):
``` bash
Expand All @@ -21,7 +21,7 @@ curl -O https://raw.githubusercontent.com/brookshi/Hitchhiker/release/deploy/doc

# 编辑 docker-compose.yml, 把localhost换成你机器的局域网ip,如果是只有本机一个人用那就localhost也可以
sudo vim docker-compose.yml
# 修改完成后,保存退出 (国内用户改image地址:registry.cn-hangzhou.aliyuncs.com/brook/hitchhiker-cn:v0.9, 以及写入环境变量配置hitchhiker以及mysql)
# 修改完成后,保存退出 (国内用户改image地址:registry.cn-hangzhou.aliyuncs.com/brook/hitchhiker-cn:v0.10, 以及写入环境变量配置hitchhiker以及mysql)
...

# 执行docker-compose up安装镜像
Expand All @@ -36,7 +36,7 @@ curl http://ip:8080/
version: '2'
services:
hitchhiker:
image: brookshi/hitchhiker:v0.9
image: brookshi/hitchhiker:v0.10
container_name: hitchhiker
environment:
- HITCHHIKER_DB_HOST=hitchhiker-mysql
Expand Down Expand Up @@ -65,7 +65,7 @@ services:
version: '2'
services:
hitchhiker:
image: registry.cn-hangzhou.aliyuncs.com/brook/hitchhiker-cn:v0.9
image: registry.cn-hangzhou.aliyuncs.com/brook/hitchhiker-cn:v0.10
container_name: hitchhiker
environment:
- HITCHHIKER_DB_HOST=hitchhiker-mysql
Expand All @@ -92,7 +92,7 @@ services:
version: '2'
services:
hitchhiker:
image: registry.cn-hangzhou.aliyuncs.com/brook/hitchhiker-cn:v0.9
image: registry.cn-hangzhou.aliyuncs.com/brook/hitchhiker-cn:v0.10
container_name: hitchhiker
environment:
- HITCHHIKER_DB_HOST=192.168.0.10
Expand All @@ -108,4 +108,8 @@ services:
#### 使用nginx和域名

因为使用域名的话基本上是用80端口,如果主机还是使用8080端口是没有问题,因为默认用的是这个端口。但如果用其他端口或要使用压力测试就需要使用另外一个环境变量来设置端口:HITCHHIKER_APP_PORT。
要注意的是hitchhiker和nginx对主机的端口不能冲突。
要注意的是hitchhiker和nginx对主机的端口不能冲突。

#### 可能遇到的问题
1. 如果docker部署完成后,浏览器访问时界面停留在转圈那里
解决: 很可能是数据库里的表没创建起来,需要去hitchhiker-mysql容器里查看下,命令:sudo docker exec -it hitchhiker-mysql bash 进入容器, mysql -uroot -p 密码进到mysql, use hitchhker-prod; show tables; 来查看表。如果表确实没创建起来,去到hitchhiker容器里 sudo docker exec -it hitchhiker bash, 执行pm2 restart index重启服务就可以了。
2 changes: 1 addition & 1 deletion deploy/docker/hitchhiker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
hitchhiker:
image: brookshi/hitchhiker:v0.9
image: brookshi/hitchhiker:v0.10
container_name: hitchhiker
environment:
- HITCHHIKER_DB_HOST=hitchhiker-mysql
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker/hitchhiker_and_mysql/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
hitchhiker:
image: brookshi/hitchhiker:v0.9
image: brookshi/hitchhiker:v0.10
container_name: hitchhiker
environment:
- HITCHHIKER_DB_HOST=hitchhiker-mysql
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker/push_docker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export HITCHHIKER_VERSION="v0.9"
export HITCHHIKER_VERSION="v0.10"
sudo docker pull registry.us-east-1.aliyuncs.com/brook/hitchhiker:$HITCHHIKER_VERSION
sudo docker login --username=brookshi --password=$DOCKER_ID_PWD
sudo docker tag registry.us-east-1.aliyuncs.com/brook/hitchhiker:$HITCHHIKER_VERSION brookshi/hitchhiker:$HITCHHIKER_VERSION
Expand Down
1 change: 1 addition & 0 deletions en/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [3.3 Create a Request and Send](Simple_Tutorial/Create_Request.md)
* [3.4 Use Environment Variable](Simple_Tutorial/Use_Env_Var.md)
* [3.5 Use Parameters](Simple_Tutorial/Use_Param.md)
* [3.6 Assert base on UI](Simple_Tutorial/Assert_Base_On_UI.md)
* [4. Variable](Variable/README.md)
* [4.1 Environment Variable](Variable/Env_Var.md)
* [4.2 Parameter Variable](Variable/Param_Var.md)
Expand Down
10 changes: 10 additions & 0 deletions en/Simple_Tutorial/Assert_Base_On_UI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#### Assert base on UI

QA could use assertions to validate if response is right, of course, use script is a good way to do this, but for some QA, it's not easy to write js script.
For this, hitchhiker support set assertions base on UI, only need click and enter target value.

![](https://raw.githubusercontent.com/brookshi/images/master/Hitchhiker/assert.PNG)

#### How to create

![](https://raw.githubusercontent.com/brookshi/images/master/Hitchhiker/assert.gif)
4 changes: 3 additions & 1 deletion en/Simple_Tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ Follow these steps below to get familiar with Hitchhiker:

4. [Use Environment Variable](Use_Env_Var.md)

5. [Use Parameters](Use_Param.md)
5. [Use Parameters](Use_Param.md)

6. [Assert base on UI](Assert_Base_On_UI.md)
2 changes: 1 addition & 1 deletion en/installation/StepByStep.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Dependence: nodejs 7.60+, recommend use LTS (8.9) and `mysql 5.7+` with json col
> create DB: CREATE DATABASE IF NOT EXISTS \`hitchhiker-prod\` default charset utf8 COLLATE utf8_general_ci;
> change variable: add `max_allowed_packet=200M` under [mysqld] section in /my.conf file, refer to:[change max_allowed_packet](https://stackoverflow.com/questions/8062496/how-to-change-max-allowed-packet-size)
1. Download app package from [https://github.com/brookshi/Hitchhiker/releases/download/v0.9/Hitchhiker.zip](https://github.com/brookshi/Hitchhiker/releases/download/v0.9/Hitchhiker.zip);
1. Download app package from [https://github.com/brookshi/Hitchhiker/releases/download/v0.10/Hitchhiker.zip](https://github.com/brookshi/Hitchhiker/releases/download/v0.10/Hitchhiker.zip);

2. Unzip and run command `node setup.js`(windows), `sudo node setup.js`(linux) in `build` folder;

Expand Down
11 changes: 8 additions & 3 deletions en/installation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ when type of variable is boolean, use 1 for true and 0 for false.
"host": "http://localhost:3000/", // set ip and port, Env Variable:HITCHHIKER_APP_HOST
"port": 8080, // port, use for nginx HITCHHIKER_APP_PORT
"api": "http://localhost:81/api/", // API interface, used for debug, Env Variable same as above
"language": "en", // language, only support mail right now, HITCHHIKER_APP_LANG
"language": "en", // language, en for english, zh for chinese, HITCHHIKER_APP_LANG
"encryptKey": "hitchhikerapi",
"defaultPassword": "123456", // default password for new user
"tempUser": "test@test.test", // email for `use without login`
Expand All @@ -21,6 +21,7 @@ when type of variable is boolean, use 1 for true and 0 for false.
"User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36",
"Cache-Control:no-cache"
],
"requestTimeout": 1800000, // request timeout (ms), HITCHHIKER_APP_SCRIPT_TIMEOUT
"scriptTimeout": 60000, // script timeout (ms), HITCHHIKER_SCRIPT_TIMEOUT
"safeVM": false, // run script in safe VM, eg: require, HITCHHIKER_SAFE_VM
"enableUpload": true, // enable upload js lib or data, HITCHHIKER_ENABLE_UPLOAD
Expand All @@ -35,10 +36,14 @@ when type of variable is boolean, use 1 for true and 0 for false.
},
"schedule": {
"duration": 60, // schedule check interval (second), HITCHHIKER_SCHEDULE_DURATION
"storeMaxCount": 50, // max length of schedule list, HITCHHIKER_SCHEDULE_COUNT
"storeUnit": "count", // store unit, HITCHHIKER_SCHEDULE_STORE_UNIT
"storeLimit": 50, // store limit, HITCHHIKER_SCHEDULE_STORE_LIMIT
"storeContent": "forFail", // value: none, forFail, all; store body/header condition, HITCHHIKER_SCHEDULE_STORE_CONTENT
"pageSize": 20, // schedule page size in browser, HITCHHIKER_SCHEDULE_PAGESIZE
"mailOnlyForFail": true // only send schedule mail if failed, HITCHHIKER_SCHEDULE_MAILFORFAIL
},
"stress": {
"type": "node", // stress type, support node and go, HITCHHIKER_STRESS_TYPE
"storeMaxCount": 5, // max length of stress test list, HITCHHIKER_STRESS_COUNT
"stressPort": 11010, // port of stres test, HITCHHIKER_STRESS_PORT
"stressUpdateInterval": 1000 // stress test update interval (second), HITCHHIKER_STRESS_UPDATE_INTERVAL
Expand All @@ -48,7 +53,7 @@ when type of variable is boolean, use 1 for true and 0 for false.
},
"mail": {
"host": "http://email.hitchhiker-api.com/api/mail/", // mail default interface
"custom": "none", // custom mail: support "api" or "smtp", HITCHHIKER_MAIL_CUSTOM
"customType": "none", // custom mail: support "api" or "smtp", HITCHHIKER_MAIL_CUSTOM_TYPE
"customApi": "http://", // if custom is "api", this custom mail interface will be available, Hitchhiker will post {target, subject, content} to this interface HITCHHIKER_MAIL_API
"smtp": { // if custom is "smtp", hitchhiker will use this smtp config, Note: some company use its internal mail host without user and pass, this config MUST empty user and pass too.
"host": "smtp.qq.com", // HITCHHIKER_MAIL_SMTP_HOST
Expand Down
2 changes: 1 addition & 1 deletion en/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ If you want to use another port, should replace all 8080.
version: '2'
services:
hitchhiker:
image: brookshi/hitchhiker:v0.9
image: brookshi/hitchhiker:v0.10
container_name: hitchhiker
environment:
- HITCHHIKER_DB_HOST=hitchhiker-mysql
Expand Down

0 comments on commit 70d712a

Please sign in to comment.