Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/windows smoke tests #180

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
195d9af
Locate docker and docker-compose using the path variable.
Mar 1, 2017
ab078a6
Merge branch 'feature/use-path-to-find-executables' of https://github…
hpryce Mar 7, 2017
a12076d
Reintroduce support for explicitly setting docker-compose location.
hpryce Mar 7, 2017
35ab870
Docker for Mac is not in the path when tests run from IDE.
hpryce Mar 7, 2017
252a88e
Split out finding possible command locations from testing those locat…
hpryce Mar 7, 2017
0a61921
Add jsr dep
hpryce Mar 7, 2017
d39fb31
Refactor to simply logic and improve test coverage by using Environme…
hpryce Mar 8, 2017
19791dd
Add case for Windows path variable "Path"
hpryce Mar 8, 2017
a734f16
Process builder will look for command on the path
hpryce Mar 8, 2017
215f427
Move integ tests into separate source set.
hpryce Mar 8, 2017
a8ce98b
Add very simple windows smoke test.
hpryce Mar 8, 2017
cc06e21
Wire up smoke test for Windows to appveyor.
hpryce Mar 9, 2017
186aba0
Thread.sleep isn't accurate on Windows
hpryce Mar 9, 2017
ed0d9cf
Simply don't run the tes that relies upon Thread.sleep on Windows
hpryce Mar 9, 2017
17a0b3b
Merge branch 'feature/look_in_path' into feature/windows_smoke_tests
hpryce Mar 9, 2017
bc6bdd9
Do we have the latest image?
hpryce Mar 10, 2017
1df8a38
Use Windows Server 2016 image
hpryce Mar 10, 2017
e903dac
Install docker-compose before running tests that need it
hpryce Mar 10, 2017
8c41711
Use image with more up to date docker
hpryce Mar 10, 2017
479efca
Correct appveyor.yml syntax
hpryce Mar 10, 2017
9492fb4
Try cinst
hpryce Mar 10, 2017
eafa3b0
Try installing both docker and docker-compose on old image
hpryce Mar 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .baseline/findbugs/excludeFilter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
<!-- Ignore the following bug patterns in test code -->
<!-- (i.e., classes ending in 'Test' or 'Tests', and inner classes of same) -->
<Match>
<Class name="~.*\.*Tests?(\$.*)?" />
<Class name="~.*\.*(Test|Tests|Should)?(\$.*)?" />
<Or>
<Bug pattern="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> <!-- common in tests to have non-final variables instantiated in @Before methods, which FindBugs can't detect -->
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/> <!-- if a null is dereferenced, test will fail anyway. Plus assertNotNull() is often a bad pattern. -->
<Bug pattern="RV_RETURN_VALUE_IGNORED_INFERRED"/> <!-- common in tests to call a method [that has a return value] to deliberately cause an exception, then test that exception -->
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/> <!-- ditto above -->
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/> <!-- @Rule ivars can be public and unused -->
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME"/> <!-- tests should be able to refer to notional directories -->
</Or>
</Match>
</FindBugsFilter>
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ build_script:
- gradlew.bat compileJava compileTestJava --info --no-daemon

test_script:
- gradlew.bat dependencies --info --no-daemon
- cinst -y docker docker-compose
- gradlew.bat test windowsSmokeTest --info --no-daemon

