mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
some updates
This commit is contained in:
parent
094dbded65
commit
7ec0315c39
@ -1158,7 +1158,7 @@ func (f *fakeVMSet) GetVMSetNames(service *v1.Service, nodes []*v1.Node) (availa
|
|||||||
return nil, fmt.Errorf("unimplemented")
|
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")
|
return fmt.Errorf("unimplemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ func TestMapLoadBalancerNameToVMSet(t *testing.T) {
|
|||||||
cases := []struct {
|
cases := []struct {
|
||||||
description string
|
description string
|
||||||
lbName string
|
lbName string
|
||||||
|
useStandardLB bool
|
||||||
clusterName string
|
clusterName string
|
||||||
expectedVMSet string
|
expectedVMSet string
|
||||||
}{
|
}{
|
||||||
@ -157,10 +158,124 @@ func TestMapLoadBalancerNameToVMSet(t *testing.T) {
|
|||||||
clusterName: "azure",
|
clusterName: "azure",
|
||||||
expectedVMSet: "azuretest",
|
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 {
|
for _, c := range cases {
|
||||||
|
if c.useStandardLB {
|
||||||
|
az.Config.LoadBalancerSku = loadBalancerSkuStandard
|
||||||
|
} else {
|
||||||
|
az.Config.LoadBalancerSku = loadBalancerSkuBasic
|
||||||
|
}
|
||||||
vmset := az.mapLoadBalancerNameToVMSet(c.lbName, c.clusterName)
|
vmset := az.mapLoadBalancerNameToVMSet(c.lbName, c.clusterName)
|
||||||
assert.Equal(t, c.expectedVMSet, vmset, c.description)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user