Search in sources :

Example 1 with StatePath

use of org.dcache.services.info.base.StatePath in project dcache by dCache.

the class ReservationByDescMaintainerTests method testTwoReservationsSameVoTransitionRemovesReservation.

@Test
public void testTwoReservationsSameVoTransitionRemovesReservation() {
    /* Common info */
    String role = "";
    String vo = "atlas";
    String group = "/" + vo;
    String FQAN = group;
    String resv1Desc = "MCDISK";
    String resv1Id = "id-1";
    int resv1Total = 10;
    int resv1Used = 1;
    int resv1Allocated = 1;
    int resv1Free = 8;
    String resv2Desc = "SCRATCH";
    String resv2Id = "id-2";
    int resv2Total = 20;
    int resv2Used = 2;
    int resv2Allocated = 3;
    int resv2Free = 15;
    StateLocation.putReservationDescription(_exhibitor, resv1Id, resv1Desc);
    StateLocation.putReservationAuth(_exhibitor, resv1Id, FQAN, group, role);
    StateLocation.putReservationSpace(_exhibitor, resv1Id, resv1Total, resv1Used, resv1Allocated, resv1Free);
    StateLocation.putReservationState(_exhibitor, resv1Id, ReservationInfo.State.RESERVED);
    StateLocation.putReservationDescription(_exhibitor, resv2Id, resv2Desc);
    StateLocation.putReservationAuth(_exhibitor, resv2Id, FQAN, group, role);
    StateLocation.putReservationSpace(_exhibitor, resv2Id, resv2Total, resv2Used, resv2Allocated, resv2Free);
    StateLocation.putReservationState(_exhibitor, resv2Id, ReservationInfo.State.RESERVED);
    StateLocation.transitionRemovesReservation(_transition, resv2Id);
    triggerWatcher();
    StatePath expectedSummary = SUMMARY_RESERVATIONS_BY_VO.newChild(vo);
    assertPurge("check all of reservation-2 is removed", expectedSummary.newChild("by-description").newChild(resv2Desc));
}
Also used : StatePath(org.dcache.services.info.base.StatePath) Test(org.junit.Test)

Example 2 with StatePath

use of org.dcache.services.info.base.StatePath in project dcache by dCache.

the class ReservationByDescMaintainerTests method testReservationTransitionUpdatesSpaceMetric.

@Test
public void testReservationTransitionUpdatesSpaceMetric() {
    String id = "id";
    String vo = "atlas";
    String group = "/" + vo;
    String role = "";
    String FQAN = group;
    String description = "SCRATCH";
    long oldTotal = 10;
    long newTotal = 20;
    long used = 2;
    long allocated = 1;
    long free = 7;
    StateLocation.putReservationAuth(_exhibitor, id, FQAN, group, role);
    StateLocation.putReservationDescription(_exhibitor, id, description);
    StateLocation.putReservationSpace(_exhibitor, id, oldTotal, used, allocated, free);
    StateLocation.putReservationState(_exhibitor, id, ReservationInfo.State.RESERVED);
    StateLocation.transitionAddsReservationSpaceTotal(_transition, 4, id, newTotal);
    triggerWatcher();
    assertEquals("Check number of purges", 0, _update.countPurges());
    StatePath expectedSummarySpace = SUMMARY_RESERVATIONS_BY_VO.newChild(vo).newChild("by-description").newChild(description).newChild("space");
    assertIntegerMetric("total metric", expectedSummarySpace.newChild("total"), newTotal);
}
Also used : StatePath(org.dcache.services.info.base.StatePath) Test(org.junit.Test)

Example 3 with StatePath

use of org.dcache.services.info.base.StatePath in project dcache by dCache.

the class ReservationByDescMaintainerTests method testEmptyNewReservation.

/**
 * State is empty.  We add a complete reservation.
 */
@Test
public void testEmptyNewReservation() {
    String id = "id";
    String vo = "atlas";
    String group = "/" + vo;
    String role = "";
    String FQAN = group;
    String description = "MCDISK";
    long total = 10;
    long used = 2;
    long allocated = 1;
    long free = 7;
    StateLocation.transitionAddsReservation(_transition, id, 0);
    StateLocation.transitionAddsReservationDescription(_transition, 2, id, description);
    StateLocation.transitionAddsReservationAuth(_transition, 2, id, FQAN, group, role);
    StateLocation.transitionAddsReservationSpace(_transition, 2, id, total, used, allocated, free);
    StateLocation.transitionAddsReservationState(_transition, 2, id, ReservationInfo.State.RESERVED);
    triggerWatcher();
    assertEquals("Check number of purges", 0, _update.countPurges());
    StatePath expectedSummary = SUMMARY_RESERVATIONS_BY_VO.newChild(vo).newChild("by-description").newChild(description);
    assertStringMetric("vo metric", expectedSummary.newChild("vo"), vo);
    StatePath expectedSummarySpace = expectedSummary.newChild("space");
    assertIntegerMetric("total metric", expectedSummarySpace.newChild("total"), total);
    assertIntegerMetric("used metric", expectedSummarySpace.newChild("used"), used);
    assertIntegerMetric("free metric", expectedSummarySpace.newChild("free"), free);
    assertIntegerMetric("allocated metric", expectedSummarySpace.newChild("allocated"), allocated);
    Set<String> ids = new HashSet<>();
    ids.add(id);
    assertList("reservations list", expectedSummary.newChild("reservations"), ids);
}
Also used : StatePath(org.dcache.services.info.base.StatePath) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with StatePath

use of org.dcache.services.info.base.StatePath in project dcache by dCache.

the class ReservationByDescMaintainerTests method testReservationTransitionUpdatesVo.

