Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions e2e/e2e_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestCore_Deploy_Basic(t *testing.T) {
clean(t, name, Namespace)
}()

if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestCore_Deploy_Template(t *testing.T) {

// The default implementation responds with HTTP 200 and the string
// "testcore-deploy-template" for all requests.
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch(name)) {
t.Fatal("function did not update correctly")
}
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestCore_Update(t *testing.T) {
defer func() {
clean(t, name, Namespace)
}()
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}

Expand All @@ -198,7 +198,7 @@ func TestCore_Update(t *testing.T) {
if err := newCmd(t, "deploy").Run(); err != nil {
t.Fatal(err)
}
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch("UPDATED")) {
t.Fatal("function did not update correctly")
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestCore_Describe(t *testing.T) {
t.Fatalf("deploy error. %v", err)
}

if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}

Expand Down Expand Up @@ -308,7 +308,7 @@ func TestCore_Invoke(t *testing.T) {
defer func() {
clean(t, name, Namespace)
}()
if !waitFor(t, fmt.Sprintf("http://%s.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}

Expand All @@ -334,7 +334,7 @@ func TestCore_Delete(t *testing.T) {
defer func() {
clean(t, name, Namespace)
}()
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}

Expand Down
4 changes: 2 additions & 2 deletions e2e/e2e_matrix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestMatrix_Deploy(t *testing.T) {
}

// Ensure the Function comes up
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withWaitTimeout(timeout),
withTemplate(template)) {
t.Fatal("function did not deploy correctly")
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestMatrix_Remote(t *testing.T) {
}

// Ensure the Function comes up
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withWaitTimeout(timeout),
withTemplate(template)) {
t.Fatal("function did not deploy correctly")
Expand Down
18 changes: 9 additions & 9 deletions e2e/e2e_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestMetadata_Envs_Add(t *testing.T) {
defer func() {
clean(t, name, Namespace)
}()
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch("OK")) {
t.Fatal("handler failed")
}
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestMetadata_Envs_Remove(t *testing.T) {
defer func() {
clean(t, name, Namespace)
}()
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch("OK")) {
t.Fatal("handler failed")
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestMetadata_Envs_Remove(t *testing.T) {
if err := newCmd(t, "deploy").Run(); err != nil {
t.Fatal(err)
}
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch("OK")) {
t.Fatal("handler failed")
}
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestMetadata_Labels_Add(t *testing.T) {
defer func() {
clean(t, name, Namespace)
}()
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}

Expand Down Expand Up @@ -318,7 +318,7 @@ func TestMetadata_Labels_Remove(t *testing.T) {
defer func() {
clean(t, name, Namespace)
}()
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}

Expand Down Expand Up @@ -350,7 +350,7 @@ func TestMetadata_Labels_Remove(t *testing.T) {
if err := newCmd(t, "deploy").Run(); err != nil {
t.Fatal(err)
}
if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not redeploy correctly")
}

Expand Down Expand Up @@ -494,7 +494,7 @@ func Handle(w http.ResponseWriter, _ *http.Request) {
}()

// Verify the function has access to all volumes
if !waitFor(t, fmt.Sprintf("http://%s.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch("OK")) {
t.Fatal("function failed to access volumes correctly")
}
Expand Down Expand Up @@ -555,7 +555,7 @@ func Handle(w http.ResponseWriter, _ *http.Request) {
t.Fatal(err)
}

if !waitFor(t, fmt.Sprintf("http://%s.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch("OK")) {
t.Fatal("function failed after volume removal")
}
Expand Down Expand Up @@ -601,7 +601,7 @@ func TestMetadata_Subscriptions(t *testing.T) {
}
defer clean(t, subscriberName, Namespace)

subscriberURL := fmt.Sprintf("http://%s.%s.%s", subscriberName, Namespace, Domain)
subscriberURL := ksvcUrl(subscriberName)
if !waitFor(t, subscriberURL, withTemplate("cloudevents")) {
t.Fatal("subscriber not ready")
}
Expand Down
5 changes: 2 additions & 3 deletions e2e/e2e_podman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package e2e

import (
"fmt"
"testing"
)

Expand Down Expand Up @@ -32,7 +31,7 @@ func TestPodman_Pack(t *testing.T) {
clean(t, name, Namespace)
}()

if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}
}
Expand Down Expand Up @@ -61,7 +60,7 @@ func TestPodman_S2I(t *testing.T) {
clean(t, name, Namespace)
}()

if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}
}
Expand Down
8 changes: 4 additions & 4 deletions e2e/e2e_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestRemote_Deploy(t *testing.T) {
clean(t, name, Namespace)
}()

if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain)) {
if !waitFor(t, ksvcUrl(name)) {
t.Fatal("function did not deploy correctly")
}
}
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestRemote_Source(t *testing.T) {
clean(t, name, Namespace)
}()

if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch(name)) {
t.Fatal("function did not deploy correctly")
}
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestRemote_Ref(t *testing.T) {
clean(t, name, Namespace)
}()

if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch(name)) {
t.Fatal("function did not deploy correctly")
}
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestRemote_Dir(t *testing.T) {
clean(t, name, Namespace)
}()

if !waitFor(t, fmt.Sprintf("http://%v.%s.%s", name, Namespace, Domain),
if !waitFor(t, ksvcUrl(name),
withContentMatch(name)) {
t.Fatal("function did not deploy correctly")
}
Expand Down
20 changes: 20 additions & 0 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"strconv"
"strings"
"testing"
"text/template"
"time"

fn "knative.dev/func/pkg/functions"
Expand Down Expand Up @@ -1216,3 +1217,22 @@ func parseRunJSON(t *testing.T, cmd *exec.Cmd) string {
t.Cleanup(func() { stdoutWriter.Close() })
return address
}

func ksvcUrl(name string) string {
// TODO get `default-external-scheme` from the config in cluster
const ksvcDefaultExternalScheme = `http`
// TODO get `domain-template` from the config in cluster
Comment on lines +1222 to +1224
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we planning these TODOs in a subsequent PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I do not plan to do it soon. Even with this hardcoded value this is a lot better what what we had before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can mark it as good first issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep that sounds good

const ksvcDomainTemplate = `{{.Name}}-{{.Namespace}}-ksvc.{{.Domain}}`
t, err := template.New("").Parse(ksvcDomainTemplate)
if err != nil {
panic(err)
}
var buf bytes.Buffer
err = t.Execute(&buf, struct {
Name, Namespace, Domain string
}{name, Namespace, Domain})
if err != nil {
panic(err)
}
return ksvcDefaultExternalScheme + `://` + buf.String()
}
3 changes: 3 additions & 0 deletions hack/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ networking() {
--type merge \
--patch '{"data":{"ingress-class":"contour.ingress.networking.knative.dev"}}'

echo "Patch domain-template"
$KUBECTL patch -n knative-serving cm/config-network --patch '{"data":{"domain-template":"{{.Name}}-{{.Namespace}}-ksvc.{{.Domain}}"}}'

echo "Patching contour to prefer duals-tack"
kubectl patch -n contour-external svc/envoy --type merge --patch '{"spec":{"ipFamilyPolicy":"PreferDualStack"}}'

Expand Down
Loading