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

    https://github.com/apache/incubator-brooklyn/pull/5#discussion_r14663151
  
    --- Diff: 
software/nosql/src/test/java/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeIntegrationTest.java
 ---
    @@ -0,0 +1,94 @@
    +package brooklyn.entity.nosql.elasticsearch;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +import java.net.URI;
    +import java.net.URISyntaxException;
    +
    +import org.apache.http.client.methods.HttpGet;
    +import org.bouncycastle.util.Strings;
    +import org.testng.annotations.AfterMethod;
    +import org.testng.annotations.BeforeMethod;
    +import org.testng.annotations.Test;
    +
    +import brooklyn.entity.basic.ApplicationBuilder;
    +import brooklyn.entity.basic.Attributes;
    +import brooklyn.entity.basic.Entities;
    +import brooklyn.entity.proxying.EntitySpec;
    +import brooklyn.entity.trait.Startable;
    +import brooklyn.event.feed.http.HttpValueFunctions;
    +import brooklyn.location.Location;
    +import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
    +import brooklyn.test.EntityTestUtils;
    +import brooklyn.test.entity.TestApplication;
    +import brooklyn.util.http.HttpTool;
    +import brooklyn.util.http.HttpToolResponse;
    +
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.ImmutableMap;
    +
    +public class ElasticSearchNodeIntegrationTest {
    +    
    +    protected TestApplication app;
    +    protected Location testLocation;
    +    protected ElasticSearchNode elasticSearchNode;
    +
    +    @BeforeMethod(alwaysRun = true)
    +    public void setup() throws Exception {
    +        app = ApplicationBuilder.newManagedApp(TestApplication.class);
    +        testLocation = new LocalhostMachineProvisioningLocation();
    +    }
    +
    +    @AfterMethod(alwaysRun = true)
    +    public void shutdown() {
    +        Entities.destroyAll(app.getManagementContext());
    +    }
    +    
    +    @Test(groups = {"Integration"})
    +    public void testStartupAndShutdown() {
    +        elasticSearchNode = 
app.createAndManageChild(EntitySpec.create(ElasticSearchNode.class));
    +        app.start(ImmutableList.of(testLocation));
    +        
    +        EntityTestUtils.assertAttributeEqualsEventually(elasticSearchNode, 
Startable.SERVICE_UP, true);
    +        
    +        elasticSearchNode.stop();
    +        
    +        EntityTestUtils.assertAttributeEqualsEventually(elasticSearchNode, 
Startable.SERVICE_UP, false);
    +    }
    +    
    +    @Test(groups = {"Integration"})
    +    public void testDocumentCount() throws URISyntaxException {
    +        elasticSearchNode = 
app.createAndManageChild(EntitySpec.create(ElasticSearchNode.class));
    +        app.start(ImmutableList.of(testLocation));
    +        
    +        EntityTestUtils.assertAttributeEqualsEventually(elasticSearchNode, 
Startable.SERVICE_UP, true);
    +        
    +        EntityTestUtils.assertAttributeEquals(elasticSearchNode, 
ElasticSearchNode.DOCUMENT_COUNT, 0);
    +        
    +        String baseUri = "http://"; + 
elasticSearchNode.getAttribute(Attributes.HOSTNAME) + ":" + 
elasticSearchNode.getAttribute(Attributes.HTTP_PORT);
    +        
    +        HttpToolResponse pingResponse = HttpTool.execAndConsume(
    +                HttpTool.httpClientBuilder().build(),
    +                new HttpGet(baseUri));
    +        assertEquals(pingResponse.getResponseCode(), 200);
    +        
    +        String document = "{\"foo\" : \"bar\",\"baz\" : \"quux\"}";
    +        
    +        HttpToolResponse putResponse = HttpTool.httpPut(
    +                HttpTool.httpClientBuilder()
    +                    
.port(elasticSearchNode.getAttribute(Attributes.HTTP_PORT))
    --- End diff --
    
    Surprised we have to pass port in here, given it's in the `baseUri`. I 
think it would only be needed if using `https`. But I'm fine leaving it here.


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