-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add DomainMapping conformance test #9780
Changes from 1 commit
ab7fefe
870e47e
f7e1d6f
0b0555b
8823a40
db0d36f
fd1c4f2
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// +build e2e | ||
|
||
/* | ||
Copyright 2020 The Knative Authors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
"testing" | ||
"time" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/util/wait" | ||
duckv1 "knative.dev/pkg/apis/duck/v1" | ||
"knative.dev/serving/pkg/apis/serving/v1alpha1" | ||
"knative.dev/serving/test" | ||
"knative.dev/serving/test/conformance/api/shared" | ||
v1test "knative.dev/serving/test/v1" | ||
) | ||
|
||
func TestDomainMapping(t *testing.T) { | ||
if !test.ServingFlags.EnableAlphaFeatures { | ||
t.Skip("Alpha features not enabled") | ||
} | ||
Comment on lines
+36
to
+38
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. We should enable this in I'd kinda like to see the istio class annotation moved to be config-based before we start adding e2e tests that will light up folks testgrid. 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. added to kind-e2e in #9837, Im gonna ping on slack to try to get some hand-holding for how to go about trying to iterate on modifications to e2e-tests.sh :) 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. .. and added prow e2e in #9851. Think this may be ready to go now. |
||
|
||
t.Parallel() | ||
ctx, clients := context.Background(), test.Setup(t) | ||
|
||
names := test.ResourceNames{ | ||
Service: test.ObjectNameForTest(t), | ||
Image: test.HelloWorld, | ||
} | ||
|
||
// Clean up on test failure or interrupt. | ||
test.EnsureTearDown(t, clients, &names) | ||
|
||
// Setup initial Service. | ||
svc, err := v1test.CreateServiceReady(t, clients, &names) | ||
if err != nil { | ||
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err) | ||
} | ||
|
||
// Using fixed hostnames can lead to conflicts when multiple tests run at | ||
// once, so include the svc name to avoid collisions. | ||
host := svc.Service.Name + ".mapping.com" | ||
|
||
// Point DomainMapping at our service. | ||
dm, err := clients.ServingAlphaClient.DomainMappings.Create(ctx, &v1alpha1.DomainMapping{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: host, | ||
Namespace: svc.Service.Namespace, | ||
}, | ||
Spec: v1alpha1.DomainMappingSpec{ | ||
Ref: duckv1.KReference{ | ||
Namespace: svc.Service.Namespace, | ||
Name: svc.Service.Name, | ||
}, | ||
}, | ||
}, metav1.CreateOptions{}) | ||
if err != nil { | ||
t.Fatalf("Create(DomainMapping) = %v, expected no error", err) | ||
} | ||
|
||
t.Cleanup(func() { | ||
clients.ServingAlphaClient.DomainMappings.Delete(ctx, dm.Name, metav1.DeleteOptions{}) | ||
}) | ||
|
||
// Wait for DomainMapping to go Ready. | ||
waitErr := wait.PollImmediate(test.PollInterval, 1*time.Minute, func() (bool, error) { | ||
state, err := clients.ServingAlphaClient.DomainMappings.Get(context.Background(), dm.Name, metav1.GetOptions{}) | ||
if err != nil { | ||
return true, err | ||
} | ||
|
||
return state.Status.IsReady(), nil | ||
}) | ||
if waitErr != nil { | ||
t.Fatalf("The DomainMapping %s was not marked as Ready: %v", dm.Name, waitErr) | ||
} | ||
|
||
// Should be able to access the test image text via the mapped domain. | ||
if err := shared.CheckDistribution(ctx, t, clients, &url.URL{Host: host, Scheme: "http"}, test.ConcurrentRequests, test.ConcurrentRequests, []string{test.HelloWorldText}); err != nil { | ||
t.Errorf("CheckDistribution=%v, expected no error", err) | ||
} | ||
} |
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 think we have moved away from this and are instead providing this method on the type itself, including a Generation check, like:
(this would also make the currently unused ReadyCondition constant used 😂 )
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.
ah, I copied this from
Route
but sure that makes sense, lemme update