Improve resource usage in nginx controller
This commit is contained in:
parent
1a68536e29
commit
cd288b9993
17 changed files with 388 additions and 794 deletions
|
|
@ -18,7 +18,6 @@ package status
|
|||
|
||||
import (
|
||||
"os"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -35,7 +34,7 @@ import (
|
|||
"k8s.io/ingress/core/pkg/task"
|
||||
)
|
||||
|
||||
func buildLoadBalancerIngressByIP() loadBalancerIngressByIP {
|
||||
func buildLoadBalancerIngressByIP() []apiv1.LoadBalancerIngress {
|
||||
return []apiv1.LoadBalancerIngress{
|
||||
{
|
||||
IP: "10.0.0.1",
|
||||
|
|
@ -232,6 +231,7 @@ func buildIngressListener() store.IngressLister {
|
|||
},
|
||||
},
|
||||
})
|
||||
|
||||
return store.IngressLister{Store: s}
|
||||
}
|
||||
|
||||
|
|
@ -376,7 +376,6 @@ func TestRunningAddresessWithPods(t *testing.T) {
|
|||
func TestUpdateStatus(t *testing.T) {
|
||||
fk := buildStatusSync()
|
||||
newIPs := buildLoadBalancerIngressByIP()
|
||||
sort.Sort(loadBalancerIngressByIP(newIPs))
|
||||
fk.updateStatus(newIPs)
|
||||
|
||||
fooIngress1, err1 := fk.Client.Extensions().Ingresses(apiv1.NamespaceDefault).Get("foo_ingress_1", metav1.GetOptions{})
|
||||
|
|
@ -460,61 +459,3 @@ func TestIngressSliceEqual(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadBalancerIngressByIPLen(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
ips loadBalancerIngressByIP
|
||||
el int
|
||||
}{
|
||||
{[]apiv1.LoadBalancerIngress{}, 0},
|
||||
{buildLoadBalancerIngressByIP(), 4},
|
||||
{nil, 0},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
r := fooTest.ips.Len()
|
||||
if r != fooTest.el {
|
||||
t.Errorf("returned %v but expected %v ", r, fooTest.el)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadBalancerIngressByIPSwap(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
ips loadBalancerIngressByIP
|
||||
i int
|
||||
j int
|
||||
}{
|
||||
{buildLoadBalancerIngressByIP(), 0, 1},
|
||||
{buildLoadBalancerIngressByIP(), 2, 1},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
fooi := fooTest.ips[fooTest.i]
|
||||
fooj := fooTest.ips[fooTest.j]
|
||||
fooTest.ips.Swap(fooTest.i, fooTest.j)
|
||||
if fooi.IP != fooTest.ips[fooTest.j].IP ||
|
||||
fooj.IP != fooTest.ips[fooTest.i].IP {
|
||||
t.Errorf("failed to swap for loadBalancerIngressByIP")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadBalancerIngressByIPLess(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
ips loadBalancerIngressByIP
|
||||
i int
|
||||
j int
|
||||
er bool
|
||||
}{
|
||||
{buildLoadBalancerIngressByIP(), 0, 1, true},
|
||||
{buildLoadBalancerIngressByIP(), 2, 1, false},
|
||||
}
|
||||
|
||||
for _, fooTest := range fooTests {
|
||||
r := fooTest.ips.Less(fooTest.i, fooTest.j)
|
||||
if r != fooTest.er {
|
||||
t.Errorf("returned %v but expected %v ", r, fooTest.er)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue