public void testAppStoppedAndEntityNullBeforeStarting() { // AbstractApplication has default logic to ensure service is not up if it hasn't been started, // (this can be removed by updating the problem indicator associated with the SERVICE_STATE_ACTUAL sensor) assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, false); // and from that it imputes stopped state assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); // TestEntity has no such indicators however assertAttributeEquals(entity, Attributes.SERVICE_UP, null); assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, null); }
public void testStopsNicelyToo() { app.start(ImmutableList.<Location>of()); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); app.stop(); assertAttributeEquals(app, Attributes.SERVICE_UP, false); assertAttributeEquals(entity, Attributes.SERVICE_UP, false); // above should be immediate, app and entity should then derive STOPPED from the expected state assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); }
public void testManuallySettingIndicatorsOnEntities() { assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
public void testTwoIndicatorsAreBetterThanOne() { // if we set a not up indicator, entity service up should become false ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_1, "We're pretending to block service up"); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_2, "We're also pretending to block service up"); ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_1); // clearing one indicator is not sufficient assertAttributeEquals(entity, Attributes.SERVICE_UP, false); // but it does not become true when both are cleared ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_2); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); }
@Test(groups={"WIP", "Broken"}) public void testServiceStateNotCalledExplicitly() throws Exception { ComputeServiceState oldEnricher = (ComputeServiceState) Iterables.find(app.enrichers(), Predicates.instanceOf(ComputeServiceState.class)); String oldUniqueTag = oldEnricher.getUniqueTag(); CountingComputeServiceState enricher = app.enrichers().add(EnricherSpec.create(CountingComputeServiceState.class) .uniqueTag(oldUniqueTag)); // Confirm that we only have one enricher now (i.e. we've replaced the original) Iterable<Enricher> newEnrichers = Iterables.filter(app.enrichers(), Predicates.instanceOf(ComputeServiceState.class)); assertEquals(Iterables.size(newEnrichers), 1, "newEnrichers="+newEnrichers); assertEquals(Iterables.getOnlyElement(newEnrichers), enricher, "newEnrichers="+newEnrichers); // When setting the expected state, previously that caused a onEvent(null) to be triggered synchronously ServiceStateLogic.setExpectedState(app, Lifecycle.RUNNING); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); assertTrue(enricher.cntCalled.get() > 0); assertEquals(enricher.cntCalledWithNull.get(), 0); }
public void testAllUpAndRunningAfterStart() { app.start(ImmutableList.<Location>of()); assertAttributeEquals(app, Attributes.SERVICE_UP, true); assertAttributeEquals(entity, Attributes.SERVICE_UP, true); // above should be immediate, entity should then derive RUNNING from expected state, and then so should app from children assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); }
assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); assertAttributeEqualsContinually(app, Attributes.SERVICE_UP, true); assertAttributeEqualsContinually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, false); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);