mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Cleaning up EndpointSlice update validation tests
This commit is contained in:
parent
506861c0a0
commit
ff46573692
@ -596,22 +596,22 @@ func TestValidateEndpointSliceUpdate(t *testing.T) {
|
|||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
expectedErrors int
|
expectedErrors int
|
||||||
nodeNameGateEnabled bool
|
nodeNameGateEnabled bool
|
||||||
newEndpointSlice *discovery.EndpointSlice
|
|
||||||
oldEndpointSlice *discovery.EndpointSlice
|
oldEndpointSlice *discovery.EndpointSlice
|
||||||
|
newEndpointSlice *discovery.EndpointSlice
|
||||||
}{
|
}{
|
||||||
"valid and identical slices": {
|
"valid and identical slices": {
|
||||||
newEndpointSlice: &discovery.EndpointSlice{
|
oldEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv6,
|
AddressType: discovery.AddressTypeIPv6,
|
||||||
},
|
},
|
||||||
oldEndpointSlice: &discovery.EndpointSlice{
|
newEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv6,
|
AddressType: discovery.AddressTypeIPv6,
|
||||||
},
|
},
|
||||||
expectedErrors: 0,
|
expectedErrors: 0,
|
||||||
},
|
},
|
||||||
"node name set before + after, gate disabled": {
|
"node name set before + after, gate disabled": {
|
||||||
newEndpointSlice: &discovery.EndpointSlice{
|
oldEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
Endpoints: []discovery.Endpoint{{
|
Endpoints: []discovery.Endpoint{{
|
||||||
@ -619,7 +619,7 @@ func TestValidateEndpointSliceUpdate(t *testing.T) {
|
|||||||
NodeName: utilpointer.StringPtr("foo"),
|
NodeName: utilpointer.StringPtr("foo"),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
oldEndpointSlice: &discovery.EndpointSlice{
|
newEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
Endpoints: []discovery.Endpoint{{
|
Endpoints: []discovery.Endpoint{{
|
||||||
@ -631,14 +631,14 @@ func TestValidateEndpointSliceUpdate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"node name set after, gate enabled": {
|
"node name set after, gate enabled": {
|
||||||
nodeNameGateEnabled: true,
|
nodeNameGateEnabled: true,
|
||||||
newEndpointSlice: &discovery.EndpointSlice{
|
oldEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
Endpoints: []discovery.Endpoint{{
|
Endpoints: []discovery.Endpoint{{
|
||||||
Addresses: []string{"10.1.2.3"},
|
Addresses: []string{"10.1.2.3"},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
oldEndpointSlice: &discovery.EndpointSlice{
|
newEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
Endpoints: []discovery.Endpoint{{
|
Endpoints: []discovery.Endpoint{{
|
||||||
@ -652,6 +652,13 @@ func TestValidateEndpointSliceUpdate(t *testing.T) {
|
|||||||
// expected errors
|
// expected errors
|
||||||
"invalide node name set after, gate enabled": {
|
"invalide node name set after, gate enabled": {
|
||||||
nodeNameGateEnabled: true,
|
nodeNameGateEnabled: true,
|
||||||
|
oldEndpointSlice: &discovery.EndpointSlice{
|
||||||
|
ObjectMeta: standardMeta,
|
||||||
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
|
Endpoints: []discovery.Endpoint{{
|
||||||
|
Addresses: []string{"10.1.2.3"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
newEndpointSlice: &discovery.EndpointSlice{
|
newEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
@ -660,25 +667,18 @@ func TestValidateEndpointSliceUpdate(t *testing.T) {
|
|||||||
NodeName: utilpointer.StringPtr("INVALID foo"),
|
NodeName: utilpointer.StringPtr("INVALID foo"),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
oldEndpointSlice: &discovery.EndpointSlice{
|
|
||||||
ObjectMeta: standardMeta,
|
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
|
||||||
Endpoints: []discovery.Endpoint{{
|
|
||||||
Addresses: []string{"10.1.2.3"},
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
expectedErrors: 1,
|
expectedErrors: 1,
|
||||||
},
|
},
|
||||||
"node name set after, gate disabled": {
|
"node name set after, gate disabled": {
|
||||||
nodeNameGateEnabled: false,
|
nodeNameGateEnabled: false,
|
||||||
newEndpointSlice: &discovery.EndpointSlice{
|
oldEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
Endpoints: []discovery.Endpoint{{
|
Endpoints: []discovery.Endpoint{{
|
||||||
Addresses: []string{"10.1.2.3"},
|
Addresses: []string{"10.1.2.3"},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
oldEndpointSlice: &discovery.EndpointSlice{
|
newEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
Endpoints: []discovery.Endpoint{{
|
Endpoints: []discovery.Endpoint{{
|
||||||
@ -686,31 +686,35 @@ func TestValidateEndpointSliceUpdate(t *testing.T) {
|
|||||||
NodeName: utilpointer.StringPtr("foo"),
|
NodeName: utilpointer.StringPtr("foo"),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
expectedErrors: 0,
|
expectedErrors: 1,
|
||||||
},
|
},
|
||||||
"deprecated address type": {
|
"deprecated address type": {
|
||||||
expectedErrors: 1,
|
expectedErrors: 1,
|
||||||
newEndpointSlice: &discovery.EndpointSlice{
|
oldEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressType("IP"),
|
AddressType: discovery.AddressType("IP"),
|
||||||
},
|
},
|
||||||
oldEndpointSlice: &discovery.EndpointSlice{
|
newEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressType("IP"),
|
AddressType: discovery.AddressType("IP"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"valid and identical slices with different address types": {
|
"valid and identical slices with different address types": {
|
||||||
newEndpointSlice: &discovery.EndpointSlice{
|
|
||||||
ObjectMeta: standardMeta,
|
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
|
||||||
},
|
|
||||||
oldEndpointSlice: &discovery.EndpointSlice{
|
oldEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressType("other"),
|
AddressType: discovery.AddressType("other"),
|
||||||
},
|
},
|
||||||
|
newEndpointSlice: &discovery.EndpointSlice{
|
||||||
|
ObjectMeta: standardMeta,
|
||||||
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
|
},
|
||||||
expectedErrors: 1,
|
expectedErrors: 1,
|
||||||
},
|
},
|
||||||
"invalid slices with valid address types": {
|
"invalid slices with valid address types": {
|
||||||
|
oldEndpointSlice: &discovery.EndpointSlice{
|
||||||
|
ObjectMeta: standardMeta,
|
||||||
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
|
},
|
||||||
newEndpointSlice: &discovery.EndpointSlice{
|
newEndpointSlice: &discovery.EndpointSlice{
|
||||||
ObjectMeta: standardMeta,
|
ObjectMeta: standardMeta,
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
AddressType: discovery.AddressTypeIPv4,
|
||||||
@ -719,10 +723,6 @@ func TestValidateEndpointSliceUpdate(t *testing.T) {
|
|||||||
Protocol: protocolPtr(api.Protocol("invalid")),
|
Protocol: protocolPtr(api.Protocol("invalid")),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
oldEndpointSlice: &discovery.EndpointSlice{
|
|
||||||
ObjectMeta: standardMeta,
|
|
||||||
AddressType: discovery.AddressTypeIPv4,
|
|
||||||
},
|
|
||||||
expectedErrors: 1,
|
expectedErrors: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user