-
Notifications
You must be signed in to change notification settings - Fork 78
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 base on docker-compose
- Loading branch information
1 parent
a628783
commit dd6c4ae
Showing
14 changed files
with
356 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Testing | ||
|
||
on: | ||
- pull_request | ||
|
||
jobs: | ||
Test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
fetch-depth: 0 | ||
- name: Build Image | ||
run: | | ||
make autok3s | ||
docker build . -t cnrancher/autok3s:dev | ||
- name: Run e2e | ||
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 | ||
cd test/e2e && ./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,6 @@ | ||
FROM docker.io/linuxsuren/api-testing:v0.0.14 | ||
WORKDIR /workspace | ||
COPY testcase.yaml . | ||
COPY data data | ||
COPY entrypoint.sh entrypoint.sh | ||
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,65 @@ | ||
{ | ||
"cluster": false, | ||
"datastore": "", | ||
"datastore-cafile": "", | ||
"datastore-cafile-content": "", | ||
"datastore-certfile": "", | ||
"datastore-certfile-content": "", | ||
"datastore-keyfile": "", | ||
"datastore-keyfile-content": "", | ||
"docker-arg": "", | ||
"docker-script": "https://get.docker.com", | ||
"enable": null, | ||
"k3s-channel": "stable", | ||
"k3s-install-mirror": "INSTALL_K3S_MIRROR=cn", | ||
"k3s-install-script": "https://rancher-mirror.rancher.cn/k3s/k3s-install.sh", | ||
"k3s-version": "", | ||
"manifests": "", | ||
"master": "1", | ||
"master-extra-args": "", | ||
"name": "{{randAlpha 4}}", | ||
"package-name": "", | ||
"package-path": "", | ||
"registry": "", | ||
"registry-content": "", | ||
"rollback": true, | ||
"set": null, | ||
"ssh-agent-auth": false, | ||
"ssh-cert-path": "", | ||
"ssh-key-name": "", | ||
"ssh-key-passphrase": "", | ||
"ssh-key-path": "", | ||
"ssh-password": "", | ||
"ssh-port": "22", | ||
"ssh-user": "root", | ||
"system-default-registry": "", | ||
"tls-sans": null, | ||
"token": "", | ||
"worker": "0", | ||
"worker-extra-args": "", | ||
"ssh-key": "", | ||
"ssh-cert": "", | ||
"provider": "alibaba", | ||
"options": { | ||
"access-key": "cc", | ||
"access-secret": "ccc", | ||
"cloud-controller-manager": false, | ||
"disk-category": "cloud_essd", | ||
"disk-size": "40", | ||
"eip": false, | ||
"image": "ubuntu_22_04_x64_20G_alibase_20230613.vhd", | ||
"instance-type": "ecs.c6.large", | ||
"internet-max-bandwidth-out": "5", | ||
"key-pair": "", | ||
"region": "cn-hangzhou", | ||
"security-group": "", | ||
"spot-duration": 1, | ||
"spot-price-limit": 0, | ||
"spot-strategy": "NoSpot", | ||
"tags": null, | ||
"user-data-content": "", | ||
"user-data-path": "", | ||
"v-switch": "", | ||
"zone": "cn-hangzhou-i" | ||
} | ||
} |
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 @@ | ||
{ | ||
"datastore-cafile-content": "", | ||
"datastore-certfile-content": "", | ||
"datastore-keyfile-content": "", | ||
"master": "1", | ||
"master-extra-args": "", | ||
"masters-memory": "", | ||
"name": "{{randAlpha 4}}", | ||
"network": "", | ||
"registry": "", | ||
"registry-content": "", | ||
"token": "", | ||
"worker": "0", | ||
"worker-extra-args": "", | ||
"workers-memory": "", | ||
"rollback": true, | ||
"provider": "k3d", | ||
"options": { | ||
"api-port": "0.0.0.0:0", | ||
"envs": null, | ||
"gpus": "", | ||
"image": "docker.io/rancher/k3s:v1.27.6-k3s1", | ||
"labels": null, | ||
"masters-memory": "", | ||
"no-image-volume": false, | ||
"no-lb": false, | ||
"ports": null, | ||
"volumes": null, | ||
"workers-memory": "" | ||
} | ||
} |
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 @@ | ||
{ | ||
"cluster": false, | ||
"datastore": "", | ||
"datastore-cafile": "", | ||
"datastore-cafile-content": "", | ||
"datastore-certfile": "", | ||
"datastore-certfile-content": "", | ||
"datastore-keyfile": "", | ||
"datastore-keyfile-content": "", | ||
"docker-arg": "", | ||
"docker-script": "https://get.docker.com", | ||
"enable": [], | ||
"k3s-channel": "stable", | ||
"k3s-install-mirror": "", | ||
"k3s-install-script": "https://get.k3s.io", | ||
"k3s-version": "", | ||
"manifests": "", | ||
"master-extra-args": "", | ||
"name": "{{randAlpha 4}}", | ||
"package-name": "", | ||
"package-path": "", | ||
"registry": "", | ||
"registry-content": "", | ||
"rollback": true, | ||
"set": null, | ||
"ssh-agent-auth": false, | ||
"ssh-cert-path": "", | ||
"ssh-key-name": "", | ||
"ssh-key-passphrase": "", | ||
"ssh-key-path": "", | ||
"ssh-password": "", | ||
"ssh-port": "22", | ||
"ssh-user": "root", | ||
"system-default-registry": "", | ||
"tls-sans": null, | ||
"token": "", | ||
"worker-extra-args": "", | ||
"ssh-key": "", | ||
"ssh-cert": "", | ||
"values": {}, | ||
"provider": "native", | ||
"options": { | ||
"master-ips": "0.0.0.0", | ||
"worker-ips": "" | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"provider": "alibaba", | ||
"secrets": { | ||
"access-key": "sdfsf", | ||
"access-secret": "sdfsfd" | ||
} | ||
} |
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 @@ | ||
{ | ||
"provider": "aws", | ||
"secrets": { | ||
"access-key": "test", | ||
"secret-key": "ttest", | ||
"session-token": "" | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"provider": "google", | ||
"secrets": { | ||
"service-account": "ss", | ||
"service-account-file": "ss" | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"provider": "tencent", | ||
"secrets": { | ||
"secret-id": "sdfs", | ||
"secret-key": "fsfds" | ||
} | ||
} |
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 @@ | ||
{ | ||
"name": "{{randAlpha 4}}", | ||
"generate-key": true, | ||
"bits": 2048, | ||
"ssh-passphrase": "" | ||
} |
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,16 @@ | ||
services: | ||
testing: | ||
build: . | ||
depends_on: | ||
autok3s: | ||
condition: service_healthy | ||
links: | ||
- autok3s | ||
autok3s: | ||
image: cnrancher/autok3s:dev | ||
healthcheck: | ||
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/8080"] | ||
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,4 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
atest run -p testcase.yaml |
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=docker-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 |
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,100 @@ | ||
name: autok3s | ||
param: | ||
server: http://autok3s:8080 | ||
spec: | ||
kind: HTTP | ||
api: http://autok3s:8080/v1 | ||
items: | ||
- name: createAlibabaCredential | ||
request: | ||
api: /credentials | ||
method: POST | ||
header: | ||
Content-Type: application/json | ||
bodyFromFile: data/credential-alibaba.json | ||
expect: | ||
statusCode: 201 | ||
- name: createAwsCredential | ||
request: | ||
api: /credentials | ||
method: POST | ||
bodyFromFile: data/credential-aws.json | ||
expect: | ||
statusCode: 201 | ||
- name: createGoogleCredential | ||
request: | ||
api: /credentials | ||
method: POST | ||
bodyFromFile: data/credential-google.json | ||
expect: | ||
statusCode: 201 | ||
- name: createTencentCredential | ||
request: | ||
api: /credentials | ||
method: POST | ||
bodyFromFile: data/credential-tencent.json | ||
expect: | ||
statusCode: 201 | ||
|
||
- name: createK3dCluster | ||
request: | ||
api: /clusters | ||
bodyFromFile: data/cluster-k3d.json | ||
method: POST | ||
expect: | ||
statusCode: 201 | ||
- name: createNativeCluster | ||
request: | ||
api: /clusters | ||
bodyFromFile: data/cluster-native.json | ||
method: POST | ||
expect: | ||
statusCode: 201 | ||
- name: createAlibabaCluster | ||
request: | ||
api: /clusters | ||
bodyFromFile: data/cluster-alibaba.json | ||
method: POST | ||
expect: | ||
statusCode: 422 | ||
- name: clusters | ||
request: | ||
api: /clusters | ||
method: GET | ||
expect: | ||
verify: | ||
- len(data.data) == 2 | ||
- name: getCluster | ||
request: | ||
api: /clusters/{{(index .clusters.data 0).id}}?link=nodes | ||
method: GET | ||
- name: deleteCluster | ||
request: | ||
api: /clusters/{{(index .clusters.data 0).id}} | ||
method: DELETE | ||
|
||
## ssh key related APIs | ||
- name: generateSSHKey | ||
request: | ||
api: /sshKeys | ||
method: POST | ||
bodyFromFile: data/sshkey.json | ||
expect: | ||
statusCode: 201 | ||
- name: getSSHKeyList | ||
request: | ||
api: /sshKeys | ||
expect: | ||
verify: | ||
- len(data.data) == 1 | ||
- name: deleteSSHKey | ||
request: | ||
api: /sshKeys/{{(index .getSSHKeyList.data 0).id}} | ||
|
||
## addon related APIs | ||
- name: getAddonList | ||
request: | ||
api: /addons | ||
expect: | ||
verify: | ||
- len(data.data) == 1 |