Search in sources :

Example 31 with TagState

use of com.vmware.photon.controller.model.resources.TagService.TagState in project photon-model by vmware.

the class TagGroomerTaskServiceTest method testTagStateGroomerMultiplePagesOfResults.

@Test
public void testTagStateGroomerMultiplePagesOfResults() throws Throwable {
    List<String> usedTags = createTagStates("usedExt-", TAG_COUNT_200, true, EnumSet.of(DISCOVERED));
    usedTags.addAll(createTagStates("usedInt-", TAG_COUNT_200, false, EnumSet.of(SYSTEM)));
    List<String> unusedTagsExt = createTagStates("unusedExt-", 10, true, EnumSet.of(DISCOVERED));
    List<String> unusedTagsInt = createTagStates("unusedInt-", 8, false, EnumSet.of(SYSTEM));
    int totalTagsCreated = usedTags.size() + unusedTagsExt.size() + unusedTagsInt.size();
    createComputesWithTags(400, usedTags);
    createDisksWithTags(400, usedTags);
    executeTagsGroomerTask();
    QueryTask tagsQT = createTagsQueryTask(false);
    List<TagState> tagsAfterGrooming = getTags(tagsQT);
    // the only tags returned should the ones not marked as deleted
    assertEquals(totalTagsCreated - unusedTagsExt.size(), tagsAfterGrooming.size());
    // assert used tags are marked as deleted
    assertUsedTags(tagsAfterGrooming);
    tagsQT = createTagsQueryTask(true);
    tagsAfterGrooming = getTags(tagsQT);
    // the only tags returned should be the 10 external tags that are marked as deleted
    assertEquals(unusedTagsExt.size(), tagsAfterGrooming.size());
    // assert unused tags are marked as deleted
    assertUnusedTags(tagsAfterGrooming);
}
Also used : QueryTask(com.vmware.xenon.services.common.QueryTask) TagState(com.vmware.photon.controller.model.resources.TagService.TagState) Test(org.junit.Test)

Aggregations

TagState (com.vmware.photon.controller.model.resources.TagService.TagState)31 ArrayList (java.util.ArrayList)18 HashMap (java.util.HashMap)18 Operation (com.vmware.xenon.common.Operation)15 Query (com.vmware.xenon.services.common.QueryTask.Query)15 HashSet (java.util.HashSet)14 Map (java.util.Map)14 TagsUtil.newTagState (com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState)13 Utils (com.vmware.xenon.common.Utils)13 TagService (com.vmware.photon.controller.model.resources.TagService)12 QueryTask (com.vmware.xenon.services.common.QueryTask)12 List (java.util.List)12 Set (java.util.Set)12 StatelessService (com.vmware.xenon.common.StatelessService)11 Collectors (java.util.stream.Collectors)11 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)10 UriUtils (com.vmware.xenon.common.UriUtils)10 PhotonModelConstants (com.vmware.photon.controller.model.constants.PhotonModelConstants)8 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)8 ResourceState (com.vmware.photon.controller.model.resources.ResourceState)8