Skip to content

Commit

Permalink
#188 Added DataVolumesSystemTest
Browse files Browse the repository at this point in the history
  • Loading branch information
frankscholten committed Aug 24, 2015
1 parent d533409 commit 0695333
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Protos.FrameworkInfo.Builder getBuilder() {
return frameworkBuilder;
}

private void setFrameworkId( Protos.FrameworkInfo.Builder frameworkBuilder) {
private void setFrameworkId (Protos.FrameworkInfo.Builder frameworkBuilder) {
Protos.FrameworkID frameworkID = configuration.getFrameworkId(); // DCOS certification 02
if (frameworkID != null && !frameworkID.getValue().isEmpty()) {
LOGGER.info("Found previous frameworkID: " + frameworkID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.apache.mesos.Protos;
import org.junit.Test;

import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -15,13 +15,13 @@ public class FrameworkInfoFactoryTest {
public static final int DUMMY_PORT = 1234;

@Test
public void shouldGetBuilder() {
Configuration configuration = mock(Configuration.class);
when(configuration.getFrameworkName()).thenReturn("TestFrameworkName");
when(configuration.getManagementApiPort()).thenReturn(DUMMY_PORT);
FrameworkInfoFactory frameworkInfoFactory = new FrameworkInfoFactory(configuration);
Protos.FrameworkInfo frameworkInfo = frameworkInfoFactory.getBuilder().build();
assertTrue(frameworkInfo.getWebuiUrl().contains("http://"));
assertTrue(frameworkInfo.getWebuiUrl().contains(Integer.toString(DUMMY_PORT)));
}
public void shouldGetBuilder() {
Configuration configuration = mock(Configuration.class);
when(configuration.getFrameworkName()).thenReturn("TestFrameworkName");
when(configuration.getManagementApiPort()).thenReturn(DUMMY_PORT);
FrameworkInfoFactory frameworkInfoFactory = new FrameworkInfoFactory(configuration);
Protos.FrameworkInfo frameworkInfo = frameworkInfoFactory.getBuilder().build();
assertTrue(frameworkInfo.getWebuiUrl().contains("http://"));
assertTrue(frameworkInfo.getWebuiUrl().contains(Integer.toString(DUMMY_PORT)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.apache.mesos.elasticsearch.systemtest;

import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import static org.junit.Assert.assertTrue;

/**
* Tests data volumes
*/
public class DataVolumesSystemTest extends TestBase {

public static final Logger LOGGER = Logger.getLogger(DiscoverySystemTest.class);

@Test
public void testDataVolumes() {
ElasticsearchSchedulerContainer scheduler = getScheduler();

TasksResponse tasksResponse = new TasksResponse(scheduler.getIpAddress(), NODE_COUNT);

List<JSONObject> tasks = tasksResponse.getTasks();

ElasticsearchNodesResponse nodesResponse = new ElasticsearchNodesResponse(tasks, NODE_COUNT);
assertTrue("Elasticsearch nodes did not discover each other within 5 minutes", nodesResponse.isDiscoverySuccessful());

try (InputStream inputstream = CONFIG.dockerClient.copyFileFromContainerCmd(CLUSTER.getMesosContainer().getContainerId(), "/var/lib/elasticsearch/mesos-elasticsearch").withHostPath("/tmp").exec()) {
String contents = IOUtils.toString(inputstream);
inputstream.close();
assertTrue(contents.contains("mesos-elasticsearch/nodes"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/0"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/0/_state"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/0/node.lock"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/1"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/1/_state"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/1/node.lock"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/2"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/2/_state"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/2/node.lock"));
} catch (IOException e) {
LOGGER.error("Could not copy /var/lib/elasticsearch/mesos-elasticsearch from Mesos-Local container");
}
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package org.apache.mesos.elasticsearch.systemtest;

import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import static org.junit.Assert.assertTrue;
Expand All @@ -28,23 +25,6 @@ public void testNodeDiscoveryRest() {

ElasticsearchNodesResponse nodesResponse = new ElasticsearchNodesResponse(tasks, NODE_COUNT);
assertTrue("Elasticsearch nodes did not discover each other within 5 minutes", nodesResponse.isDiscoverySuccessful());

try (InputStream inputstream = CONFIG.dockerClient.copyFileFromContainerCmd(CLUSTER.getMesosContainer().getContainerId(), "/var/lib/elasticsearch/mesos-elasticsearch").withHostPath("/tmp").exec()) {
String contents = IOUtils.toString(inputstream);
inputstream.close();
assertTrue(contents.contains("mesos-elasticsearch/nodes"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/0"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/0/_state"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/0/node.lock"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/1"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/1/_state"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/1/node.lock"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/2"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/2/_state"));
assertTrue(contents.contains("mesos-elasticsearch/nodes/2/node.lock"));
} catch (IOException e) {
LOGGER.error("Could not copy /var/lib/elasticsearch/mesos-elasticsearch from Mesos-Local container");
}
}

}

0 comments on commit 0695333

Please sign in to comment.