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 #212: Repeat ssh tests
Date Tue, 21 Jun 2016 19:28:34 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/212#discussion_r67935709
  
    --- Diff: test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSshCommandIntegrationTest.java
---
    @@ -58,12 +62,39 @@
         @Override
         public void setUp() throws Exception {
             super.setUp();
    -
             testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
                     .location(TestApplication.LOCALHOST_MACHINE_SPEC));
         }
     
         @Test(groups = "Integration")
    +    public void shouldRetryCommandWithinTimeout() throws Exception {
    +        TestSshCommand testWithCmd = app.createAndManageChild(EntitySpec.create(TestSshCommand.class)
    +                .configure(TARGET_ENTITY, testEntity)
    +                .configure(COMMAND, "_djaf-_f£39r24")
    +                .configure(RUN_DIR, "/tmp")
    +                .configure(TIMEOUT, Duration.TEN_SECONDS)
    +                .configure(ASSERT_STATUS, makeAssertions(ImmutableMap.of(EQUALS, 0))));
    +
    +        // Run the test's assertions in parallel with the app.
    +        Thread t = new Thread() {
    +            @Override
    +            public void run() {
    +                app.start(ImmutableList.<Location>of());
    +            }
    +        };
    +        t.start();
    +
    +        // Times out in one second.
    +        EntityAsserts.assertAttributeContinuallyNotEqualTo(testWithCmd, Attributes.SERVICE_STATE_ACTUAL,
Lifecycle.RUNNING);
    +
    +        // Replace command with a valid one and the test should start to pass.
    +        testWithCmd.config().set(COMMAND, "true");
    +        EntityAsserts.assertAttributeEqualsEventually(testWithCmd, Attributes.SERVICE_STATE_ACTUAL,
Lifecycle.RUNNING);
    +
    +        t.join();
    --- End diff --
    
    I'd prefer a timeout in the join - so if we introduce something that causes the thread
to not return, then the test would fail rather than hanging. But no strong feelings (given
we call app.start all over the place in the main thread for tests).


---
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