Skip to content
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 option to run all e2e tests with different http and https settings #5157

Merged
merged 3 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ these flags:
- [`--tag`](#using-a-docker-tag)
- [`--ingressendpoint`](#using-a-custom-ingress-endpoint)
- [`--resolvabledomain`](#using-a-resolvable-domain)
- [`--https`](#using-https)

### Overridding docker repo

Expand Down Expand Up @@ -226,3 +227,7 @@ the header.
If you have configured your cluster to use a resolvable domain, you can use the
`--resolvabledomain` flag to indicate that the test should make requests
directly against `Route.Status.Domain` and does not need to spoof the `Host`.

### Using https

You can use the `--https` flag to have all tests run with https.
3 changes: 2 additions & 1 deletion test/conformance/api/v1alpha1/blue_green_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func TestBlueGreenRoute(t *testing.T) {

// Setup Initial Service
t.Log("Creating a new Service in runLatest")
objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names)
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */)
if err != nil {
t.Fatalf("Failed to create initial Service: %v: %v", names.Service, err)
}
Expand Down
4 changes: 3 additions & 1 deletion test/conformance/api/v1alpha1/generatename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func TestServiceGenerateName(t *testing.T) {

// Create the service using the generate name field. If the service does not become ready this will fail.
t.Logf("Creating new service with generateName %s", generateName)
resources, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, setServiceGenerateName(generateName))
resources, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
setServiceGenerateName(generateName))
if err != nil {
t.Fatalf("Failed to create service with generateName %s: %v", generateName, err)
}
Expand Down
4 changes: 3 additions & 1 deletion test/conformance/api/v1alpha1/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func TestCustomResourcesLimits(t *testing.T) {
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })
defer test.TearDown(clients, names)

objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, v1a1opts.WithResourceRequirements(resources))
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
v1a1opts.WithResourceRequirements(resources))
if err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}
Expand Down
13 changes: 9 additions & 4 deletions test/conformance/api/v1alpha1/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func TestRunLatestService(t *testing.T) {
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })

// Setup initial Service
objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names)
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */)
if err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}
Expand Down Expand Up @@ -196,7 +197,9 @@ func TestRunLatestServiceBYOName(t *testing.T) {
revName := names.Service + "-byoname"

// Setup initial Service
objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, func(svc *v1alpha1.Service) {
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
func(svc *v1alpha1.Service) {
svc.Spec.ConfigurationSpec.GetTemplate().Name = revName
})
if err != nil {
Expand Down Expand Up @@ -265,7 +268,8 @@ func TestReleaseService(t *testing.T) {
)

// Setup initial Service
objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names)
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */)
if err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}
Expand Down Expand Up @@ -529,7 +533,8 @@ func TestAnnotationPropagation(t *testing.T) {
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })

// Setup initial Service
objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names)
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */)
if err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}
Expand Down
4 changes: 3 additions & 1 deletion test/conformance/api/v1alpha1/single_threaded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ func TestSingleConcurrency(t *testing.T) {
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })
defer test.TearDown(clients, names)

objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, v1a1opts.WithContainerConcurrency(1))
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
v1a1opts.WithContainerConcurrency(1))
if err != nil {
t.Fatalf("Failed to create Service: %v", err)
}
Expand Down
20 changes: 15 additions & 5 deletions test/conformance/api/v1alpha1/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ func TestConfigMapVolume(t *testing.T) {
})

// Setup initial Service
if _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, withVolume, withOptionalBadVolume); err != nil {
if _, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
withVolume, withOptionalBadVolume); err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}

Expand Down Expand Up @@ -162,7 +164,9 @@ func TestProjectedConfigMapVolume(t *testing.T) {
})

// Setup initial Service
if _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, withVolume); err != nil {
if _, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
withVolume); err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}

Expand Down Expand Up @@ -228,7 +232,9 @@ func TestSecretVolume(t *testing.T) {
})

// Setup initial Service
if _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, withVolume, withOptionalBadVolume); err != nil {
if _, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
withVolume, withOptionalBadVolume); err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}

Expand Down Expand Up @@ -298,7 +304,9 @@ func TestProjectedSecretVolume(t *testing.T) {
}

// Setup initial Service
if _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, withVolume, withSubpath); err != nil {
if _, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
withVolume, withSubpath); err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}

Expand Down Expand Up @@ -395,7 +403,9 @@ func TestProjectedComplex(t *testing.T) {
})

// Setup initial Service
if _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, withVolume); err != nil {
if _, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
withVolume); err != nil {
t.Fatalf("Failed to create initial Service %v: %v", names.Service, err)
}

Expand Down
4 changes: 3 additions & 1 deletion test/conformance/runtime/readiness_probe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func TestProbeRuntime(t *testing.T) {
defer test.TearDown(clients, names)

t.Log("Creating a new Service")
_, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, v1a1opts.WithReadinessProbe(
_, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
v1a1opts.WithReadinessProbe(
&corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Expand Down
4 changes: 3 additions & 1 deletion test/conformance/runtime/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func fetchRuntimeInfo(
svc.Spec.Template.Spec.Containers[0].ImagePullPolicy = "Always"
})

objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, names, serviceOpts...)
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
serviceOpts...)
if err != nil {
return nil, nil, err
}
Expand Down
14 changes: 14 additions & 0 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ CERT_MANAGER_VERSION="0.9.1"
ISTIO_VERSION=""
GLOO_VERSION=""

HTTPS=0

# Current YAMLs used to install Knative Serving.
INSTALL_RELEASE_YAML=""
INSTALL_MONITORING_YAML=""
Expand Down Expand Up @@ -68,6 +70,10 @@ function parse_flags() {
readonly MESH=0
return 1
;;
--https)
readonly HTTPS=1
return 1
;;
--install-monitoring)
readonly INSTALL_MONITORING=1
return 1
Expand Down Expand Up @@ -290,6 +296,14 @@ function use_resolvable_domain() {
echo "false"
}

# Check if we should use --https.
function use_https() {
if (( HTTPS )); then
echo "--https"
else
echo ""
fi
}

# Uninstalls Knative Serving from the current cluster.
function knative_teardown() {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ go_test_e2e -timeout=30m \
./test/conformance/... \
./test/e2e \
${parallelism} \
"--resolvabledomain=$(use_resolvable_domain)" || failed=1
"--resolvabledomain=$(use_resolvable_domain)" "$(use_https)" || failed=1

# Run scale tests.
go_test_e2e -timeout=10m \
Expand All @@ -63,7 +63,7 @@ go_test_e2e -timeout=10m \
if [[ -n "${ISTIO_VERSION}" ]]; then
go_test_e2e -timeout=10m \
./test/e2e/istio \
"--resolvabledomain=$(use_resolvable_domain)" || failed=1
"--resolvabledomain=$(use_resolvable_domain)" "$(use_https)" || failed=1
fi

# Dump cluster state in case of failure
Expand Down
8 changes: 4 additions & 4 deletions test/e2e-upgrade-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,29 @@ TIMEOUT=10m
header "Running preupgrade tests"

go_test_e2e -tags=preupgrade -timeout=${TIMEOUT} ./test/upgrade \
--resolvabledomain=$(use_resolvable_domain) || fail_test
--resolvabledomain=$(use_resolvable_domain) "$(use_https)" || fail_test

header "Starting prober test"

# Remove this in case we failed to clean it up in an earlier test.
rm -f /tmp/prober-signal

go_test_e2e -tags=probe -timeout=${TIMEOUT} ./test/upgrade \
--resolvabledomain=$(use_resolvable_domain) &
--resolvabledomain=$(use_resolvable_domain) "$(use_https)" &
PROBER_PID=$!
echo "Prober PID is ${PROBER_PID}"

install_head

header "Running postupgrade tests"
go_test_e2e -tags=postupgrade -timeout=${TIMEOUT} ./test/upgrade \
--resolvabledomain=$(use_resolvable_domain) || fail_test
--resolvabledomain=$(use_resolvable_domain) "$(use_https)" || fail_test

install_latest_release

header "Running postdowngrade tests"
go_test_e2e -tags=postdowngrade -timeout=${TIMEOUT} ./test/upgrade \
--resolvabledomain=$(use_resolvable_domain) || fail_test
--resolvabledomain=$(use_resolvable_domain) "$(use_https)" || fail_test

# The prober is blocking on /tmp/prober-signal to know when it should exit.
#
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/activator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ func TestActivatorOverload(t *testing.T) {
t.Log("Creating a service with run latest configuration.")
// Create a service with concurrency 1 that sleeps for N ms.
// Limit its maxScale to 10 containers, wait for the service to scale down and hit it with concurrent requests.
resources, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, func(service *v1alpha1.Service) {
resources, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
func(service *v1alpha1.Service) {
service.Spec.ConfigurationSpec.Template.Spec.ContainerConcurrency = ptr.Int64(1)
service.Spec.ConfigurationSpec.Template.Annotations = map[string]string{"autoscaling.knative.dev/maxScale": "10"}
})
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ func setup(t *testing.T, class, metric string, target float64, targetUtilization
Image: "autoscale",
}
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })
resources, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
resources, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
append(fopts, rtesting.WithConfigAnnotations(map[string]string{
autoscaling.ClassAnnotationKey: class,
autoscaling.MetricAnnotationKey: metric,
Expand Down
8 changes: 6 additions & 2 deletions test/e2e/destroypod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ func TestDestroyPodTimely(t *testing.T) {
defer test.TearDown(clients, names)
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })

objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, v1a1opts.WithRevisionTimeoutSeconds(int64(revisionTimeout.Seconds())))
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
v1a1opts.WithRevisionTimeoutSeconds(int64(revisionTimeout.Seconds())))
if err != nil {
t.Fatalf("Failed to create a service: %v", err)
}
Expand Down Expand Up @@ -229,7 +231,9 @@ func TestDestroyPodWithRequests(t *testing.T) {
defer test.TearDown(clients, names)
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })

objects, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, v1a1opts.WithRevisionTimeoutSeconds(int64(revisionTimeout.Seconds())))
objects, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
v1a1opts.WithRevisionTimeoutSeconds(int64(revisionTimeout.Seconds())))
if err != nil {
t.Fatalf("Failed to create a service: %v", err)
}
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/egress_traffic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func TestEgressTraffic(t *testing.T) {
defer test.TearDown(clients, names)
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })

service, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, v1a1opts.WithEnv(envVars...))
service, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
v1a1opts.WithEnv(envVars...))
if err != nil {
t.Fatalf("Failed to create a service: %v", err)
}
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ func testGRPC(t *testing.T, f grpcTest, fopts ...rtesting.ServiceOption) {

test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })
defer test.TearDown(clients, names)
resources, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, fopts...)
resources, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
fopts...)
if err != nil {
t.Fatalf("Failed to create initial Service: %v: %v", names.Service, err)
}
Expand Down
27 changes: 23 additions & 4 deletions test/e2e/helloworld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,41 @@ func TestHelloWorld(t *testing.T) {
Image: "helloworld",
}

if test.ServingFlags.Https {
// Save the current Gateway to restore it after the test
oldGateway, err := clients.SharedClient.NetworkingV1alpha3().Gateways(v1a1test.Namespace).Get(v1a1test.GatewayName, metav1.GetOptions{})
if err != nil {
t.Fatalf("Failed to get Gateway %s/%s", v1a1test.Namespace, v1a1test.GatewayName)
}
test.CleanupOnInterrupt(func () { v1a1test.RestoreGateway(t, clients, *oldGateway) })
defer v1a1test.RestoreGateway(t, clients, *oldGateway)
}
test.CleanupOnInterrupt(func() { test.TearDown(clients, names) })
defer test.TearDown(clients, names)

t.Log("Creating a new Service")
resources, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names)
resources, httpsTransportOption, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names, test.ServingFlags.Https)
if err != nil {
t.Fatalf("Failed to create initial Service: %v: %v", names.Service, err)
}

url := resources.Route.Status.URL.URL()
if _, err = pkgTest.WaitForEndpointState(
var opt interface{}
if test.ServingFlags.Https {
url.Scheme = "https"
if httpsTransportOption == nil {
t.Fatalf("Https transport option is nil")
}
opt = *httpsTransportOption
}
if _, err := pkgTest.WaitForEndpointState(
clients.KubeClient,
t.Logf,
url,
v1a1test.RetryingRouteInconsistency(pkgTest.MatchesAllOf(pkgTest.IsStatusOK, pkgTest.MatchesBody(test.HelloWorldText))),
"HelloWorldServesText",
test.ServingFlags.ResolvableDomain); err != nil {
test.ServingFlags.ResolvableDomain,
opt); err != nil {
t.Fatalf("The endpoint %s for Route %s didn't serve the expected text %q: %v", url, names.Route, test.HelloWorldText, err)
}

Expand Down Expand Up @@ -99,7 +117,8 @@ func TestQueueSideCarResourceLimit(t *testing.T) {
defer test.TearDown(clients, names)

t.Log("Creating a new Service")
resources, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
resources, _, err := v1a1test.CreateRunLatestServiceReady(t, clients, &names,
false /* https TODO(taragu) turn this on after helloworld test running with https */,
v1a1opts.WithResourceRequirements(corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceName("cpu"): resource.MustParse("50m"),
Expand Down
Loading