-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add more test cases for different scenarios #64
Conversation
|
||
// when reconcile is triggered by single component refresh | ||
// only update the corresponding component reconcile state and next refresh time | ||
It("Should update reconcile state when keyValue pageEtag, featureFlag pageEtag and secret references updated when configuration, secret and feature flag refresh enabled", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should update the corresponding target's reconcile state, and those that shouldn't be updated should be as is.
}]).Should(Equal(updatedFeatureFlagEtags[acpv1.Selector{ | ||
KeyFilter: &wildcard, | ||
}])) | ||
Expect(processor.ReconciliationState.NextSecretReferenceRefreshReconcileTime).Should(Equal(expectedNextSecretReferenceRefreshReconcileTime)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert the NextKeyValueRefreshReconcileTime
and NextFeatureFlagRefreshReconcileTime
not been updated, still keep the previous expectedNextKeyValueRefreshReconcileTime
and cachedNextFeatureFlagRefreshReconcileTime
value.
secretResult["testSecretKey"] = []byte("testSecretValue") | ||
existingSecrets := make(map[string]corev1.Secret) | ||
existingSecrets[secretName] = corev1.Secret{ | ||
Data: secretResult, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
ResourceVersion: fakeSecretResourceVersion, | ||
}, | ||
} | ||
|
||
var fakeId azsecrets.ID = "fakeSecretId" | ||
var cachedFakeId azsecrets.ID = "cachedFakeSecretId" | ||
|
||
secretMetadata := make(map[string]loader.KeyVaultSecretMetadata) | ||
secretMetadata2 := make(map[string]loader.KeyVaultSecretMetadata) | ||
cachedSecretReferences := make(map[string]*loader.TargetSecretReference) | ||
secretMetadata["testSecretKey"] = loader.KeyVaultSecretMetadata{ | ||
SecretId: &fakeId, | ||
} | ||
secretMetadata2["testSecretKey"] = loader.KeyVaultSecretMetadata{ | ||
SecretId: &cachedFakeId, | ||
} | ||
cachedSecretReferences[secretName] = &loader.TargetSecretReference{ | ||
Type: corev1.SecretType("Opaque"), | ||
SecretsMetadata: secretMetadata2, | ||
SecretResourceVersion: fakeSecretResourceVersion, | ||
} | ||
|
||
allSettings := &loader.TargetKeyValueSettings{ | ||
SecretSettings: map[string]corev1.Secret{ | ||
secretName: { | ||
Data: secretResult, | ||
Type: corev1.SecretType("Opaque"), | ||
}, | ||
}, | ||
SecretReferences: map[string]*loader.TargetSecretReference{ | ||
secretName: { | ||
Type: corev1.SecretType("Opaque"), | ||
SecretsMetadata: secretMetadata, | ||
}, | ||
}, | ||
} | ||
|
||
configProvider := &acpv1.AzureAppConfigurationProvider{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: "appconfig.kubernetes.config/v1", | ||
Kind: "AzureAppConfigurationProvider", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: providerName, | ||
Namespace: ProviderNamespace, | ||
Generation: 1, | ||
}, | ||
Spec: acpv1.AzureAppConfigurationProviderSpec{ | ||
Endpoint: &EndpointName, | ||
Target: acpv1.ConfigurationGenerationParameters{ | ||
ConfigMapName: configMapName, | ||
ConfigMapData: &acpv1.ConfigMapDataOptions{ | ||
Type: "json", | ||
Key: "filestyle.json", | ||
}, | ||
}, | ||
Secret: &acpv1.SecretReference{ | ||
Target: acpv1.SecretGenerationParameters{ | ||
SecretName: secretName, | ||
}, | ||
Refresh: &acpv1.RefreshSettings{ | ||
Interval: "1m", | ||
Enabled: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
fakeResourceVersion := "1" | ||
tmpTime := metav1.Now() | ||
processor := AppConfigurationProviderProcessor{ | ||
Context: ctx, | ||
Retriever: mockConfigurationSettings, | ||
Provider: configProvider, | ||
ShouldReconcile: false, | ||
Settings: &loader.TargetKeyValueSettings{}, | ||
ReconciliationState: &ReconciliationState{ | ||
NextSecretReferenceRefreshReconcileTime: tmpTime, | ||
ExistingSecretReferences: cachedSecretReferences, | ||
Generation: 1, | ||
ConfigMapResourceVersion: &fakeResourceVersion, | ||
}, | ||
CurrentTime: metav1.NewTime(tmpTime.Time.Add(1 * time.Minute)), | ||
RefreshOptions: &RefreshOptions{}, | ||
} | ||
|
||
mockConfigurationSettings.EXPECT().ResolveSecretReferences(gomock.Any(), gomock.Any(), gomock.Any()).Return(allSettings, nil) | ||
|
||
_ = processor.PopulateSettings(&corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{ | ||
ResourceVersion: fakeResourceVersion, | ||
}}, existingSecrets) | ||
|
||
_, _ = processor.Finish() | ||
|
||
Expect(processor.ReconciliationState.ExistingSecretReferences).Should(Equal(allSettings.SecretReferences)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need these tests? Shouldn't it has been covered by the last one?
* add more test for refresh scenarios * add more test cases * add more refresh test cases * resolve comments
No description provided.