private ElasticPlacementZoneState createEpz(String rpLink, String... tagLinks) throws Throwable { return doPost(buildEpzState(rpLink, tagLinks), ElasticPlacementZoneService.FACTORY_LINK); }
@Test public void testCreateDelete() throws Throwable { ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState = buildRpState(); state.epzState = buildEpzState(null, "tag1", "tag2"); ElasticPlacementZoneConfigurationState createdState = sendState(state, Action.POST); delete(ElasticPlacementZoneConfigurationService.SELF_LINK + createdState.resourcePoolState.documentSelfLink); assertNull( searchForDocument(ResourcePoolState.class, createdState.resourcePoolState.documentSelfLink)); assertNull(searchForDocument(ElasticPlacementZoneState.class, createdState.epzState.documentSelfLink)); }
@Test public void testUpdateWithEpz() throws Throwable { // create through the config service ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState = buildRpState(); state.epzState = buildEpzState(null, "tag1", "tag2"); ElasticPlacementZoneConfigurationState createdState = sendState(state, Action.POST); // update through the config service ElasticPlacementZoneConfigurationState patchState = createState(true); patchState.resourcePoolState.documentSelfLink = createdState.resourcePoolState.documentSelfLink; patchState.resourcePoolState.name = "new-name"; patchState.epzState = buildEpzState(patchState.resourcePoolState.documentSelfLink, "tag3", "tag4"); patchState.epzState.documentSelfLink = createdState.epzState.documentSelfLink; ElasticPlacementZoneConfigurationState latestState = sendState(patchState, Action.PATCH); // validate returned state assertEquals("new-name", latestState.resourcePoolState.name); assertNotNull(latestState.resourcePoolState.query); assertEquals(patchState.epzState.tagLinksToMatch, latestState.epzState.tagLinksToMatch); // validate the actual RP state ResourcePoolState rp = getDocument(ResourcePoolState.class, createdState.resourcePoolState.documentSelfLink); assertEquals("new-name", rp.name); // validate the actual EPZ state ElasticPlacementZoneState epz = getDocument(ElasticPlacementZoneState.class, createdState.epzState.documentSelfLink); assertEquals(patchState.epzState.tagLinksToMatch, epz.tagLinksToMatch); }
@Test public void testCreateWithEpz() throws Throwable { ElasticPlacementZoneConfigurationState state = createState(true); state.resourcePoolState = buildRpState(); state.epzState = buildEpzState(null, "tag1", "tag2"); ElasticPlacementZoneConfigurationState returnedState = sendState(state, Action.POST); assertNotNull(returnedState.resourcePoolState.documentSelfLink); assertNotNull(searchForDocument(ResourcePoolState.class, returnedState.resourcePoolState.documentSelfLink)); assertNotNull(returnedState.epzState.documentSelfLink); assertNotNull(searchForDocument(ElasticPlacementZoneState.class, returnedState.epzState.documentSelfLink)); assertEquals(state.resourcePoolState.name, returnedState.resourcePoolState.name); assertEquals(state.epzState.tagLinksToMatch, returnedState.epzState.tagLinksToMatch); }
@Test public void testUpdateAddingEpz() throws Throwable { // create through the config service with no EPZ ElasticPlacementZoneConfigurationState state = createState(false); state.resourcePoolState = buildRpState(); ElasticPlacementZoneConfigurationState createdState = sendState(state, Action.POST); // add EPZ through the config service ElasticPlacementZoneConfigurationState patchState = createState(false); patchState.resourcePoolState.documentSelfLink = createdState.resourcePoolState.documentSelfLink; patchState.epzState = buildEpzState(patchState.resourcePoolState.documentSelfLink, "tag3", "tag4"); ElasticPlacementZoneConfigurationState latestState = sendState(patchState, Action.PATCH); // validate returned state assertNotNull(latestState.epzState); assertNotNull(latestState.epzState.documentSelfLink); assertEquals(patchState.epzState.tagLinksToMatch, latestState.epzState.tagLinksToMatch); // validate the actual EPZ state ElasticPlacementZoneState epz = getDocument(ElasticPlacementZoneState.class, latestState.epzState.documentSelfLink); assertEquals(patchState.epzState.tagLinksToMatch, epz.tagLinksToMatch); }