smiklosovic commented on code in PR #2577:
URL: https://github.com/apache/cassandra/pull/2577#discussion_r1300333049
##########
test/distributed/org/apache/cassandra/distributed/test/jmx/JMXGetterCheckTest.java:
##########
@@ -29,44 +29,67 @@
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
import com.google.common.collect.ImmutableSet;
import org.junit.Test;
import org.apache.cassandra.distributed.Cluster;
import org.apache.cassandra.distributed.api.Feature;
+import org.apache.cassandra.distributed.api.IInstanceConfig;
import org.apache.cassandra.distributed.api.IInvokableInstance;
+import org.apache.cassandra.distributed.shared.JMXUtil;
import org.apache.cassandra.distributed.test.TestBaseImpl;
public class JMXGetterCheckTest extends TestBaseImpl
{
private static final Set<String> IGNORE_ATTRIBUTES = ImmutableSet.of(
- "org.apache.cassandra.net:type=MessagingService:BackPressurePerHost" //
throws unsupported saying the feature was removed... dropped in CASSANDRA-15375
+ "org.apache.cassandra.net:type=MessagingService:BackPressurePerHost", //
throws unsupported saying the feature was removed... dropped in CASSANDRA-15375
+ "org.apache.cassandra.db:type=StorageService:MaxNativeProtocolVersion" //
Throws NPE
);
private static final Set<String> IGNORE_OPERATIONS = ImmutableSet.of(
"org.apache.cassandra.db:type=StorageService:stopDaemon", // halts the
instance, which then causes the JVM to exit
"org.apache.cassandra.db:type=StorageService:drain", // don't drain, it
stops things which can cause other APIs to be unstable as we are in a stopped
state
"org.apache.cassandra.db:type=StorageService:stopGossiping", // if we stop
gossip this can cause other issues, so avoid
"org.apache.cassandra.db:type=StorageService:resetLocalSchema", // this
will fail when there are no other nodes which can serve schema
-
"org.apache.cassandra.db:type=HintedHandoffManager:listEndpointsPendingHints",
// this will fail because it only exists to match an old, deprecated mbean and
just throws an UnsportedOperationException
- "org.apache.cassandra.db:type=StorageService:decommission" // Don't
decommission nodes! Note that in future versions of C* this is unnecessary
because decommission takes an argument.
+ "org.apache.cassandra.db:type=StorageService:joinRing", // Causes
bootstrapping errors
+ "org.apache.cassandra.db:type=StorageService:clearConnectionHistory", //
Throws a NullPointerException
+ "org.apache.cassandra.db:type=StorageService:startGossiping", // causes
multiple loops to fail
+ "org.apache.cassandra.db:type=StorageService:startNativeTransport", //
causes multiple loops to fail
+
"org.apache.cassandra.db:type=Tables,keyspace=system,table=local:loadNewSSTables",
// Shouldn't attempt to load SSTables as sometimes the temp directories don't
work
+
"org.apache.cassandra.db:type=HintedHandoffManager:listEndpointsPendingHints",
// hard-coded to throw UnsupportedOperationException
+ "org.apache.cassandra.db:type=StorageService:startRPCServer", // In looped
tests this can sometimes fail
+ "org.apache.cassandra.db:type=StorageService:decommission" // shutting
down the node and decommissioning it is bad - in later versions, it takes a
parameter and wouldn't be run in this test
);
- public static final String JMX_SERVICE_URL_FMT =
"service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi";
-
@Test
public void testGetters() throws Exception
{
- try (Cluster cluster = Cluster.build(1).withConfig(c ->
c.with(Feature.values())).start())
+ for (int i=0; i < 2; i++)
{
- IInvokableInstance instance = cluster.get(1);
+ try (Cluster cluster = Cluster.build(1).withConfig(c ->
c.with(Feature.values())).start())
+ {
+ testAllValidGetters(cluster);
+ }
+ }
+ }
- String jmxHost =
instance.config().broadcastAddress().getAddress().getHostAddress();
- String url = String.format(JMX_SERVICE_URL_FMT, jmxHost,
instance.config().jmxPort());
+ /**
+ * Tests JMX getters and operations.
+ * Useful for more than just testing getters, it also is used in
JMXFeatureTest
+ * to make sure we've touched the complete JMX code path.
+ * @param cluster the cluster to test
+ * @throws Exception several kinds of exceptions can be thrown, mostly
from JMX infrastructure issues.
+ */
+ public static void testAllValidGetters(Cluster cluster) throws Exception
+ {
+ for (IInvokableInstance instance: cluster)
+ {
+ if (instance.isShutdown()) {
Review Comment:
@JeetKunDoug this actually does not need to be enclosed with `{ }`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]