Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #34

Merged
merged 16 commits into from
Jun 27, 2024
Merged

Dev #34

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: E2E

on:
pull_request:
branches:
- main
- dev

concurrency:
group: ${{github.workflow}} - ${{github.ref}}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: E2E Testing
run: |
sudo curl -L https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod u+x /usr/local/bin/docker-compose
docker compose up --build testing --exit-code-from testing --remove-orphans -f docker-compose-testing.yml
79 changes: 79 additions & 0 deletions docker-compose-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: '3.3'
services:
orion-visor-service:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.10
privileged: true
ports:
- 1081:80
environment:
- MYSQL_HOST=orion-visor-mysql
- MYSQL_PORT=3306
- MYSQL_DATABASE=orion_visor
- MYSQL_USER=root
- MYSQL_PASSWORD=Data@123456
- REDIS_HOST=orion-visor-redis
- REDIS_PASSWORD=Data@123456
- SECRET_KEY=uQeacXV8b3isvKLK
- DEMO_MODE=false
volumes:
- /data/orion-visor-space/docker-volumes/service/root-orion:/root/orion
healthcheck:
test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ]
interval: 3s
timeout: 300s
retries: 200
start_period: 3s
depends_on:
orion-visor-mysql:
condition: service_healthy
orion-visor-redis:
condition: service_healthy
links:
- orion-visor-mysql
- orion-visor-redis
orion-visor-mysql:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.10
privileged: true
ports:
- 3307:3306
environment:
- MYSQL_DATABASE=orion_visor
- MYSQL_USER=orion
- MYSQL_PASSWORD=Data@123456
- MYSQL_ROOT_PASSWORD=Data@123456
volumes:
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql:/var/lib/mysql
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql-files:/var/lib/mysql-files
- /data/orion-visor-space/docker-volumes/mysql/etc-mysql:/etc/mysql
healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ]
interval: 3s
timeout: 60s
retries: 10
start_period: 3s
orion-visor-redis:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.10
privileged: true
ports:
- 6380:6379
environment:
- REDIS_PASSWORD=Data@123456
volumes:
- /data/orion-visor-space/docker-volumes/redis/data:/data
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 3s
timeout: 60s
retries: 10
start_period: 3s
testing:
build:
context: ./docker/e2e
environment:
SERVER: http://orion-visor-service:80
depends_on:
orion-visor-service:
condition: service_healthy
links:
- orion-visor-service
39 changes: 31 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.3'
services:
orion-visor-service:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.9
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.10
privileged: true
ports:
- 1081:80
Expand All @@ -16,12 +16,23 @@ services:
- SECRET_KEY=uQeacXV8b3isvKLK
- DEMO_MODE=false
volumes:
- /data/orion-visor-space/docker-volumes/orion-visor-service/root-orion:/root/orion
- /data/orion-visor-space/docker-volumes/service/root-orion:/root/orion
healthcheck:
test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ]
interval: 3s
timeout: 300s
retries: 200
start_period: 3s
depends_on:
orion-visor-mysql:
condition: service_healthy
orion-visor-redis:
condition: service_healthy
links:
- orion-visor-mysql
- orion-visor-redis
orion-visor-mysql:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.9
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.10
privileged: true
ports:
- 3307:3306
Expand All @@ -31,19 +42,31 @@ services:
- MYSQL_PASSWORD=Data@123456
- MYSQL_ROOT_PASSWORD=Data@123456
volumes:
- /data/orion-visor-space/docker-volumes/orion-visor-mysql/var-lib-mysql:/var/lib/mysql
- /data/orion-visor-space/docker-volumes/orion-visor-mysql/var-lib-mysql-files:/var/lib/mysql-files
- /data/orion-visor-space/docker-volumes/orion-visor-mysql/etc-mysql:/etc/mysql
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql:/var/lib/mysql
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql-files:/var/lib/mysql-files
- /data/orion-visor-space/docker-volumes/mysql/etc-mysql:/etc/mysql
healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ]
interval: 3s
timeout: 60s
retries: 10
start_period: 3s
orion-visor-redis:
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.9
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.10
privileged: true
ports:
- 6380:6379
environment:
- REDIS_PASSWORD=Data@123456
volumes:
- /data/orion-visor-space/docker-volumes/orion-visor-redis/data:/data
- /data/orion-visor-space/docker-volumes/redis/data:/data
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 3s
timeout: 60s
retries: 10
start_period: 3s
orion-visor-adminer:
image: adminer
ports:
Expand Down
6 changes: 6 additions & 0 deletions docker/e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/linuxsuren/api-testing:v0.0.17

WORKDIR /workspace
COPY . .

