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

Some test fixes to improve test suite stability #4390

Merged
merged 1 commit into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ public void execute(BuildContext context) {
}

ProtocolMetaData metadata = new ProtocolMetaData();
URI uri = URI.create(TestHTTPResourceManager.getUri());

String testUri = TestHTTPResourceManager.getUri();
System.setProperty("test.url", testUri);
URI uri = URI.create(testUri);
HTTPContext httpContext = new HTTPContext(uri.getHost(), uri.getPort());
// This is to work around https://github.com/arquillian/arquillian-core/issues/216
httpContext.add(new Servlet("dummy", "/"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public NativeImageLauncher(Class<?> testClass, int port, long imageWaitTime) {

public void start() throws IOException {

System.setProperty("test.url", TestHTTPResourceManager.getUri());

String path = System.getProperty("native.image.path");
if (path == null) {
path = guessPath(testClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public static String getUri() {
String host = config.getOptionalValue("quarkus.http.host", String.class).orElse("localhost");
String port = config.getOptionalValue("quarkus.http.test-port", String.class).orElse("8081");
String contextPath = config.getOptionalValue("quarkus.servlet.context-path", String.class).orElse("");
String testUrl = "http://" + host + ":" + port + contextPath;
System.setProperty("test.url", testUrl);
return testUrl;
return "http://" + host + ":" + port + contextPath;
}

public static void inject(Object testCase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,18 @@ void modifyFile(String name, Function<String, String> mutator, Path path) {
}

public void sleepForFileChanges(Path path) {
long currentTime = System.currentTimeMillis();
try {
//we want to make sure the last modified time is larger than both the current time
//and the current last modified time. Some file systems only resolve file
//time to the nearest second, so this is necessary for dev mode to pick up the changes
long timeToBeat = Math.max(System.currentTimeMillis(), Files.getLastModifiedTime(path).toMillis());
for (;;) {
Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis()));
long fm = Files.getLastModifiedTime(path).toMillis();
if (fm > currentTime) {
Thread.sleep(10);
if (fm > timeToBeat) {
return;
}
Thread.sleep(50);
}
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public void execute(BuildContext context) {
fail("The build was expected to fail");
}
started = true;
System.setProperty("test.url", TestHTTPResourceManager.getUri());
Instance<?> factory;
try {
factory = CDI.current()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public void execute(BuildContext context) {
.build();
runtimeRunner.run();

System.setProperty("test.url", TestHTTPResourceManager.getUri());

Closeable shutdownTask = new Closeable() {
@Override
public void close() throws IOException {
Expand Down