Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions pkg/config/deployment_lambda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/pipe-cd/pipe/pkg/model"
)

func TestLambdaDeploymentConfig(t *testing.T) {
Expand All @@ -45,6 +47,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) {
Expand Down
11 changes: 1 addition & 10 deletions pkg/config/testdata/application/lambda-app-bluegreen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
apiVersion: pipecd.dev/v1beta1
kind: LambdaApp
spec:
input:
# Where to fetch the source code to create lambda package.
git: [email protected]:org/source-repo.git
path: lambdas/demoapp
ref: v1.0.0
pipeline:
stages:
# Deploy workloads of the new version.
Expand All @@ -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
13 changes: 2 additions & 11 deletions pkg/config/testdata/application/lambda-app-canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
apiVersion: pipecd.dev/v1beta1
kind: LambdaApp
spec:
input:
# Where to fetch the source code to create lambda package.
git: [email protected]:org/source-repo.git
path: lambdas/demoapp
ref: v1.0.0
pipeline:
stages:
# Deploy workloads of the new version.
Expand All @@ -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