tests: Removes node created by test

The test "A node shouldn't be able to create another node" could create
a node during its run, but it doesn't delete it in this case.

This commit addresses this issue.
This commit is contained in:
Claudiu Belu 2019-06-08 21:33:23 -07:00
parent e1c1fd9edf
commit ee9be7ce5a

View File

@ -174,6 +174,13 @@ var _ = SIGDescribe("[Feature:NodeAuthorizer]", func() {
}
ginkgo.By(fmt.Sprintf("Create node foo by user: %v", asUser))
_, err := c.CoreV1().Nodes().Create(context.TODO(), node, metav1.CreateOptions{})
// NOTE: If the test fails and a new node IS created, we need to delete it. If we don't, we'd have
// a zombie node in a NotReady state which will delay further tests since we're waiting for all
// tests to be in the Ready state.
defer func() {
f.ClientSet.CoreV1().Nodes().Delete(context.TODO(), node.Name, metav1.DeleteOptions{})
}()
framework.ExpectEqual(apierrors.IsForbidden(err), true)
})