chore(cloudflare): migrate customhostname to v5#5891
Conversation
Pull Request Test Coverage Report for Build 20995964271Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
|
@vflaux @mrozentsvayg Any comment on this PR ? Do you think you can review it ? |
|
@vflaux: changing LGTM is restricted to collaborators DetailsIn response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
How did broken tests get merged in? |
This should be fixed, see #5896. |
|
/retest |
|
@vflaux everything look good now? |
vflaux
left a comment
There was a problem hiding this comment.
I've not review all the new tests yet.
Looks like IA generated, some clearly improve test coverage, others seems less relevant. 😄
|
The tests just fail because of rate limits to coveralls |
|
Did you @AndrewCharlesHay address comments by @vflaux ? Cleaning up things that are not useful is always great for maintaining the software. |
|
@szuecs yep all updated |
|
@AndrewCharlesHay Would you please rebase ? |
e0eb277 to
bcad628
Compare
| func TestSubmitChangesEdgeCases(t *testing.T) { | ||
| ctx := context.Background() | ||
|
|
||
| t.Run("EmptyChanges", func(t *testing.T) { | ||
| client := NewMockCloudFlareClient() | ||
| provider := &CloudFlareProvider{ | ||
| Client: client, | ||
| } | ||
|
|
||
| err := provider.submitChanges(ctx, []*cloudFlareChange{}) | ||
| assert.NoError(t, err, "Empty changes should not error") | ||
| }) | ||
|
|
||
| t.Run("DryRun", func(t *testing.T) { | ||
| client := NewMockCloudFlareClient() | ||
| provider := &CloudFlareProvider{ | ||
| Client: client, | ||
| DryRun: true, | ||
| } | ||
|
|
||
| changes := []*cloudFlareChange{ | ||
| { | ||
| Action: cloudFlareCreate, | ||
| ResourceRecord: dns.RecordResponse{ | ||
| Name: "test.bar.com", | ||
| Type: "A", | ||
| Content: "1.2.3.4", | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| err := provider.submitChanges(ctx, changes) | ||
| assert.NoError(t, err, "Dry run should not error") | ||
| assert.Empty(t, client.Actions, "Dry run should not execute actions") | ||
| }) | ||
| } |
There was a problem hiding this comment.
This don't increase test coverage.
There was a problem hiding this comment.
This has been addressed by the v5 test migration. Verification is included in the updated cloudflare_test.go.
| func TestGroupByNameAndTypeWithCustomHostnames(t *testing.T) { | ||
| provider := &CloudFlareProvider{} | ||
|
|
||
| t.Run("WithCustomHostnames", func(t *testing.T) { | ||
| records := DNSRecordsMap{ | ||
| DNSRecordIndex{Name: "origin.example.com", Type: "A", Content: "1.2.3.4"}: { | ||
| ID: "rec1", | ||
| Name: "origin.example.com", | ||
| Type: "A", | ||
| Content: "1.2.3.4", | ||
| TTL: 300, | ||
| }, | ||
| } | ||
|
|
||
| customHostnames := CustomHostnamesMap{ | ||
| CustomHostnameIndex{Hostname: "custom1.example.com"}: { | ||
| ID: "ch1", | ||
| Hostname: "custom1.example.com", | ||
| CustomOriginServer: "origin.example.com", | ||
| }, | ||
| CustomHostnameIndex{Hostname: "custom2.example.com"}: { | ||
| ID: "ch2", | ||
| Hostname: "custom2.example.com", | ||
| CustomOriginServer: "origin.example.com", | ||
| }, | ||
| } | ||
|
|
||
| endpoints := provider.groupByNameAndTypeWithCustomHostnames(records, customHostnames) | ||
| require.Len(t, endpoints, 1) | ||
|
|
||
| customHostnamesProp, ok := endpoints[0].GetProviderSpecificProperty(annotations.CloudflareCustomHostnameKey) | ||
| assert.True(t, ok) | ||
| assert.Contains(t, customHostnamesProp, "custom1.example.com") | ||
| assert.Contains(t, customHostnamesProp, "custom2.example.com") | ||
| }) | ||
|
|
||
| t.Run("WithoutCustomHostnames", func(t *testing.T) { | ||
| records := DNSRecordsMap{ | ||
| DNSRecordIndex{Name: "example.com", Type: "A", Content: "1.2.3.4"}: { | ||
| ID: "rec1", | ||
| Name: "example.com", | ||
| Type: "A", | ||
| Content: "1.2.3.4", | ||
| TTL: 300, | ||
| }, | ||
| } | ||
|
|
||
| endpoints := provider.groupByNameAndTypeWithCustomHostnames(records, nil) | ||
| require.Len(t, endpoints, 1) | ||
|
|
||
| _, ok := endpoints[0].GetProviderSpecificProperty(annotations.CloudflareCustomHostnameKey) | ||
| assert.False(t, ok, "Should not have custom hostname when none exist") | ||
| }) | ||
| } |
There was a problem hiding this comment.
This don't increase test coverage.
There was a problem hiding this comment.
This has been addressed by the v5 test migration. Verification is included in the updated cloudflare_test.go.
| func TestBuildCustomHostnameSSLParams(t *testing.T) { | ||
| ssl := &CustomHostnameSSL{ | ||
| Type: "dv", | ||
| Method: "http", | ||
| BundleMethod: "ubiquitous", | ||
| CertificateAuthority: "lets_encrypt", | ||
| Settings: CustomHostnameSSLSettings{MinTLSVersion: "1.2"}, | ||
| } | ||
|
|
||
| params := custom_hostnames.CustomHostnameNewParamsSSL{} | ||
| if ssl.Method != "" { | ||
| params.Method = cloudflare.F(custom_hostnames.DCVMethod(ssl.Method)) | ||
| } | ||
| if ssl.Type != "" { | ||
| params.Type = cloudflare.F(custom_hostnames.DomainValidationType(ssl.Type)) | ||
| } | ||
| if ssl.BundleMethod != "" { | ||
| params.BundleMethod = cloudflare.F(custom_hostnames.BundleMethod(ssl.BundleMethod)) | ||
| } | ||
| if ssl.CertificateAuthority != "" && ssl.CertificateAuthority != "none" { | ||
| params.CertificateAuthority = cloudflare.F(cloudflare.CertificateCA(ssl.CertificateAuthority)) | ||
| } | ||
| if ssl.Settings.MinTLSVersion != "" { | ||
| params.Settings = cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettings{ | ||
| MinTLSVersion: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsMinTLSVersion(ssl.Settings.MinTLSVersion)), | ||
| }) | ||
| } | ||
|
|
||
| // Assert all fields are set as expected | ||
| require.Equal(t, custom_hostnames.DCVMethod("http"), params.Method.Value) | ||
| require.Equal(t, custom_hostnames.DomainValidationType("dv"), params.Type.Value) | ||
| require.Equal(t, custom_hostnames.BundleMethod("ubiquitous"), params.BundleMethod.Value) | ||
| require.Equal(t, cloudflare.CertificateCA("lets_encrypt"), params.CertificateAuthority.Value) | ||
| require.Equal(t, custom_hostnames.CustomHostnameNewParamsSSLSettingsMinTLSVersion("1.2"), params.Settings.Value.MinTLSVersion.Value) | ||
| } |
There was a problem hiding this comment.
This has been addressed by the v5 test migration. Verification is included in the updated cloudflare_test.go.
…handling - Replace all cloudflarev0.Error usages with cloudflare.Error in tests - Remove unused cloudflarev0 import - Fix getDNSRecordsMap to use PerPage configuration - Add early return in convertCloudflareError for structured v5 errors - Update TestConvertCloudflareError to handle v5 error types safely - Remove ErrorCodes field from error structs (not in v5 SDK) Signed-off-by: Andrew Hay <andrew.hay@benchmarkanalytics.com>
Signed-off-by: Andrew Hay <andrew.hay@benchmarkanalytics.com>
|
@vflaux I believe I've addressed your previous concerns regarding test coverage and relevance. The tests have been updated to fully support the v5 SDK migration, including the new |
vflaux
left a comment
There was a problem hiding this comment.
Sorry for the additional change requests.
Could you also move back TestGroupByNameAndTypeWithCustomHostnames_MX, TestProviderPropertiesIdempotency & ExampleDomain to their original location to minimize the diff noise?
After that, we should be good.
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
- Remove SDK migration status section from cloudflare.md (per vflaux and ivankatliarchuk) - Add newCloudflareError() helper for proper v5 SDK error testing - Move ExampleDomain, TestGroupByNameAndTypeWithCustomHostnames_MX, and TestProviderPropertiesIdempotency back to original locations to minimize diff
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
|
/lgtm |
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
|
/lgtm |
|
Running d9921ef build in our stage environment for about a week now. Until merged, this PR is effectively blocking further development of the Cloudflare provider. For example, I have a new feature/extension pending (Origin SNI Override), but it doesn't make sense to implement it on top of the older API. If there are no further concerns to address, it would be great to get this merged. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ivankatliarchuk The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* master: (25 commits) feat(event): standardize event messages and add resource kind lookup for events (kubernetes-sigs#6101) refactor(informers): unify cache sync functions using generics (kubernetes-sigs#6102) fix(fqdn): support kind and api version (kubernetes-sigs#6097) test(fqdn): cover sources without any fqdn tests (kubernetes-sigs#6094) chore(tools): CRD generation script moved and add validation workflow (kubernetes-sigs#6079) fix(metrics): add CNAME to known record types (kubernetes-sigs#6115) chore(cloudflare): migrate customhostname to v5 (kubernetes-sigs#5891) test(provider/exoscale): improved the test coverage for exoscale provider from 62.8% to 80.4% (kubernetes-sigs#6112) feat(source): gateway api hostname source annotation (kubernetes-sigs#5959) test: cover pkg/events/fake package (kubernetes-sigs#6096) refactor(controller): controller no longer responsible for SingletonClientGenerator creation (kubernetes-sigs#6077) refactor(source): standardize FQDN template accross sources (kubernetes-sigs#6093) feat(coredns): rename ownerId and ownedBy to owner (kubernetes-sigs#6032) docs: fix typo in README (The are → There are) (kubernetes-sigs#6095) refactor(aws): abstract provider-specific boolean parsing (kubernetes-sigs#6078) refactor(api): deduplicate addKnownTypes (kubernetes-sigs#6087) fix(api): rollback changes for omitempty (kubernetes-sigs#6086) chore(deps): bump renovatebot/github-action (kubernetes-sigs#6080) fix(aws): enable AWS API validation for routing policies without setIdentifier (kubernetes-sigs#6082) chore(aws): document and test behavior for ALB and NLB (kubernetes-sigs#6063) ...
What does it do ?
Migrate customhostname to v5
Motivation
Closes #5540
More