Skip to content

Commit

Permalink
Ensure that nginx test waits properly to reduce flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
rnorth committed Aug 5, 2018
1 parent 3012e8e commit 8541d62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.Collections;
import java.util.Set;

/**
Expand All @@ -22,7 +22,7 @@ public NginxContainer() {
@NotNull
@Override
protected Set<Integer> getLivenessCheckPorts() {
return new HashSet<>(getMappedPort(80));
return Collections.singleton(getMappedPort(80));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.NginxContainer;
import org.testcontainers.containers.wait.HttpWaitStrategy;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;

import java.io.*;
import java.net.URLConnection;

import static org.rnorth.visibleassertions.VisibleAssertions.*;
import static org.rnorth.visibleassertions.VisibleAssertions.assertTrue;
import static org.rnorth.visibleassertions.VisibleAssertions.info;


/**
Expand All @@ -22,9 +23,10 @@ public class SimpleNginxTest {

@Rule
public NginxContainer nginx = new NginxContainer<>()
.withCustomContent(contentFolder.toString())
.waitingFor(new HttpWaitStrategy());
.withCustomContent(contentFolder.toString())
.waitingFor(new HttpWaitStrategy());

@SuppressWarnings({"Duplicates", "ResultOfMethodCallIgnored"})
@BeforeClass
public static void setupContent() throws FileNotFoundException {
contentFolder.mkdir();
Expand Down

0 comments on commit 8541d62

Please sign in to comment.