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 <LinuxSuRen@users.noreply.github.com>
This commit is contained in:
parent
1765d139c0
commit
92d517f7b9
|
@ -4,7 +4,7 @@ Making sure that your local build is OK before committing will help you reduce d
|
||||||
and make it easier for maintainers to review.
|
and make it easier for maintainers to review.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
> We highly recommend you read [the contributor's documentation](https://github.com/LinuxSuRen/api-testing/blob/master/CONTRIBUTION.md) before starting the review process especially since this is your first contribution to this project.
|
> We highly recommend you read [the contributor's documentation](https://github.com/LinuxSuRen/api-testing/blob/master/CONTRIBUTING.md) before starting the review process especially since this is your first contribution to this project.
|
||||||
>
|
>
|
||||||
> It was updated on 2024/5/27
|
> It was updated on 2024/5/27
|
||||||
|
|
||||||
|
|
|
@ -105,8 +105,8 @@ jobs:
|
||||||
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 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
|
sudo chmod u+x /usr/local/bin/docker-compose
|
||||||
make test-e2e
|
make test-e2e
|
||||||
# - name: Operator Image
|
- name: Code Generator Test
|
||||||
# run: cd operator && make docker-build
|
run: cd e2e/code-generator && ./start.sh
|
||||||
|
|
||||||
BuildEmbedUI:
|
BuildEmbedUI:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
You can build the image locally in the repository root directory:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
REGISTRY=ghcr.io TAG=master make image
|
||||||
|
```
|
|
@ -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" ]
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
'''
|
||||||
Copyright 2024 API Testing Authors.
|
Copyright 2024 API Testing Authors.
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -9,7 +9,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
'''
|
||||||
import io
|
import io
|
||||||
import requests
|
import requests
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
'''
|
||||||
Copyright 2024 API Testing Authors.
|
Copyright 2024 API Testing Authors.
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -9,7 +9,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
'''
|
||||||
import io
|
import io
|
||||||
import requests
|
import requests
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
'''
|
||||||
Copyright 2024 API Testing Authors.
|
Copyright 2024 API Testing Authors.
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -9,7 +9,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
'''
|
||||||
import io
|
import io
|
||||||
import requests
|
import requests
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
'''
|
||||||
Copyright 2024 API Testing Authors.
|
Copyright 2024 API Testing Authors.
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -9,7 +9,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
'''
|
||||||
import io
|
import io
|
||||||
import requests
|
import requests
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
Loading…
Reference in New Issue