Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*.log
test-output/
*.tmp
*/target/

# OS
.DS_Store
Expand Down
19 changes: 11 additions & 8 deletions src/test/java/org/jboss/modcluster/test/DebugTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension;
import org.jboss.modcluster.test.base.ModClusterTestExtension;
import org.jboss.modcluster.test.base.ModClusterTestExtension.TestCluster;
import org.jboss.modcluster.test.utils.DockerWildFlyWorker;
import org.jboss.modcluster.test.utils.HttpClient;
import org.jboss.modcluster.test.utils.HttpClient.HttpResponse;
import org.jboss.modcluster.test.utils.balancer.DockerBalancer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -20,6 +22,7 @@
import static org.jboss.modcluster.test.utils.WildFlyDeploymentManager.DEMO_APP;

@Tag("undertow")
@Tag("docker")
@ExtendWith({ModClusterTestExtension.class, SoftAssertionsExtension.class})
public class DebugTest {

Expand All @@ -34,8 +37,8 @@ public void testDirectWorkerAccess(TestCluster cluster, HttpClient httpClient) t
cluster.startWorkers(1);

// Try accessing worker directly with trailing slash
String worker1Url = cluster.getWorker1().getContainer().getHost() + ":" +
cluster.getWorker1().getContainer().getMappedPort(8080);
String worker1Url = ((DockerWildFlyWorker) cluster.getWorker1()).getDockerContainer().getHost() + ":" +
((DockerWildFlyWorker) cluster.getWorker1()).getDockerContainer().getMappedPort(8080);
String directUrl = "http://" + worker1Url + "/" + DEMO_APP + "/";

log.info("Trying direct access to worker: {}", directUrl);
Expand Down Expand Up @@ -77,19 +80,19 @@ public void testDirectWorkerAccess(TestCluster cluster, HttpClient httpClient) t
log.info("Worker outbound-socket-binding: {}", socketBindingResult.value());

// Check network setup - compare network IDs properly
String balancerNetworkId = cluster.getBalancer().getNetwork().getId();
String workerNetworkName = cluster.getWorker1().getContainer().getContainerInfo()
String balancerNetworkId = ((DockerBalancer) cluster.getBalancer()).getNetwork().getId();
String workerNetworkName = ((DockerWildFlyWorker) cluster.getWorker1()).getDockerContainer().getContainerInfo()
.getNetworkSettings().getNetworks().keySet().iterator().next();
String workerNetworkId = cluster.getWorker1().getContainer().getContainerInfo()
String workerNetworkId = ((DockerWildFlyWorker) cluster.getWorker1()).getDockerContainer().getContainerInfo()
.getNetworkSettings().getNetworks().get(workerNetworkName).getNetworkID();
log.info("Balancer network ID: {}", balancerNetworkId);
log.info("Worker network name: {}, ID: {}", workerNetworkName, workerNetworkId);
log.info("Same network? {}", balancerNetworkId.equals(workerNetworkId));

// Check balancer's Undertow subsystem configuration
OnlineManagementClient balancerClient = ManagementClientFactory.create(
cluster.getBalancer().getContainer().getHost(),
cluster.getBalancer().getContainer().getMappedPort(9990));
cluster.getBalancer().getManagementHost(),
cluster.getBalancer().getManagementPort());

Operations balancerOps =
new Operations(balancerClient);
Expand Down Expand Up @@ -127,7 +130,7 @@ public void testDirectWorkerAccess(TestCluster cluster, HttpClient httpClient) t

