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

Fix test for Win & filter tests requiring remote resources #1127

Merged
merged 7 commits into from
May 13, 2019

Conversation

AndyGee
Copy link
Contributor

@AndyGee AndyGee commented May 9, 2019

Trivial cleanups

Short description of what this resolves:

Fix tests on Win and allow filtering of tests that attempt to access remote resources (eg, blocked by a firewall).

Changes proposed in this pull request:

  • Flag tests with RequiresRemoteResource to enable filtering
  • Remove unused imports
  • Update junit5 version
  • Log useful info and error conditions

Preparation of #1107 - Which is a much larger WIP PR for later

…cleanups

Flag tests with RequiresRemoteResource to enable filtering
Remove unused imports
Update junit version
Log useful info and error conditions
iteration++;
iteration++;
loop = !result && iteration < totalIterations;
if (loop) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only wait if we're going to loop again

@AndyGee AndyGee changed the title Fix test for Win & filter tests requiring remote resources WIP: Fix test for Win & filter tests requiring remote resources May 12, 2019
@AndyGee AndyGee changed the title WIP: Fix test for Win & filter tests requiring remote resources Fix test for Win & filter tests requiring remote resources May 12, 2019
@@ -37,7 +37,7 @@
public static final String CLEAN = "clean";
public static final String REMOVE_VOLUMES = "removeVolumes";
public static final String CLEAN_BUILD_IMAGE = "cleanBuildImage";
static final String DIND_RESOLUTION = "dockerInsideDockerResolution";
public static final String DIND_RESOLUTION = "dockerInsideDockerResolution";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required outside


String machineName = config.get(CubeDockerConfiguration.DOCKER_MACHINE_NAME);
String machineUrl = CubeDockerConfiguration.resolveUrl(machineVersion);

if (!dockerMachineFileExist) {
dockerMachineFile.getParentFile().mkdirs();
final File parentFile = dockerMachineFile.getParentFile();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safer

System.setProperty(String.format("%s.ip", cubePrefix), bindings.getIP());
System.setProperty(String.format("%s.internal.ip", cubePrefix), bindings.getInternalIP());

final String ip = bindings.getIP();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value or empty string

@@ -519,6 +506,16 @@ private void initializeCube() {
}
cubeController.create(containerName);
cubeController.start(containerName);
logger.log(Level.INFO, "Started container: " + getContainerInfo(containerName));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really useful info if available


this.dockerClient = buildDockerClient();


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than exposing this outside it made sense to me to add a shutdown hook for this important cleanup.

@@ -1168,6 +1182,10 @@ public URI getDockerUri() {
return dockerUri;
}

public boolean isDockerInsideDockerResolution() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Object is passed around (config is not) and providing this here is useful to understand the client context.

@@ -57,11 +59,11 @@
Top top;

private static Matcher<String> defaultDockerMachineCertPath() {
return containsString(".docker/machine/machines");
return containsString(".docker" + File.separator + "machine" + File.separator + "machines");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win fix, really need to ensure such paths are independent everywhere.

}

return null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is always the fallback

import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
@Category({RequiresRemoteResource.class})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows tests to be excluded that make real remote calls, which just breaks when behind a corporate firewall.

@@ -26,12 +26,11 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managed higher up

<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.2</version>
<version>1.3.2</version>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Junit 5 doesn't need Java 7 backwards compatibility

import java.util.logging.Logger;

import static org.arquillian.cube.docker.impl.client.reporter.DockerEnvironmentReportKey.*;
import static org.arquillian.cube.docker.impl.client.reporter.DockerEnvironmentReportKey.DOCKER_API_VERSION;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot more import cleanups, but it'd make this PR crazy.

.hasName(DOCKER_ENVIRONMENT)
.hasNumberOfSubReports(1)
.hasEntriesContaining(
new KeyValueEntry(DOCKER_COMPOSITION_SCHEMA, new FileEntry("reports" + File.separatorChar + "schemas" + File.separatorChar + "docker_composition.png")),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross platform

@lordofthejars lordofthejars merged commit 089cc74 into arquillian:master May 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants