forked from knative/serving
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Egress traffic e2e test (knative#3742)
* Egress traffic e2e test * Error logging fix * Build tag and license added * Istio template update * Deprecated status Domain replaced with URL. Istio-lean template updated * Test method switched to v1alpha1 pkg
- Loading branch information
1 parent
084ea91
commit 53d92be
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// +build e2e | ||
|
||
/* | ||
Copyright 2019 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 e2e | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/knative/serving/test" | ||
v1a1test "github.com/knative/serving/test/v1alpha1" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
const ( | ||
targetHostEnvName = "TARGET_HOST" | ||
targetHostDomain = "www.google.com" | ||
) | ||
|
||
func TestEgressTraffic(t *testing.T) { | ||
t.Parallel() | ||
clients := Setup(t) | ||
|
||
names := test.ResourceNames{ | ||
Service: test.ObjectNameForTest(t), | ||
Image: "httpproxy", | ||
} | ||
envVars := []corev1.EnvVar{{ | ||
Name: targetHostEnvName, | ||
Value: targetHostDomain, | ||
}} | ||
defer test.TearDown(clients, names) | ||
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) }) | ||
|
||
service, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, &v1a1test.Options{EnvVars: envVars}) | ||
if err != nil { | ||
t.Fatalf("Failed to create a service: %v", err) | ||
} | ||
if service.Route.Status.URL == nil { | ||
t.Fatalf("Can't get internal request domain: service.Route.Status.URL is nil") | ||
} | ||
t.Log(service.Route.Status.URL.Host) | ||
response, err := sendRequest(t, clients, test.ServingFlags.ResolvableDomain, service.Route.Status.URL.Host) | ||
if err != nil { | ||
t.Fatalf("Failed to send request to httpproxy: %v", err) | ||
} | ||
if got, want := response.StatusCode, http.StatusOK; got != want { | ||
t.Fatalf("%v response StatusCode = %v, want %v", targetHostDomain, got, want) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters