Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding e2e tests for validating cascading deletion of federation resources #36630

Merged
merged 2 commits into from
Nov 19, 2016

Conversation

nikhiljindal
Copy link
Contributor

@nikhiljindal nikhiljindal commented Nov 11, 2016

Ref #33612

Adding e2e tests for code in #36330 and #36476.

Adding test cases to ensure that cascading deletion happens as expected.
Also adding code to ensure that all resources are cleaned up in AfterEach.

cc @kubernetes/sig-cluster-federation @caesarxuchao @madhusudancs


This change is Reviewable

@nikhiljindal nikhiljindal added area/cluster-federation area/test release-note-none Denotes a PR that doesn't merit a release note. labels Nov 11, 2016
@nikhiljindal nikhiljindal added this to the v1.5 milestone Nov 11, 2016
@nikhiljindal
Copy link
Contributor Author

Adding to 1.5 milestone.
Test only changes should be fine.
cc @saad-ali as FYI.

@nikhiljindal
Copy link
Contributor Author

@k8s-bot federation gce e2e test this

@k8s-github-robot k8s-github-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 11, 2016
@nikhiljindal nikhiljindal assigned mwielgus and unassigned ixdy Nov 11, 2016
@nikhiljindal
Copy link
Contributor Author

federation e2e failed to come up. It timed out waiting for load balancer status. Unrelated to this PR. Retrying.

@k8s-bot federation gce e2e test this

@dims
Copy link
Member

dims commented Nov 11, 2016

looks like unrelated errors:

W1111 00:28:53.685] ssh: connect to host 107.178.220.197 port 22: Connection timed out
W1111 00:28:53.690] ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. See https://cloud.google.com/compute/docs/troubleshooting#ssherrors for troubleshooting hints.

@dims
Copy link
Member

dims commented Nov 11, 2016

@k8s-bot federation gce e2e test this

1 similar comment
@nikhiljindal
Copy link
Contributor Author

@k8s-bot federation gce e2e test this

@saad-ali
Copy link
Member

Adding to 1.5 milestone.
Test only changes should be fine.
cc @saad-ali as FYI.

Ack. Thanks.

@dims
Copy link
Member

dims commented Nov 13, 2016

@k8s-bot federation gce e2e test this

@dims
Copy link
Member

dims commented Nov 14, 2016

@nikhiljindal looks like the tests never ends. i see a started.json from 4 hours ago and it has not finished yet

http://gcsweb.k8s.io/gcs/kubernetes-jenkins/pr-logs/pull/36630/pull-kubernetes-federation-e2e-gce/22

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2016
@nikhiljindal
Copy link
Contributor Author

haha I still see it as running :)
Will try again after rebasing

@nikhiljindal nikhiljindal removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2016
@nikhiljindal
Copy link
Contributor Author

@k8s-bot federation gce e2e test this

@k8s-ci-robot
Copy link
Contributor

Jenkins GCE etcd3 e2e failed for commit b3759b9. Full PR test history.

The magic incantation to run this job again is @k8s-bot gce etcd3 e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GKE smoke e2e failed for commit b3759b9. Full PR test history.

The magic incantation to run this job again is @k8s-bot cvm gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GCE e2e failed for commit b3759b9. Full PR test history.

The magic incantation to run this job again is @k8s-bot cvm gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GCE e2e failed for commit b3759b9. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins Kubemark GCE e2e failed for commit b3759b9. Full PR test history.

The magic incantation to run this job again is @k8s-bot kubemark e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins Federation GCE e2e failed for commit b3759b9. Full PR test history.

The magic incantation to run this job again is @k8s-bot federation gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@nikhiljindal
Copy link
Contributor Author

GCE e2e failed with jq: command not found which is unrelated.
Retrying.
@k8s-bot cvm gce e2e test this

Also verified that all federation e2es are passing by running all of them locally.

@mwielgus Can you please take a look

@nikhiljindal
Copy link
Contributor Author

Adding @madhusudancs as second reviewer since @mwielgus seems busy this week.

Copy link
Contributor

@madhusudancs madhusudancs left a comment

Choose a reason for hiding this comment

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

@nikhiljindal Mostly minor comments.

