From a5b256e6013b4f62f91c0bfc52711721bd030114 Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Mon, 8 Nov 2021 19:46:24 +0900 Subject: [PATCH 1/2] Revise lambda application configuration test data --- pkg/config/deployment_lambda_test.go | 74 +++++++++++++++++++ .../application/lambda-app-bluegreen.yaml | 11 +-- .../application/lambda-app-canary.yaml | 13 +--- 3 files changed, 77 insertions(+), 21 deletions(-) diff --git a/pkg/config/deployment_lambda_test.go b/pkg/config/deployment_lambda_test.go index de79f56648..d7ef9344fc 100644 --- a/pkg/config/deployment_lambda_test.go +++ b/pkg/config/deployment_lambda_test.go @@ -18,6 +18,7 @@ import ( "testing" "time" + "github.com/pipe-cd/pipe/pkg/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -45,6 +46,79 @@ func TestLambdaDeploymentConfig(t *testing.T) { }, expectedError: nil, }, + { + fileName: "testdata/application/lambda-app-canary.yaml", + expectedKind: KindLambdaApp, + expectedAPIVersion: "pipecd.dev/v1beta1", + expectedSpec: &LambdaDeploymentSpec{ + GenericDeploymentSpec: GenericDeploymentSpec{ + Timeout: Duration(6 * time.Hour), + Pipeline: &DeploymentPipeline{ + Stages: []PipelineStage{ + { + Name: model.StageLambdaCanaryRollout, + LambdaCanaryRolloutStageOptions: &LambdaCanaryRolloutStageOptions{}, + }, + { + Name: model.StageLambdaPromote, + LambdaPromoteStageOptions: &LambdaPromoteStageOptions{ + Percent: Percentage{ + Number: 10, + HasSuffix: false, + }, + }, + }, + { + Name: model.StageLambdaPromote, + LambdaPromoteStageOptions: &LambdaPromoteStageOptions{ + Percent: Percentage{ + Number: 100, + HasSuffix: false, + }, + }, + }, + }, + }, + }, + Input: LambdaDeploymentInput{ + FunctionManifestFile: "function.yaml", + AutoRollback: true, + }, + }, + expectedError: nil, + }, + { + fileName: "testdata/application/lambda-app-bluegreen.yaml", + expectedKind: KindLambdaApp, + expectedAPIVersion: "pipecd.dev/v1beta1", + expectedSpec: &LambdaDeploymentSpec{ + GenericDeploymentSpec: GenericDeploymentSpec{ + Timeout: Duration(6 * time.Hour), + Pipeline: &DeploymentPipeline{ + Stages: []PipelineStage{ + { + Name: model.StageLambdaCanaryRollout, + LambdaCanaryRolloutStageOptions: &LambdaCanaryRolloutStageOptions{}, + }, + { + Name: model.StageLambdaPromote, + LambdaPromoteStageOptions: &LambdaPromoteStageOptions{ + Percent: Percentage{ + Number: 100, + HasSuffix: false, + }, + }, + }, + }, + }, + }, + Input: LambdaDeploymentInput{ + FunctionManifestFile: "function.yaml", + AutoRollback: true, + }, + }, + expectedError: nil, + }, } for _, tc := range testcases { t.Run(tc.fileName, func(t *testing.T) { diff --git a/pkg/config/testdata/application/lambda-app-bluegreen.yaml b/pkg/config/testdata/application/lambda-app-bluegreen.yaml index bc903552f2..faed917016 100644 --- a/pkg/config/testdata/application/lambda-app-bluegreen.yaml +++ b/pkg/config/testdata/application/lambda-app-bluegreen.yaml @@ -3,11 +3,6 @@ apiVersion: pipecd.dev/v1beta1 kind: LambdaApp spec: - input: - # Where to fetch the source code to create lambda package. - git: git@github.com:org/source-repo.git - path: lambdas/demoapp - ref: v1.0.0 pipeline: stages: # Deploy workloads of the new version. @@ -18,8 +13,4 @@ spec: # This is known as blue-green strategy. - name: LAMBDA_PROMOTE with: - canary: 100 - # Optional: We can also add an ANALYSIS stage to verify the new version. - # If this stage finds any not good metrics of the new version, - # a rollback process to the previous version will be executed. - - name: ANALYSIS + percent: 100 diff --git a/pkg/config/testdata/application/lambda-app-canary.yaml b/pkg/config/testdata/application/lambda-app-canary.yaml index c5970751f2..4f581ad867 100644 --- a/pkg/config/testdata/application/lambda-app-canary.yaml +++ b/pkg/config/testdata/application/lambda-app-canary.yaml @@ -3,11 +3,6 @@ apiVersion: pipecd.dev/v1beta1 kind: LambdaApp spec: - input: - # Where to fetch the source code to create lambda package. - git: git@github.com:org/source-repo.git - path: lambdas/demoapp - ref: v1.0.0 pipeline: stages: # Deploy workloads of the new version. @@ -18,13 +13,9 @@ spec: # This is known as multi-phase canary strategy. - name: LAMBDA_PROMOTE with: - canary: 10 - # Optional: We can also add an ANALYSIS stage to verify the new version. - # If this stage finds any not good metrics of the new version, - # a rollback process to the previous version will be executed. - - name: ANALYSIS + percent: 10 # Change the traffic routing state where # thre new version will receive 100% of the traffic. - name: LAMBDA_PROMOTE with: - canary: 100 + percent: 100 From d0e108f6c797b5883bb230f17bc16cdc9a87a3b5 Mon Sep 17 00:00:00 2001 From: pipecd-bot Date: Mon, 8 Nov 2021 10:54:05 +0000 Subject: [PATCH 2/2] Format unfmt-ed files --- pkg/config/deployment_lambda_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/config/deployment_lambda_test.go b/pkg/config/deployment_lambda_test.go index d7ef9344fc..385d1f0241 100644 --- a/pkg/config/deployment_lambda_test.go +++ b/pkg/config/deployment_lambda_test.go @@ -18,9 +18,10 @@ import ( "testing" "time" - "github.com/pipe-cd/pipe/pkg/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/pipe-cd/pipe/pkg/model" ) func TestLambdaDeploymentConfig(t *testing.T) {