Skip to content

Commit

Permalink
Merge pull request #5218 from parsharma/WFCORE-6061
Browse files Browse the repository at this point in the history
WFCORE-6061 [Primary/Secondary]]Problematic Language usage deprecation and replacement of unit test cases.
  • Loading branch information
yersan authored Sep 29, 2022
2 parents 7d34111 + 3a67386 commit 60ff67c
Show file tree
Hide file tree
Showing 30 changed files with 239 additions and 1,082 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void testServerRestore2() {

@Test
public void testServerRestore3() {
PathAddress pa = PathAddress.parseCLIStyleAddress("/host=slave/server=*/subsystem=logging");
PathAddress pa = PathAddress.parseCLIStyleAddress("/host=secondary/server=*/subsystem=logging");
Assert.assertTrue(pa.isMultiTarget());
PathAddress translated = ProxyOperationAddressTranslator.SERVER.translateAddress(pa);
Assert.assertEquals("/subsystem=logging", translated.toCLIStyleString());
Expand All @@ -88,7 +88,7 @@ public void testServerRestore3() {

@Test
public void testServerRestore4() {
PathAddress pa = PathAddress.parseCLIStyleAddress("/host=slave/server=server-one/subsystem=*");
PathAddress pa = PathAddress.parseCLIStyleAddress("/host=secondary/server=server-one/subsystem=*");
Assert.assertTrue(pa.isMultiTarget());
PathAddress translated = ProxyOperationAddressTranslator.SERVER.translateAddress(pa);
Assert.assertEquals("/subsystem=*", translated.toCLIStyleString());
Expand All @@ -112,47 +112,47 @@ public void testServerRestore6() {
Assert.assertTrue(pa.isMultiTarget());
PathAddress translated = ProxyOperationAddressTranslator.SERVER.translateAddress(pa);
Assert.assertEquals("/subsystem=logging", translated.toCLIStyleString());
PathAddress resultAddress = PathAddress.parseCLIStyleAddress("/host=master/server=server-one/subsystem=logging");
PathAddress resultAddress = PathAddress.parseCLIStyleAddress("/host=primary/server=server-one/subsystem=logging");
PathAddress restoredPath = ProxyOperationAddressTranslator.SERVER.restoreAddress(resultAddress, translated);
Assert.assertEquals(resultAddress, restoredPath);
}

@Test
public void testServerRestore7() {
ModelNode node = createOpNode("host=slave/server=*/subsystem=1", READ_RESOURCE_OPERATION);
ModelNode node = createOpNode("host=secondary/server=*/subsystem=1", READ_RESOURCE_OPERATION);
PathAddress pa = PathAddress.pathAddress(node.get(OP_ADDR));
Assert.assertTrue(pa.isMultiTarget());
PathAddress translated = ProxyOperationAddressTranslator.SERVER.translateAddress(pa);
Assert.assertEquals("/subsystem=1", translated.toCLIStyleString());
PathAddress resultAddress = PathAddress.parseCLIStyleAddress("/server=server-one/subsystem=1");
PathAddress restoredPath = ProxyOperationAddressTranslator.SERVER.restoreAddress(pa, resultAddress);
PathAddress resolvedResultAddress = PathAddress.parseCLIStyleAddress("/host=slave/server=server-one/subsystem=1");
PathAddress resolvedResultAddress = PathAddress.parseCLIStyleAddress("/host=secondary/server=server-one/subsystem=1");
Assert.assertEquals(resolvedResultAddress, restoredPath);
}

@Test
public void testServerRestore8() {
ModelNode node = createOpNode("host=slave/server=*/subsystem=*", READ_RESOURCE_OPERATION);
ModelNode node = createOpNode("host=secondary/server=*/subsystem=*", READ_RESOURCE_OPERATION);
PathAddress pa = PathAddress.pathAddress(node.get(OP_ADDR));
Assert.assertTrue(pa.isMultiTarget());
PathAddress translated = ProxyOperationAddressTranslator.SERVER.translateAddress(pa);
Assert.assertEquals("/subsystem=*", translated.toCLIStyleString());
PathAddress resultAddress = PathAddress.parseCLIStyleAddress("/server=server-one/subsystem=1");
PathAddress restoredPath = ProxyOperationAddressTranslator.SERVER.restoreAddress(pa, resultAddress);
PathAddress resolvedResultAddress = PathAddress.parseCLIStyleAddress("/host=slave/server=server-one/subsystem=1");
PathAddress resolvedResultAddress = PathAddress.parseCLIStyleAddress("/host=secondary/server=server-one/subsystem=1");
Assert.assertEquals(resolvedResultAddress, restoredPath);
}

@Test
public void testServerRestore9() {
ModelNode node = createOpNode("host=master/server=server-one/socket-binding-group=*/socket-binding=*", READ_RESOURCE_OPERATION);
ModelNode node = createOpNode("host=primary/server=server-one/socket-binding-group=*/socket-binding=*", READ_RESOURCE_OPERATION);
PathAddress pa = PathAddress.pathAddress(node.get(OP_ADDR));
Assert.assertTrue(pa.isMultiTarget());
PathAddress translated = ProxyOperationAddressTranslator.SERVER.translateAddress(pa);
Assert.assertEquals("/socket-binding-group=*/socket-binding=*", translated.toCLIStyleString());
PathAddress resultAddress = PathAddress.parseCLIStyleAddress("/socket-binding-group=full-sockets/socket-binding=https");
PathAddress restoredPath = ProxyOperationAddressTranslator.SERVER.restoreAddress(pa, resultAddress);
PathAddress resolvedResultAddress = PathAddress.parseCLIStyleAddress("/host=master/server=server-one/socket-binding-group=full-sockets/socket-binding=https");
PathAddress resolvedResultAddress = PathAddress.parseCLIStyleAddress("/host=primary/server=server-one/socket-binding-group=full-sockets/socket-binding=https");
Assert.assertEquals(resolvedResultAddress, restoredPath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class SuggestCapabilitiesTestCase {

private static final String HOST = "host";

private static final PathElement MASTER_HOST = PathElement.pathElement(HOST, "master");
private static final PathElement PRIMARY_HOST = PathElement.pathElement(HOST, "primary");

// global
private static final String GLOBAL = "global";
Expand All @@ -74,12 +74,12 @@ public class SuggestCapabilitiesTestCase {

// server config
private static final String SC_CAPABILITY_STATIC_NAME = "org.wildfly.sc";
private static final PathAddress SC_ALL = PathAddress.pathAddress(MASTER_HOST,
private static final PathAddress SC_ALL = PathAddress.pathAddress(PRIMARY_HOST,
PathElement.pathElement(SERVER_CONFIG, "*"));

// host
private static final String HOST_CAPABILITY_STATIC_NAME = "org.wildfly.host";
private static final PathAddress HOST_ALL = PathAddress.pathAddress(MASTER_HOST,
private static final PathAddress HOST_ALL = PathAddress.pathAddress(PRIMARY_HOST,
PathElement.pathElement(SUBSYSTEM, "*"));

// socket-binding-group
Expand Down Expand Up @@ -145,10 +145,10 @@ public void setup() {
sgs = registerMultipleCapabilities(reg, SG_CAPABILITY_STATIC_NAME,
(i) -> PathAddress.pathAddress(SERVER_GROUP, "ser:ver" + i));
scs = registerMultipleCapabilities(reg, SC_CAPABILITY_STATIC_NAME,
(i) -> PathAddress.pathAddress(MASTER_HOST,
(i) -> PathAddress.pathAddress(PRIMARY_HOST,
PathElement.pathElement(SERVER_CONFIG, "conf" + i)));
hosts = registerMultipleCapabilities(reg, HOST_CAPABILITY_STATIC_NAME,
(i) -> PathAddress.pathAddress(MASTER_HOST,
(i) -> PathAddress.pathAddress(PRIMARY_HOST,
PathElement.pathElement(SUBSYSTEM, "susbsystem" + i)));
sbgs = registerMultipleCapabilities(reg, SBG_CAPABILITY_STATIC_NAME,
(i) -> PathAddress.pathAddress(SOCKET_BINDING_GROUP, "socket" + i));
Expand Down Expand Up @@ -191,14 +191,14 @@ private Set<String> suggestFromServerGroup(String cap) {
private Set<String> suggestFromServerConfig(String cap) {
return reg.getDynamicCapabilityNames(cap,
CapabilityScope.Factory.create(ProcessType.HOST_CONTROLLER,
PathAddress.pathAddress(MASTER_HOST,
PathAddress.pathAddress(PRIMARY_HOST,
PathElement.pathElement(ModelDescriptionConstants.SERVER_CONFIG, "toto"))));
}

private Set<String> suggestFromHost(String cap) {
return reg.getDynamicCapabilityNames(cap,
CapabilityScope.Factory.create(ProcessType.HOST_CONTROLLER,
PathAddress.pathAddress(MASTER_HOST,
PathAddress.pathAddress(PRIMARY_HOST,
PathElement.pathElement(SUBSYSTEM, "toto"))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void testCustomRejectChecker() throws Exception {
Assert.assertNotNull(toto);
final ModelNode model = toto.getModel();
//The rejection does not trigger for resource transformation
//TODO this could be done if 'slave' is >= 7.2.0
//TODO this could be done if 'secondary' is >= 7.2.0
Assert.assertTrue(model.hasDefined("reject"));
Assert.assertTrue(dontRejectChecker.called);
Set<String> rejections = rejectAttributeChecker.getRejections();
Expand Down Expand Up @@ -195,7 +195,7 @@ public void testListReject() throws Exception {
Assert.assertNotNull(toto);
final ModelNode model = toto.getModel();
//The rejection does not trigger for resource transformation
//TODO this could be done if 'slave' is >= 7.2.0
//TODO this could be done if 'secondary' is >= 7.2.0
Assert.assertTrue(model.hasDefined("reject"));
Assert.assertEquals(2, checker.count);
Assert.assertTrue(checker.rejected);
Expand Down Expand Up @@ -244,7 +244,7 @@ public void testObjectReject() throws Exception {
Assert.assertNotNull(toto);
final ModelNode model = toto.getModel();
//The rejection does not trigger for resource transformation
//TODO this could be done if 'slave' is >= 7.2.0
//TODO this could be done if 'secondary' is >= 7.2.0
Assert.assertTrue(model.hasDefined("reject"));
//The order is unpredicatble since a plain hashmap is used
//Assert.assertEquals(2, checker.count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class FindNonProgressingOpUnitTestCase {

@Test
public void testBasic() throws OperationFailedException {
Resource res = assemble(getSlaveResource());
Resource res = assemble(getSecondaryResource());
assertEquals("0", findNonProgressingOp(res, false, 50));
assertEquals("0", findNonProgressingOp(res, true, 50));
}
Expand All @@ -62,7 +62,7 @@ public void testBasic() throws OperationFailedException {
@Test
public void testServer() throws OperationFailedException {
// The domain getDelayedServerResource stuff is irrelevant to a server
Resource res = assemble(getSlaveResource(), getDelayedServerResource());
Resource res = assemble(getSecondaryResource(), getDelayedServerResource());
assertEquals("0", findNonProgressingOp(res, true, 50));
}

Expand All @@ -76,14 +76,14 @@ public void testOriginatingNode() throws OperationFailedException {
@Test
public void testSingleDelayedServer() throws OperationFailedException {
// WFCORE-263 case
Resource res = assemble(getSlaveResource(), getDelayedServerResource());
Resource res = assemble(getSecondaryResource(), getDelayedServerResource());
assertEquals("1", findNonProgressingOp(res, false, 50));
}

@Test
public void testMultipleDelayedServers() {
// WFCORE-263 case
Resource res = assemble(getSlaveResource(), getDelayedServerResource(), getDelayedServerResource());
Resource res = assemble(getSecondaryResource(), getDelayedServerResource(), getDelayedServerResource());
try {
findNonProgressingOp(res, false, 50);
fail("multiple servers should fail");
Expand All @@ -95,8 +95,8 @@ public void testMultipleDelayedServers() {

@Test
public void testHealthyServer() throws OperationFailedException {
// Healthy server op does not overrule the slave op
Resource res = assemble(getSlaveResource(), getHealthyServerResource());
// Healthy server op does not overrule the secondary op
Resource res = assemble(getSecondaryResource(), getHealthyServerResource());
assertEquals("0", findNonProgressingOp(res, false, 50));
}

Expand All @@ -113,7 +113,7 @@ private static Resource getMasterResource() {
return getHCResource(false);
}

private static Resource getSlaveResource() {
private static Resource getSecondaryResource() {
return getHCResource(true);
}

Expand Down

This file was deleted.

Loading

0 comments on commit 60ff67c

Please sign in to comment.