|
|
@ -476,6 +476,129 @@ func TestUgrade_newerVersion(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestUpgrade_identical(t *testing.T) {
|
|
|
|
|
|
|
|
image := "gcr.io/kubernetes-helm/tiller:v2.0.0"
|
|
|
|
|
|
|
|
serviceAccount := "newServiceAccount"
|
|
|
|
|
|
|
|
existingDeployment, _ := deployment(&Options{
|
|
|
|
|
|
|
|
Namespace: v1.NamespaceDefault,
|
|
|
|
|
|
|
|
ImageSpec: "imageToReplace:v2.0.0",
|
|
|
|
|
|
|
|
ServiceAccount: "serviceAccountToReplace",
|
|
|
|
|
|
|
|
UseCanary: false,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
existingService := service(v1.NamespaceDefault)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fc := &fake.Clientset{}
|
|
|
|
|
|
|
|
fc.AddReactor("get", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
return true, existingDeployment, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
fc.AddReactor("update", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
obj := action.(testcore.UpdateAction).GetObject().(*v1beta1.Deployment)
|
|
|
|
|
|
|
|
i := obj.Spec.Template.Spec.Containers[0].Image
|
|
|
|
|
|
|
|
if i != image {
|
|
|
|
|
|
|
|
t.Errorf("expected image = '%s', got '%s'", image, i)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sa := obj.Spec.Template.Spec.ServiceAccountName
|
|
|
|
|
|
|
|
if sa != serviceAccount {
|
|
|
|
|
|
|
|
t.Errorf("expected serviceAccountName = '%s', got '%s'", serviceAccount, sa)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true, obj, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
fc.AddReactor("get", "services", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
return true, existingService, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opts := &Options{Namespace: v1.NamespaceDefault, ImageSpec: image, ServiceAccount: serviceAccount}
|
|
|
|
|
|
|
|
if err := Upgrade(fc, opts); err != nil {
|
|
|
|
|
|
|
|
t.Errorf("unexpected error: %#+v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if actions := fc.Actions(); len(actions) != 3 {
|
|
|
|
|
|
|
|
t.Errorf("unexpected actions: %v, expected 3 actions got %d", actions, len(actions))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestUpgrade_canaryClient(t *testing.T) {
|
|
|
|
|
|
|
|
image := "gcr.io/kubernetes-helm/tiller:canary"
|
|
|
|
|
|
|
|
serviceAccount := "newServiceAccount"
|
|
|
|
|
|
|
|
existingDeployment, _ := deployment(&Options{
|
|
|
|
|
|
|
|
Namespace: v1.NamespaceDefault,
|
|
|
|
|
|
|
|
ImageSpec: "imageToReplace:v1.0.0",
|
|
|
|
|
|
|
|
ServiceAccount: "serviceAccountToReplace",
|
|
|
|
|
|
|
|
UseCanary: false,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
existingService := service(v1.NamespaceDefault)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fc := &fake.Clientset{}
|
|
|
|
|
|
|
|
fc.AddReactor("get", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
return true, existingDeployment, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
fc.AddReactor("update", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
obj := action.(testcore.UpdateAction).GetObject().(*v1beta1.Deployment)
|
|
|
|
|
|
|
|
i := obj.Spec.Template.Spec.Containers[0].Image
|
|
|
|
|
|
|
|
if i != image {
|
|
|
|
|
|
|
|
t.Errorf("expected image = '%s', got '%s'", image, i)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sa := obj.Spec.Template.Spec.ServiceAccountName
|
|
|
|
|
|
|
|
if sa != serviceAccount {
|
|
|
|
|
|
|
|
t.Errorf("expected serviceAccountName = '%s', got '%s'", serviceAccount, sa)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true, obj, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
fc.AddReactor("get", "services", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
return true, existingService, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opts := &Options{Namespace: v1.NamespaceDefault, ImageSpec: image, ServiceAccount: serviceAccount}
|
|
|
|
|
|
|
|
if err := Upgrade(fc, opts); err != nil {
|
|
|
|
|
|
|
|
t.Errorf("unexpected error: %#+v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if actions := fc.Actions(); len(actions) != 3 {
|
|
|
|
|
|
|
|
t.Errorf("unexpected actions: %v, expected 3 actions got %d", actions, len(actions))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestUpgrade_canaryServer(t *testing.T) {
|
|
|
|
|
|
|
|
image := "gcr.io/kubernetes-helm/tiller:v2.0.0"
|
|
|
|
|
|
|
|
serviceAccount := "newServiceAccount"
|
|
|
|
|
|
|
|
existingDeployment, _ := deployment(&Options{
|
|
|
|
|
|
|
|
Namespace: v1.NamespaceDefault,
|
|
|
|
|
|
|
|
ImageSpec: "imageToReplace:canary",
|
|
|
|
|
|
|
|
ServiceAccount: "serviceAccountToReplace",
|
|
|
|
|
|
|
|
UseCanary: false,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
existingService := service(v1.NamespaceDefault)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fc := &fake.Clientset{}
|
|
|
|
|
|
|
|
fc.AddReactor("get", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
return true, existingDeployment, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
fc.AddReactor("update", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
obj := action.(testcore.UpdateAction).GetObject().(*v1beta1.Deployment)
|
|
|
|
|
|
|
|
i := obj.Spec.Template.Spec.Containers[0].Image
|
|
|
|
|
|
|
|
if i != image {
|
|
|
|
|
|
|
|
t.Errorf("expected image = '%s', got '%s'", image, i)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sa := obj.Spec.Template.Spec.ServiceAccountName
|
|
|
|
|
|
|
|
if sa != serviceAccount {
|
|
|
|
|
|
|
|
t.Errorf("expected serviceAccountName = '%s', got '%s'", serviceAccount, sa)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true, obj, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
fc.AddReactor("get", "services", func(action testcore.Action) (bool, runtime.Object, error) {
|
|
|
|
|
|
|
|
return true, existingService, nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opts := &Options{Namespace: v1.NamespaceDefault, ImageSpec: image, ServiceAccount: serviceAccount}
|
|
|
|
|
|
|
|
if err := Upgrade(fc, opts); err != nil {
|
|
|
|
|
|
|
|
t.Errorf("unexpected error: %#+v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if actions := fc.Actions(); len(actions) != 3 {
|
|
|
|
|
|
|
|
t.Errorf("unexpected actions: %v, expected 3 actions got %d", actions, len(actions))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func tlsTestFile(t *testing.T, path string) string {
|
|
|
|
func tlsTestFile(t *testing.T, path string) string {
|
|
|
|
const tlsTestDir = "../../../testdata"
|
|
|
|
const tlsTestDir = "../../../testdata"
|
|
|
|
path = filepath.Join(tlsTestDir, path)
|
|
|
|
path = filepath.Join(tlsTestDir, path)
|
|
|
|