mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
145988d48f
This commit removes support for the following API versions: * `discovery.k8s.io/v1beta1` API version of EndpointSlice (no longer served as of v1.25). * `networking.k8s.io/v1beta1` API version of Ingress (no longer served as of v1.22). Closes #12884 Signed-off-by: Simon Pasquier <spasquie@redhat.com>
50 lines
2.2 KiB
Go
50 lines
2.2 KiB
Go
// Copyright 2020 The Prometheus Authors
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package kubernetes
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
v1 "k8s.io/api/discovery/v1"
|
|
)
|
|
|
|
func Test_EndpointSliceAdaptor_v1(t *testing.T) {
|
|
endpointSlice := makeEndpointSliceV1()
|
|
adaptor := newEndpointSliceAdaptorFromV1(endpointSlice)
|
|
|
|
require.Equal(t, endpointSlice.ObjectMeta.Name, adaptor.name())
|
|
require.Equal(t, endpointSlice.ObjectMeta.Namespace, adaptor.namespace())
|
|
require.Equal(t, endpointSlice.AddressType, v1.AddressType(adaptor.addressType()))
|
|
require.Equal(t, endpointSlice.Labels, adaptor.labels())
|
|
require.Equal(t, "testendpoints", endpointSlice.Labels[v1.LabelServiceName])
|
|
|
|
for i, endpointAdaptor := range adaptor.endpoints() {
|
|
require.Equal(t, endpointSlice.Endpoints[i].Addresses, endpointAdaptor.addresses())
|
|
require.Equal(t, endpointSlice.Endpoints[i].Hostname, endpointAdaptor.hostname())
|
|
require.Equal(t, endpointSlice.Endpoints[i].Conditions.Ready, endpointAdaptor.conditions().ready())
|
|
require.Equal(t, endpointSlice.Endpoints[i].Conditions.Serving, endpointAdaptor.conditions().serving())
|
|
require.Equal(t, endpointSlice.Endpoints[i].Conditions.Terminating, endpointAdaptor.conditions().terminating())
|
|
require.Equal(t, endpointSlice.Endpoints[i].TargetRef, endpointAdaptor.targetRef())
|
|
require.Equal(t, endpointSlice.Endpoints[i].DeprecatedTopology, endpointAdaptor.topology())
|
|
}
|
|
|
|
for i, portAdaptor := range adaptor.ports() {
|
|
require.Equal(t, endpointSlice.Ports[i].Name, portAdaptor.name())
|
|
require.Equal(t, endpointSlice.Ports[i].Port, portAdaptor.port())
|
|
require.EqualValues(t, endpointSlice.Ports[i].Protocol, portAdaptor.protocol())
|
|
require.Equal(t, endpointSlice.Ports[i].AppProtocol, portAdaptor.appProtocol())
|
|
}
|
|
}
|