-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e testing for some basic APIs (#1387)
Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
- Loading branch information
1 parent
1a59261
commit 8905f0e
Showing
13 changed files
with
411 additions
and
2 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
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,8 @@ | ||
# This configuration file was automatically generated by Gitpod. | ||
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) | ||
# and commit this file to your remote git repository to share the goodness with others. | ||
|
||
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart | ||
|
||
tasks: | ||
- init: mvn install -DskipTests=false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM ghcr.io/linuxsuren/api-testing:master | ||
|
||
WORKDIR /workspace | ||
COPY . . | ||
|
||
CMD [ "/workspace/entrypoint.sh" ] |
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,2 @@ | ||
demo: | ||
docker compose up hertzbeat |
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,14 @@ | ||
Please add the corresponding e2e (aka end-to-end) test cases if you add or update APIs. | ||
|
||
## How to work | ||
* Start and watch the [docker-compose](https://docs.docker.com/compose/) via [the script](start.sh) | ||
* Run the e2e testing via [api-testing](https://github.com/LinuxSuRen/api-testing) | ||
* It will run the test cases from top to bottom | ||
* You can add the necessary asserts to it | ||
|
||
## Run locally | ||
Please follow these steps if you want to run the e2e testing locally. | ||
|
||
> Please make sure you have installed docker-compose v2 | ||
* Change the directory to `e2e`, then execute `./start.sh` |
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,24 @@ | ||
version: '3.1' | ||
services: | ||
testing: | ||
build: | ||
context: . | ||
environment: | ||
SERVER: http://hertzbeat:1157 | ||
depends_on: | ||
hertzbeat: | ||
condition: service_healthy | ||
links: | ||
- hertzbeat | ||
hertzbeat: | ||
image: tancloud/hertzbeat | ||
ports: | ||
- 1157:1157 | ||
environment: | ||
ALLOW_NONE_AUTHENTICATION: "yes" | ||
healthcheck: | ||
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/1157"] | ||
interval: 3s | ||
timeout: 60s | ||
retries: 10 | ||
start_period: 3s |
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,80 @@ | ||
|
||
{ | ||
"detected": false, | ||
"collector": "", | ||
"monitor": { | ||
"intervals": 60, | ||
"tags": [], | ||
"app": "api", | ||
"host": "127.0.0.1", | ||
"name": "{{.param.monitorHTTP}}" | ||
}, | ||
"params": [ | ||
{ | ||
"field": "host", | ||
"type": 1, | ||
"value": "127.0.0.1" | ||
}, | ||
{ | ||
"field": "port", | ||
"type": 0, | ||
"value": 80 | ||
}, | ||
{ | ||
"field": "method", | ||
"type": 1, | ||
"value": "GET" | ||
}, | ||
{ | ||
"field": "uri", | ||
"type": 1, | ||
"value": "" | ||
}, | ||
{ | ||
"field": "ssl", | ||
"type": 1, | ||
"value": false | ||
}, | ||
{ | ||
"field": "headers", | ||
"type": 3 | ||
}, | ||
{ | ||
"field": "params", | ||
"type": 3 | ||
}, | ||
{ | ||
"field": "timeout", | ||
"type": 0 | ||
}, | ||
{ | ||
"field": "contentType", | ||
"type": 1 | ||
}, | ||
{ | ||
"field": "payload", | ||
"type": 1 | ||
}, | ||
{ | ||
"field": "authType", | ||
"type": 1 | ||
}, | ||
{ | ||
"field": "username", | ||
"type": 1 | ||
}, | ||
{ | ||
"field": "password", | ||
"type": 1 | ||
}, | ||
{ | ||
"field": "keyword", | ||
"type": 1 | ||
}, | ||
{ | ||
"field": "successCode", | ||
"type": 4, | ||
"value": "200, 201" | ||
} | ||
] | ||
} |
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,4 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
atest run -p testsuite.yaml --report md |
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,31 @@ | ||
#!/bin/bash | ||
|
||
file=$1 | ||
if [ "$file" == "" ] | ||
then | ||
file=compose.yaml | ||
fi | ||
|
||
docker-compose version | ||
docker-compose -f "$file" up --build -d | ||
|
||
while true | ||
do | ||
docker-compose -f "$file" ps | grep testing | ||
if [ $? -eq 1 ] | ||
then | ||
code=-1 | ||
docker-compose -f "$file" logs | grep e2e-testing | ||
docker-compose -f "$file" logs | grep e2e-testing | grep Usage | ||
if [ $? -eq 1 ] | ||
then | ||
code=0 | ||
echo "successed" | ||
fi | ||
|
||
docker-compose -f "$file" down | ||
set -e | ||
exit $code | ||
fi | ||
sleep 1 | ||
done |
Oops, something went wrong.