Skip to content

Commit

Permalink
fix: add simple e2e test about custom-domain
Browse files Browse the repository at this point in the history
  • Loading branch information
rsonghuster committed Aug 8, 2024
1 parent a5f7416 commit 62707e7
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def handler(event, context):
return "hello wolrd!"
return "hello wolrd!\n"
10 changes: 4 additions & 6 deletions examples/s.yaml → __tests__/e2e/artifact/s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ edition: 3.0.0
name: hello-world-app
access: "quanxi"

vars: # 全局变量
region: "cn-hangzhou"
vars:
region: ${env('REGION', 'cn-huhehaote')}

resources:
hello_world:
#component: fc3@dev
component: ${path("../")}
component: ${env('fc_component_version', path('../../../'))}
props:
region: ${vars.region}
functionName: "test-devs-artifact"
description: 'hello world by serverless devs'
runtime: "python3.10"
code: ./code
# artifact: test-devs-artifact_cn-hangzhou@1555622798284556248
artifact: acs:devs:cn-hangzhou:1431999136518149:artifacts/test-devs-artifact_cn-hangzhou
artifact: test-devs-artifact_cn-hangzhou
handler: index.handler
memorySize: 128
timeout: 40
24 changes: 24 additions & 0 deletions __tests__/e2e/artifact/s2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ------------------------------------
# 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3
# 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/
# 有问题快来钉钉群问一下吧:33947367
# ------------------------------------
edition: 3.0.0
name: hello-world-app
access: "quanxi"

vars:
region: ${env('REGION', 'cn-huhehaote')}

resources:
hello_world:
component: ${env('fc_component_version', path('../../../'))}
props:
region: ${vars.region}
functionName: "test-devs-artifact-2"
description: 'hello world by serverless devs'
runtime: "python3.10"
artifact: test-devs-artifact_cn-hangzhou
handler: index.handler
memorySize: 128
timeout: 40
27 changes: 27 additions & 0 deletions __tests__/e2e/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@
set -e
set -v

echo "test custom-domain"
cd custom-domain
s deploy -y
curl -v xiliu-test.devsapp.net
curl -v xiliu-test.devsapp.net/a
s info
s remove -y

s deploy -y -t s2.yaml
curl -v test-cd3.fcv3.1431999136518149.cn-huhehaote.fc.devsapp.net
s info -t s2.yaml
s remove -y -t s2.yaml
cd ..

# echo "test artifact"
# cd artifact
# s deploy -y
# s invoke
# s info
# s remove -y

# s deploy -y -t s2.yaml
# s invoke -t s2.yaml
# s info -t s2.yaml
# s remove -y -t s2.yaml
# cd ..

echo " ********* command-api *********"
cd command-api && bash ./run && cd -
cd command-api && bash ./run_cli_mode && cd -
Expand Down
2 changes: 2 additions & 0 deletions __tests__/e2e/custom-domain/code/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def handler(event, context):
return "hello wolrd!\n"
73 changes: 73 additions & 0 deletions __tests__/e2e/custom-domain/s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# ------------------------------------
# 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3
# 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/
# 有问题快来钉钉群问一下吧:33947367
# ------------------------------------
edition: 3.0.0
name: hello-world-app
access: "quanxi"

vars:
region: ${env('REGION', 'cn-huhehaote')}

resources:
hello_world_1:
#component: fc3@dev
component: ${env('fc_component_version', path('../../../'))}
props:
region: ${vars.region}
functionName: "test-cd"
description: 'hello world by serverless devs'
runtime: "python3.10"
code: ./code
handler: index.handler
memorySize: 128
timeout: 45
triggers:
- triggerName: httpTrigger
triggerType: http
triggerConfig:
methods:
- GET
- POST
authType: anonymous
disableURLInternet: false
customDomain:
#domainName: auto
domainName: "xiliu-test.devsapp.net"
protocol: HTTP
route:
# methods:
# - GET
path: /*
qualifier: LATEST

hello_world_2:
#component: fc3@dev
component: ${env('fc_component_version', path('../../../'))}
props:
region: ${vars.region}
functionName: "test-cd2"
description: 'hello world by serverless devs'
runtime: "python3.10"
code: ./code
handler: index.handler
memorySize: 128
timeout: 45
triggers:
- triggerName: httpTrigger
triggerType: http
triggerConfig:
methods:
- GET
- POST
authType: anonymous
disableURLInternet: false
customDomain:
domainName: "xiliu-test.devsapp.net"
protocol: HTTP
route:
methods:
- GET
path: /a
qualifier: LATEST
18 changes: 6 additions & 12 deletions examples/s2.yaml → __tests__/e2e/custom-domain/s2.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
# ------------------------------------
# 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3
# 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/
# 有问题快来钉钉群问一下吧:33947367
# ------------------------------------
edition: 3.0.0
name: hello-world-app
access: "quanxi"

vars: # 全局变量
region: "cn-hangzhou"
vars:
region: ${env('REGION', 'cn-huhehaote')}

resources:
hello_world:
hello_world_1:
#component: fc3@dev
component: ${path("../")}
component: ${env('fc_component_version', path('../../../'))}
props:
region: ${vars.region}
functionName: "test-cd"
functionName: "test-cd3"
description: 'hello world by serverless devs'
runtime: "python3.10"
code: ./code
Expand All @@ -34,10 +29,9 @@ resources:
disableURLInternet: false
customDomain:
domainName: auto
#domainName: "xiliu-test.devsapp.net"
protocol: HTTP
route:
# methods:
# - GET
path: /*
qualifier: LATEST
qualifier: LATEST
2 changes: 1 addition & 1 deletion src/subCommands/deploy/impl/custom_domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class CustomDomain extends Base {
}
deployInput.props.domainName = domainName;
const id = `${this.functionName}/${domainName}`;
logger.debug(
logger.info(
`deploy ${id}, deployInput props = \n${JSON.stringify(deployInput.props, null, 2)}`,
);
return await this.domainInstance.deploy(deployInput);
Expand Down
4 changes: 2 additions & 2 deletions src/subCommands/deploy/impl/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export default class Service extends Base {
connectTimeout: FC_CLIENT_CONNECT_TIMEOUT,
});
config.endpoint = 'devs.cn-hangzhou.aliyuncs.com';
if (process.env.ARTIFACT_ENV === 'pre') {
config.endpoint = `devs-pre.cn-hangzhou.aliyuncs.com`;
if (process.env.ARTIFACT_ENDPOINT) {
config.endpoint = process.env.ARTIFACT_ENDPOINT;
}
this.devsClient = new Devs20230714(config);
}
Expand Down
1 change: 0 additions & 1 deletion src/subCommands/remove/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default class Remove {
private fcSdk: FC;

constructor(readonly inputs: IInputs) {
console.log(JSON.stringify(inputs));
const opts = parseArgv(inputs.args, {
alias: {
'assume-yes': 'y',
Expand Down

0 comments on commit 62707e7

Please sign in to comment.