Updating instances interface to accept all named ports at once
This commit is contained in:
parent
abc8b9de51
commit
3dcdc2600e
11 changed files with 135 additions and 93 deletions
|
|
@ -80,7 +80,7 @@ func TestBackendPoolAdd(t *testing.T) {
|
|||
// Add a backend for a port, then re-add the same port and
|
||||
// make sure it corrects a broken link from the backend to
|
||||
// the instance group.
|
||||
err := pool.Add(nodePort, nil)
|
||||
err := pool.Ensure([]ServicePort{nodePort}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Did not find expect error when adding a nodeport: %v, err: %v", nodePort, err)
|
||||
}
|
||||
|
|
@ -95,10 +95,11 @@ func TestBackendPoolAdd(t *testing.T) {
|
|||
t.Fatalf("Backend %v has wrong port %v, expected %v", be.Name, be.Port, nodePort)
|
||||
}
|
||||
|
||||
// Check that the instance group has the new port
|
||||
// Check that the instance group has the new port.
|
||||
ig, err := fakeIGs.GetInstanceGroup(namer.IGName(), defaultZone)
|
||||
var found bool
|
||||
for _, port := range fakeIGs.Ports {
|
||||
if port == nodePort.Port {
|
||||
for _, port := range ig.NamedPorts {
|
||||
if port.Port == nodePort.Port {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
|
@ -143,7 +144,7 @@ func TestHealthCheckMigration(t *testing.T) {
|
|||
hcp.CreateHttpHealthCheck(legacyHC)
|
||||
|
||||
// Add the service port to the backend pool
|
||||
pool.Add(p, nil)
|
||||
pool.Ensure([]ServicePort{p}, nil)
|
||||
|
||||
// Assert the proper health check was created
|
||||
hc, _ := pool.healthChecker.Get(p.Port)
|
||||
|
|
@ -168,7 +169,7 @@ func TestBackendPoolUpdate(t *testing.T) {
|
|||
namer := utils.Namer{}
|
||||
|
||||
p := ServicePort{Port: 3000, Protocol: utils.ProtocolHTTP}
|
||||
pool.Add(p, nil)
|
||||
pool.Ensure([]ServicePort{p}, nil)
|
||||
beName := namer.BeName(p.Port)
|
||||
|
||||
be, err := f.GetGlobalBackendService(beName)
|
||||
|
|
@ -188,7 +189,7 @@ func TestBackendPoolUpdate(t *testing.T) {
|
|||
|
||||
// Update service port to encrypted
|
||||
p.Protocol = utils.ProtocolHTTPS
|
||||
pool.Sync([]ServicePort{p}, nil)
|
||||
pool.Ensure([]ServicePort{p}, nil)
|
||||
|
||||
be, err = f.GetGlobalBackendService(beName)
|
||||
if err != nil {
|
||||
|
|
@ -214,7 +215,7 @@ func TestBackendPoolChaosMonkey(t *testing.T) {
|
|||
namer := utils.Namer{}
|
||||
|
||||
nodePort := ServicePort{Port: 8080, Protocol: utils.ProtocolHTTP}
|
||||
pool.Add(nodePort, nil)
|
||||
pool.Ensure([]ServicePort{nodePort}, nil)
|
||||
beName := namer.BeName(nodePort.Port)
|
||||
|
||||
be, _ := f.GetGlobalBackendService(beName)
|
||||
|
|
@ -227,7 +228,7 @@ func TestBackendPoolChaosMonkey(t *testing.T) {
|
|||
f.calls = []int{}
|
||||
f.UpdateGlobalBackendService(be)
|
||||
|
||||
pool.Add(nodePort, nil)
|
||||
pool.Ensure([]ServicePort{nodePort}, nil)
|
||||
for _, call := range f.calls {
|
||||
if call == utils.Create {
|
||||
t.Fatalf("Unexpected create for existing backend service")
|
||||
|
|
@ -260,10 +261,10 @@ func TestBackendPoolSync(t *testing.T) {
|
|||
f := NewFakeBackendServices(noOpErrFunc)
|
||||
fakeIGs := instances.NewFakeInstanceGroups(sets.NewString())
|
||||
pool, _ := newTestJig(f, fakeIGs, true)
|
||||
pool.Add(ServicePort{Port: 81}, nil)
|
||||
pool.Add(ServicePort{Port: 90}, nil)
|
||||
if err := pool.Sync(svcNodePorts, nil); err != nil {
|
||||
t.Errorf("Expected backend pool to sync, err: %v", err)
|
||||
pool.Ensure([]ServicePort{ServicePort{Port: 81}}, nil)
|
||||
pool.Ensure([]ServicePort{ServicePort{Port: 90}}, nil)
|
||||
if err := pool.Ensure(svcNodePorts, nil); err != nil {
|
||||
t.Errorf("Expected backend pool to add node ports, err: %v", err)
|
||||
}
|
||||
if err := pool.GC(svcNodePorts); err != nil {
|
||||
t.Errorf("Expected backend pool to GC, err: %v", err)
|
||||
|
|
@ -361,7 +362,7 @@ func TestBackendPoolDeleteLegacyHealthChecks(t *testing.T) {
|
|||
})
|
||||
|
||||
// Have pool sync the above backend service
|
||||
bp.Add(ServicePort{Port: 80, Protocol: utils.ProtocolHTTPS}, nil)
|
||||
bp.Ensure([]ServicePort{ServicePort{Port: 80, Protocol: utils.ProtocolHTTPS}}, nil)
|
||||
|
||||
// Verify the legacy health check has been deleted
|
||||
_, err = hcp.GetHttpHealthCheck(beName)
|
||||
|
|
@ -388,7 +389,7 @@ func TestBackendPoolShutdown(t *testing.T) {
|
|||
namer := utils.Namer{}
|
||||
|
||||
// Add a backend-service and verify that it doesn't exist after Shutdown()
|
||||
pool.Add(ServicePort{Port: 80}, nil)
|
||||
pool.Ensure([]ServicePort{ServicePort{Port: 80}}, nil)
|
||||
pool.Shutdown()
|
||||
if _, err := f.GetGlobalBackendService(namer.BeName(80)); err == nil {
|
||||
t.Fatalf("%v", err)
|
||||
|
|
@ -402,7 +403,7 @@ func TestBackendInstanceGroupClobbering(t *testing.T) {
|
|||
namer := utils.Namer{}
|
||||
|
||||
// This will add the instance group k8s-ig to the instance pool
|
||||
pool.Add(ServicePort{Port: 80}, nil)
|
||||
pool.Ensure([]ServicePort{ServicePort{Port: 80}}, nil)
|
||||
|
||||
be, err := f.GetGlobalBackendService(namer.BeName(80))
|
||||
if err != nil {
|
||||
|
|
@ -420,7 +421,7 @@ func TestBackendInstanceGroupClobbering(t *testing.T) {
|
|||
}
|
||||
|
||||
// Make sure repeated adds don't clobber the inserted instance group
|
||||
pool.Add(ServicePort{Port: 80}, nil)
|
||||
pool.Ensure([]ServicePort{ServicePort{Port: 80}}, nil)
|
||||
be, err = f.GetGlobalBackendService(namer.BeName(80))
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
|
|
@ -462,7 +463,7 @@ func TestBackendCreateBalancingMode(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
|
||||
pool.Add(nodePort, nil)
|
||||
pool.Ensure([]ServicePort{nodePort}, nil)
|
||||
be, err := f.GetGlobalBackendService(namer.BeName(nodePort.Port))
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue