From 5407b50568cd7eb566a1051587e2dc2422620b3f Mon Sep 17 00:00:00 2001 From: Charel Baum Date: Wed, 21 Dec 2022 19:12:48 +0100 Subject: [PATCH] fix(docdb/dbcluster): remove dbsubnetgroup isuptodate-check Signed-off-by: Charel Baum --- pkg/controller/docdb/dbcluster/setup.go | 1 - pkg/controller/docdb/dbcluster/setup_test.go | 173 ------------------- 2 files changed, 174 deletions(-) diff --git a/pkg/controller/docdb/dbcluster/setup.go b/pkg/controller/docdb/dbcluster/setup.go index 6eeb73c0a7..ab41e1e0a0 100644 --- a/pkg/controller/docdb/dbcluster/setup.go +++ b/pkg/controller/docdb/dbcluster/setup.go @@ -162,7 +162,6 @@ func (e *hooks) isUpToDate(cr *svcapitypes.DBCluster, resp *svcsdk.DescribeDBClu switch { case awsclient.Int64Value(cr.Spec.ForProvider.BackupRetentionPeriod) != awsclient.Int64Value(cluster.BackupRetentionPeriod), awsclient.StringValue(cr.Spec.ForProvider.DBClusterParameterGroupName) != awsclient.StringValue(cluster.DBClusterParameterGroup), - awsclient.StringValue(cr.Spec.ForProvider.DBSubnetGroupName) != awsclient.StringValue(cluster.DBSubnetGroup), awsclient.BoolValue(cr.Spec.ForProvider.DeletionProtection) != awsclient.BoolValue(cluster.DeletionProtection), !areSameElements(cr.Spec.ForProvider.EnableCloudwatchLogsExports, cluster.EnabledCloudwatchLogsExports), awsclient.Int64Value(cr.Spec.ForProvider.Port) != awsclient.Int64Value(cluster.Port), diff --git a/pkg/controller/docdb/dbcluster/setup_test.go b/pkg/controller/docdb/dbcluster/setup_test.go index 21ae664e86..e041e6edff 100644 --- a/pkg/controller/docdb/dbcluster/setup_test.go +++ b/pkg/controller/docdb/dbcluster/setup_test.go @@ -51,7 +51,6 @@ var ( testDBClusterParameterGroupName = "some-db-cluster-parameter-group" testOtherDBClusterParameterGroupName = "some-other-db-cluster-parameter-group" testDBSubnetGroupName = "some-db-subnet-group" - testOtherDBSubnetGroupName = "some-other-db-subnet-group" testCloudWatchLog = "some-log" testOtherCloudWatchLog = "some-other-log" testEngine = "some-engine" @@ -174,12 +173,6 @@ func withDBSubnetGroup(value string) docDBModifier { } } -func withStatusDBSubnetGroup(value string) docDBModifier { - return func(o *svcapitypes.DBCluster) { - o.Status.AtProvider.DBSubnetGroup = awsclient.String(value) - } -} - func withDeletionProtection(value bool) docDBModifier { return func(o *svcapitypes.DBCluster) { o.Spec.ForProvider.DeletionProtection = awsclient.Bool(value, awsclient.FieldRequired) @@ -718,172 +711,6 @@ func TestObserve(t *testing.T) { }, }, }, - "AvailableState_and_changed_DBSubnetGroupName_should_not_be_UpToDate": { - args: args{ - docdb: &fake.MockDocDBClient{ - MockDescribeDBClustersWithContext: func(c context.Context, ddi *docdb.DescribeDBClustersInput, o []request.Option) (*docdb.DescribeDBClustersOutput, error) { - return &docdb.DescribeDBClustersOutput{ - DBClusters: []*docdb.DBCluster{ - { - DBClusterIdentifier: awsclient.String(testDBClusterIdentifier), - Status: awsclient.String(svcapitypes.DocDBInstanceStateAvailable), - DBSubnetGroup: awsclient.String(testDBSubnetGroupName), - }, - }, - }, nil - }, - }, - cr: instance( - withDBClusterIdentifier(testDBClusterIdentifier), - withExternalName(testDBClusterIdentifier), - withDBSubnetGroup(testOtherDBSubnetGroupName), - ), - }, - want: want{ - cr: instance( - withDBClusterIdentifier(testDBClusterIdentifier), - withExternalName(testDBClusterIdentifier), - withConditions(xpv1.Available()), - withStatus(svcapitypes.DocDBInstanceStateAvailable), - withDBSubnetGroup(testOtherDBSubnetGroupName), - withStatusDBSubnetGroup(testDBSubnetGroupName), - withVpcSecurityGroupIds(), - ), - result: managed.ExternalObservation{ - ResourceExists: true, - ResourceUpToDate: false, - ResourceLateInitialized: true, - ConnectionDetails: generateConnectionDetails("", "", "", "", 0), - }, - docdb: fake.MockDocDBClientCall{ - DescribeDBClustersWithContext: []*fake.CallDescribeDBClustersWithContext{ - { - Ctx: context.Background(), - I: &docdb.DescribeDBClustersInput{ - DBClusterIdentifier: awsclient.String(testDBClusterIdentifier), - }, - }, - }, - }, - }, - }, - "AvailableState_and_same_DBSubnetGroupName_should_be_UpToDate": { - args: args{ - docdb: &fake.MockDocDBClient{ - MockDescribeDBClustersWithContext: func(c context.Context, ddi *docdb.DescribeDBClustersInput, o []request.Option) (*docdb.DescribeDBClustersOutput, error) { - return &docdb.DescribeDBClustersOutput{ - DBClusters: []*docdb.DBCluster{ - { - DBClusterIdentifier: awsclient.String(testDBClusterIdentifier), - Status: awsclient.String(svcapitypes.DocDBInstanceStateAvailable), - DBSubnetGroup: awsclient.String(testDBSubnetGroupName), - }, - }, - }, nil - }, - MockListTagsForResource: func(ltfri *docdb.ListTagsForResourceInput) (*docdb.ListTagsForResourceOutput, error) { - return &docdb.ListTagsForResourceOutput{ - TagList: []*docdb.Tag{}, - }, nil - }, - }, - cr: instance( - withDBClusterIdentifier(testDBClusterIdentifier), - withExternalName(testDBClusterIdentifier), - withDBSubnetGroup(testDBSubnetGroupName), - ), - }, - want: want{ - cr: instance( - withDBClusterIdentifier(testDBClusterIdentifier), - withExternalName(testDBClusterIdentifier), - withConditions(xpv1.Available()), - withStatus(svcapitypes.DocDBInstanceStateAvailable), - withDBSubnetGroup(testDBSubnetGroupName), - withStatusDBSubnetGroup(testDBSubnetGroupName), - withVpcSecurityGroupIds(), - ), - result: managed.ExternalObservation{ - ResourceExists: true, - ResourceUpToDate: true, - ResourceLateInitialized: true, - ConnectionDetails: generateConnectionDetails("", "", "", "", 0), - }, - docdb: fake.MockDocDBClientCall{ - DescribeDBClustersWithContext: []*fake.CallDescribeDBClustersWithContext{ - { - Ctx: context.Background(), - I: &docdb.DescribeDBClustersInput{ - DBClusterIdentifier: awsclient.String(testDBClusterIdentifier), - }, - }, - }, - ListTagsForResource: []*fake.CallListTagsForResource{ - { - I: &docdb.ListTagsForResourceInput{}, - }, - }, - }, - }, - }, - "AvailableState_and_no_spec_DBSubnetGroupName_should_be_UpToDate": { - args: args{ - docdb: &fake.MockDocDBClient{ - MockDescribeDBClustersWithContext: func(c context.Context, ddi *docdb.DescribeDBClustersInput, o []request.Option) (*docdb.DescribeDBClustersOutput, error) { - return &docdb.DescribeDBClustersOutput{ - DBClusters: []*docdb.DBCluster{ - { - DBClusterIdentifier: awsclient.String(testDBClusterIdentifier), - Status: awsclient.String(svcapitypes.DocDBInstanceStateAvailable), - DBSubnetGroup: awsclient.String(testDBSubnetGroupName), - }, - }, - }, nil - }, - MockListTagsForResource: func(ltfri *docdb.ListTagsForResourceInput) (*docdb.ListTagsForResourceOutput, error) { - return &docdb.ListTagsForResourceOutput{ - TagList: []*docdb.Tag{}, - }, nil - }, - }, - cr: instance( - withDBClusterIdentifier(testDBClusterIdentifier), - withExternalName(testDBClusterIdentifier), - ), - }, - want: want{ - cr: instance( - withDBClusterIdentifier(testDBClusterIdentifier), - withDBSubnetGroup(testDBSubnetGroupName), - withExternalName(testDBClusterIdentifier), - withConditions(xpv1.Available()), - withStatus(svcapitypes.DocDBInstanceStateAvailable), - withStatusDBSubnetGroup(testDBSubnetGroupName), - withVpcSecurityGroupIds(), - ), - result: managed.ExternalObservation{ - ResourceExists: true, - ResourceUpToDate: true, - ResourceLateInitialized: true, - ConnectionDetails: generateConnectionDetails("", "", "", "", 0), - }, - docdb: fake.MockDocDBClientCall{ - DescribeDBClustersWithContext: []*fake.CallDescribeDBClustersWithContext{ - { - Ctx: context.Background(), - I: &docdb.DescribeDBClustersInput{ - DBClusterIdentifier: awsclient.String(testDBClusterIdentifier), - }, - }, - }, - ListTagsForResource: []*fake.CallListTagsForResource{ - { - I: &docdb.ListTagsForResourceInput{}, - }, - }, - }, - }, - }, "AvailableState_and_changed_DeletionProtection_should_not_be_UpToDate": { args: args{ docdb: &fake.MockDocDBClient{