murblanc commented on a change in pull request #2133: URL: https://github.com/apache/lucene-solr/pull/2133#discussion_r546778721
########## File path: solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java ########## @@ -220,6 +231,66 @@ public void testDynamicReconfiguration() throws Exception { assertNull("no factory should be present", factory); } + @Test + public void testAttributeFetcherImpl() throws Exception { + CollectionAdminResponse rsp = CollectionAdminRequest.createCollection(COLLECTION, "conf", 2, 2) + .process(cluster.getSolrClient()); + assertTrue(rsp.isSuccess()); + cluster.waitForActiveCollection(COLLECTION, 2, 4); + Cluster cluster = new SimpleClusterAbstractionsImpl.ClusterImpl(cloudManager); + SolrCollection collection = cluster.getCollection(COLLECTION); + AttributeFetcher attributeFetcher = new AttributeFetcherImpl(cloudManager); + String someMetricName = "solr.jvm:system.properties:user.name"; + String sysprop = "user.name"; + String sysenv = "PWD"; + attributeFetcher + .fetchFrom(cluster.getLiveNodes()) + .requestNodeHeapUsage() + .requestNodeMetric(someMetricName) + .requestNodeSystemProperty(sysprop) + .requestNodeEnvironmentVariable(sysenv) + .requestNodeTotalDisk() + .requestNodeFreeDisk() + .requestNodeCoresCount() + .requestCollectionMetrics(collection, Set.of(ReplicaMetric.QUERY_RATE_1MIN, ReplicaMetric.UPDATE_RATE_1MIN)); + AttributeValues attributeValues = attributeFetcher.fetchAttributes(); + String userName = System.getProperty("user.name"); + String pwd = System.getenv("PWD"); + // node metrics + for (Node node : cluster.getLiveNodes()) { + assertTrue("heap usage", attributeValues.getHeapUsage(node).isPresent()); + assertTrue("total disk", attributeValues.getTotalDisk(node).isPresent()); + assertTrue("free disk", attributeValues.getFreeDisk(node).isPresent()); + assertTrue("cores count", attributeValues.getCoresCount(node).isPresent()); + Optional<Object> userNameOpt = attributeValues.getNodeMetric(node, someMetricName); + assertTrue("user.name", userNameOpt.isPresent()); + assertEquals("userName", userName, userNameOpt.get()); + Optional<String> syspropOpt = attributeValues.getSystemProperty(node, sysprop); + assertTrue("sysprop", syspropOpt.isPresent()); + assertEquals("user.name sysprop", userName, syspropOpt.get()); + Optional<String> sysenvOpt = attributeValues.getEnvironmentVariable(node, sysenv); + assertTrue("sysenv", sysenvOpt.isPresent()); + assertEquals("PWD sysenv", pwd, sysenvOpt.get()); + } + assertTrue(attributeValues.getCollectionMetrics(COLLECTION).isPresent()); + CollectionMetrics collectionMetrics = attributeValues.getCollectionMetrics(COLLECTION).get(); + collection.shards().forEach(shard -> { + Optional<ShardMetrics> shardMetricsOpt = collectionMetrics.getShardMetrics(shard.getShardName()); + assertTrue("shard metrics", shardMetricsOpt.isPresent()); + shard.replicas().forEach(replica -> { + Optional<ReplicaMetrics> replicaMetricsOpt = shardMetricsOpt.get().getReplicaMetrics(replica.getReplicaName()); + assertTrue("replica metrics", replicaMetricsOpt.isPresent()); + ReplicaMetrics replicaMetrics = replicaMetricsOpt.get(); + // this should always be present + assertNotNull("size", replicaMetrics.getReplicaSizeGB()); + assertTrue("should be greater than 0 but was " + replicaMetrics.getReplicaSizeGB(), + replicaMetrics.getReplicaSizeGB() > 0); + assertNotNull("queryRate", replicaMetrics.getReplicaMetric(ReplicaMetric.QUERY_RATE_1MIN.getName())); Review comment: We need to retrieve the value of a replica metric and verify it (previously it would have been making sure it is cast to the appropriate type, but with the ongoing changes, show how these values are read and make sure things actually works). ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org