[ 
https://issues.apache.org/jira/browse/BROOKLYN-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16240819#comment-16240819
 ] 

ASF GitHub Bot commented on BROOKLYN-547:
-----------------------------------------

Github user duncangrant commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/881#discussion_r149190906
  
    --- Diff: 
software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessTest.java
 ---
    @@ -294,4 +309,63 @@ public void 
testCmdNotInheritedFromParentOfSoftwareProcess() throws Exception {
             assertExecHasOnlyOnce(RecordingSshTool.getExecCmds(), 
"preInstallCommand");
             assertExecHasOnlyOnce(RecordingSshTool.getExecCmds(), 
"launchCommand");
         }
    +    
    +    @Test
    +    public void testUseSshMonitoringDisabled() throws Exception {
    +        // Setup a custom health-check that returns true after launch is 
called, 
    +        // and false after stop is called.
    +        final AtomicBoolean customHealth = new AtomicBoolean(false);
    +        
    +        RecordingSshTool.setCustomResponse(".*launchCommand.*", new 
CustomResponseGenerator() {
    +            @Override public CustomResponse generate(ExecParams 
execParams) throws Exception {
    +                customHealth.set(true);
    +                return new CustomResponse(0, "", "");
    +            }});
    +        RecordingSshTool.setCustomResponse(".*stopCommand.*", new 
CustomResponseGenerator() {
    +            @Override public CustomResponse generate(ExecParams 
execParams) throws Exception {
    +                customHealth.set(false);
    +                return new CustomResponse(0, "", "");
    +            }});
    +        
    +        // The entity polls for the custom-health; it populates the 
service-up-indicators using that.
    +        VanillaSoftwareProcess entity = 
app.createAndManageChild(EntitySpec.create(VanillaSoftwareProcess.class)
    +                .configure(VanillaSoftwareProcess.USE_SSH_MONITORING, 
false)
    +                
.configure(VanillaSoftwareProcess.SERVICE_PROCESS_IS_RUNNING_POLL_PERIOD, 
Duration.ONE_MILLISECOND)
    +                .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, 
"launchCommand")
    +                .configure(VanillaSoftwareProcess.CHECK_RUNNING_COMMAND, 
"checkRunningCommand")
    +                .configure(VanillaSoftwareProcess.STOP_COMMAND, 
"stopCommand")
    +                .addInitializer(new 
FunctionSensor<Boolean>(ConfigBag.newInstance()
    +                        .configure(FunctionSensor.SENSOR_NAME, 
"myCustomHealth")
    +                        .configure(FunctionSensor.SUPPRESS_DUPLICATES, 
true)
    +                        .configure(FunctionSensor.SENSOR_PERIOD, 
Duration.ONE_MILLISECOND)
    +                        .configure(FunctionSensor.FUNCTION, new 
Callable<Boolean>() {
    +                            public Boolean call() {
    +                                return customHealth.get();
    +                            }})
    +                        ))
    +                .enricher(EnricherSpec.create(UpdatingMap.class)
    +                        .configure(UpdatingMap.SOURCE_SENSOR, 
Sensors.newBooleanSensor("myCustomHealth"))
    +                        .configure(UpdatingMap.TARGET_SENSOR, 
Attributes.SERVICE_NOT_UP_INDICATORS)
    +                        .configure(UpdatingMap.COMPUTING, Functions.forMap(
    +                                MutableMap.of(true, null, false, 
"custom-health-is-false"),
    +                                "custom-health-unknown")))
    +                        );
    +        
    +        // Start the entity
    +        app.start(ImmutableList.of(loc));
    +        EntityAsserts.assertAttributeEqualsEventually(entity, 
Attributes.SERVICE_UP, true);
    +
    +        // Expect to have ssh "checkRunningCommand" called once during 
startup, and not again 
    +        assertExecHasAtLeastOnce(RecordingSshTool.getExecCmds(), 
"checkRunningCommand");
    +        
    +        RecordingSshTool.clearCmdHistory();
    +        Asserts.succeedsContinually(ImmutableMap.of("timeout", 
Duration.millis(100)), new Runnable() {
    +            public void run() {
    +                assertExecHasNever(RecordingSshTool.getExecCmds(), 
"checkRunningCommand");
    +            }});
    +
    +        // Restart (see https://issues.apache.org/jira/browse/BROOKLYN-547)
    +        entity.restart();
    --- End diff --
    
    Should test SERVICE_UP false first?


> VanillaSoftwareProcess.restart fails if sshMonitoring disabled
> --------------------------------------------------------------
>
>                 Key: BROOKLYN-547
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-547
>             Project: Brooklyn
>          Issue Type: Bug
>            Reporter: Aled Sage
>
> When using {{VanillaSoftwareProcess}} with {{sshMonitoring.enabled: false}}, 
> the entity is set on fire if you call the {{restart}} effector.
> This is because... when the entity transitions to service.isUp=false during 
> the restart, it triggers the enricher 
> {{UpdatingNotUpFromServiceProcessIsRunning}}, which populates the 
> service-not-up-indicator with {{service.process.isRunning}}. This is never 
> cleared because we are not polling over ssh for the check-running.
> A solution would be to remove this enricher in {{VanillaSoftwareProcess}}, if 
> ssh-monitoring is disabled.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to