Skip to content

Commit

Permalink
update uts
Browse files Browse the repository at this point in the history
  • Loading branch information
vagababov committed Dec 7, 2019
1 parent 3f05930 commit 656fdb5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 38 deletions.
3 changes: 0 additions & 3 deletions pkg/reconciler/ingress/resources/virtual_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func makeVirtualServiceSpec(ia *v1alpha1.Ingress, gateways map[v1alpha1.IngressV
}

for _, rule := range ia.Spec.Rules {
fmt.Printf("### %s => rule: %#v\n", ia.Name, rule)
for _, p := range rule.HTTP.Paths {
hosts := hosts.Intersection(sets.NewString(rule.Hosts...))
if hosts.Len() != 0 {
Expand All @@ -185,10 +184,8 @@ func makeVirtualServiceSpec(ia *v1alpha1.Ingress, gateways map[v1alpha1.IngressV
func makeVirtualServiceRoute(hosts sets.String, http *v1alpha1.HTTPIngressPath, gateways map[v1alpha1.IngressVisibility]sets.String, visibility v1alpha1.IngressVisibility) *istiov1alpha3.HTTPRoute {
matches := []*istiov1alpha3.HTTPMatchRequest{}
clusterDomainName := network.GetClusterDomainName()
fmt.Println("#### ===== ")
for _, host := range hosts.List() {
g := gateways[visibility]
fmt.Printf("### host: %s, gw: %+v\n", host, g)
if strings.HasSuffix(host, clusterDomainName) && len(gateways[v1alpha1.IngressVisibilityClusterLocal]) > 0 {
// For local hostname, always use private gateway
g = gateways[v1alpha1.IngressVisibilityClusterLocal]
Expand Down
3 changes: 0 additions & 3 deletions pkg/reconciler/route/resources/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package resources

import (
"context"
"fmt"
"sort"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -97,7 +96,6 @@ func MakeIngressSpec(
}
// Sort the names to give things a deterministic ordering.
sort.Strings(names)
fmt.Printf("### Names: %+v\n", names)

// The routes are matching rule based on domain name to traffic split targets.
rules := make([]v1alpha1.IngressRule, 0, len(names))
Expand All @@ -106,7 +104,6 @@ func MakeIngressSpec(
if err != nil {
return v1alpha1.IngressSpec{}, err
}
fmt.Printf("### svcDomain: %s\n", serviceDomain)

isClusterLocal := clusterLocalServices.Has(serviceDomain)

Expand Down
70 changes: 43 additions & 27 deletions pkg/reconciler/route/resources/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,36 +381,52 @@ func TestGetDesiredServiceNames(t *testing.T) {
traffic RouteOption
want sets.String
wantErr bool
}{
{
name: "no traffic defined",
},
{
name: "only default traffic",
traffic: WithSpecTraffic(v1alpha1.TrafficTarget{TrafficTarget: v1.TrafficTarget{}}),
want: sets.NewString("myroute"),
}{{
name: "no traffic defined",
want: sets.NewString("myroute"),
}, {
name: "only default traffic",
traffic: WithSpecTraffic(v1alpha1.TrafficTarget{TrafficTarget: v1.TrafficTarget{}}),
want: sets.NewString("myroute"),
}, {
name: "traffic targets with default and tags",
traffic: WithSpecTraffic(v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "hello",
},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "hello",
},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "bye",
},
},
{
name: "traffic targets with tag",
traffic: WithSpecTraffic(v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "hello",
},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "hello",
},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "bye",
},
),
want: sets.NewString("myroute", "hello-myroute", "bye-myroute"),
}, {
name: "traffic targets with NO default and tags",
traffic: WithSpecTraffic(v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "hello",
},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "hello",
},
}, v1alpha1.TrafficTarget{
TrafficTarget: v1.TrafficTarget{
Tag: "bye",
},
),
want: sets.NewString("myroute", "hello-myroute", "bye-myroute"),
},
}
),
want: sets.NewString("myroute", "hello-myroute", "bye-myroute"),
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := testConfig()
Expand Down
5 changes: 0 additions & 5 deletions pkg/reconciler/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ package route

import (
"context"
"fmt"
"strings"

"github.com/davecgh/go-spew/spew"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
Expand Down Expand Up @@ -197,7 +195,6 @@ func (c *Reconciler) reconcile(ctx context.Context, r *v1alpha1.Route) error {
if err != nil {
return err
}
fmt.Printf("#### ServiceNames:\n%s\n", spew.Sdump(serviceNames))

if err := c.updateRouteStatusURL(ctx, r, serviceNames.clusterLocal()); err != nil {
return err
Expand Down Expand Up @@ -243,7 +240,6 @@ func (c *Reconciler) reconcile(ctx context.Context, r *v1alpha1.Route) error {
}

// Reconcile ingress and its children resources.
fmt.Printf("### %s => %s\n", r.Name, spew.Sdump(clusterLocalServiceNames))
ingress, err := c.reconcileIngressResources(ctx, r, traffic, tls, clusterLocalServiceNames, ingressClassForRoute(ctx, r))
if err != nil {
return err
Expand Down Expand Up @@ -480,7 +476,6 @@ func (c *Reconciler) getServiceNames(ctx context.Context, route *v1alpha1.Route)

// Populate desired service name sets
desiredServiceNames, err := resources.GetDesiredServiceNames(ctx, route)
fmt.Printf("### Desired service names: %s\n", spew.Sdump(desiredServiceNames))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 656fdb5

Please sign in to comment.