-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e: add e2e tests for code generators (#458)
* e2e: add e2e tests for code generators * improve the verifying of java code generating --------- Co-authored-by: rick <[email protected]>
- Loading branch information
1 parent
1765d13
commit 92d517f
Showing
17 changed files
with
191 additions
and
11 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
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,5 @@ | ||
You can build the image locally in the repository root directory: | ||
|
||
```shell | ||
REGISTRY=ghcr.io TAG=master make image | ||
``` |
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,12 @@ | ||
ARG LAN_ENV=docker.io/library/golang:1.21 | ||
|
||
FROM ghcr.io/linuxsuren/api-testing:master AS atest | ||
FROM docker.io/stedolan/jq AS jq | ||
FROM $LAN_ENV | ||
|
||
WORKDIR /workspace | ||
COPY . . | ||
COPY --from=jq /usr/local/bin/jq /usr/local/bin/jq | ||
COPY --from=atest /usr/local/bin/atest /usr/local/bin/atest | ||
|
||
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,13 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export sourcefile=$1 | ||
# exit if no source file is specified | ||
if [ -z "$sourcefile" ] | ||
then | ||
echo "no source file is specified" | ||
exit 1 | ||
fi | ||
|
||
mv ${sourcefile} main.js | ||
node main.js |
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,46 @@ | ||
services: | ||
golang: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- LAN_ENV=docker.io/library/golang:1.21 | ||
command: | ||
- /workspace/entrypoint.sh | ||
- golang | ||
java: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- LAN_ENV=docker.io/library/openjdk:23 | ||
command: | ||
- /workspace/entrypoint.sh | ||
- java | ||
python: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- LAN_ENV=docker.io/library/python:3.8 | ||
command: | ||
- /workspace/entrypoint.sh | ||
- python | ||
javascript: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- LAN_ENV=docker.io/library/node:22 | ||
command: | ||
- /workspace/entrypoint.sh | ||
- JavaScript | ||
curl: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- LAN_ENV=docker.io/library/openjdk:23 | ||
command: | ||
- /workspace/entrypoint.sh | ||
- curl |
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,13 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export sourcefile=$1 | ||
# exit if no source file is specified | ||
if [ -z "$sourcefile" ] | ||
then | ||
echo "no source file is specified" | ||
exit 1 | ||
fi | ||
|
||
mv ${sourcefile} main.sh | ||
sh main.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,26 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export lang=$1 | ||
# exit if no language is specified | ||
if [ -z "$lang" ] | ||
then | ||
echo "no language is specified" | ||
exit 1 | ||
fi | ||
|
||
mkdir -p /root/.config/atest | ||
mkdir -p /var/data | ||
|
||
nohup atest server --local-storage '/workspace/test-suites/*.yaml'& | ||
sleep 1 | ||
|
||
curl http://localhost:8080/server.Runner/GenerateCode -X POST \ | ||
-d '{"TestSuite": "test", "TestCase": "requestWithHeader", "Generator": "'"$lang"'"}' > code.json | ||
|
||
cat code.json | jq .message -r | sed 's/\\n/\n/g' | sed 's/\\t/\t/g' | sed 's/\\\"/"/g' > code.txt | ||
cat code.txt | ||
|
||
sh /workspace/${lang}.sh code.txt | ||
|
||
exit 0 |
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,13 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export sourcefile=$1 | ||
# exit if no source file is specified | ||
if [ -z "$sourcefile" ] | ||
then | ||
echo "no source file is specified" | ||
exit 1 | ||
fi | ||
|
||
mv ${sourcefile} main.go | ||
go run main.go |
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,13 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export sourcefile=$1 | ||
# exit if no source file is specified | ||
if [ -z "$sourcefile" ] | ||
then | ||
echo "no source file is specified" | ||
exit 1 | ||
fi | ||
|
||
mv ${sourcefile} Main.java | ||
java Main.java |
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 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export sourcefile=$1 | ||
# exit if no source file is specified | ||
if [ -z "$sourcefile" ] | ||
then | ||
echo "no source file is specified" | ||
exit 1 | ||
fi | ||
|
||
mv ${sourcefile} main.py | ||
pip install requests | ||
python main.py |
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,10 @@ | ||
#!/bin/bash | ||
|
||
docker-compose version | ||
|
||
targets=(golang java python javascript curl) | ||
for target in "${targets[@]}" | ||
do | ||
docker-compose down | ||
docker-compose up --build $target | ||
done |
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,15 @@ | ||
#!api-testing | ||
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json | ||
# https://docs.gitlab.com/ee/api/api_resources.html | ||
name: test | ||
api: http://localhost:8080/server.Runner | ||
param: | ||
suiteName: test | ||
caseName: test | ||
items: | ||
- name: requestWithHeader | ||
request: | ||
api: /GetSuites | ||
method: POST | ||
header: | ||
auth: fake |
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
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