Skip to content

Commit

Permalink
test: fix ManagersExecutionTest and StuckRequestsTest
Browse files Browse the repository at this point in the history
  • Loading branch information
NiccoMlt committed Dec 1, 2024
1 parent e0633ba commit 75cfd27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.carapaceproxy.core.ProxyRequest.PROPERTY_URI;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
Expand All @@ -40,14 +39,8 @@
import org.carapaceproxy.core.ProxyRequestsManager;
import org.carapaceproxy.server.backends.BackendHealthStatus;
import org.carapaceproxy.server.config.ActionConfiguration;
import org.carapaceproxy.server.config.BackendConfiguration;
import org.carapaceproxy.server.config.DirectorConfiguration;
import org.carapaceproxy.server.config.NetworkListenerConfiguration;
import org.carapaceproxy.server.config.RouteConfiguration;
import org.carapaceproxy.server.config.SafeBackendSelector;
import org.carapaceproxy.server.mapper.EndpointMapper;
import org.carapaceproxy.server.mapper.StandardEndpointMapper;
import org.carapaceproxy.server.mapper.requestmatcher.RegexpRequestMatcher;
import org.carapaceproxy.utils.RawHttpClient;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -87,21 +80,13 @@ public void testBackendUnreachableOnStuckRequest(boolean backendsUnreachableOnSt
final int theport = wireMockRule.port();
EndpointKey key = new EndpointKey("localhost", theport);

final EndpointMapper.Factory mapperFactory = parent -> {
StandardEndpointMapper mapper = new StandardEndpointMapper(parent, SafeBackendSelector::new);
mapper.addBackend(new BackendConfiguration("backend-a", "localhost", theport, "/", -1));
mapper.addDirector(new DirectorConfiguration("director-1").addBackend("backend-a"));
mapper.addAction(new ActionConfiguration("proxy-1", ActionConfiguration.TYPE_PROXY, "director-1", null, -1));
mapper.addRoute(new RouteConfiguration("route-1", "proxy-1", true, new RegexpRequestMatcher(PROPERTY_URI, ".*index.html.*")));
return mapper;
};
try (HttpProxyServer server = new HttpProxyServer(mapperFactory, tmpDir.newFolder())) {
try (HttpProxyServer server = new HttpProxyServer(StandardEndpointMapper::new, tmpDir.newFolder())) {
Properties properties = new Properties();
properties.put("healthmanager.tolerant", "true");
properties.put("backend.1.id", "backend-a");
properties.put("backend.1.enabled", "true");
properties.put("backend.1.host", "localhost");
properties.put("backend.1.port", theport);
properties.put("backend.1.port", String.valueOf(theport));
properties.put("backend.1.probePath", "/");
properties.put("director.1.id", "director-1");
properties.put("director.1.backends", properties.getProperty("backend.1.id"));
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
Expand Down

0 comments on commit 75cfd27

Please sign in to comment.