brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #388: Add a stop latch to SoftwareProcess.
Date Thu, 20 Oct 2016 16:47:59 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/388#discussion_r84326971
  
    --- Diff: software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
---
    @@ -116,14 +118,36 @@ public void testLaunchLatchBlocks() throws Exception {
             runTestLatchBlocks(SoftwareProcess.LAUNCH_LATCH, ImmutableList.of("setup", "copyInstallResources",
"install", "customize", "copyRuntimeResources"));
         }
     
    +    @Test
    +    public void testStopLatchBlocks() throws Exception {
    +        final AttributeSensor<Boolean> stopper = Sensors.newBooleanSensor("stop.now");
    +        final BasicEntity triggerEntity = app.createAndManageChild(EntitySpec.create(BasicEntity.class));
    +        final MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class)
    +                .configure(SoftwareProcess.STOP_LATCH, DependentConfiguration.attributeWhenReady(app,
stopper)));
    +        
    +        final Task<Void> startTask = Entities.invokeEffector(app, app, MyService.START,
ImmutableMap.of("locations", ImmutableList.of(loc)));
    +        ((EntityLocal)triggerEntity).sensors().set(Attributes.SERVICE_UP, true);
    +        startTask.get(Duration.THIRTY_SECONDS);
    +
    +        final Task<Void> stopTask = Entities.invokeEffector(app, app, MyService.STOP);
    +
    +        assertEffectorBlockingDetailsEventually(entity, MyService.STOP.getName(), "Waiting
for config " + SoftwareProcess.STOP_LATCH.getName());
    +
    +        app.sensors().set(stopper, true);
    +        stopTask.get(Duration.THIRTY_SECONDS);
    --- End diff --
    
    Very minor: I have a personal preference to use `Asserts.DEFAULT_LONG_TIMEOUT` rather
than hard-coding 30 seconds here (it comes to the same thing, because that default timeout
is 30 seconds).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message