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

Make sure to read association configuration again from annotations if it was cleared #5489

Merged
merged 14 commits into from
Mar 24, 2022
Prev Previous commit
Next Next commit
Add test case
  • Loading branch information
thbkrkr committed Mar 21, 2022
commit eb8bfb9401605457782e193e73014dfda0008337
20 changes: 16 additions & 4 deletions pkg/apis/elasticsearch/v1/elasticsearch_types_test.go
Original file line number Diff line number Diff line change
@@ -343,6 +343,10 @@ func Test_AssociationConfs(t *testing.T) {
}

// es with associations
metricsEsRef := commonv1.ObjectSelector{
Name: "metrics",
Namespace: "default",
}
esMon := &Elasticsearch{
ObjectMeta: metav1.ObjectMeta{
Name: "esmon",
@@ -355,10 +359,7 @@ func Test_AssociationConfs(t *testing.T) {
Spec: ElasticsearchSpec{
Monitoring: Monitoring{
Metrics: MetricsMonitoring{
ElasticsearchRefs: []commonv1.ObjectSelector{{
Name: "metrics",
Namespace: "default"},
},
ElasticsearchRefs: []commonv1.ObjectSelector{metricsEsRef},
},
Logs: LogsMonitoring{
ElasticsearchRefs: []commonv1.ObjectSelector{{
@@ -388,4 +389,15 @@ func Test_AssociationConfs(t *testing.T) {
assert.NotNil(t, assoc.AssociationConf())
}
assert.Equal(t, 2, len(esMon.AssocConfs))

// delete just one entry in the map
delete(esMon.AssocConfs, metricsEsRef.NamespacedName())
assert.Equal(t, 1 , len(esMon.AssocConfs))

// checks that the map the missing entry is set again
thbkrkr marked this conversation as resolved.
Show resolved Hide resolved
for _, assoc := range esMon.GetAssociations() {
assert.NotNil(t, assoc.AssociationConf())
}
assert.Equal(t, 2, len(esMon.AssocConfs))

}