Skip to content

Commit

Permalink
updates from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislovecnm committed Jan 18, 2017
1 parent fbebae7 commit f1ed339
Showing 1 changed file with 9 additions and 33 deletions.
42 changes: 9 additions & 33 deletions pkg/model/components/kubecontrollermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"time"

api "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
)

type ClusterParams struct {
Expand All @@ -30,42 +29,18 @@ type ClusterParams struct {
UpdatePolicy string
}

func buildCluster(clusterArgs interface{}) *api.Cluster {

if clusterArgs == nil {
clusterArgs = ClusterParams{CloudProvider: "aws", KubernetesVersion: "1.4.0"}
}

cParams := clusterArgs.(ClusterParams)

if cParams.CloudProvider == "" {
cParams.CloudProvider = "aws"
}

if cParams.KubernetesVersion == "" {
cParams.KubernetesVersion = "v1.4.0"
}

networking := &api.NetworkingSpec{
CNI: &api.CNINetworkingSpec{},
}
func buildCluster() *api.Cluster {

return &api.Cluster{
Spec: api.ClusterSpec{
CloudProvider: cParams.CloudProvider,
KubernetesVersion: cParams.KubernetesVersion,
Networking: networking,
UpdatePolicy: fi.String(cParams.UpdatePolicy),
Topology: &api.TopologySpec{
Masters: api.TopologyPublic,
Nodes: api.TopologyPublic,
},
CloudProvider: "aws",
KubernetesVersion: "v1.4.0",
},
}
}

func Test_Build_KCM_Builder_Lower_Version(t *testing.T) {
c := buildCluster(nil)
c := buildCluster()

kcm := &KubeControllerManagerOptionsBuilder{
Context: &OptionsContext{
Expand All @@ -77,17 +52,18 @@ func Test_Build_KCM_Builder_Lower_Version(t *testing.T) {
err := kcm.BuildOptions(&spec)

if err != nil {
t.Fatalf("k-c-m builder errors: %v", err)
t.Fatalf("unexpected error from BuildOptions: %v", err)
}

if spec.KubeControllerManager.AttachDetachReconcileSyncPeriod != nil {
t.Fatalf("k-c-m builder cannot be set for k8s %s", spec.KubernetesVersion)
t.Fatalf("AttachDetachReconcileSyncPeriod should not be set for old kubernetes version %s", spec.KubernetesVersion)
}

}

func Test_Build_KCM_Builder_High_Enough_Version(t *testing.T) {
c := buildCluster(ClusterParams{KubernetesVersion: "1.4.8"})
c := buildCluster()
c.Spec.KubernetesVersion = "1.4.8"

kcm := &KubeControllerManagerOptionsBuilder{
Context: &OptionsContext{
Expand All @@ -99,7 +75,7 @@ func Test_Build_KCM_Builder_High_Enough_Version(t *testing.T) {
err := kcm.BuildOptions(&spec)

if err != nil {
t.Fatalf("k-c-m builder errors: %v", err)
t.Fatalf("unexpected error from BuildOptions %s", err)
}

if spec.KubeControllerManager.AttachDetachReconcileSyncPeriod.Duration != time.Minute {
Expand Down

0 comments on commit f1ed339

Please sign in to comment.