branches:
only:
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ subprojects {
apply plugin: 'com.palantir.baseline-eclipse'
apply plugin: 'com.palantir.baseline-findbugs'
apply plugin: 'com.palantir.baseline-idea'
apply from: "${rootDir}/gradle/integTest.gradle"
apply from: "${rootDir}/gradle/publish.gradle"

apply plugin: 'org.inferred.processors'
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test:
override:
- ? >
case $CIRCLE_NODE_INDEX in
0) ./gradlew test --info ;;
0) ./gradlew test integTest --info ;;
1) ./gradlew findbugsMain findbugsTest checkstyleMain checkstyleTest javadoc --info ;;
esac
:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-rule-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies {
compile "com.google.guava:guava:$guavaVersion"
compile "joda-time:joda-time:$jodaVersion"
compile "com.github.zafarkhaja:java-semver:$javaSemverVersion"
compile "com.google.code.findbugs:jsr305:3.0.0"

compile 'com.jayway.awaitility:awaitility:1.6.5'

Expand All @@ -18,7 +19,6 @@ dependencies {
testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
testCompile "org.mockito:mockito-core:$mockitoVersion"
testCompile "com.github.tomakehurst:wiremock:2.0.6-beta"
testCompile "com.google.code.findbugs:jsr305:3.0.0"
testCompile "com.github.stefanbirkner:system-rules:1.16.1"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ContainerIntegrationTests {
@Test
public void testStateChanges_withoutHealthCheck() throws IOException, InterruptedException {
DockerCompose dockerCompose = new DefaultDockerCompose(
DockerComposeFiles.from("src/test/resources/no-healthcheck.yaml"),
DockerComposeFiles.from("src/integTest/resources/no-healthcheck.yaml"),
dockerMachine,
ProjectName.random());

Expand All @@ -60,7 +60,7 @@ public void testStateChanges_withHealthCheck() throws IOException, InterruptedEx
assumeThat("docker-compose version", DockerCompose.version(), new GreaterOrEqual<>(Version.forIntegers(1, 10, 0)));

DockerCompose dockerCompose = new DefaultDockerCompose(
DockerComposeFiles.from("src/test/resources/native-healthcheck.yaml"),
DockerComposeFiles.from("src/integTest/resources/native-healthcheck.yaml"),
dockerMachine,
ProjectName.random());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -35,7 +34,7 @@ public class Docker {
private static final Logger log = LoggerFactory.getLogger(Docker.class);

// Without java escape characters: ^(\d+)\.(\d+)\.(\d+)(?:-.*)?$
private static final Pattern VERSION_PATTERN = Pattern.compile("^Docker version (\\d+)\\.(\\d+)\\.(\\d+)(?:-.*)?$");
private static final Pattern VERSION_PATTERN = Pattern.compile("^Docker version (\\d+)\\.(\\d+)\\.(\\d+)(?:(-|,).*)?$");
private static final String HEALTH_STATUS_FORMAT =
"--format="
+ "{{if not .State.Running}}DOWN"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2016 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.palantir.docker.compose.execution;

import com.google.common.collect.ImmutableList;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.commons.lang3.SystemUtils;
import org.immutables.value.Value;

@Value.Immutable
public abstract class DockerCommandLocator {

private static final List<String> MAC_SEARCH_LOCATIONS = ImmutableList.of("/usr/local/bin", "/usr/bin");

protected abstract String command();

@Value.Default
protected boolean isWindows() {
return SystemUtils.IS_OS_WINDOWS;
}

@Value.Default
protected List<String> macSearchLocations() {
return MAC_SEARCH_LOCATIONS;
}

@Value.Derived
protected String executableName() {
if (isWindows()) {
return command() + ".exe";
}
return command();
}

@Nullable
protected abstract String locationOverride();

public String getLocation() {
if (locationOverride() != null) {
return locationOverride();
}
return macSearchLocations()
.stream()
.map(p -> Paths.get(p, executableName()))
.filter(Files::exists)
.findFirst()
.map(Path::toString)
.orElse(executableName());
}

public static ImmutableDockerCommandLocator.Builder forCommand(String command) {
return ImmutableDockerCommandLocator.builder()
.command(command);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,12 @@
public abstract class DockerComposeExecutable implements Executable {
private static final Logger log = LoggerFactory.getLogger(DockerComposeExecutable.class);

private static final DockerCommandLocations DOCKER_COMPOSE_LOCATIONS = new DockerCommandLocations(
System.getenv("DOCKER_COMPOSE_LOCATION"),
"/usr/local/bin/docker-compose",
"/usr/bin/docker-compose"
);

private static String defaultDockerComposePath() {
String pathToUse = DOCKER_COMPOSE_LOCATIONS.preferredLocation()
.orElseThrow(() -> new IllegalStateException(
"Could not find docker-compose, looked in: " + DOCKER_COMPOSE_LOCATIONS));

DockerCommandLocator commandLocator = DockerCommandLocator.forCommand("docker-compose")
.locationOverride(System.getenv("DOCKER_COMPOSE_LOCATION"))
.build();
String pathToUse = commandLocator.getLocation();
log.debug("Using docker-compose found at " + pathToUse);

return pathToUse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
public abstract class DockerExecutable implements Executable {
private static final Logger log = LoggerFactory.getLogger(DockerExecutable.class);

private static final DockerCommandLocations DOCKER_LOCATIONS = new DockerCommandLocations(
System.getenv("DOCKER_LOCATION"),
"/usr/local/bin/docker",
"/usr/bin/docker"
);

@Value.Parameter protected abstract DockerConfiguration dockerConfiguration();

@Override
Expand All @@ -41,12 +35,11 @@ public final String commandName() {

@Value.Derived
protected String dockerPath() {
String pathToUse = DOCKER_LOCATIONS.preferredLocation()
.orElseThrow(() -> new IllegalStateException(
"Could not find docker, looked in: " + DOCKER_LOCATIONS));

DockerCommandLocator commandLocator = DockerCommandLocator.forCommand("docker")
.locationOverride(System.getenv("DOCKER_LOCATION"))
.build();
String pathToUse = commandLocator.getLocation();
log.debug("Using docker found at " + pathToUse);

return pathToUse;
}

Expand All @@ -66,4 +59,5 @@ public Process execute(String... commands) throws IOException {
public static ImmutableDockerExecutable.Builder builder() {
return ImmutableDockerExecutable.builder();
}

}

This file was deleted.