Skip to content

Commit

Permalink
Reafctor IngressCRUD into adapter package
Browse files Browse the repository at this point in the history
  • Loading branch information
skmatti committed Apr 6, 2020
1 parent 7debbf9 commit d7cc07a
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 36 deletions.
3 changes: 2 additions & 1 deletion cmd/e2e-test/affinity_beta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/ingress-gce/pkg/annotations"
backendconfigbeta "k8s.io/ingress-gce/pkg/apis/backendconfig/v1beta1"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
"k8s.io/ingress-gce/pkg/fuzz/features"
)
Expand Down Expand Up @@ -79,7 +80,7 @@ func TestAffinityBeta(t *testing.T) {
ing := fuzz.NewIngressBuilder(s.Namespace, "ingress-1", "").
AddPath("test.com", "/", svcName, intstr.FromInt(80)).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("crud.Create(%#v) = %v, want nil", ing, err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/e2e-test/affinity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestAffinity(t *testing.T) {
ing := fuzz.NewIngressBuilder(s.Namespace, "ingress-1", "").
AddPath("test.com", "/", "service-1", intstr.FromInt(80)).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestILBSA(t *testing.T) {
AddPath("test.com", "/", "service-1", intstr.FromInt(80)).
ConfigureForILB().
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/e2e-test/app_protocols_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/ingress-gce/pkg/annotations"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
"k8s.io/ingress-gce/pkg/fuzz/features"
)
Expand Down Expand Up @@ -62,7 +63,7 @@ func TestAppProtocol(t *testing.T) {
DefaultBackend("service-1", intstr.FromString("https-port")).
AddPath("test.com", "/", "service-1", intstr.FromString("https-port")).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down Expand Up @@ -132,7 +133,7 @@ func TestAppProtocolTransition(t *testing.T) {
DefaultBackend("service-1", intstr.FromString("https-port")).
AddPath("test.com", "/", "service-1", intstr.FromString("https-port")).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/e2e-test/backend_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestBackendConfigNegatives(t *testing.T) {
testIng := fuzz.NewIngressBuilder(s.Namespace, "ingress-1", "").
AddPath("test.com", "/", "service-1", port80).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
testIng, err := crud.Create(testIng)
if err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
Expand Down
3 changes: 2 additions & 1 deletion cmd/e2e-test/basic_https_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
)

Expand Down Expand Up @@ -98,7 +99,7 @@ func TestBasicHTTPS(t *testing.T) {
}
t.Logf("Echo service created (%s/%s)", s.Namespace, "service-1")

crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/e2e-test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
"k8s.io/ingress-gce/pkg/fuzz/features"
"k8s.io/ingress-gce/pkg/utils/common"
Expand Down Expand Up @@ -78,7 +79,7 @@ func testBasicOS(t *testing.T, os e2e.OS) {
}
t.Logf("Echo service created (%s/%s)", s.Namespace, "service-1")

crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
tc.ing.Namespace = s.Namespace // namespace depends on sandbox
if _, err = crud.Create(tc.ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
Expand Down Expand Up @@ -128,7 +129,7 @@ func TestBasicStaticIP(t *testing.T) {
DefaultBackend("service-1", intstr.FromInt(80)).
AddStaticIP(addrName).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
testIng, err = crud.Create(testIng)
if err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
Expand Down Expand Up @@ -189,7 +190,7 @@ func TestEdge(t *testing.T) {
t.Fatalf("error creating echo service: %v", err)
}
t.Logf("Echo service created (%s/%s)", s.Namespace, "service-1")
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
tc.ing.Namespace = s.Namespace // namespace depends on sandbox
if _, err = crud.Create(tc.ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
Expand Down Expand Up @@ -264,7 +265,7 @@ func TestFrontendResourceDeletion(t *testing.T) {
AddPath(host, "/", svcName, port80).AddTLS([]string{}, cert.Name).Build()
ingKey := common.NamespacedName(ing)

crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("crud.Create(%s) = %v, want nil; Ingress: %v", ingKey, err, ing)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/e2e-test/cdn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestCDN(t *testing.T) {
ing := fuzz.NewIngressBuilder(s.Namespace, "ingress-1", "").
AddPath("test.com", "/", "service-1", intstr.FromInt(80)).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/e2e-test/draining_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestDraining(t *testing.T) {
ing := fuzz.NewIngressBuilder(s.Namespace, "ingress-1", "").
AddPath("test.com", "/", "service-1", intstr.FromInt(80)).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/e2e-test/finalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
"k8s.io/ingress-gce/pkg/utils/common"
)
Expand All @@ -45,7 +46,7 @@ func TestFinalizer(t *testing.T) {
}
t.Logf("Echo service created (%s/%s)", s.Namespace, svcName)

crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
ing.Namespace = s.Namespace
ingKey := common.NamespacedName(ing)
if _, err := crud.Create(ing); err != nil {
Expand Down Expand Up @@ -96,7 +97,7 @@ func TestFinalizerIngressClassChange(t *testing.T) {
}
t.Logf("Echo service created (%s/%s)", s.Namespace, svcName)

crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
ing.Namespace = s.Namespace
ingKey := common.NamespacedName(ing)
if _, err := crud.Create(ing); err != nil {
Expand Down Expand Up @@ -160,7 +161,7 @@ func TestFinalizerIngressesWithSharedResources(t *testing.T) {
}
t.Logf("Echo service created (%s/%s)", s.Namespace, svcName)

crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
ing.Namespace = s.Namespace
ingKey := common.NamespacedName(ing)
if _, err := crud.Create(ing); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/e2e-test/iap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestIAP(t *testing.T) {
ing := fuzz.NewIngressBuilder(s.Namespace, "ingress-1", "").
AddPath("test.com", "/", "service-1", intstr.FromInt(80)).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/e2e-test/security_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestSecurityPolicyEnable(t *testing.T) {
DefaultBackend("service-1", port80).
AddPath("test.com", "/", "service-1", port80).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
testIng, err = crud.Create(testIng)
if err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestSecurityPolicyTransition(t *testing.T) {
DefaultBackend("service-1", port80).
AddPath("test.com", "/", "service-1", port80).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
testIng, err = crud.Create(testIng)
if err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/e2e-test/timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestTimeout(t *testing.T) {
ing := fuzz.NewIngressBuilder(s.Namespace, "ingress-1", "").
AddPath("test.com", "/", "service-1", intstr.FromInt(80)).
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestILBCT(t *testing.T) {
AddPath("test.com", "/", "service-1", intstr.FromInt(80)).
ConfigureForILB().
Build()
crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/e2e-test/upgrade/basic_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
"k8s.io/ingress-gce/pkg/utils/common"
)
Expand All @@ -37,7 +38,7 @@ type BasicHTTP struct {
t *testing.T
s *e2e.Sandbox
framework *e2e.Framework
crud e2e.IngressCRUD
crud adapter.IngressCRUD
ing *v1beta1.Ingress
}

Expand Down Expand Up @@ -72,7 +73,7 @@ func (bh *BasicHTTP) PreUpgrade() error {
AddPath("foo.com", "/", svcName, port80).
Build()
ingKey := common.NamespacedName(bh.ing)
bh.crud = e2e.IngressCRUD{C: bh.framework.Clientset}
bh.crud = adapter.IngressCRUD{C: bh.framework.Clientset}
if _, err := bh.crud.Create(bh.ing); err != nil {
bh.t.Fatalf("error creating Ingress %s: %v", ingKey, err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/e2e-test/upgrade/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"k8s.io/api/networking/v1beta1"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
"k8s.io/ingress-gce/pkg/utils/common"
)
Expand All @@ -31,7 +32,7 @@ type Finalizer struct {
t *testing.T
s *e2e.Sandbox
framework *e2e.Framework
crud e2e.IngressCRUD
crud adapter.IngressCRUD
ing *v1beta1.Ingress
}

Expand Down Expand Up @@ -67,7 +68,7 @@ func (fr *Finalizer) PreUpgrade() error {
AddPath("foo.com", "/", svcName, port80).
Build()
ingKey := common.NamespacedName(ing)
fr.crud = e2e.IngressCRUD{C: fr.framework.Clientset}
fr.crud = adapter.IngressCRUD{C: fr.framework.Clientset}
if _, err := fr.crud.Create(ing); err != nil {
fr.t.Fatalf("error creating Ingress %s: %v", ingKey, err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/e2e-test/upgrade/v2frontendnamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"k8s.io/api/networking/v1beta1"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
"k8s.io/ingress-gce/pkg/utils/common"
)
Expand All @@ -31,7 +32,7 @@ type V2FrontendNamer struct {
t *testing.T
s *e2e.Sandbox
framework *e2e.Framework
crud e2e.IngressCRUD
crud adapter.IngressCRUD
ing *v1beta1.Ingress
}

Expand Down Expand Up @@ -67,7 +68,7 @@ func (vf *V2FrontendNamer) PreUpgrade() error {
SetIngressClass("gce").
Build()
ingKey := common.NamespacedName(vf.ing)
vf.crud = e2e.IngressCRUD{C: vf.framework.Clientset}
vf.crud = adapter.IngressCRUD{C: vf.framework.Clientset}

if _, err := vf.crud.Create(vf.ing); err != nil {
vf.t.Fatalf("Create(%s) = %v, want nil; Ingress: %v", ingKey, err, vf.ing)
Expand Down
3 changes: 2 additions & 1 deletion cmd/e2e-test/v2frontendnamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/ingress-gce/pkg/e2e"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/fuzz"
"k8s.io/ingress-gce/pkg/utils/common"
)
Expand Down Expand Up @@ -69,7 +70,7 @@ func TestV2FrontendNamer(t *testing.T) {
}
t.Logf("Echo service created (%s/%s)", s.Namespace, svcName)

crud := e2e.IngressCRUD{C: Framework.Clientset}
crud := adapter.IngressCRUD{C: Framework.Clientset}
var gclbs []*fuzz.GCLB
var updatedIngs []*v1beta1.Ingress

Expand Down
2 changes: 1 addition & 1 deletion pkg/e2e/legacy.go → pkg/e2e/adapter/ingress.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package e2e
package adapter

// Legacy conversion code for the old extensions v1beta1 API group.

Expand Down
2 changes: 1 addition & 1 deletion pkg/e2e/legacy_test.go → pkg/e2e/adapter/ingress_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package e2e
package adapter

import (
"reflect"
Expand Down
3 changes: 2 additions & 1 deletion pkg/e2e/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/ingress-gce/pkg/e2e/adapter"
"k8s.io/ingress-gce/pkg/utils"

"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta"
Expand Down Expand Up @@ -265,7 +266,7 @@ func DeleteSecret(s *Sandbox, name string) error {

// EnsureIngress creates a new Ingress or updates an existing one.
func EnsureIngress(s *Sandbox, ing *v1beta1.Ingress) (*v1beta1.Ingress, error) {
crud := &IngressCRUD{s.f.Clientset}
crud := &adapter.IngressCRUD{C: s.f.Clientset}
currentIng, err := crud.Get(ing.ObjectMeta.Namespace, ing.ObjectMeta.Name)
if currentIng == nil || err != nil {
return crud.Create(ing)
Expand Down
Loading

0 comments on commit d7cc07a

Please sign in to comment.