Skip to content

Commit

Permalink
Egress traffic e2e test (knative#3742)
Browse files Browse the repository at this point in the history
* 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
tzununbekov authored and knative-prow-robot committed Jul 8, 2019
1 parent 084ea91 commit 53d92be
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
66 changes: 66 additions & 0 deletions test/e2e/egress_traffic_test.go
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)
}
}
8 changes: 8 additions & 0 deletions third_party/istio-1.1.3/download-istio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ helm template --namespace=istio-system \
--set gateways.istio-ingressgateway.enabled=false \
--set gateways.istio-egressgateway.enabled=false \
--set gateways.istio-ilbgateway.enabled=false \
--set global.outboundTrafficPolicy.mode=ALLOW_ANY \
--set pilot.env.PILOT_ENABLE_FALLTHROUGH_ROUTE=1 \
install/kubernetes/helm/istio \
-f install/kubernetes/helm/istio/example-values/values-istio-gateways.yaml \
| sed -e "s/custom-gateway/cluster-local-gateway/g" -e "s/customgateway/clusterlocalgateway/g" \
Expand All @@ -42,6 +44,9 @@ helm template --namespace=istio-system \
--set global.proxy.autoInject=disabled \
--set global.disablePolicyChecks=true \
--set prometheus.enabled=false \
`# Enable egress traffic.` \
--set global.outboundTrafficPolicy.mode=ALLOW_ANY \
--set pilot.env.PILOT_ENABLE_FALLTHROUGH_ROUTE=1 \
`# Disable mixer prometheus adapter to remove istio default metrics.` \
--set mixer.adapters.prometheus.enabled=false \
`# Disable mixer policy check, since in our template we set no policy.` \
Expand Down Expand Up @@ -89,6 +94,9 @@ helm template --namespace=istio-system \
--set gateways.istio-ingressgateway.sds.enabled=true \
`# Set pilot trace sampling to 100%` \
--set pilot.traceSampling=100 \
`# Enable egress traffic.` \
--set global.outboundTrafficPolicy.mode=ALLOW_ANY \
--set pilot.env.PILOT_ENABLE_FALLTHROUGH_ROUTE=1 \
install/kubernetes/helm/istio \
`# Removing trailing whitespaces to make automation happy` \
| sed 's/[ \t]*$//' \
Expand Down
2 changes: 2 additions & 0 deletions third_party/istio-1.1.3/istio-lean.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ spec:
fieldPath: metadata.namespace
- name: GODEBUG
value: "gctrace=1"
- name: PILOT_ENABLE_FALLTHROUGH_ROUTE
value: "1"
- name: PILOT_PUSH_THROTTLE
value: "100"
- name: PILOT_TRACE_SAMPLING
Expand Down
2 changes: 2 additions & 0 deletions third_party/istio-1.1.3/istio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,8 @@ spec:
fieldPath: metadata.namespace
- name: GODEBUG
value: "gctrace=1"
- name: PILOT_ENABLE_FALLTHROUGH_ROUTE
value: "1"
- name: PILOT_PUSH_THROTTLE
value: "100"
- name: PILOT_TRACE_SAMPLING
Expand Down

0 comments on commit 53d92be

Please sign in to comment.