@Test
public void testReservationTransitionUpdatesVo() {
    String id = "id";
    String oldVo = "atlas";
    String oldGroup = "/" + oldVo;
    String oldRole = "";
    String oldFQAN = oldGroup;
    String description = "SCRATCH";
    long total = 10;
    long used = 2;
    long allocated = 1;
    long free = 7;
    StateLocation.putReservationAuth(_exhibitor, id, oldFQAN, oldGroup, oldRole);
    StateLocation.putReservationDescription(_exhibitor, id, description);
    StateLocation.putReservationSpace(_exhibitor, id, total, used, allocated, free);
    StateLocation.putReservationState(_exhibitor, id, ReservationInfo.State.RESERVED);
    String newVo = "cms";
    String newGroup = "/" + newVo;
    String newFQAN = newGroup;
    String newRole = "";
    StateLocation.transitionAddsReservationAuth(_transition, 4, id, newFQAN, newGroup, newRole);
    triggerWatcher();
    // SIP should purge the old atlas information
    assertEquals("Check number of purges", 1, _update.countPurges());
    // Check that new summary is created with the new VO.
    StatePath expectedSummaryBase = SUMMARY_RESERVATIONS_BY_VO.newChild(newVo).newChild("by-description").newChild(description);
    assertStringMetric("checking new vo summary", expectedSummaryBase.newChild("vo"), newVo);
    StatePath expectedSummarySpace = expectedSummaryBase.newChild("space");
    assertIntegerMetric("checking total", expectedSummarySpace.newChild("total"), total);
    assertIntegerMetric("checking used", expectedSummarySpace.newChild("used"), used);
    assertIntegerMetric("checking allocated", expectedSummarySpace.newChild("allocated"), allocated);
    assertIntegerMetric("checking free", expectedSummarySpace.newChild("free"), free);
}
Also used : StatePath(org.dcache.services.info.base.StatePath) Test(org.junit.Test)

Example 5 with StatePath

use of org.dcache.services.info.base.StatePath in project dcache by dCache.

the class ReservationByDescMaintainerTests method testTwoReservationsSameVoAndDescriptionTransitionRemovesReservation.

@Test
public void testTwoReservationsSameVoAndDescriptionTransitionRemovesReservation() {
    /* Common info */
    String resvDesc = "MCDISK";
    String role = "";
    String vo = "atlas";
    String group = "/" + vo;
    String FQAN = group;
    String resv1Id = "id-1";
    int resv1Total = 10;
    int resv1Used = 1;
    int resv1Allocated = 1;
    int resv1Free = 8;
    String resv2Id = "id-2";
    int resv2Total = 20;
    int resv2Used = 2;
    int resv2Allocated = 3;
    int resv2Free = 15;
    StateLocation.putReservationDescription(_exhibitor, resv1Id, resvDesc);
    StateLocation.putReservationAuth(_exhibitor, resv1Id, FQAN, group, role);
    StateLocation.putReservationSpace(_exhibitor, resv1Id, resv1Total, resv1Used, resv1Allocated, resv1Free);
    StateLocation.putReservationState(_exhibitor, resv1Id, ReservationInfo.State.RESERVED);
    StateLocation.putReservationDescription(_exhibitor, resv2Id, resvDesc);
    StateLocation.putReservationAuth(_exhibitor, resv2Id, FQAN, group, role);
    StateLocation.putReservationSpace(_exhibitor, resv2Id, resv2Total, resv2Used, resv2Allocated, resv2Free);
    StateLocation.putReservationState(_exhibitor, resv2Id, ReservationInfo.State.RESERVED);
    StateLocation.transitionRemovesReservation(_transition, resv2Id);
    triggerWatcher();
    StatePath expectedSummary = SUMMARY_RESERVATIONS_BY_VO.newChild(vo).newChild("by-description").newChild(resvDesc);
    StatePath expectedReservations = expectedSummary.newChild("reservations");
    assertPurge("check reservation 2 is removed", expectedReservations.newChild(resv2Id));
    /* Should update to reflect new space info */
    StatePath expectedSummarySpace = expectedSummary.newChild("space");
    assertIntegerMetric("total metric", expectedSummarySpace.newChild("total"), resv1Total);
    assertIntegerMetric("used metric", expectedSummarySpace.newChild("used"), resv1Used);
    assertIntegerMetric("free metric", expectedSummarySpace.newChild("free"), resv1Free);
    assertIntegerMetric("allocated metric", expectedSummarySpace.newChild("allocated"), resv1Allocated);
}
Also used : StatePath(org.dcache.services.info.base.StatePath) Test(org.junit.Test)

Aggregations

StatePath (org.dcache.services.info.base.StatePath)72 IntegerStateValue (org.dcache.services.info.base.IntegerStateValue)16 StringStateValue (org.dcache.services.info.base.StringStateValue)16 Test (org.junit.Test)14 StateUpdate (org.dcache.services.info.base.StateUpdate)11 StateComposite (org.dcache.services.info.base.StateComposite)7 Map (java.util.Map)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 Set (java.util.Set)3 BadStatePathException (org.dcache.services.info.base.BadStatePathException)3 BooleanStateValue (org.dcache.services.info.base.BooleanStateValue)3 Date (java.util.Date)2 SpaceInfo (org.dcache.services.info.stateInfo.SpaceInfo)2 InetAddresses.toUriString (com.google.common.net.InetAddresses.toUriString)1 PoolCostInfo (diskCacheV111.pools.PoolCostInfo)1 NamedPoolQueueInfo (diskCacheV111.pools.PoolCostInfo.NamedPoolQueueInfo)1 LinkGroup (diskCacheV111.services.space.LinkGroup)1 Space (diskCacheV111.services.space.Space)1 GetLinkGroupsMessage (diskCacheV111.services.space.message.GetLinkGroupsMessage)1