IngressList, err := clientset.Extensions().Ingresses(nsName).List(v1.ListOptions{})
Expect(err).NotTo(HaveOccurred())
orphanDependents := false
for _, Ingress := range IngressList.Items {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use DeleteCollection instead of looping through the items?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

found there was an existing function here doing the same thing. Changed the code to reuse that

// Verifies that ingresses are deleted from underlying clusters when orphan dependents is false
// and they are not deleted when orphan dependents is true.
func verifyCascadingDeletionForIngress(clientset *fedclientset.Clientset,
clusters map[string]*cluster, orphanDependents *bool, nsName string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this line break? We generally don't do it in Go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

old habit. Fixed

/*
equivalent returns true if the two ingress spec are equivalent.
*/
func equivalentIngress(federatedIngress, clusterIngress v1beta1.Ingress) bool {
return reflect.DeepEqual(clusterIngress.Spec, federatedIngress.Spec)
}

// Verifies that ingresses are deleted from underlying clusters when orphan dependents is false
Copy link
Contributor

Choose a reason for hiding this comment

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

"verifyCascadingDeletionForIngress verifies that ..." is the recommended way, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We are not as strict about that for private functions. Fixed it here

ingressName := ingress.Name
// Check subclusters if the ingress was created there.
By(fmt.Sprintf("Waiting for ingress %s to be created in all underlying clusters", ingressName))
err := wait.Poll(5*time.Second, 2*time.Minute, func() (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make 5*time.Second, 2*time.Minute package level constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this code to reuse an existing function

err := wait.Poll(5*time.Second, 2*time.Minute, func() (bool, error) {
for _, cluster := range clusters {
_, err := cluster.Extensions().Ingresses(nsName).Get(ingressName)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is somewhat more straightforward and easier to read/understand if it is written as:

if !errors.IsNotFound(err) {
    return false, err
}
if err != nil {
    return false, nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Problem with that is that !errors.IsNotFound(err) is true when err = nil. We do not want to return false in that case.
Changed it to:

if err != nil && errors.IsNotFound(err) {
    return false, nil
}
if err != nil {
    return false, err
}

errMessages := []string{}
for clusterName, clusterClientset := range clusters {
_, err := clusterClientset.Extensions().ReplicaSets(nsName).Get(replicaSetName)
if (orphanDependents == nil || *orphanDependents == true) && errors.IsNotFound(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

By(fmt.Sprintf("Deleting replicaSet %s", replicaSetName))
deleteReplicaSetOrFail(clientset, nsName, replicaSetName, orphanDependents)

By(fmt.Sprintf("Verifying replicaSets %s in underlying clusters", replicaSetName))
Copy link
Contributor

Choose a reason for hiding this comment

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

ReplicaSets or replica sets. Here and everywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
return true, nil
})
framework.ExpectNoError(err, "Not all replicaSets created")
Copy link
Contributor

Choose a reason for hiding this comment

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

ReplicaSets or replica sets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

replicaSet := createReplicaSetOrFail(clientset, nsName)
replicaSetName := replicaSet.Name
// Check subclusters if the replicaSet was created there.
By(fmt.Sprintf("Waiting for replicaSet %s to be created in all underlying clusters", replicaSetName))
Copy link
Contributor

Choose a reason for hiding this comment

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

ReplicaSets or replica sets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. here and at other places

// Wait for the replicaSet to be deleted.
err = wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) {
_, err := clientset.Extensions().ReplicaSets(nsName).Get(replicaSetName)
if err != nil && errors.IsNotFound(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@nikhiljindal
Copy link
Contributor Author

Thanks @madhusudancs Pushed a new commit with fixes.
PTAL

shouldExist := orphanDependents == nil || *orphanDependents == true
for clusterName, clusterClientset := range clusters {
_, err := clusterClientset.Extensions().Ingresses(nsName).Get(ingressName)
if shouldExist && errors.IsNotFound(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a big fan of having lots of logic in tests and I still think it should be split into 3 separate functions. But it is fine for now, I guess.

@madhusudancs
Copy link
Contributor

LGTM!

@madhusudancs madhusudancs added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 18, 2016
@nikhiljindal nikhiljindal removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 18, 2016
@nikhiljindal
Copy link
Contributor Author

Squashed commits.
Thanks @madhusudancs

@nikhiljindal nikhiljindal added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 18, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GKE smoke e2e failed for commit 90645ce. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 18, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants