some updates

This commit is contained in:
Pengfei Ni 2018-03-30 16:52:42 +08:00
parent 094dbded65
commit 7ec0315c39
2 changed files with 116 additions and 1 deletions

View File

@ -1158,7 +1158,7 @@ func (f *fakeVMSet) GetVMSetNames(service *v1.Service, nodes []*v1.Node) (availa
return nil, fmt.Errorf("unimplemented")
}
func (f *fakeVMSet) EnsureHostsInPool(serviceName string, nodes []*v1.Node, backendPoolID string, vmSetName string) error {
func (f *fakeVMSet) EnsureHostsInPool(serviceName string, nodes []*v1.Node, backendPoolID string, vmSetName string, isInternal bool) error {
return fmt.Errorf("unimplemented")
}

View File

@ -130,6 +130,7 @@ func TestMapLoadBalancerNameToVMSet(t *testing.T) {
cases := []struct {
description string
lbName string
useStandardLB bool
clusterName string
expectedVMSet string
}{
@ -157,10 +158,124 @@ func TestMapLoadBalancerNameToVMSet(t *testing.T) {
clusterName: "azure",
expectedVMSet: "azuretest",
},
{
description: "default standard external LB should map to empty string",
lbName: "azure",
useStandardLB: true,
clusterName: "azure",
expectedVMSet: "",
},
{
description: "default standard internal LB should map to empty string",
lbName: "azure-internal",
useStandardLB: true,
clusterName: "azure",
expectedVMSet: "",
},
{
description: "non-default standard external LB should map to empty string",
lbName: "azuretest",
useStandardLB: true,
clusterName: "azure",
expectedVMSet: "",
},
{
description: "non-default standard internal LB should map to empty string",
lbName: "azuretest-internal",
useStandardLB: true,
clusterName: "azure",
expectedVMSet: "",
},
}
for _, c := range cases {
if c.useStandardLB {
az.Config.LoadBalancerSku = loadBalancerSkuStandard
} else {
az.Config.LoadBalancerSku = loadBalancerSkuBasic
}
vmset := az.mapLoadBalancerNameToVMSet(c.lbName, c.clusterName)
assert.Equal(t, c.expectedVMSet, vmset, c.description)
}
}
func TestGetLoadBalancerName(t *testing.T) {
az := getTestCloud()
az.PrimaryAvailabilitySetName = "primary"
cases := []struct {
description string
vmSet string
isInternal bool
useStandardLB bool
clusterName string
expected string
}{
{
description: "default external LB should get primary vmset",
vmSet: "primary",
clusterName: "azure",
expected: "azure",
},
{
description: "default internal LB should get primary vmset",
vmSet: "primary",
clusterName: "azure",
isInternal: true,
expected: "azure-internal",
},
{
description: "non-default external LB should get its own vmset",
vmSet: "as",
clusterName: "azure",
expected: "as",
},
{
description: "non-default internal LB should get its own vmset",
vmSet: "as",
clusterName: "azure",
isInternal: true,
expected: "as-internal",
},
{
description: "default standard external LB should get cluster name",
vmSet: "primary",
useStandardLB: true,
clusterName: "azure",
expected: "azure",
},
{
description: "default standard internal LB should get cluster name",
vmSet: "primary",
useStandardLB: true,
isInternal: true,
clusterName: "azure",
expected: "azure-internal",
},
{
description: "non-default standard external LB should get cluster-name",
vmSet: "as",
useStandardLB: true,
clusterName: "azure",
expected: "azure",
},
{
description: "non-default standard internal LB should get cluster-name",
vmSet: "as",
useStandardLB: true,
isInternal: true,
clusterName: "azure",
expected: "azure-internal",
},
}
for _, c := range cases {
if c.useStandardLB {
az.Config.LoadBalancerSku = loadBalancerSkuStandard
} else {
az.Config.LoadBalancerSku = loadBalancerSkuBasic
}
loadbalancerName := az.getLoadBalancerName(c.clusterName, c.vmSet, c.isInternal)
assert.Equal(t, c.expected, loadbalancerName, c.description)
}
}