Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace AWS.Kinesis/Stream with AWS.S3/Bucket in functional tests #5227

Merged
merged 5 commits into from
Mar 7, 2023
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
34 changes: 21 additions & 13 deletions test/functional/corerp/mechanics/aws_mechanics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,50 @@ import (

func Test_AWSRedeployWithUpdatedResourceUpdatesResource(t *testing.T) {
templateFmt := "testdata/aws-mechanics-redeploy-withupdatedresource.step%d.bicep"
name := "ms" + uuid.New().String()
name := "radiusfunctionaltestbucket-" + uuid.New().String()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this run into length constraints?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be 63 characters (e.g. radiusfunctionaltestbucket-4c4f3c7e-8341-41f3-a275-e4b39bbcc449), which conforms to our spec as well as AWS', so we should be good
image


test := corerp.NewCoreRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 1), "streamName="+name),
Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 1), "bucketName="+name),
SkipKubernetesOutputResourceValidation: true,
SkipObjectValidation: true,
AWSResources: &validation.AWSResourceSet{
Resources: []validation.AWSResource{
{
Name: name,
Type: validation.KinesisResourceType,
Type: validation.AWSS3BucketResourceType,
Identifier: name,
Properties: map[string]any{
"Name": name,
"RetentionPeriodHours": float64(168),
"ShardCount": float64(3),
"BucketName": name,
"Tags": []any{
map[string]any{
"Key": "testKey",
"Value": "testValue",
},
},
},
},
},
},
},
{
Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 2), "streamName="+name),
Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 2), "bucketName="+name),
SkipKubernetesOutputResourceValidation: true,
SkipObjectValidation: true,
AWSResources: &validation.AWSResourceSet{
Resources: []validation.AWSResource{
{
Name: name,
Type: validation.KinesisResourceType,
Type: validation.AWSS3BucketResourceType,
Identifier: name,
Properties: map[string]any{
"Name": name,
"RetentionPeriodHours": float64(48),
"ShardCount": float64(3),
"BucketName": name,
"Tags": []any{
map[string]any{
"Key": "testKey",
"Value": "testValue2",
},
},
},
},
},
Expand All @@ -76,7 +84,7 @@ func Test_AWSRedeployWithCreateAndWriteOnlyPropertyUpdate(t *testing.T) {
Resources: []validation.AWSResource{
{
Name: name,
Type: validation.DBInstanceResourceType,
Type: validation.AWSRDSDBInstanceResourceType,
Identifier: name,
Properties: map[string]any{
"Endpoint": map[string]any{
Expand All @@ -95,7 +103,7 @@ func Test_AWSRedeployWithCreateAndWriteOnlyPropertyUpdate(t *testing.T) {
Resources: []validation.AWSResource{
{
Name: name,
Type: validation.DBInstanceResourceType,
Type: validation.AWSRDSDBInstanceResourceType,
Identifier: name,
Properties: map[string]any{
"Endpoint": map[string]any{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import aws as aws

param streamName string
param bucketName string

resource stream 'AWS.Kinesis/Stream@default' = {
alias: streamName
resource bucket 'AWS.S3/Bucket@default' = {
alias: bucketName
properties: {
Name: streamName
RetentionPeriodHours: 168
ShardCount: 3
BucketName: bucketName
Tags: [
{
Key: 'testKey'
Value: 'testValue'
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import aws as aws

param streamName string
param bucketName string

resource stream 'AWS.Kinesis/Stream@default' = {
alias: streamName
resource bucket 'AWS.S3/Bucket@default' = {
alias: bucketName
properties: {
Name: streamName
RetentionPeriodHours: 48
ShardCount: 3
BucketName: bucketName
Tags: [
{
Key: 'testKey'
Value: 'testValue2'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this value tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
]
}
}
108 changes: 0 additions & 108 deletions test/functional/corerp/resources/aws_kinesis_stream_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func Test_AWS_MultiIdentifier_Resource(t *testing.T) {
Resources: []validation.AWSResource{
{
Name: logGroupName,
Type: validation.LogGroupResourceType,
Type: validation.AWSLogsLogGroupResourceType,
Identifier: logGroupName,
},
{
Name: filterName,
Type: validation.MetricFilterResourceType,
Type: validation.AWSLogsMetricFilterResourceType,
Identifier: logGroupName + "|" + filterName,
},
},
Expand Down
111 changes: 111 additions & 0 deletions test/functional/corerp/resources/aws_s3_bucket_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------

package resource_test

import (
"testing"

"github.com/google/uuid"
"github.com/project-radius/radius/test/functional/corerp"
"github.com/project-radius/radius/test/step"
"github.com/project-radius/radius/test/validation"
)

func Test_AWS_S3Bucket(t *testing.T) {
template := "testdata/aws-s3-bucket.bicep"
name := generateS3BucketName()

test := corerp.NewCoreRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, "bucketName="+name),
SkipKubernetesOutputResourceValidation: true,
SkipObjectValidation: true,
AWSResources: &validation.AWSResourceSet{
Resources: []validation.AWSResource{
{
Name: name,
Type: validation.AWSS3BucketResourceType,
Identifier: name,
Properties: map[string]any{
"BucketName": name,
"Tags": []any{
map[string]any{
"Key": "testKey",
"Value": "testValue",
},
},
},
},
},
},
},
})

test.Test(t)
}

func Test_AWS_S3Bucket_Existing(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add doc here to identify the difference between this test and the one above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you point me to the doc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically the idea is that the first step deploys the S3Bucket resource, then the second step uses the bicep existing keyword during the deployment, which should retrieve the same resource. If you check the bicep definition here, you can see that the key and the value are not specified. We add them in the test to make sure we get the same resource. Sorry for the confusion :)

template := "testdata/aws-s3-bucket.bicep"
templateExisting := "testdata/aws-s3-bucket-existing.bicep"
name := generateS3BucketName()

test := corerp.NewCoreRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, "bucketName="+name),
SkipKubernetesOutputResourceValidation: true,
SkipObjectValidation: true,
AWSResources: &validation.AWSResourceSet{
Resources: []validation.AWSResource{
{
Name: name,
Type: validation.AWSS3BucketResourceType,
Identifier: name,
Properties: map[string]any{
"BucketName": name,
"Tags": []any{
map[string]any{
"Key": "testKey",
"Value": "testValue",
},
},
},
},
},
},
},
// The following step deploys an existing resource and validates that it retrieves the same
// resource as was deployed above
{
Executor: step.NewDeployExecutor(templateExisting, "bucketName="+name),
SkipKubernetesOutputResourceValidation: true,
SkipObjectValidation: true,
AWSResources: &validation.AWSResourceSet{
Resources: []validation.AWSResource{
{
Name: name,
Type: validation.AWSS3BucketResourceType,
Identifier: name,
Properties: map[string]any{
"BucketName": name,
"Tags": []any{
map[string]any{
"Key": "testKey",
"Value": "testValue",
},
},
},
},
},
},
},
})

test.Test(t)
}

func generateS3BucketName() string {
return "radiusfunctionaltestbucket-" + uuid.New().String()
}
Loading