@Override public void run() { EntityAsserts.assertAttributeChangesEventually(entity, TestEntity.NAME); } });
@Test(groups="Integration") public void testEnrichersOnRebindJavaApp() throws Exception { VanillaJavaApp javaProcess = app.addChild(EntitySpec.create(VanillaJavaApp.class, EnrichedVanillaJavaAppImpl.class) .configure("main", MAIN_CLASS.getCanonicalName()).configure("classpath", ImmutableList.of(BROOKLYN_THIS_CLASSPATH))); app.start(ImmutableList.of(loc)); EntityAsserts.assertAttributeEventuallyNonNull(javaProcess, EnrichedVanillaJavaAppImpl.AVG1); EntityAsserts.assertAttributeEventuallyNonNull(javaProcess, EnrichedVanillaJavaAppImpl.AVG2); LOG.info("Got avg "+javaProcess.getAttribute(EnrichedVanillaJavaAppImpl.AVG1)); rebind(); VanillaJavaApp javaProcess2 = (VanillaJavaApp) Iterables.find(app.getChildren(), Predicates.instanceOf(VanillaJavaApp.class)); // check sensors working EntityAsserts.assertAttributeChangesEventually(javaProcess2, EnrichedVanillaJavaAppImpl.PROCESS_CPU_TIME); LOG.info("Avg now "+javaProcess2.getAttribute(EnrichedVanillaJavaAppImpl.AVG1)); // check enrichers are functioning EntityAsserts.assertAttributeChangesEventually(javaProcess2, EnrichedVanillaJavaAppImpl.AVG1); EntityAsserts.assertAttributeChangesEventually(javaProcess2, EnrichedVanillaJavaAppImpl.AVG2); LOG.info("Avg now "+javaProcess2.getAttribute(EnrichedVanillaJavaAppImpl.AVG1)); // and check we don't have too many Assert.assertEquals(javaProcess2.getEnrichers().size(), javaProcess.getEnrichers().size()); }
EntityAsserts.assertAttributeChangesEventually(newServer, JBoss7Server.REQUEST_COUNT); EntityAsserts.assertAttributeChangesEventually(newServer, JBoss7Server.REQUESTS_PER_SECOND_IN_WINDOW); EntityAsserts.assertAttributeChangesEventually(newServer, JBoss7Server.REQUESTS_PER_SECOND_IN_WINDOW); EntityAsserts.assertAttributeChangesEventually(newServer, JBoss7Server.PROCESSING_TIME_FRACTION_IN_WINDOW);
protected void runRebindWithHttpFeed(boolean setHostnameToNull) throws Exception { EmptySoftwareProcess origEntity = origApp.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class) .impl(SoftwareProcessWithHttpFeedImpl.class) .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true) .configure(EmptySoftwareProcess.USE_SSH_MONITORING, false) .configure(MOCK_URL, baseUrl.toString()) .location(LocationSpec.create(SshMachineLocation.class) .configure("address", baseUrl.getHost()) .configure(SshMachineLocation.SSH_TOOL_CLASS, RecordingSshTool.class.getName()))); origApp.start(ImmutableList.<Location>of()); if (setHostnameToNull) { origEntity.sensors().set(EmptySoftwareProcess.HOSTNAME, null); } newApp = rebind(); EmptySoftwareProcess newEntity = (EmptySoftwareProcess) Iterables.find(newApp.getChildren(), Predicates.instanceOf(EmptySoftwareProcess.class)); if (setHostnameToNull) { EntityAsserts.assertAttributeEqualsEventually(newEntity, SENSOR_STRING, "Failed"); } else { EntityAsserts.assertAttributeChangesEventually(newEntity, SENSOR_STRING); } }
for (Entity newERaw : newApp.getChildren()) { MyServiceWithFeeds newE = (MyServiceWithFeeds) newERaw; EntityAsserts.assertAttributeChangesEventually(newE, MyServiceWithFeeds.COUNTER); assertFalse(newE.isFeedCalledWhenNotManaged());