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

    https://github.com/apache/brooklyn-server/pull/225#discussion_r69135517
  
    --- Diff: 
test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSshCommandTest.java
 ---
    @@ -278,6 +274,28 @@ public void shouldFailIfTestEntityHasNoMachine() 
throws Exception {
         }
         
         @Test
    +    public void shouldFailFastIfNoCommand() throws Exception {
    +        Map<String, ?> equalsZero = ImmutableMap.of(EQUALS, 0);
    +        
    +        TestSshCommand test = 
app.createAndManageChild(EntitySpec.create(TestSshCommand.class)
    +                .configure(TIMEOUT, Duration.ONE_MINUTE)
    +                .configure(TARGET_ENTITY, testEntity)
    +                .configure(ASSERT_STATUS, makeAssertions(equalsZero)));
    +
    +        Stopwatch stopwatch = Stopwatch.createStarted();
    +        try {
    +            app.start(ImmutableList.<Location>of());
    +            Asserts.shouldHaveFailedPreviously();
    +        } catch (Exception e) {
    +            Asserts.expectedFailureContains(e, "Must specify exactly one 
of download.url and command");
    +            Duration elapsed = Duration.of(stopwatch);
    +            
Asserts.assertTrue(elapsed.isShorterThan(Duration.THIRTY_SECONDS), 
"elapsed="+elapsed);
    +        }
    +
    +        assertServiceFailed(test);
    +    }
    --- End diff --
    
    What do you think about adding the opposite test:
    ```java
        @Test
        public void 
testTargetEntityByIdWithDelayedEntityCreationAndNoTargetResolutionTimeout() {
            final Duration entityCreationDelay = Duration.millis(250);
            ExecutorService executor = Executors.newCachedThreadPool();
    
            try {
                executor.submit(new Runnable() {
                    @Override
                    public void run() {
                        Time.sleep(entityCreationDelay);
                        TestEntity target = 
app.addChild(EntitySpec.create(TestEntity.class)
                                .configure(BrooklynCampConstants.PLAN_ID, 
"myTargetId"));
                        target.sensors().set(STRING_SENSOR, "myval");
                    }
                });
    
                app.addChild(EntitySpec.create(TestSensor.class)
                        .configure(TestSensor.TARGET_ID, "myTargetId")
                        .configure(TestSensor.SENSOR_NAME, 
STRING_SENSOR.getName())
                        .configure(TestSensor.ASSERTIONS, 
ImmutableList.of(ImmutableMap.of("equals", "myval"))));
    
    
                app.start(ImmutableList.<Location>of());
    
            } catch (Exception e) {
                Throwable noSuchElementException = 
Exceptions.getFirstThrowableOfType(e, NoSuchElementException.class);
                Asserts.assertNotNull(noSuchElementException);
                
Asserts.assertTrue(noSuchElementException.getMessage().equals("No entity 
matching id myTargetId"));
            } finally {
                executor.shutdownNow();
            }
        }
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to