com.palantir.docker.compose.connection.waiting.HealthChecks Java Examples

The following examples show how to use com.palantir.docker.compose.connection.waiting.HealthChecks. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandaloneYamlTest.java    From nifi-minifi with Apache License 2.0 6 votes vote down vote up
public StandaloneYamlTest(String version, String name) throws IOException {
    this.version = version;
    this.name = name;
    String dockerComposeYmlFile = "target/test-classes/docker-compose-" + version + "-" + name + "Test-yml.yml";
    try (InputStream inputStream = StandaloneYamlTest.class.getClassLoader().getResourceAsStream("docker-compose-v1-standalone.yml");
         InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
         BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
         FileWriter fileWriter = new FileWriter(dockerComposeYmlFile);
         BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) {
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            bufferedWriter.write(line.replace("REPLACED_WITH_CONFIG_FILE", getConfigYml()));
            bufferedWriter.newLine();
        }
    }
    dockerComposeRule = DockerComposeRule.builder()
            .file(dockerComposeYmlFile)
            .waitingForService("minifi", HealthChecks.toRespond2xxOverHttp(8000, dockerPort -> "http://" + dockerPort.getIp() + ":" + dockerPort.getExternalPort()))
            .build();
}
 
Example #2
Source File: ArtifactoryServerConnection.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
@Override
public DockerComposeRule createRule() {
	return DockerComposeRule.builder()
			.file("src/integration/resources/docker-compose.yml")
			.waitingForService("artifactory", HealthChecks.toRespond2xxOverHttp(
					8081, DockerDelegate::artifactoryHealthUri))
			.build();
}
 
Example #3
Source File: EventsIntegrationTest.java    From docker-compose-rule with Apache License 2.0 5 votes vote down vote up
@Test
public void produce_events_on_a_successful_run() throws Throwable {
    DockerComposeManager dockerComposeManager = new DockerComposeManager.Builder()
            .file(ALL_GOOD_DOCKER_COMPOSE_YAML)
            .waitingForService("one", HealthChecks.toHaveAllPortsOpen())
            .addEventConsumer(eventConsumer)
            .build();

    runDockerComposeRule(dockerComposeManager);

    List<Event> events = getEvents();

    List<Class<?>> expected = ImmutableList.of(
            BuildEvent.class,
            UpEvent.class,
            // 2 cluster waits, one native, one user
            ClusterWaitEvent.class,
            ClusterWaitEvent.class,
            WaitForServicesEvent.class,
            ShutdownStopEvent.class,
            LogCollectionEvent.class,
            ShutdownEvent.class
    );

    assertThat(events).hasSameSizeAs(expected);
    for (int i = 0; i < events.size(); i++) {
        assertThat(events.get(i).toString()).contains(expected.get(i).getSimpleName());
    }
}
 
Example #4
Source File: DockerComposeFactory.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public static Extension startDockerCompose(Path tempFolder) {

		if (DockerComposeFactoryProperties.isDockerComposeDisabled()) {
			return (BeforeAllCallback) context -> logger.info("Docker Compose installation is disabled!");
		}

		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_DATAFLOW_VERSIONN,
				DockerComposeFactoryProperties.get(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_DATAFLOW_VERSIONN, DEFAULT_DATAFLOW_VERSION));
		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_SKIPPER_VERSIONN,
				DockerComposeFactoryProperties.get(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_SKIPPER_VERSIONN, DEFAULT_SKIPPER_VERSION));
		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_STREAM_APPS_URI,
				DockerComposeFactoryProperties.get(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_STREAM_APPS_URI, DEFAULT_STREAM_APPS_URI));
		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_TASK_APPS_URI,
				DockerComposeFactoryProperties.get(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_TASK_APPS_URI, DEFAULT_TASK_APPS_URI));
		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_PATHS,
				DockerComposeFactoryProperties.getDockerComposePaths(DEFAULT_DOCKER_COMPOSE_PATHS));

		String[] dockerComposePaths = new ResourceExtractor(tempFolder).extract(
				DockerComposeFactoryProperties.getDockerComposePaths(DEFAULT_DOCKER_COMPOSE_PATHS));
		logger.info("Extracted docker compose files = {}", Arrays.toString(dockerComposePaths));

		return DockerComposeExtension.builder()
				.files(DockerComposeFiles.from(dockerComposePaths))
				.machine(dockerMachine)
				.saveLogsTo("target/dockerLogs/DockerComposeIT")
				.waitingForService("dataflow-server", HealthChecks.toRespond2xxOverHttp(9393,
						(port) -> port.inFormat("http://$HOST:$EXTERNAL_PORT")), org.joda.time.Duration.standardMinutes(10))
				.waitingForService("skipper-server", HealthChecks.toRespond2xxOverHttp(7577,
						(port) -> port.inFormat("http://$HOST:$EXTERNAL_PORT")), org.joda.time.Duration.standardMinutes(10))
				// set to false to test with local dataflow and skipper images.
				.pullOnStartup(DockerComposeFactoryProperties.getBoolean(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_PULLONSTARTUP, true))
				.build();
	}