Merge "GroupsUpdate: Evict group caches on group creation" into stable-2.16
This commit is contained in:
		@@ -345,6 +345,9 @@ public class GroupsUpdate {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private void updateCachesOnGroupCreation(InternalGroup createdGroup) throws IOException {
 | 
					  private void updateCachesOnGroupCreation(InternalGroup createdGroup) throws IOException {
 | 
				
			||||||
 | 
					    groupCache.evict(createdGroup.getGroupUUID());
 | 
				
			||||||
 | 
					    groupCache.evict(createdGroup.getId());
 | 
				
			||||||
 | 
					    groupCache.evict(createdGroup.getNameKey());
 | 
				
			||||||
    indexer.get().index(createdGroup.getGroupUUID());
 | 
					    indexer.get().index(createdGroup.getGroupUUID());
 | 
				
			||||||
    createdGroup.getMembers().forEach(groupIncludeCache::evictGroupsWithMember);
 | 
					    createdGroup.getMembers().forEach(groupIncludeCache::evictGroupsWithMember);
 | 
				
			||||||
    createdGroup.getSubgroups().forEach(groupIncludeCache::evictParentGroupsOf);
 | 
					    createdGroup.getSubgroups().forEach(groupIncludeCache::evictParentGroupsOf);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.api.group;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
 | 
					import static com.google.common.collect.ImmutableList.toImmutableList;
 | 
				
			||||||
import static com.google.common.truth.Truth.assertThat;
 | 
					import static com.google.common.truth.Truth.assertThat;
 | 
				
			||||||
 | 
					import static com.google.common.truth.Truth8.assertThat;
 | 
				
			||||||
import static com.google.gerrit.acceptance.GitUtil.deleteRef;
 | 
					import static com.google.gerrit.acceptance.GitUtil.deleteRef;
 | 
				
			||||||
import static com.google.gerrit.acceptance.GitUtil.fetch;
 | 
					import static com.google.gerrit.acceptance.GitUtil.fetch;
 | 
				
			||||||
import static com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo;
 | 
					import static com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo;
 | 
				
			||||||
@@ -203,6 +204,15 @@ public class GroupsIT extends AbstractDaemonTest {
 | 
				
			|||||||
    assertThat(groupsWithMemberAfterRemoval).doesNotContain(groupUuid);
 | 
					    assertThat(groupsWithMemberAfterRemoval).doesNotContain(groupUuid);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Test
 | 
				
			||||||
 | 
					  public void cachedGroupByNameIsUpdatedOnCreation() throws Exception {
 | 
				
			||||||
 | 
					    String newGroupName = name("newGroup");
 | 
				
			||||||
 | 
					    AccountGroup.NameKey nameKey = new AccountGroup.NameKey(newGroupName);
 | 
				
			||||||
 | 
					    assertThat(groupCache.get(nameKey)).isEmpty();
 | 
				
			||||||
 | 
					    gApi.groups().create(newGroupName);
 | 
				
			||||||
 | 
					    assertThat(groupCache.get(nameKey)).isPresent();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Test
 | 
					  @Test
 | 
				
			||||||
  public void addExistingMember_OK() throws Exception {
 | 
					  public void addExistingMember_OK() throws Exception {
 | 
				
			||||||
    String g = "Administrators";
 | 
					    String g = "Administrators";
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user