From e938f5a67fe47426326fcdc0523a72e171d95334 Mon Sep 17 00:00:00 2001 From: Matias Charriere Date: Thu, 25 May 2023 21:45:19 +0200 Subject: [PATCH] remove tests from missing endpoint tests from controller the entire logic of missing endpoints was removed from the controller taking leverage on the planner Signed-off-by: Matias Charriere --- controller/controller_test.go | 99 ----------------------------------- 1 file changed, 99 deletions(-) diff --git a/controller/controller_test.go b/controller/controller_test.go index f6b03d433..9f37ab295 100644 --- a/controller/controller_test.go +++ b/controller/controller_test.go @@ -311,51 +311,6 @@ func testControllerFiltersDomains(t *testing.T, configuredEndpoints []*endpoint. } } -type noopRegistryWithMissing struct { - *registry.NoopRegistry - missingRecords []*endpoint.Endpoint -} - -func (r *noopRegistryWithMissing) MissingRecords() []*endpoint.Endpoint { - return r.missingRecords -} - -func testControllerFiltersDomainsWithMissing(t *testing.T, configuredEndpoints []*endpoint.Endpoint, domainFilter endpoint.DomainFilterInterface, providerEndpoints, missingEndpoints []*endpoint.Endpoint, expectedChanges []*plan.Changes) { - t.Helper() - cfg := externaldns.NewConfig() - cfg.ManagedDNSRecordTypes = []string{endpoint.RecordTypeA, endpoint.RecordTypeCNAME} - - source := new(testutils.MockSource) - source.On("Endpoints").Return(configuredEndpoints, nil) - - // Fake some existing records in our DNS provider and validate some desired changes. - provider := &filteredMockProvider{ - RecordsStore: providerEndpoints, - } - noop, err := registry.NewNoopRegistry(provider) - require.NoError(t, err) - - r := &noopRegistryWithMissing{ - NoopRegistry: noop, - missingRecords: missingEndpoints, - } - - ctrl := &Controller{ - Source: source, - Registry: r, - Policy: &plan.SyncPolicy{}, - DomainFilter: domainFilter, - ManagedRecordTypes: cfg.ManagedDNSRecordTypes, - } - - assert.NoError(t, ctrl.RunOnce(context.Background())) - assert.Equal(t, 1, provider.RecordsCallCount) - require.Len(t, provider.ApplyChangesCalls, len(expectedChanges)) - for i, change := range expectedChanges { - assert.Equal(t, *change, *provider.ApplyChangesCalls[i]) - } -} - func TestControllerSkipsEmptyChanges(t *testing.T) { testControllerFiltersDomains( t, @@ -683,60 +638,6 @@ func TestARecords(t *testing.T) { assert.Equal(t, math.Float64bits(1), valueFromMetric(registryARecords)) } -// TestMissingRecordsApply validates that the missing records result in the dedicated plan apply. -func TestMissingRecordsApply(t *testing.T) { - testControllerFiltersDomainsWithMissing( - t, - []*endpoint.Endpoint{ - { - DNSName: "record1.used.tld", - RecordType: endpoint.RecordTypeA, - Targets: endpoint.Targets{"1.2.3.4"}, - }, - { - DNSName: "record2.used.tld", - RecordType: endpoint.RecordTypeA, - Targets: endpoint.Targets{"8.8.8.8"}, - }, - }, - endpoint.NewDomainFilter([]string{"used.tld"}), - []*endpoint.Endpoint{ - { - DNSName: "record1.used.tld", - RecordType: endpoint.RecordTypeA, - Targets: endpoint.Targets{"1.2.3.4"}, - }, - }, - []*endpoint.Endpoint{ - { - DNSName: "a-record1.used.tld", - RecordType: endpoint.RecordTypeTXT, - Targets: endpoint.Targets{"\"heritage=external-dns,external-dns/owner=owner\""}, - }, - }, - []*plan.Changes{ - // Missing record had its own plan applied. - { - Create: []*endpoint.Endpoint{ - { - DNSName: "a-record1.used.tld", - RecordType: endpoint.RecordTypeTXT, - Targets: endpoint.Targets{"\"heritage=external-dns,external-dns/owner=owner\""}, - }, - }, - }, - { - Create: []*endpoint.Endpoint{ - { - DNSName: "record2.used.tld", - RecordType: endpoint.RecordTypeA, - Targets: endpoint.Targets{"8.8.8.8"}, - }, - }, - }, - }) -} - func TestAAAARecords(t *testing.T) { testControllerFiltersDomains( t,