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 upgrade test for new defaults #6165

Merged
merged 2 commits into from
Dec 5, 2019
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
28 changes: 26 additions & 2 deletions test/upgrade/service_postupgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/ptr"
ptest "knative.dev/pkg/test"
"knative.dev/serving/pkg/apis/serving/v1"
serviceresourcenames "knative.dev/serving/pkg/reconciler/service/resources/names"
"knative.dev/serving/test"
"knative.dev/serving/test/e2e"
v1test "knative.dev/serving/test/v1"
v1a1test "knative.dev/serving/test/v1alpha1"
)

Expand All @@ -39,11 +42,32 @@ func TestRunLatestServicePostUpgradeFromScaleToZero(t *testing.T) {
updateService(scaleToZeroServiceName, t)
}

// TestBYORevisionPostUpgrade attempts to update the RouteSpec of a Service using BYO Revision name. This
// test is meant to catch new defaults that break the immutability of BYO Revision name.
func TestBYORevisionPostUpgrade(t *testing.T) {
t.Parallel()
clients := e2e.Setup(t)
names := test.ResourceNames{
Service: byoServiceName,
}

if _, err := v1test.UpdateServiceRouteSpec(t, clients, names, v1.RouteSpec{
Traffic: []v1.TrafficTarget{{
Tag: "example-tag",
RevisionName: byoRevName,
Percent: ptr.Int64(100),
}},
}); err != nil {
t.Fatalf("Failed to update Service: %v", err)
}
}

func updateService(serviceName string, t *testing.T) {
t.Helper()
clients := e2e.Setup(t)
var names test.ResourceNames
names.Service = serviceName
names := test.ResourceNames{
Service: serviceName,
}

t.Logf("Getting service %q", names.Service)
svc, err := clients.ServingAlphaClient.Services.Get(names.Service, metav1.GetOptions{})
Expand Down
21 changes: 21 additions & 0 deletions test/upgrade/service_preupgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import (
"testing"

"knative.dev/serving/pkg/apis/autoscaling"
"knative.dev/serving/pkg/apis/serving/v1"
revisionresourcenames "knative.dev/serving/pkg/reconciler/revision/resources/names"
rtesting "knative.dev/serving/pkg/testing/v1alpha1"
"knative.dev/serving/test"
"knative.dev/serving/test/e2e"
v1test "knative.dev/serving/test/v1"
v1a1test "knative.dev/serving/test/v1alpha1"
)

Expand Down Expand Up @@ -72,3 +74,22 @@ func TestRunLatestServicePreUpgradeAndScaleToZero(t *testing.T) {
t.Fatalf("Could not scale to zero: %v", err)
}
}

// TestBYORevisionUpgrade creates a Service that uses the BYO Revision name functionality. This test
// is meant to catch new defaults that break bring your own revision name immutability.
func TestBYORevisionPreUpgrade(t *testing.T) {
t.Parallel()
clients := e2e.Setup(t)
names := test.ResourceNames{
Service: byoServiceName,
Image: test.PizzaPlanet1,
}

_, err := v1test.CreateServiceReady(t, clients, &names,
func(svc *v1.Service) {
svc.Spec.ConfigurationSpec.Template.Name = byoRevName
})
if err != nil {
t.Fatalf("Failed to create Service: %v", err)
}
}
2 changes: 2 additions & 0 deletions test/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
// multiple "go test" invocations.
serviceName = "pizzaplanet-upgrade-service"
scaleToZeroServiceName = "scale-to-zero-upgrade-service"
byoServiceName = "byo-revision-name-upgrade-test"
byoRevName = byoServiceName + "-" + "rev1"
)

// Shamelessly cribbed from conformance/service_test.
Expand Down