CMD [ "/workspace/entrypoint.sh" ]
3 changes: 3 additions & 0 deletions docker/e2e/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -e
atest run -p testsuite.yaml --report md
57 changes: 57 additions & 0 deletions docker/e2e/testsuite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!api-testing
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json
name: orion-visor
api: |
{{default "http://orion-visor-service:80" (env "SERVER")}}
items:
- name: login
request:
api: /orion-visor/api/infra/auth/login
method: POST
header:
Content-type: application/json
body: |
{"username":"admin","password":"21232f297a57a5a743894a0e4a801fc3"}
expect:
bodyFieldsExpect:
code: 200
- name: userPermission
request:
api: /orion-visor/api/infra/permission/user
header:
Authorization: Bearer {{.login.data.token}}
expect:
bodyFieldsExpect:
code: 200
msg: "success"
- name: menu
request:
api: /orion-visor/api/infra/permission/menu
header:
Authorization: Bearer {{.login.data.token}}
expect:
bodyFieldsExpect:
code: 200
msg: "success"
- name: haveUnRead
request:
api: /orion-visor/api/infra/system-message/has-unread
header:
Authorization: Bearer {{.login.data.token}}
- name: queryOperatorLog
request:
api: /orion-visor/api/infra/mine/query-operator-log
method: POST
header:
Authorization: Bearer {{.login.data.token}}
- name: hostList
request:
api: /orion-visor/api/infra/tag/list?type=HOST
header:
Authorization: Bearer {{.login.data.token}}
- name: queryHost
request:
api: /orion-visor/api/asset/host/query
method: POST
header:
Authorization: Bearer {{.login.data.token}}
2 changes: 1 addition & 1 deletion docker/mysql/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.0.9
version=2.0.10
cp -r ../../sql ./sql
docker build -t orion-visor-mysql:${version} .
rm -rf ./sql
Expand Down
2 changes: 1 addition & 1 deletion docker/redis/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.0.9
version=2.0.10
docker build -t orion-visor-redis:${version} .
docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
2 changes: 1 addition & 1 deletion docker/service/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.0.9
version=2.0.10
mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar
mv ../../orion-visor-ui/dist ./dist
docker build -t orion-visor-service:${version} .
Expand Down
2 changes: 1 addition & 1 deletion orion-visor-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<url>https://github.com/dromara/orion-visor</url>

<properties>
<revision>2.0.9</revision>
<revision>2.0.10</revision>
<spring.boot.version>2.7.17</spring.boot.version>
<spring.boot.admin.version>2.7.15</spring.boot.admin.version>
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface AppConst extends OrionConst {
/**
* 同 ${orion.version} 迭代时候需要手动更改
*/
String VERSION = "2.0.9";
String VERSION = "2.0.10";

/**
* 同 ${spring.application.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ public interface ErrorMessage {

String UNKNOWN_TYPE = "未知类型";

String ERROR_TYPE = "错误的类型";

String FILE_ABSENT = "文件不存在";

String FILE_ABSENT_CLEAR = "文件不存在 (可能已被清理)";

String LOG_ABSENT = "日志不存在";

String TASK_ABSENT = "任务不存在";
Expand All @@ -95,6 +99,8 @@ public interface ErrorMessage {

String FILE_READ_ERROR = "文件读取失败";

String FILE_READ_ERROR_CLEAR = "文件读取失败 (可能已被清理)";

String PLEASE_CHECK_HOST_SSH = "请检查主机 {} 是否存在/权限/SSH配置";

String CLIENT_ABORT = "手动中断";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.orion.visor.framework.common.constant;

/**
* 路径常量
* 文件常量
*
* @author Jiahang Li
* @version 1.0.0
* @since 2024/4/17 10:35
*/
public interface PathConst {
public interface FileConst {

String ERROR_LOG = "error.log";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.orion.visor.framework.common.entity;

import lombok.Data;

/**
* 自动清理配置
*
* @author Jiahang Li
* @version 1.0.0
* @since 2024/6/24 15:03
*/
@Data
public class AutoClearConfig {

/**
* 是否开启
*/
private Boolean enabled;

/**
* 保留周期 (天)
*/
private Integer keepPeriod;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.orion.visor.framework.common.enums;

import com.orion.lang.utils.Strings;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* 端点定义
*
* @author Jiahang Li
* @version 1.0.0
* @since 2024/6/21 19:15
*/
@Getter
@AllArgsConstructor
public enum EndpointDefine {

/**
* 上传临时分区
*/
UPLOAD_SWAP("/upload/swap/{}"),

/**
* 批量执行日志
*/
EXEC_LOG("/exec/{}/{}.log"),

;

/**
* 端点
*/
private final String endpoint;

/**
* 格式化
*
* @param params params
* @return path
*/
public String format(Object... params) {
return Strings.format(this.endpoint, params);
}

}
Loading
Loading