diff --git a/java/test/src/main/java/test/Ice/metrics/AMDServer.java b/java/test/src/main/java/test/Ice/metrics/AMDServer.java index ee753dd90a9..90a0f157395 100644 --- a/java/test/src/main/java/test/Ice/metrics/AMDServer.java +++ b/java/test/src/main/java/test/Ice/metrics/AMDServer.java @@ -20,7 +20,13 @@ public void run(String[] args) { adapter.add(new AMDMetricsI(), com.zeroc.Ice.Util.stringToIdentity("metrics")); adapter.activate(); - communicator.getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(1)); + communicator.getProperties().setProperty("ForwardingAdapter.Endpoints", getTestEndpoint(1)); + com.zeroc.Ice.ObjectAdapter forwardingAdapter = + communicator.createObjectAdapter("ForwardingAdapter"); + forwardingAdapter.addDefaultServant(adapter.dispatchPipeline(), ""); + forwardingAdapter.activate(); + + communicator.getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(2)); com.zeroc.Ice.ObjectAdapter controllerAdapter = communicator.createObjectAdapter("ControllerAdapter"); controllerAdapter.add( diff --git a/java/test/src/main/java/test/Ice/metrics/AllTests.java b/java/test/src/main/java/test/Ice/metrics/AllTests.java index 6a1ef12b49c..22e759e1b8a 100644 --- a/java/test/src/main/java/test/Ice/metrics/AllTests.java +++ b/java/test/src/main/java/test/Ice/metrics/AllTests.java @@ -18,9 +18,9 @@ private static void test(boolean b) { } } - static String getPort(com.zeroc.Ice.PropertiesAdminPrx p) { + static String getPort(com.zeroc.Ice.PropertiesAdminPrx p, int testPort) { return Integer.toString( - test.TestHelper.getTestPort(p.ice_getCommunicator().getProperties(), 0)); + test.TestHelper.getTestPort(p.ice_getCommunicator().getProperties(), testPort)); } static ConnectionMetrics getServerConnectionMetrics(MetricsAdminPrx metrics, long expected) { @@ -98,7 +98,7 @@ private static Map getClientProps( map += "Map." + m + '.'; } props.put("IceMX.Metrics.View." + map + "Reject.parent", "Ice\\.Admin"); - props.put("IceMX.Metrics.View." + map + "Accept.endpointPort", getPort(p)); + props.put("IceMX.Metrics.View." + map + "Accept.endpointPort", getPort(p, 0)); props.put("IceMX.Metrics.View." + map + "Reject.identity", ".*/admin|controller"); return props; } @@ -117,7 +117,9 @@ private static Map getServerProps( map += "Map." + m + '.'; } props.put("IceMX.Metrics.View." + map + "Reject.parent", "Ice\\.Admin|Controller"); - props.put("IceMX.Metrics.View." + map + "Accept.endpointPort", getPort(p)); + // Regular expression to match server test endpoint 0 and test endpoint 1 + props.put( + "IceMX.Metrics.View." + map + "Accept.endpointPort", getPort(p, 0) + "|" + getPort(p, 1)); return props; } @@ -312,6 +314,8 @@ static MetricsPrx allTests(test.TestHelper helper, CommunicatorObserverI obsv) String hostAndPort = host + ":" + port; String protocol = helper.getTestProtocol(); String endpoint = protocol + " -h " + host + " -p " + port; + String forwardingEndpoint = + protocol + " -h " + host + " -p " + Integer.toString(helper.getTestPort(1)); MetricsPrx metrics = MetricsPrx.checkedCast(communicator.stringToProxy("metrics:" + endpoint)); boolean collocated = metrics.ice_getConnection() == null; @@ -514,7 +518,7 @@ static MetricsPrx allTests(test.TestHelper helper, CommunicatorObserverI obsv) ControllerPrx controller = ControllerPrx.checkedCast( - communicator.stringToProxy("controller:" + helper.getTestEndpoint(1))); + communicator.stringToProxy("controller:" + helper.getTestEndpoint(2))); controller.hold(); map = toMap(clientMetrics.getMetricsView("View").returnValue.get("Connection")); @@ -845,6 +849,16 @@ static MetricsPrx allTests(test.TestHelper helper, CommunicatorObserverI obsv) out.println("ok"); + out.print("testing dispatch metrics with forwarding object adapter... "); + out.flush(); + MetricsPrx indirectMetrics = + MetricsPrx.createProxy(communicator, "metrics:" + forwardingEndpoint); + var secondOp = new InvokeOp(indirectMetrics); + testAttribute( + serverMetrics, serverProps, "Dispatch", "parent", "ForwardingAdapter", secondOp, out); + testAttribute(serverMetrics, serverProps, "Dispatch", "id", "metrics [op]", secondOp, out); + out.println("ok"); + out.print("testing invocation metrics... "); out.flush(); diff --git a/java/test/src/main/java/test/Ice/metrics/Collocated.java b/java/test/src/main/java/test/Ice/metrics/Collocated.java index a5ef692a98b..647386caee0 100644 --- a/java/test/src/main/java/test/Ice/metrics/Collocated.java +++ b/java/test/src/main/java/test/Ice/metrics/Collocated.java @@ -33,7 +33,12 @@ public void run(String[] args) { adapter.add(new MetricsI(), com.zeroc.Ice.Util.stringToIdentity("metrics")); // adapter.activate(); // Don't activate OA to ensure collocation is used. - communicator.getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(1)); + communicator.getProperties().setProperty("ForwardingAdapter.Endpoints", getTestEndpoint(1)); + com.zeroc.Ice.ObjectAdapter forwardingAdapter = + communicator.createObjectAdapter("ForwardingAdapter"); + forwardingAdapter.addDefaultServant(adapter.dispatchPipeline(), ""); + + communicator.getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(2)); com.zeroc.Ice.ObjectAdapter controllerAdapter = communicator.createObjectAdapter("ControllerAdapter"); controllerAdapter.add( diff --git a/java/test/src/main/java/test/Ice/metrics/Server.java b/java/test/src/main/java/test/Ice/metrics/Server.java index 07d8c5c3d95..6b15f8f6b71 100644 --- a/java/test/src/main/java/test/Ice/metrics/Server.java +++ b/java/test/src/main/java/test/Ice/metrics/Server.java @@ -21,7 +21,13 @@ public void run(String[] args) { adapter.add(new MetricsI(), com.zeroc.Ice.Util.stringToIdentity("metrics")); adapter.activate(); - communicator.getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(1)); + communicator.getProperties().setProperty("ForwardingAdapter.Endpoints", getTestEndpoint(1)); + com.zeroc.Ice.ObjectAdapter forwardingAdapter = + communicator.createObjectAdapter("ForwardingAdapter"); + forwardingAdapter.addDefaultServant(adapter.dispatchPipeline(), ""); + forwardingAdapter.activate(); + + communicator.getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(2)); com.zeroc.Ice.ObjectAdapter controllerAdapter = communicator.createObjectAdapter("ControllerAdapter"); controllerAdapter.add(