use of com.palantir.docker.compose.connection.DockerPort in project atlasdb by palantir.
the class QosCassandraEteTestSetup method getAtlasDbConfig.
private static AtlasDbConfig getAtlasDbConfig() {
DockerPort cassandraPort = docker.containers().container("cassandra").port(CASSANDRA_PORT_NUMBER);
InetSocketAddress cassandraAddress = new InetSocketAddress(cassandraPort.getIp(), cassandraPort.getExternalPort());
CassandraKeyValueServiceConfig kvsConfig = ImmutableCassandraKeyValueServiceConfig.builder().servers(ImmutableList.of(cassandraAddress)).credentials(ImmutableCassandraCredentialsConfig.builder().username("cassandra").password("cassandra").build()).ssl(false).replicationFactor(1).autoRefreshNodes(false).build();
return ImmutableAtlasDbConfig.builder().namespace("qosete").keyValueService(kvsConfig).initializeAsync(true).build();
}
use of com.palantir.docker.compose.connection.DockerPort in project atlasdb by palantir.
the class NodesDownTestSetup method killCassandraContainer.
private static void killCassandraContainer(String containerName) throws IOException, InterruptedException {
CONTAINERS.getContainer(containerName).kill();
DockerPort containerPort = new DockerPort(containerName, CASSANDRA_THRIFT_PORT, CASSANDRA_THRIFT_PORT);
Awaitility.waitAtMost(10, TimeUnit.SECONDS).pollInterval(2, TimeUnit.SECONDS).until(() -> !containerPort.isListeningNow());
}
use of com.palantir.docker.compose.connection.DockerPort in project nifi-minifi by apache.
the class LogUtil method verifyLogEntries.
public static void verifyLogEntries(String expectedJsonFilename, Container container) throws Exception {
List<ExpectedLogEntry> expectedLogEntries;
try (InputStream inputStream = LogUtil.class.getClassLoader().getResourceAsStream(expectedJsonFilename)) {
List<Map<String, Object>> expected = new ObjectMapper().readValue(inputStream, List.class);
expectedLogEntries = expected.stream().map(map -> new ExpectedLogEntry(Pattern.compile((String) map.get("pattern")), (int) map.getOrDefault("occurrences", 1))).collect(Collectors.toList());
}
DockerPort dockerPort = container.port(8000);
logger.info("Connecting to external port {} for docker internal port of {}", new Object[] { dockerPort.getExternalPort(), dockerPort.getInternalPort() });
URL url = new URL("http://" + dockerPort.getIp() + ":" + dockerPort.getExternalPort());
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try (InputStream inputStream = urlConnection.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
String line;
for (ExpectedLogEntry expectedLogEntry : expectedLogEntries) {
boolean satisfied = false;
int occurrences = 0;
while ((line = bufferedReader.readLine()) != null) {
if (expectedLogEntry.pattern.matcher(line).find()) {
logger.info("Found expected: " + line);
if (++occurrences >= expectedLogEntry.numOccurrences) {
logger.info("Found target " + occurrences + " times");
satisfied = true;
break;
}
}
}
if (!satisfied) {
fail("End of log reached without " + expectedLogEntry.numOccurrences + " match(es) of " + expectedLogEntry.pattern);
}
}
} finally {
urlConnection.disconnect();
}
}
use of com.palantir.docker.compose.connection.DockerPort in project nifi-minifi by apache.
the class AbstractTestSecure method openUrlConnection.
protected HttpsURLConnection openUrlConnection(String url, SSLContext sslContext) throws IOException {
DockerPort dockerPort = docker.containers().container("squid").port(3128);
HttpsURLConnection httpURLConnection = (HttpsURLConnection) new URL(url).openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(dockerPort.getIp(), dockerPort.getExternalPort())));
httpURLConnection.setSSLSocketFactory(sslContext.getSocketFactory());
return httpURLConnection;
}
Aggregations