From 1c1f8613f61948f689b48247e6b935ea417281d6 Mon Sep 17 00:00:00 2001 From: rsonghuster Date: Wed, 16 Oct 2024 16:37:32 +0800 Subject: [PATCH] add test in action --- .github/workflows/ci_with_docker_linux.yaml | 3 -- .github/workflows/ci_with_docker_macos.yaml | 3 -- __tests__/e2e/apt/code/package-lock.json | 51 ------------------- __tests__/e2e/ci-mac-linux.sh | 54 +++++++++++++++++---- __tests__/e2e/custom-domain/s.yaml | 2 +- __tests__/e2e/nodejs/code/package-lock.json | 51 ------------------- __tests__/e2e/nodejs/s.yaml | 2 +- __tests__/e2e/trigger/run | 22 +++++++++ 8 files changed, 69 insertions(+), 119 deletions(-) delete mode 100644 __tests__/e2e/apt/code/package-lock.json delete mode 100644 __tests__/e2e/nodejs/code/package-lock.json diff --git a/.github/workflows/ci_with_docker_linux.yaml b/.github/workflows/ci_with_docker_linux.yaml index c298fe2..5d49414 100644 --- a/.github/workflows/ci_with_docker_linux.yaml +++ b/.github/workflows/ci_with_docker_linux.yaml @@ -4,9 +4,6 @@ on: push: branches: - master - pull_request: - branches: - - master env: REGION: cn-hongkong diff --git a/.github/workflows/ci_with_docker_macos.yaml b/.github/workflows/ci_with_docker_macos.yaml index f36d0b7..c9fb081 100644 --- a/.github/workflows/ci_with_docker_macos.yaml +++ b/.github/workflows/ci_with_docker_macos.yaml @@ -4,9 +4,6 @@ on: push: branches: - master - pull_request: - branches: - - master env: REGION: cn-hongkong diff --git a/__tests__/e2e/apt/code/package-lock.json b/__tests__/e2e/apt/code/package-lock.json deleted file mode 100644 index 4922ff2..0000000 --- a/__tests__/e2e/apt/code/package-lock.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "code", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "requires": { - "has-flag": "^4.0.0" - } - } - } -} diff --git a/__tests__/e2e/ci-mac-linux.sh b/__tests__/e2e/ci-mac-linux.sh index 9c8bbe9..d926e9c 100755 --- a/__tests__/e2e/ci-mac-linux.sh +++ b/__tests__/e2e/ci-mac-linux.sh @@ -7,6 +7,24 @@ set -e set -v +if [[ $(uname -s) == "Linux" ]]; then + # echo "test trigger" + # cd trigger && ./run + # cd .. + echo "test custom-domain" + cd custom-domain + s deploy -y + s info + s remove -y + + s deploy -y -t s2.yaml + s info -t s2.yaml + s remove -y -t s2.yaml + cd .. +else + echo "skip test trigger" +fi + echo "test go runtime" cd go export fc_component_function_name=go1-$(uname)-$(uname -m)-$RANDSTR @@ -40,15 +58,33 @@ s remove -y -t ./go/s.yaml rm -rf ./go/code/target cd .. -# echo "test nodejs runtime with auto ..." -# cd nodejs -# export fc_component_function_name=nodejs14-$(uname)-$(uname -m)-$RANDSTR -# s deploy -y -t ./s_auto.yaml -# s invoke -e '{"hello":"fc nodejs with auto"}' -t ./s_auto.yaml -# s info -y -t ./s_auto.yaml -# s remove -y -t ./s_auto.yaml -# cd .. +echo "test nodejs runtime with auto ..." +cd nodejs +export fc_component_function_name=nodejs14-$(uname)-$(uname -m)-$RANDSTR +s deploy -y -t s_auto.yaml +s invoke -e '{"hello":"fc nodejs with auto"}' -t s_auto.yaml +s info -y -t s_auto.yaml +s remove -y -t s_auto.yaml + +echo "test deploy with alias" +export fc_component_function_name=nodejs14-$(uname)-$(uname -m)-$RANDSTR +s deploy --function -t s2.yaml +versionId=$(s version publish -t s2.yaml --silent -o json | jq -r '."versionId"') +echo "latest version = $versionId" +if [[ "$versionId" -gt 1 ]]; then + mainVersion=$((versionId - 1)) + echo "main version = $mainVersion" + s alias publish --alias-name test --version-id $mainVersion --vw "{\"$versionId\": 0.2}" -t s2.yaml +else + s alias publish --alias-name test --version-id $versionId -t s2.yaml +fi + +s deploy --trigger -t s2.yaml +s deploy --async-invoke-config -t s2.yaml +s info -t s2.yaml +s remove -y -t s2.yaml +cd .. echo " ********* command-api *********" cd command-api && ./run && cd - -cd command-api && ./run_cli_mode && cd - +cd command-api && ./run_cli_mode && cd - \ No newline at end of file diff --git a/__tests__/e2e/custom-domain/s.yaml b/__tests__/e2e/custom-domain/s.yaml index 7b65ba9..dee7a1a 100644 --- a/__tests__/e2e/custom-domain/s.yaml +++ b/__tests__/e2e/custom-domain/s.yaml @@ -8,7 +8,7 @@ name: hello-world-app access: "quanxi" vars: - region: ${env('REGION', 'cn-huhehaote')} + region: 'cn-huhehaote' resources: hello_world_1: diff --git a/__tests__/e2e/nodejs/code/package-lock.json b/__tests__/e2e/nodejs/code/package-lock.json deleted file mode 100644 index 4922ff2..0000000 --- a/__tests__/e2e/nodejs/code/package-lock.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "code", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "requires": { - "has-flag": "^4.0.0" - } - } - } -} diff --git a/__tests__/e2e/nodejs/s.yaml b/__tests__/e2e/nodejs/s.yaml index a653e5a..8b11261 100644 --- a/__tests__/e2e/nodejs/s.yaml +++ b/__tests__/e2e/nodejs/s.yaml @@ -3,7 +3,7 @@ name: test-node-app # 项目名称 access: quanxi vars: - region: ${env('REGION', 'cn-hangzhou')} + region: ${env('REGION', 'cn-huhehaote')} resources: fcDemo: # 业务名称/模块名称 diff --git a/__tests__/e2e/trigger/run b/__tests__/e2e/trigger/run index cec2522..4e05a49 100755 --- a/__tests__/e2e/trigger/run +++ b/__tests__/e2e/trigger/run @@ -46,4 +46,26 @@ s deploy -y s info s plan s remove -y + +echo "test http trigger with jwt ..." +cd ../jwt +export fc_component_function_name=nodejs16-$(uname)-$(uname -m)-$RANDSTR +s deploy -y -t ./s.yaml +s invoke -e '{"hello":"fc http trigger with jwt"}' -t ./s.yaml +url1=$(s info -y -t ./s.yaml --silent -o json | jq -r '.hello_world.url.system_url') +url2=$(s info -y -t ./s.yaml --silent -o json | jq -r '.hello_world_2.url.system_url') +echo $url1 +echo $url2 +curl -XPOST $url1/black1/aa -d '{"test":"jwt"}' +curl -XPOST $url1/black2/aaa -d '{"test":"jwt"}' +curl -XPOST $url1/black1/bbb -d '{"test":"jwt"}' +curl -XPOST $url1/black1/bbb -d '{"test":"jwt"}' -H "Authentication: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSm9obiIsImFkbWluIjp0cnVlLCJleHAiOjE3MDkxODg1MzksIm5iZiI6MTcwOTAxNTc1NCwiaWF0IjoxNzA5MDE1NzU2fQ.LknspC5W2QEThq9xpF1OciAJKpQMJmhkPGRWCS4rRoEeyTYl7bzKLqTuEhKE1I-luzjjIXNsnK6Ypbk_ith5mV2Wz6TTfQ-BF_dfBEfx75A9lDaTyLrn_zNLlOs-qsxst2y7eAOQQ7lb2mubFlLA3LDAWO-4UBJDLes0Mn6rp5pzSbF5zNypd319J1R6gAGBUBsPFGeTkxjr3ykHlB_nKNV0G7WpK9z_QvXQkT4os3oU2rs2tL1QQO4P3pSDB2lvEJ0dsXVggJi1rr6Av22uDI1lFo0PEekJmdFns-VIS36ipy3Ppgd7f5gicBNgUyhNUggPbdyePfV7zCkw3IrU-w" +curl -XPOST $url1/black1/bbb -d '{"test":"jwt"}' -H "Authentication: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ind3dy5iZWpzb24uY29tIiwic3ViIjoiZGVtbyIsImlhdCI6MTcwOTAxOTM5MCwibmJmIjoxNzA5MDE5MzkwLCJleHAiOjE3MDkxMDU3OTB9.TmHPtcD76VBNelt0Qdjc-SsYxfpxIzNIL0FSz8JAQchhqkXnhpqK5j2_sE0ot6Fx_bwFQHEB0erJLn4Ey7OtJgT4B3etxlpcw39jk2M1YidkFfKHgq2d8tUXa-Nu8mpvVQP7kQJ-Z-l_OkiJZs1NpgaKo5646k0vEaQqmzW3aYwuL4NE2tumDoYDCzexLzUTuzNUucxZ8sZYqf5_yIcLXueHItGampnLMtsWLNH3StXoiQWkS79Lhj04Lq5YTO4Sd074KNc5juJRZwqNpjddaQ08_5ry_jhOr0C3c1uEatehCePJozQZIdELf0Y6gN0-CYRhcJPiz5ynbOB9pNMLUw" +curl -XPOST $url2/white1/aaa -d '{"test":"jwt"}' +curl -XPOST $url2/white2/ccc -d '{"test":"jwt"}' +curl -XPOST $url2/common/aaa -d '{"test":"jwt"}' -H "Authentication: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSm9obiIsImFkbWluIjp0cnVlLCJleHAiOjE3MDkxODg1MzksIm5iZiI6MTcwOTAxNTc1NCwiaWF0IjoxNzA5MDE1NzU2fQ.LknspC5W2QEThq9xpF1OciAJKpQMJmhkPGRWCS4rRoEeyTYl7bzKLqTuEhKE1I-luzjjIXNsnK6Ypbk_ith5mV2Wz6TTfQ-BF_dfBEfx75A9lDaTyLrn_zNLlOs-qsxst2y7eAOQQ7lb2mubFlLA3LDAWO-4UBJDLes0Mn6rp5pzSbF5zNypd319J1R6gAGBUBsPFGeTkxjr3ykHlB_nKNV0G7WpK9z_QvXQkT4os3oU2rs2tL1QQO4P3pSDB2lvEJ0dsXVggJi1rr6Av22uDI1lFo0PEekJmdFns-VIS36ipy3Ppgd7f5gicBNgUyhNUggPbdyePfV7zCkw3IrU-w" +curl -XPOST $url2/common/aaa -d '{"test":"jwt"}' -H "Authentication: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ind3dy5iZWpzb24uY29tIiwic3ViIjoiZGVtbyIsImlhdCI6MTcwOTAxOTM5MCwibmJmIjoxNzA5MDE5MzkwLCJleHAiOjE3MDkxMDU3OTB9.TmHPtcD76VBNelt0Qdjc-SsYxfpxIzNIL0FSz8JAQchhqkXnhpqK5j2_sE0ot6Fx_bwFQHEB0erJLn4Ey7OtJgT4B3etxlpcw39jk2M1YidkFfKHgq2d8tUXa-Nu8mpvVQP7kQJ-Z-l_OkiJZs1NpgaKo5646k0vEaQqmzW3aYwuL4NE2tumDoYDCzexLzUTuzNUucxZ8sZYqf5_yIcLXueHItGampnLMtsWLNH3StXoiQWkS79Lhj04Lq5YTO4Sd074KNc5juJRZwqNpjddaQ08_5ry_jhOr0C3c1uEatehCePJozQZIdELf0Y6gN0-CYRhcJPiz5ynbOB9pNMLUw" +s plan -t ./s.yaml +s info -y -t ./s.yaml +s remove -y -t ./s.yaml cd .. \ No newline at end of file