// Check balancer logs - show last 50 lines to see what's happening
log.info("===== BALANCER LOGS (last 50 lines) =====");
String balancerLogs = cluster.getBalancer().getContainer().getLogs();
String balancerLogs = cluster.getBalancer().getLogs();
String[] logLines = balancerLogs.split("\n");
int start = Math.max(0, logLines.length - 50);
for (int i = start; i < logLines.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jboss.modcluster.test.base;

import org.jboss.modcluster.test.utils.balancer.BalancerContainer;
import org.jboss.modcluster.test.utils.balancer.Balancer;
import org.jboss.modcluster.test.utils.HttpClient;
import org.jboss.modcluster.test.utils.WildFlyContainer;
import org.jboss.modcluster.test.utils.WildFlyWorker;
import org.junit.jupiter.api.extension.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -33,7 +33,7 @@ public void beforeEach(ExtensionContext context) {
ExtensionContext.Store store = getStore(context);

// Create balancer and store BEFORE start — so afterEach can clean up network even if start fails
BalancerContainer balancer = BalancerContainer.create(balancerType);
Balancer balancer = Balancer.create(balancerType);
store.put(BALANCER_KEY, balancer);
balancer.start();

Expand All @@ -49,7 +49,7 @@ public void afterEach(ExtensionContext context) {

// Stop workers if started
for (String workerKey : new String[]{WORKER1_KEY, WORKER2_KEY, WORKER3_KEY, WORKER4_KEY}) {
WildFlyContainer worker = store.get(workerKey, WildFlyContainer.class);
WildFlyWorker worker = store.get(workerKey, WildFlyWorker.class);
if (worker != null) {
try {
worker.stop();
Expand All @@ -60,7 +60,7 @@ public void afterEach(ExtensionContext context) {
}

// Stop balancer (also closes the per-test network if it owns it)
BalancerContainer balancer = store.get(BALANCER_KEY, BalancerContainer.class);
Balancer balancer = store.get(BALANCER_KEY, Balancer.class);
if (balancer != null) {
try {
balancer.stop();
Expand All @@ -76,7 +76,7 @@ public void afterEach(ExtensionContext context) {
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
Class<?> type = parameterContext.getParameter().getType();
return type == TestCluster.class ||
type == BalancerContainer.class ||
type == Balancer.class ||
type == HttpClient.class;
}

Expand All @@ -87,8 +87,8 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte

if (type == TestCluster.class) {
return new TestCluster(store);
} else if (type == BalancerContainer.class) {
return store.get(BALANCER_KEY, BalancerContainer.class);
} else if (type == Balancer.class) {
return store.get(BALANCER_KEY, Balancer.class);
} else if (type == HttpClient.class) {
return store.get(HTTP_CLIENT_KEY, HttpClient.class);
}
Expand All @@ -115,8 +115,8 @@ public static class TestCluster {
this.store = store;
}

public BalancerContainer getBalancer() {
return store.get(BALANCER_KEY, BalancerContainer.class);
public Balancer getBalancer() {
return store.get(BALANCER_KEY, Balancer.class);
}

public HttpClient getHttpClient() {
Expand All @@ -137,51 +137,51 @@ public void startWorkers(int count) {
* @param javaOpts JVM options (e.g. "-Xms64m -Xmx2g"), or null for default
*/
public void startWorkers(int count, String javaOpts) {
BalancerContainer balancer = getBalancer();
Balancer balancer = getBalancer();

if (count >= 1) {
WildFlyContainer worker1 = new WildFlyContainer("worker1", balancer);
WildFlyWorker worker1 = WildFlyWorker.create("worker1", balancer);
if (javaOpts != null) worker1.withJavaOpts(javaOpts);
worker1.start();
store.put(WORKER1_KEY, worker1);
}

if (count >= 2) {
WildFlyContainer worker2 = new WildFlyContainer("worker2", balancer);
WildFlyWorker worker2 = WildFlyWorker.create("worker2", balancer);
if (javaOpts != null) worker2.withJavaOpts(javaOpts);
worker2.start();
store.put(WORKER2_KEY, worker2);
}

if (count >= 3) {
WildFlyContainer worker3 = new WildFlyContainer("worker3", balancer);
WildFlyWorker worker3 = WildFlyWorker.create("worker3", balancer);
if (javaOpts != null) worker3.withJavaOpts(javaOpts);
worker3.start();
store.put(WORKER3_KEY, worker3);
}

if (count >= 4) {
WildFlyContainer worker4 = new WildFlyContainer("worker4", balancer);
WildFlyWorker worker4 = WildFlyWorker.create("worker4", balancer);
if (javaOpts != null) worker4.withJavaOpts(javaOpts);
worker4.start();
store.put(WORKER4_KEY, worker4);
}
}

public WildFlyContainer getWorker1() {
return store.get(WORKER1_KEY, WildFlyContainer.class);
public WildFlyWorker getWorker1() {
return store.get(WORKER1_KEY, WildFlyWorker.class);
}

public WildFlyContainer getWorker2() {
return store.get(WORKER2_KEY, WildFlyContainer.class);
public WildFlyWorker getWorker2() {
return store.get(WORKER2_KEY, WildFlyWorker.class);
}

public WildFlyContainer getWorker3() {
return store.get(WORKER3_KEY, WildFlyContainer.class);
public WildFlyWorker getWorker3() {
return store.get(WORKER3_KEY, WildFlyWorker.class);
}

public WildFlyContainer getWorker4() {
return store.get(WORKER4_KEY, WildFlyContainer.class);
public WildFlyWorker getWorker4() {
return store.get(WORKER4_KEY, WildFlyWorker.class);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.jboss.dmr.ModelNode;
import org.jboss.modcluster.test.base.ModClusterTestExtension;
import org.jboss.modcluster.test.base.ModClusterTestExtension.TestCluster;
import org.jboss.modcluster.test.utils.WildFlyContainer;
import org.jboss.modcluster.test.utils.WildFlyWorker;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
Expand Down Expand Up @@ -36,7 +36,7 @@ public class CliManagementTest {
@Test
public void testReadModClusterConfiguration(TestCluster cluster) throws Exception {
cluster.startWorkers(1);
WildFlyContainer worker = cluster.getWorker1();
WildFlyWorker worker = cluster.getWorker1();

// Read mod_cluster subsystem configuration using Creaper
Operations ops = worker.getOperations();
Expand All @@ -60,7 +60,7 @@ public void testReadModClusterConfiguration(TestCluster cluster) throws Exceptio
@Test
public void testEnableContextViaCLI(TestCluster cluster) throws Exception {
cluster.startWorkers(1);
WildFlyContainer worker = cluster.getWorker1();
WildFlyWorker worker = cluster.getWorker1();

// List proxies using Creaper
Operations ops = worker.getOperations();
Expand All @@ -84,7 +84,7 @@ public void testEnableContextViaCLI(TestCluster cluster) throws Exception {
@Test
public void testDisableContextViaCLI(TestCluster cluster) throws Exception {
cluster.startWorkers(1);
WildFlyContainer worker = cluster.getWorker1();
WildFlyWorker worker = cluster.getWorker1();

// Read status-interval using Creaper helper method
ModelNode statusInterval = worker.modCluster().readModClusterAttribute("status-interval");
Expand All @@ -103,7 +103,7 @@ public void testDisableContextViaCLI(TestCluster cluster) throws Exception {
@Test
public void testModClusterProxyInfo(TestCluster cluster) throws Exception {
cluster.startWorkers(1);
WildFlyContainer worker = cluster.getWorker1();
WildFlyWorker worker = cluster.getWorker1();

// Read proxy configuration using Creaper
Operations ops = worker.getOperations();
Expand Down Expand Up @@ -142,7 +142,7 @@ public void testModClusterProxyInfo(TestCluster cluster) throws Exception {
@Test
public void testModClusterStatusInterval(TestCluster cluster) throws Exception {
cluster.startWorkers(1);
WildFlyContainer worker = cluster.getWorker1();
WildFlyWorker worker = cluster.getWorker1();

// Read current status interval using Creaper
ModelNode currentValue = worker.modCluster().readModClusterAttribute("status-interval");
Expand Down Expand Up @@ -178,7 +178,7 @@ public void testModClusterStatusInterval(TestCluster cluster) throws Exception {
@Test
public void testCheckDeploymentStatus(TestCluster cluster) throws Exception {
cluster.startWorkers(1);
WildFlyContainer worker = cluster.getWorker1();
WildFlyWorker worker = cluster.getWorker1();

// Check if demo.war is deployed using Creaper
boolean isDeployed = worker.deployment().isDeployed(DEMO_APP + ".war");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.jboss.modcluster.test.base.BalancerType;
import org.jboss.modcluster.test.base.ModClusterTestExtension;
import org.jboss.modcluster.test.base.ModClusterTestExtension.TestCluster;
import org.jboss.modcluster.test.utils.balancer.BalancerContainer;
import org.jboss.modcluster.test.utils.WildFlyContainer;
import org.jboss.modcluster.test.utils.balancer.Balancer;
import org.jboss.modcluster.test.utils.WildFlyWorker;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -58,8 +58,8 @@ public class MultipleUndertowServerSupportTest {
@Test
public void testSettingListenerFromNonDefaultUndertowServer(final TestCluster cluster) throws Exception {
cluster.startWorkers(1);
final WildFlyContainer worker = cluster.getWorker1();
final BalancerContainer balancer = cluster.getBalancer();
final WildFlyWorker worker = cluster.getWorker1();
final Balancer balancer = cluster.getBalancer();

final String secondServerName = "second-server-" + randomSuffix();
final String socketBindingName = "second-socket-" + randomSuffix();
Expand Down Expand Up @@ -139,20 +139,20 @@ public void testSettingListenerFromNonDefaultUndertowServer(final TestCluster cl
@Test
public void testRegisterOneNodeWithTwoBalancers(final TestCluster cluster) throws Exception {
cluster.startWorkers(1);
final WildFlyContainer worker = cluster.getWorker1();
final BalancerContainer balancer1 = cluster.getBalancer();
final WildFlyWorker worker = cluster.getWorker1();
final Balancer balancer1 = cluster.getBalancer();

final String secondServerName = "second-server-" + randomSuffix();
final String socketBindingName = "second-socket-" + randomSuffix();
final String ajpListenerName = "secondListener-" + randomSuffix();
final String outboundSocketName = "modcluster-balancer2";
final String secondProxyName = "second-proxy-" + randomSuffix();

BalancerContainer balancer2 = BalancerContainer.create(BalancerType.UNDERTOW);
Balancer balancer2 = Balancer.create(BalancerType.UNDERTOW);

try {
// Start second balancer on the same network
balancer2.start(balancer1.getNetwork(), "balancer2");
balancer2.startOnSameNetworkAs(balancer1, "balancer2");
log.info("Second balancer started: {}", balancer2.getHttpUrl());

// Create second Undertow server + socket binding + AJP listener on worker
Expand All @@ -170,7 +170,7 @@ public void testRegisterOneNodeWithTwoBalancers(final TestCluster cluster) throw
address.add("socket-binding-group", "standard-sockets");
address.add("remote-destination-outbound-socket-binding", outboundSocketName);
addSocketBinding.get("operation").set("add");
addSocketBinding.get("host").set("balancer2");
addSocketBinding.get("host").set(balancer2.getProxyHost());
addSocketBinding.get("port").set(8080);

worker.getManagementClient().execute(addSocketBinding);
Expand Down Expand Up @@ -266,7 +266,7 @@ public void testRegisterOneNodeWithTwoBalancers(final TestCluster cluster) throw
@Test
public void proxyConfigurationIndependence(final TestCluster cluster) throws Exception {
cluster.startWorkers(1);
final WildFlyContainer worker = cluster.getWorker1();
final WildFlyWorker worker = cluster.getWorker1();

final String secondServerName = "second-server-" + randomSuffix();
final String secondSocketName = "second-socket-" + randomSuffix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.jboss.modcluster.test.base.ModClusterTestExtension;
import org.jboss.modcluster.test.base.ModClusterTestExtension.TestCluster;
import org.jboss.modcluster.test.utils.HttpClient;
import org.jboss.modcluster.test.utils.WildFlyContainer;
import org.jboss.modcluster.test.utils.WildFlyWorker;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
Expand Down Expand Up @@ -48,7 +48,7 @@ public void testDynamicWorkerRegistration(TestCluster cluster, HttpClient httpCl

// Dynamically add worker2
log.info("Dynamically adding worker2...");
WildFlyContainer worker2 = new WildFlyContainer("worker2", cluster.getBalancer());
WildFlyWorker worker2 = WildFlyWorker.create("worker2", cluster.getBalancer());
worker2.start();

try {
Expand Down Expand Up @@ -82,7 +82,7 @@ public void testDynamicWorkerRegistration(TestCluster cluster, HttpClient httpCl
@Test
public void testDynamicConfigurationChange(TestCluster cluster) throws Exception {
cluster.startWorkers(1);
WildFlyContainer worker = cluster.getWorker1();
WildFlyWorker worker = cluster.getWorker1();

// Read initial flush-packets setting using Creaper
org.jboss.dmr.ModelNode initialValue = worker.modCluster().readModClusterAttribute("flush-packets");
Expand Down
Loading
Loading