This repository has been archived by the owner on Jul 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
e2e: add delete apiserver test #539
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this sleep? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 -- would you mind throwing in a link to that issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be
310
, no?There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got it. Thanks.