Skip to content

Commit

Permalink
fix central reconciler unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes94 committed Aug 1, 2023
1 parent ee8b5ae commit 14d6d5f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fleetshard/pkg/central/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ func (r *CentralReconciler) collectReconciliationStatus(ctx context.Context, rem
}
}

// Only store secrets if central was ready once to ensure we're not trying to get secrets before they are created
// Only report secrets if central is ready to ensure we're not trying to get secrets before they are created
if isRemoteCentralReady(remoteCentral) {
secrets, err := r.collectSecretsEncrypted(ctx, remoteCentral)
if err != nil {
Expand Down
34 changes: 22 additions & 12 deletions fleetshard/pkg/central/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ func centralDBInitFunc(_ context.Context, _ postgres.DBConnection, _, _ string)
return nil
}

func centralTLSSecretObject() *v1.Secret {
return &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "central-tls",
Namespace: centralNamespace,
},
}
}

func centralDBPasswordSecretObject() *v1.Secret {
return &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "central-db-password",
Namespace: centralNamespace,
},
}
}

func conditionForType(conditions []private.DataPlaneClusterUpdateStatusRequestConditions, conditionType string) (*private.DataPlaneClusterUpdateStatusRequestConditions, bool) {
for _, c := range conditions {
if c.Type == conditionType {
Expand Down Expand Up @@ -367,6 +385,8 @@ func TestReconcileLastHashSetOnSuccess(t *testing.T) {
},
},
centralDeploymentObject(),
centralTLSSecretObject(),
centralDBPasswordSecretObject(),
)

managedCentral := simpleManagedCentral
Expand Down Expand Up @@ -434,18 +454,8 @@ func TestIgnoreCacheForCentralForceReconcileAlways(t *testing.T) {
},
},
centralDeploymentObject(),
&v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "central-tls",
Namespace: centralNamespace,
},
},
&v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "central-db-password",
Namespace: centralNamespace,
},
},
centralTLSSecretObject(),
centralDBPasswordSecretObject(),
)

managedCentral := simpleManagedCentral
Expand Down

0 comments on commit 14d6d5f

Please sign in to comment.