Skip to content

Commit

Permalink
Add test flags for the conformance suite
Browse files Browse the repository at this point in the history
- service domain to allow for customizing the domain used by the test
- request delay to allow for a delay before trying the request to allow the service to get ready
  • Loading branch information
nader-ziada committed Apr 8, 2024
1 parent 97688e7 commit fff22b1
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 49 deletions.
2 changes: 1 addition & 1 deletion test/conformance/certificate/nonhttp01/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// TestSecret verifies that a certificate creates a secret
func TestSecret(t *testing.T) {
ctx, clients := context.Background(), test.Setup(t)
certName := test.ObjectNameForTest(t) + ".example.com"
certName := test.ObjectNameForTest(t) + "." + test.NetworkingFlags.ServiceDomain

cert := utils.CreateCertificate(ctx, t, clients, []string{certName})

Expand Down
8 changes: 4 additions & 4 deletions test/conformance/ingress/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestBasics(t *testing.T) {
// Create a simple Ingress over the Service.
_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -52,7 +52,7 @@ func TestBasics(t *testing.T) {
}},
})

RuntimeRequest(ctx, t, client, "http://"+name+".example.com")
RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain)
}

// TestBasicsHTTP2 verifies that the same no-frills Ingress over a Service with http/2 configured
Expand All @@ -69,7 +69,7 @@ func TestBasicsHTTP2(t *testing.T) {
// Create a simple Ingress over the Service.
_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -85,7 +85,7 @@ func TestBasicsHTTP2(t *testing.T) {
}},
})

ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com")
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain)
if ri == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/ingress/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func verifyIngressWithAnnotations(ctx context.Context, t *testing.T, clients *te
original, _ := CreateIngress(ctx, t, clients,
v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{backend.ServiceName + ".example.com"},
Hosts: []string{backend.ServiceName + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand Down
4 changes: 2 additions & 2 deletions test/conformance/ingress/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestGRPC(t *testing.T) {
const suffix = "- pong"
name, port, _ := CreateGRPCService(ctx, t, clients, suffix)

domain := name + ".example.com"
domain := name + "." + test.NetworkingFlags.ServiceDomain

// Create a simple Ingress over the Service.
_, dialCtx, _ := createIngressReadyDialContext(ctx, t, clients, v1alpha1.IngressSpec{
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestGRPCSplit(t *testing.T) {

// Create a simple Ingress over the Service.
name := test.ObjectNameForTest(t)
domain := name + ".example.com"
domain := name + "." + test.NetworkingFlags.ServiceDomain
_, dialCtx, _ := createIngressReadyDialContext(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{domain},
Expand Down
20 changes: 10 additions & 10 deletions test/conformance/ingress/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestProbeHeaders(t *testing.T) {
// Create a simple Ingress over the Service.
ing, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestProbeHeaders(t *testing.T) {
r.Header.Set(header.HashKey, tt.req)
})

ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com", ros...)
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, ros...)
if ri == nil {
t.Error("Couldn't make request")
return
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestTagHeaders(t *testing.T) {

_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand Down Expand Up @@ -195,7 +195,7 @@ func TestTagHeaders(t *testing.T) {
})
}

ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com", ros...)
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, ros...)
if ri == nil {
t.Error("Couldn't make request")
return
Expand All @@ -221,7 +221,7 @@ func TestPreSplitSetHeaders(t *testing.T) {
// Create a simple Ingress over the 10 Services.
_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -243,7 +243,7 @@ func TestPreSplitSetHeaders(t *testing.T) {
t.Run("Check without passing header", func(t *testing.T) {
t.Parallel()

ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com")
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain)
if ri == nil {
return
}
Expand All @@ -256,7 +256,7 @@ func TestPreSplitSetHeaders(t *testing.T) {
t.Run("Check with passing header", func(t *testing.T) {
t.Parallel()

ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com", func(req *http.Request) {
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, func(req *http.Request) {
// Specify a value for the header to verify that implementations
// use set vs. append semantics.
req.Header.Set(headerName, "bogus")
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestPostSplitSetHeaders(t *testing.T) {
name := test.ObjectNameForTest(t)
_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -324,7 +324,7 @@ func TestPostSplitSetHeaders(t *testing.T) {
// particular test.
seen := make(sets.Set[string], len(names))
for i := 0; i < maxRequests; i++ {
ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com")
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain)
if ri == nil {
return
}
Expand All @@ -347,7 +347,7 @@ func TestPostSplitSetHeaders(t *testing.T) {
// particular test.
seen := make(sets.Set[string], len(names))
for i := 0; i < maxRequests; i++ {
ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com", func(req *http.Request) {
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, func(req *http.Request) {
// Specify a value for the header to verify that implementations
// use set vs. append semantics.
req.Header.Set(headerName, "bogus")
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/ingress/httpoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestHTTPOption(t *testing.T) {
func create(ctx context.Context, t *testing.T, clients *test.Clients, httpOption v1alpha1.HTTPOption) (string, *http.Client) {
name, port, _ := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1)

hosts := []string{name + ".example.com"}
hosts := []string{name + "." + test.NetworkingFlags.ServiceDomain}

secretName, tlsConfig, _ := CreateTLSSecret(ctx, t, clients, hosts)

Expand Down
8 changes: 4 additions & 4 deletions test/conformance/ingress/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestPath(t *testing.T) {

_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestPath(t *testing.T) {
t.Run(path, func(t *testing.T) {
t.Parallel()

ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com"+path)
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain+path)
if ri == nil {
return
}
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestPathAndPercentageSplit(t *testing.T) {

_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestPathAndPercentageSplit(t *testing.T) {

for i := 0; i < total; i++ {
g.Go(func() error {
ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com/foo")
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain+"/foo")
if ri == nil {
return errors.New("failed to request")
}
Expand Down
4 changes: 2 additions & 2 deletions test/conformance/ingress/percentage.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestPercentage(t *testing.T) {
name := test.ObjectNameForTest(t)
_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestPercentage(t *testing.T) {

for i := 0.0; i < totalRequests; i++ {
g.Go(func() error {
ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com")
ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain)
if ri == nil {
return errors.New("failed to request")
}
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/ingress/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestRetry(t *testing.T) {
t.Parallel()
ctx, clients := context.Background(), test.Setup(t)
name, port, _ := CreateRetryService(ctx, t, clients)
domain := name + ".example.com"
domain := name + "." + test.NetworkingFlags.ServiceDomain

// Create a simple Ingress over the Service.
_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Expand Down
8 changes: 4 additions & 4 deletions test/conformance/ingress/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestRule(t *testing.T) {

_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{fooName + ".example.com"},
Hosts: []string{fooName + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -58,7 +58,7 @@ func TestRule(t *testing.T) {
}},
},
}, {
Hosts: []string{barName + ".example.com"},
Hosts: []string{barName + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -77,12 +77,12 @@ func TestRule(t *testing.T) {
}},
})

ri := RuntimeRequest(ctx, t, client, "http://"+fooName+".example.com")
ri := RuntimeRequest(ctx, t, client, "http://"+fooName+"."+test.NetworkingFlags.ServiceDomain)
if got := ri.Request.Headers.Get(headerName); got != fooName {
t.Errorf("Header[Host] = %q, wanted %q", got, fooName)
}

ri = RuntimeRequest(ctx, t, client, "http://"+barName+".example.com")
ri = RuntimeRequest(ctx, t, client, "http://"+barName+"."+test.NetworkingFlags.ServiceDomain)
if got := ri.Request.Headers.Get(headerName); got != barName {
t.Errorf("Header[Host] = %q, wanted %q", got, barName)
}
Expand Down
6 changes: 3 additions & 3 deletions test/conformance/ingress/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestTimeout(t *testing.T) {
// Create a simple Ingress over the Service.
_, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{name + ".example.com"},
Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand Down Expand Up @@ -87,8 +87,8 @@ func TestTimeout(t *testing.T) {
func checkTimeout(ctx context.Context, t *testing.T, client *http.Client, name string, code int, initial time.Duration, timeout time.Duration) {
t.Helper()

resp, err := client.Get(fmt.Sprintf("http://%s.example.com?initialTimeout=%d&timeout=%d",
name, initial.Milliseconds(), timeout.Milliseconds()))
resp, err := client.Get(fmt.Sprintf("http://%s.%s?initialTimeout=%d&timeout=%d",
name, test.NetworkingFlags.ServiceDomain, initial.Milliseconds(), timeout.Milliseconds()))
if err != nil {
t.Fatal("Error making GET request:", err)
}
Expand Down
6 changes: 3 additions & 3 deletions test/conformance/ingress/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestIngressTLS(t *testing.T) {

name, port, _ := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1)

hosts := []string{name + ".example.com"}
hosts := []string{name + "." + test.NetworkingFlags.ServiceDomain}

secretName, tlsConfig, _ := CreateTLSSecret(ctx, t, clients, hosts)

Expand Down Expand Up @@ -61,10 +61,10 @@ func TestIngressTLS(t *testing.T) {
}, tlsConfig)

// Check without TLS.
RuntimeRequest(ctx, t, client, "http://"+name+".example.com")
RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain)

// Check with TLS.
RuntimeRequest(ctx, t, client, "https://"+name+".example.com")
RuntimeRequest(ctx, t, client, "https://"+name+"."+test.NetworkingFlags.ServiceDomain)
}

// TODO(mattmoor): Consider adding variants where we have multiple hosts with distinct certificates.
12 changes: 6 additions & 6 deletions test/conformance/ingress/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestUpdate(t *testing.T) {
hostname := test.ObjectNameForTest(t)
ing, client, cancel := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{hostname + ".example.com"},
Hosts: []string{hostname + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -68,7 +68,7 @@ func TestUpdate(t *testing.T) {
firstCancel()
}

proberCancel := checkOK(ctx, t, "http://"+hostname+".example.com", client)
proberCancel := checkOK(ctx, t, "http://"+hostname+"."+test.NetworkingFlags.ServiceDomain, client)
defer func() {
proberCancel()
previousVersionCancel()
Expand All @@ -87,7 +87,7 @@ func TestUpdate(t *testing.T) {
// Update the Ingress, and wait for it to report ready.
UpdateIngressReady(ctx, t, clients, ing.Name, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{hostname + ".example.com"},
Hosts: []string{hostname + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -108,7 +108,7 @@ func TestUpdate(t *testing.T) {

// Check that it serves the right message as soon as we get "Ready",
// but before we stop probing.
ri := RuntimeRequest(ctx, t, client, "http://"+hostname+".example.com")
ri := RuntimeRequest(ctx, t, client, "http://"+hostname+"."+test.NetworkingFlags.ServiceDomain)
if ri != nil {
if got := ri.Request.Headers.Get(updateHeaderName); got != sentinel {
t.Errorf("Header[%q] = %q, wanted %q", updateHeaderName, got, sentinel)
Expand All @@ -130,7 +130,7 @@ func TestUpdate(t *testing.T) {
// Update the Ingress, and wait for it to report ready.
UpdateIngressReady(ctx, t, clients, ing.Name, v1alpha1.IngressSpec{
Rules: []v1alpha1.IngressRule{{
Hosts: []string{hostname + ".example.com"},
Hosts: []string{hostname + "." + test.NetworkingFlags.ServiceDomain},
Visibility: v1alpha1.IngressVisibilityExternalIP,
HTTP: &v1alpha1.HTTPIngressRuleValue{
Paths: []v1alpha1.HTTPIngressPath{{
Expand All @@ -151,7 +151,7 @@ func TestUpdate(t *testing.T) {

// Check that it serves the right message as soon as we get "Ready",
// but before we stop probing.
ri := RuntimeRequest(ctx, t, client, "http://"+hostname+".example.com")
ri := RuntimeRequest(ctx, t, client, "http://"+hostname+"."+test.NetworkingFlags.ServiceDomain)
if ri != nil {
if got := ri.Request.Headers.Get(updateHeaderName); got != sentinel {
t.Errorf("Header[%q] = %q, wanted %q", updateHeaderName, got, sentinel)
Expand Down
Loading

0 comments on commit fff22b1

Please sign in to comment.