Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

e2e: add delete apiserver test #539

Merged
merged 3 commits into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions e2e/deleteapi_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package e2e

import (
"fmt"
"testing"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestDeleteAPI(t *testing.T) {
apiPods, err := client.CoreV1().Pods("kube-system").List(metav1.ListOptions{LabelSelector: "k8s-app=kube-apiserver"})
if err != nil {
t.Fatal(err)
}

// delete any api-server pods
for i, pod := range apiPods.Items {
err := client.CoreV1().Pods("kube-system").Delete(pod.ObjectMeta.Name, &metav1.DeleteOptions{})
if err != nil {
// TODO: if HA we should be able to successfully
// delete all. Until then just log if we can't delete
// something that isn't the first pod.
if i == 0 {
t.Fatalf("error deleting api-server pod: %v", err)
} else {
t.Logf("error deleting api-server pod: %v", err)
}
}
}

// wait for api-server to go down by waiting until listing pods returns
// errors. This is potentially error prone, but without waiting for the
// apiserver to go down the next step will return sucess before the
// apiserver is ever destroyed.
waitDestroy := func() error {
// only checking api being down , specific function not important
_, err := client.Discovery().ServerVersion()

if err == nil {
return fmt.Errorf("waiting for apiserver to go down: %v", err)
}
return nil
}

if err := retry(100, 500*time.Millisecond, waitDestroy); err != nil {
t.Fatal(err)
}

// wait until api server is back up
waitAPI := func() error {
// only checking for presence of api returning, specific function not important
_, err := client.Discovery().ServerVersion()
if err != nil {
return fmt.Errorf("waiting for apiserver to return: %v", err)
}
return nil
}
if err := retry(30, 10*time.Second, waitAPI); err != nil {
t.Fatal(err)
}
}
4 changes: 2 additions & 2 deletions e2e/etcdscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ func resizeSelfHostedEtcd(c kubernetes.Interface, size int) error {
return nil
}

if err := retry(15, 10*time.Second, podsReady); err != nil {
return fmt.Errorf("Waited 150 seconds for etcd to scale: %v", err)
if err := retry(31, 10*time.Second, podsReady); err != nil {
return fmt.Errorf("Waited 300 seconds for etcd to scale: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be 310, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would think, but the retry function actually will do N retries and N-1 pauses. So try -> pause -> try -> pause -> try It doesn't pause after the last try.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. Thanks.

}

return nil
Expand Down
6 changes: 5 additions & 1 deletion hack/terraform-quickstart/iam.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
resource "aws_iam_instance_profile" "bk_profile" {
name_prefix = "bootkube_e2e_profile"
role = "${aws_iam_role.bk_role.name}"
role = "${aws_iam_role.bk_role.id}"

provisioner "local-exec" {
command = "sleep 90"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this sleep?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 -- would you mind throwing in a link to that issue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included it in the commit, adding it to PR text as well

}
}

resource "aws_iam_role" "bk_role" {
Expand Down
8 changes: 4 additions & 4 deletions hack/terraform-quickstart/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ resource "aws_instance" "worker_node" {
}

resource "aws_instance" "master_node" {
ami = "${data.aws_ami.coreos_ami.image_id}"
instance_type = "m3.medium"
key_name = "${var.ssh_key}"
count = "${var.additional_masters}"
ami = "${data.aws_ami.coreos_ami.image_id}"
instance_type = "m3.medium"
key_name = "${var.ssh_key}"
count = "${var.additional_masters}"
iam_instance_profile = "${aws_iam_instance_profile.bk_profile.id}"

tags {
Expand Down