Update nginx and generic controller
This commit is contained in:
parent
c7c2a564a9
commit
e0561ddeb9
62 changed files with 1043 additions and 510 deletions
|
|
@ -21,23 +21,25 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
tc "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
|
||||
"k8s.io/kubernetes/pkg/client/leaderelection/resourcelock"
|
||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
||||
|
||||
"k8s.io/ingress/core/pkg/ingress/status/leaderelection/resourcelock"
|
||||
)
|
||||
|
||||
func TestGetCurrentLeaderLeaderExist(t *testing.T) {
|
||||
fkER := resourcelock.LeaderElectionRecord{
|
||||
HolderIdentity: "currentLeader",
|
||||
LeaseDurationSeconds: 30,
|
||||
AcquireTime: unversioned.Now(),
|
||||
RenewTime: unversioned.Now(),
|
||||
AcquireTime: meta_v1.NewTime(time.Now()),
|
||||
RenewTime: meta_v1.NewTime(time.Now()),
|
||||
LeaderTransitions: 3,
|
||||
}
|
||||
leaderInfo, _ := json.Marshal(fkER)
|
||||
fkEndpoints := api.Endpoints{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
fkEndpoints := api_v1.Endpoints{
|
||||
ObjectMeta: meta_v1.ObjectMeta{
|
||||
Name: "ingress-controller-test",
|
||||
Namespace: api.NamespaceSystem,
|
||||
Annotations: map[string]string{
|
||||
|
|
@ -45,7 +47,7 @@ func TestGetCurrentLeaderLeaderExist(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
fk := tc.NewSimpleClientset(&api.EndpointsList{Items: []api.Endpoints{fkEndpoints}})
|
||||
fk := fake.NewSimpleClientset(&api_v1.EndpointsList{Items: []api_v1.Endpoints{fkEndpoints}})
|
||||
identity, endpoints, err := getCurrentLeader("ingress-controller-test", api.NamespaceSystem, fk)
|
||||
if err != nil {
|
||||
t.Fatalf("expected identitiy and endpoints but returned error %s", err)
|
||||
|
|
@ -61,14 +63,14 @@ func TestGetCurrentLeaderLeaderExist(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetCurrentLeaderLeaderNotExist(t *testing.T) {
|
||||
fkEndpoints := api.Endpoints{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
fkEndpoints := api_v1.Endpoints{
|
||||
ObjectMeta: meta_v1.ObjectMeta{
|
||||
Name: "ingress-controller-test",
|
||||
Namespace: api.NamespaceSystem,
|
||||
Annotations: map[string]string{},
|
||||
},
|
||||
}
|
||||
fk := tc.NewSimpleClientset(&api.EndpointsList{Items: []api.Endpoints{fkEndpoints}})
|
||||
fk := fake.NewSimpleClientset(&api_v1.EndpointsList{Items: []api_v1.Endpoints{fkEndpoints}})
|
||||
identity, endpoints, err := getCurrentLeader("ingress-controller-test", api.NamespaceSystem, fk)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpeted error: %v", err)
|
||||
|
|
@ -84,8 +86,8 @@ func TestGetCurrentLeaderLeaderNotExist(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetCurrentLeaderAnnotationError(t *testing.T) {
|
||||
fkEndpoints := api.Endpoints{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
fkEndpoints := api_v1.Endpoints{
|
||||
ObjectMeta: meta_v1.ObjectMeta{
|
||||
Name: "ingress-controller-test",
|
||||
Namespace: api.NamespaceSystem,
|
||||
Annotations: map[string]string{
|
||||
|
|
@ -93,7 +95,7 @@ func TestGetCurrentLeaderAnnotationError(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
fk := tc.NewSimpleClientset(&api.EndpointsList{Items: []api.Endpoints{fkEndpoints}})
|
||||
fk := fake.NewSimpleClientset(&api_v1.EndpointsList{Items: []api_v1.Endpoints{fkEndpoints}})
|
||||
_, _, err := getCurrentLeader("ingress-controller-test", api.NamespaceSystem, fk)
|
||||
if err == nil {
|
||||
t.Errorf("expected error")
|
||||
|
|
@ -101,15 +103,15 @@ func TestGetCurrentLeaderAnnotationError(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNewElection(t *testing.T) {
|
||||
fk := tc.NewSimpleClientset(&api.EndpointsList{Items: []api.Endpoints{
|
||||
fk := fake.NewSimpleClientset(&api_v1.EndpointsList{Items: []api_v1.Endpoints{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: meta_v1.ObjectMeta{
|
||||
Name: "ingress-controller-test",
|
||||
Namespace: api.NamespaceSystem,
|
||||
},
|
||||
},
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: meta_v1.ObjectMeta{
|
||||
Name: "ingress-controller-test-020",
|
||||
Namespace: api.NamespaceSystem,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue