Merge pull request #30 from LinuxSuRen/e2e
🚀 add e2e testing base on docker compose.
This commit is contained in:
22
.github/workflows/e2e.yaml
vendored
Normal file
22
.github/workflows/e2e.yaml
vendored
Normal file
@@ -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
|
||||||
@@ -17,7 +17,18 @@ services:
|
|||||||
- DEMO_MODE=false
|
- DEMO_MODE=false
|
||||||
volumes:
|
volumes:
|
||||||
- /data/orion-visor-space/docker-volumes/orion-visor-service/root-orion:/root/orion
|
- /data/orion-visor-space/docker-volumes/orion-visor-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:
|
depends_on:
|
||||||
|
orion-visor-mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
orion-visor-redis:
|
||||||
|
condition: service_healthy
|
||||||
|
links:
|
||||||
- orion-visor-mysql
|
- orion-visor-mysql
|
||||||
- orion-visor-redis
|
- orion-visor-redis
|
||||||
orion-visor-mysql:
|
orion-visor-mysql:
|
||||||
@@ -34,6 +45,12 @@ services:
|
|||||||
- /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:/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/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/orion-visor-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:
|
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.9
|
||||||
privileged: true
|
privileged: true
|
||||||
@@ -44,7 +61,23 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- /data/orion-visor-space/docker-volumes/orion-visor-redis/data:/data
|
- /data/orion-visor-space/docker-volumes/orion-visor-redis/data:/data
|
||||||
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
|
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:
|
orion-visor-adminer:
|
||||||
image: adminer
|
image: adminer
|
||||||
ports:
|
ports:
|
||||||
- 8081:8080
|
- 8081:8080
|
||||||
|
testing:
|
||||||
|
build:
|
||||||
|
context: e2e
|
||||||
|
environment:
|
||||||
|
SERVER: http://orion-visor-service:80
|
||||||
|
depends_on:
|
||||||
|
orion-visor-service:
|
||||||
|
condition: service_healthy
|
||||||
|
links:
|
||||||
|
- orion-visor-service
|
||||||
|
|||||||
6
e2e/Dockerfile
Normal file
6
e2e/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FROM ghcr.io/linuxsuren/api-testing:v0.0.17
|
||||||
|
|
||||||
|
WORKDIR /workspace
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD [ "/workspace/entrypoint.sh" ]
|
||||||
3
e2e/entrypoint.sh
Executable file
3
e2e/entrypoint.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
atest run -p testsuite.yaml --report md
|
||||||
54
e2e/testsuite.yaml
Normal file
54
e2e/testsuite.yaml
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#!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}}
|
||||||
|
expect:
|
||||||
|
bodyFieldsExpect:
|
||||||
|
data: false
|
||||||
|
- name: queryOperatorLog
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/infra/mine/query-operator-log
|
||||||
|
method: POST
|
||||||
|
- name: hostList
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/infra/tag/list?type=HOST
|
||||||
|
- name: queryHost
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/asset/host/query
|
||||||
|
method: POST
|
||||||
Reference in New Issue
Block a user