Skip to content

Commit

Permalink
spc class test changes and typo fix for placeholder pod test
Browse files Browse the repository at this point in the history
  • Loading branch information
aamgayle committed Oct 19, 2023
1 parent 9369c4c commit 82996d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions pkg/controller/keyvault/ingress_secret_provider_class_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestIngressSecretProviderClassReconcilerIntegration(t *testing.T) {
ing.Annotations = map[string]string{
"kubernetes.azure.com/tls-cert-keyvault-uri": "https://testvault.vault.azure.net/certificates/testcert/f8982febc6894c0697b884f946fb1a34",
}
ing.Labels = manifests.GetTopLevelLabels()

c := fake.NewClientBuilder().WithObjects(ing).Build()
require.NoError(t, secv1.AddToScheme(c.Scheme()))
Expand Down Expand Up @@ -70,7 +69,7 @@ func TestIngressSecretProviderClassReconcilerIntegration(t *testing.T) {
spc := &secv1.SecretProviderClass{}
spc.Name = "keyvault-" + ing.Name
spc.Namespace = ing.Namespace
spc.Labels = ing.Labels
spc.Labels = manifests.GetTopLevelLabels()
require.NoError(t, c.Get(ctx, client.ObjectKeyFromObject(spc), spc))

expected := &secv1.SecretProviderClass{
Expand Down Expand Up @@ -142,26 +141,22 @@ func TestIngressSecretProviderClassReconcilerIntegration(t *testing.T) {
require.Greater(t, testutils.GetReconcileMetricCount(t, ingressSecretProviderControllerName, metrics.LabelSuccess), beforeRequestCount)

fakeLabels := map[string]string{"fake1": "label1", "fake2": "label2", "fake3": "label3"}

// Check for top level labels with additional labels
ing.Labels = util.MergeMaps(manifests.GetTopLevelLabels(), fakeLabels)
spc.Labels = fakeLabels
require.NoError(t, i.client.Update(ctx, ing))
beforeErrCount = testutils.GetErrMetricCount(t, ingressSecretProviderControllerName)
beforeRequestCount = testutils.GetReconcileMetricCount(t, ingressSecretProviderControllerName, metrics.LabelSuccess)
_, err = i.Reconcile(ctx, req)
require.NoError(t, err)
require.Equal(t, testutils.GetErrMetricCount(t, ingressSecretProviderControllerName), beforeErrCount)
require.Greater(t, testutils.GetReconcileMetricCount(t, ingressSecretProviderControllerName, metrics.LabelSuccess), beforeRequestCount)

// Check for labels without top level labels
ing.Labels = fakeLabels
require.NoError(t, i.client.Update(ctx, ing))
beforeErrCount = testutils.GetErrMetricCount(t, ingressSecretProviderControllerName)
beforeRequestCount = testutils.GetReconcileMetricCount(t, ingressSecretProviderControllerName, metrics.LabelSuccess)
_, err = i.Reconcile(ctx, req)
require.NoError(t, err)
require.Equal(t, testutils.GetErrMetricCount(t, ingressSecretProviderControllerName), beforeErrCount)
require.Greater(t, testutils.GetReconcileMetricCount(t, ingressSecretProviderControllerName, metrics.LabelSuccess), beforeRequestCount)

// Prove spc was not deleted
require.False(t, errors.IsNotFound(c.Get(ctx, client.ObjectKeyFromObject(spc), spc)))
// Prove idempotence
require.False(t, errors.IsNotFound(c.Get(ctx, client.ObjectKeyFromObject(spc), spc)))
}

func TestIngressSecretProviderClassReconcilerInvalidURL(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/keyvault/placeholder_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestPlaceholderPodControllerIntegration(t *testing.T) {
require.Equal(t, testutils.GetErrMetricCount(t, placeholderPodControllerName), beforeErrCount)
require.Greater(t, testutils.GetReconcileMetricCount(t, placeholderPodControllerName, metrics.LabelSuccess), beforeReconcileCount)

// Prove the deployment was not deleted
// Prove the deployment was deleted
require.True(t, errors.IsNotFound(c.Get(ctx, client.ObjectKeyFromObject(dep), dep)))

// Prove idempotence
Expand Down

0 comments on commit 82996d4

Please sign in to comment.