Remove usless test and resolved comments
@@ -302,14 +302,15 @@ func TestAuthorizationResolution(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
- // try to add Valerie to a non-existent role, looping until it is true due to
- // the policy cache taking time to react
+ // try to add Valerie to a non-existent role, looping until it is done.
+ // If a Not Found error is raised, simply retry as this is likely due to
+ // the role cache taking time to react
if err := wait.Poll(time.Second, 2*time.Minute, func() (bool, error) {
err := addValerie.AddRole()
- if err == nil || kapierror.IsNotFound(err) { // TODO what does this mean?
- return true, nil
+ if err != nil && kapierror.IsNotFound(err) {
+ return false, nil
}
- return false, err
+ return (err == nil), err
}); err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -318,7 +319,7 @@ func TestAuthorizationResolution(t *testing.T) {
roleWithGroup.Name = "with-group"
roleWithGroup.Rules = append(roleWithGroup.Rules, authorizationapi.PolicyRule{
Verbs: sets.NewString("list"),
- Resources: sets.NewString("builds"), // TODO we may need to track these down
+ Resources: sets.NewString("builds"),
})
if _, err := clusterAdminClient.ClusterRoles().Create(roleWithGroup); err != nil {
t.Fatalf("unexpected error: %v", err)
@@ -1655,46 +1656,3 @@ func TestClusterPolicyCache(t *testing.T) {
}
}
}
-
-// TestPolicyCache confirms that the creation of role bindings fallback to live lookups when the referenced role is not cached
-func TestPolicyCache(t *testing.T) {
- masterConfig, clusterAdminKubeConfig, err := testserver.StartTestMasterAPI()
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
- defer testserver.CleanupMasterEtcd(t, masterConfig)
-
- clusterAdminClient, err := testutil.GetClusterAdminClient(clusterAdminKubeConfig)
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- clusterAdminClientConfig, err := testutil.GetClusterAdminClientConfig(clusterAdminKubeConfig)
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- user := "harold"
- namespace := "hammer-project"
-
- haroldClient, err := testserver.CreateNewProject(clusterAdminClient, *clusterAdminClientConfig, namespace, user)
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
- haroldClient.RESTClient.Throttle = flowcontrol.NewFakeAlwaysRateLimiter() // turn off rate limiting so cache misses are more likely
-
- for i := 0; i < 100; i++ { // usually takes less than 60 attempts for this to cache miss
- role := &authorizationapi.Role{ObjectMeta: metav1.ObjectMeta{GenerateName: time.Now().String()}}
- role, err = haroldClient.Roles(namespace).Create(role)
- if err != nil {
- t.Fatalf("unexpected error creating role %q: %v", role.Name, err)
- }
- roleBinding := &authorizationapi.RoleBinding{
- ObjectMeta: metav1.ObjectMeta{Name: role.Name},
- Subjects: []kapi.ObjectReference{{Name: user, Kind: authorizationapi.UserKind}},
- RoleRef: kapi.ObjectReference{Name: role.Name, Namespace: namespace}}
- if _, err := haroldClient.RoleBindings(namespace).Create(roleBinding); err != nil {
- t.Fatalf("cache error creating role binding %d %q: %v", i, roleBinding.Name, err)
- }
- }
-}
