-
Notifications
You must be signed in to change notification settings - Fork 480
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
Allow configuring DialContext for RoundTripper. #2963
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import ( | |
"errors" | ||
"fmt" | ||
"io/fs" | ||
"net" | ||
"slices" | ||
"sort" | ||
"strings" | ||
|
@@ -118,17 +119,18 @@ type ConformanceTestSuite struct { | |
|
||
// Options can be used to initialize a ConformanceTestSuite. | ||
type ConformanceOptions struct { | ||
Client client.Client | ||
Clientset clientset.Interface | ||
RestConfig *rest.Config | ||
GatewayClassName string | ||
Debug bool | ||
RoundTripper roundtripper.RoundTripper | ||
BaseManifests string | ||
MeshManifests string | ||
NamespaceLabels map[string]string | ||
NamespaceAnnotations map[string]string | ||
ReportOutputPath string | ||
Client client.Client | ||
Clientset clientset.Interface | ||
RestConfig *rest.Config | ||
GatewayClassName string | ||
Debug bool | ||
RoundTripperDialContext func(context.Context, string, string) (net.Conn, error) | ||
RoundTripper roundtripper.RoundTripper | ||
BaseManifests string | ||
MeshManifests string | ||
NamespaceLabels map[string]string | ||
NamespaceAnnotations map[string]string | ||
ReportOutputPath string | ||
|
||
// CleanupBaseResources indicates whether or not the base test | ||
// resources such as Gateways should be cleaned up after the run. | ||
|
@@ -185,7 +187,11 @@ func NewConformanceTestSuite(options ConformanceOptions) (*ConformanceTestSuite, | |
|
||
roundTripper := options.RoundTripper | ||
if roundTripper == nil { | ||
roundTripper = &roundtripper.DefaultRoundTripper{Debug: options.Debug, TimeoutConfig: options.TimeoutConfig} | ||
roundTripper = &roundtripper.DefaultRoundTripper{ | ||
Debug: options.Debug, | ||
TimeoutConfig: options.TimeoutConfig, | ||
CustomDialContext: options.RoundTripperDialContext, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @candita, thanks for the comment. Please correct me if I'm wrong, but according to the https://pkg.go.dev/net/http#Transport
|
||
} | ||
} | ||
|
||
installedCRDs := &apiextensionsv1.CustomResourceDefinitionList{} | ||
|
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.
I believe you'll also want to add this to the ConformanceTestSuite. See 60d3e58 for an example in reverse.
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.
Leaving this value as
nil
should preserve the existing behavior. Please refer to the other comment regarding default value.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.
Options can be used to intialize a
ConformanceTestSuite
, so you need to addRoundTripperDialContext
toConformanceTestSuite
and make sure it gets populated from theConformanceOptions
.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.
Hi @candita,
RoundTripperDialContext
is used for initializing aroundtripper.DefaultRoundTripper
on line 190 which is then added toConformanceTestSuite
if the user has not provided a custom RoundTripper implementation. Given that this is only specific to the RoundTripper, it's not essential to incorporate this as a member ofConformanceTestSuite
since it will be present inConformanceTestSuite.RoundTripper
. Please let me know ifConformanceOptions.RoundTripperDialContext
should have a docstring describing this behavior.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.
I'm not sure I understand. You want to add this option but not allow it to be set to anything other than nil?
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.
HI @candita glad to explain the life of a
RoundTripperDialContext
option:ConformanceOptions
with a non-nilRoundTripperDialContext
.NewConformanceTestSuite
with the configured (non-nil)RoundTripperDialContext
roundtripper.DefaultRoundTripper
,roundTripper
, is constructed using the custom dial context if the user has not specified a round tripper implementation.roundTripper
is assigned toConformanceTestSuite.RoundTripper
which will be used for the conformance tests.ConformanceTestSuite.RoundTripper
tohttp.MakeRequestAndExpectEventuallyConsistentResponse
, eghttp.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, tc)
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.
The user can just set
ConformanceOption.RoundTripper
with whatever dial context they want, correct? The option RoundTripperDialContext is not used by anything other than RoundTripper.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.
Hi @candita, the default round tripper sets the TLS client config which other RoundTripper implementations would need to duplicate. Ideally this wouldn't be necessary if it's feasible to inject a custom dialer for this purpose.
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.
I personally think this could be a very useful option. In general I'd like to see as many people as possible be able to use our default/built-in roundtripper, and I think these kinds of options should help.