-
Notifications
You must be signed in to change notification settings - Fork 98
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
Changes from 1 commit
d4e3fea
09016e4
fc6790e
d817c71
cb93aa9
5471a99
1c0e4ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
import java.util.Optional; | ||
import java.util.Random; | ||
import java.util.Set; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import static org.arquillian.cube.docker.impl.client.CubeDockerConfigurator.DOCKER_HOST; | ||
|
@@ -100,15 +101,18 @@ private Map<String, String> resolveDownloadDockerMachine(Map<String, String> con | |
String machineVersion = GitHubUtil.getDockerMachineLatestVersion(); | ||
String machineCustomPath = config.get(CubeDockerConfiguration.DOCKER_MACHINE_CUSTOM_PATH); | ||
File dockerMachineFile = CubeDockerConfiguration.resolveMachinePath(machineCustomPath, machineVersion); | ||
String dockerMachinePath = dockerMachineFile.getPath(); | ||
|
||
boolean dockerMachineFileExist = dockerMachineFile != null && dockerMachineFile.exists(); | ||
boolean dockerMachineFileExist = dockerMachineFile.exists(); | ||
String dockerMachinePath = dockerMachineFile.getPath(); | ||
|
||
String machineName = config.get(CubeDockerConfiguration.DOCKER_MACHINE_NAME); | ||
String machineUrl = CubeDockerConfiguration.resolveUrl(machineVersion); | ||
|
||
if (!dockerMachineFileExist) { | ||
dockerMachineFile.getParentFile().mkdirs(); | ||
final File parentFile = dockerMachineFile.getParentFile(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Safer |
||
if(!parentFile.exists() && !parentFile.mkdirs()){ | ||
log.log(Level.SEVERE, "Failed to create directory: " + parentFile); | ||
} | ||
Spacelift.task(DownloadTool.class) | ||
.from(machineUrl) | ||
.to(dockerMachineFile) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,11 @@ public void createCubeSystemProperties(@Observes AfterStart afterStart, CubeRegi | |
|
||
final Binding bindings = cube.bindings(); | ||
final String cubePrefix = String.format("%s.%s", PREFIX, cubeId); | ||
System.setProperty(String.format("%s.ip", cubePrefix), bindings.getIP()); | ||
System.setProperty(String.format("%s.internal.ip", cubePrefix), bindings.getInternalIP()); | ||
|
||
final String ip = bindings.getIP(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value or empty string |
||
final String internalIP = bindings.getInternalIP(); | ||
System.setProperty(String.format("%s.ip", cubePrefix), null != ip ? ip : ""); | ||
System.setProperty(String.format("%s.internal.ip", cubePrefix), null != internalIP ? internalIP : ""); | ||
|
||
for (Binding.PortBinding portBinding : bindings.getPortBindings()) { | ||
final int exposedPort = portBinding.getExposedPort(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
package org.arquillian.cube.docker.impl.util; | ||
|
||
import org.arquillian.cube.docker.impl.docker.DockerClientExecutor; | ||
import org.arquillian.cube.spi.CubeOutput; | ||
|
||
import java.io.IOException; | ||
import java.net.Socket; | ||
import java.net.UnknownHostException; | ||
import java.util.Arrays; | ||
import java.util.concurrent.TimeUnit; | ||
import org.arquillian.cube.docker.impl.docker.DockerClientExecutor; | ||
import org.arquillian.cube.spi.CubeOutput; | ||
|
||
public final class Ping { | ||
|
||
|
@@ -17,19 +18,23 @@ private Ping() { | |
} | ||
|
||
public static boolean ping(int totalIterations, long sleep, TimeUnit timeUnit, PingCommand command) { | ||
boolean result = false; | ||
boolean result; | ||
boolean loop; | ||
int iteration = 0; | ||
|
||
do { | ||
result = command.call(); | ||
if (!result) { | ||
iteration++; | ||
iteration++; | ||
loop = !result && iteration < totalIterations; | ||
if (loop) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only wait if we're going to loop again |
||
try { | ||
timeUnit.sleep(sleep); | ||
} catch (InterruptedException e) { | ||
} catch (InterruptedException ignore) { | ||
break; | ||
} | ||
} | ||
} while (!result && iteration < totalIterations); | ||
|
||
} while (loop); | ||
|
||
return result; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package org.arquillian.cube.docker.impl.client; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.File; | ||
import java.io.PrintStream; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.apache.commons.lang.SystemUtils; | ||
import org.arquillian.cube.docker.impl.util.Boot2Docker; | ||
import org.arquillian.cube.docker.impl.util.CommandLineExecutor; | ||
import org.arquillian.cube.docker.impl.util.DockerMachine; | ||
import org.arquillian.cube.docker.impl.util.OperatingSystem; | ||
import org.arquillian.cube.docker.impl.util.OperatingSystemFamily; | ||
import org.arquillian.cube.docker.impl.util.OperatingSystemFamilyInterface; | ||
import org.arquillian.cube.docker.impl.util.OperatingSystemInterface; | ||
|
@@ -15,7 +22,6 @@ | |
import org.hamcrest.core.StringEndsWith; | ||
import org.jboss.arquillian.config.descriptor.api.ArquillianDescriptor; | ||
import org.jboss.arquillian.config.descriptor.api.ExtensionDef; | ||
import org.jboss.arquillian.core.api.InstanceProducer; | ||
import org.jboss.arquillian.core.api.annotation.ApplicationScoped; | ||
import org.jboss.arquillian.core.test.AbstractManagerTestBase; | ||
import org.junit.Assume; | ||
|
@@ -25,20 +31,16 @@ | |
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.PrintStream; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.collection.IsMapContaining.hasEntry; | ||
import static org.hamcrest.collection.IsMapContaining.hasKey; | ||
import static org.junit.Assert.assertThat; | ||
import static org.junit.Assume.assumeThat; | ||
import static org.mockito.Mockito.*; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class CubeConfiguratorTest extends AbstractManagerTestBase { | ||
|
@@ -57,11 +59,11 @@ public class CubeConfiguratorTest extends AbstractManagerTestBase { | |
Top top; | ||
|
||
private static Matcher<String> defaultDockerMachineCertPath() { | ||
return containsString(".docker/machine/machines"); | ||
return containsString(".docker" + File.separator + "machine" + File.separator + "machines"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Win fix, really need to ensure such paths are independent everywhere. |
||
} | ||
|
||
private static Matcher<String> defaultBootToDockerCertPath() { | ||
return containsString(".boot2docker/certs"); | ||
return containsString(".boot2docker" + File.separator + "certs"); | ||
} | ||
|
||
private static Matcher<String> pathEndsWith(String suffix) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required outside