Skip to content

Commit

Permalink
Fix JUnit 5 related compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rzo1 committed Dec 4, 2023
1 parent 0dc5639 commit 349980f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,7 @@ public void testTopologyWorkerMaxHeapSize() {
assertTrue(cluster.needsSchedulingRas(topology2));
String status = cluster.getStatusMap().get(topology2.getId());
String expectedStatusPrefix = "Not enough resources to schedule";
assertTrue("Expected status to start with \"" + expectedStatusPrefix + "\" but status is: " + status,
status.startsWith(expectedStatusPrefix));
assertTrue(status.startsWith(expectedStatusPrefix), "Expected status to start with \"" + expectedStatusPrefix + "\" but status is: " + status);
assertEquals(5, cluster.getUnassignedExecutors(topology2).size());
} finally {
rs.cleanup();
Expand Down Expand Up @@ -1137,7 +1136,7 @@ void append(TimeBlockResult other) {

private long getMedianValue(List<Long> values) {
final int numValues = values.size();
assertTrue("Expecting odd number of values to compute median, got " + numValues, (numValues % 2) == 1);
assertEquals(1, (numValues % 2), "Expecting odd number of values to compute median, got " + numValues);
List<Long> sortedValues = new ArrayList<>();
sortedValues.addAll(values);
Collections.sort(sortedValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;
import org.apache.storm.utils.Utils;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -482,25 +482,25 @@ public static void assertTopologiesNotScheduled(Cluster cluster, Class strategyC
Topologies topologies = cluster.getTopologies();
for (String topoName : topoNames) {
TopologyDetails td = topologies.getByName(topoName);
Assert.assertTrue("Cannot find topology for topoName " + topoName, td != null);
Assertions.assertNotNull(td, "Cannot find topology for topoName " + topoName);
String topoId = td.getId();
String status = cluster.getStatus(topoId);
Assert.assertTrue("Status unknown for topoName " + topoName, status != null);
Assert.assertTrue("Successful status " + status + " for topoName " + topoName, !isStatusSuccess(status));
Assert.assertTrue("Found assignment for topoId " + topoId, cluster.getAssignmentById(topoId) == null);
Assert.assertTrue("Scheduling not required for topoName " + topoName, cluster.needsSchedulingRas(td));
Assertions.assertNotNull(status, "Status unknown for topoName " + topoName);
Assertions.assertFalse(isStatusSuccess(status), "Successful status " + status + " for topoName " + topoName);
Assertions.assertNull(cluster.getAssignmentById(topoId), "Found assignment for topoId " + topoId);
Assertions.assertTrue(cluster.needsSchedulingRas(td), "Scheduling not required for topoName " + topoName);
}
}

public static void assertTopologiesFullyScheduled(Cluster cluster, Class strategyClass, String... topoNames) {
Topologies topologies = cluster.getTopologies();
for (String topoName : topoNames) {
TopologyDetails td = topologies.getByName(topoName);
Assert.assertTrue("Cannot find topology for topoName " + topoName, td != null);
Assertions.assertNotNull(td, "Cannot find topology for topoName " + topoName);
String topoId = td.getId();
assertStatusSuccess(cluster, topoId);
Assert.assertTrue("Cannot find assignment for topoId " + topoId, cluster.getAssignmentById(topoId) != null);
Assert.assertTrue("Scheduling required for topoName " + topoName, !cluster.needsSchedulingRas(td));
Assertions.assertNotNull(cluster.getAssignmentById(topoId), "Cannot find assignment for topoId " + topoId);
Assertions.assertFalse(cluster.needsSchedulingRas(td), "Scheduling required for topoName " + topoName);
}
}

Expand All @@ -523,32 +523,31 @@ public static void assertTopologiesFullyScheduled(Cluster cluster, Class strateg
public static void assertTopologiesBeenEvicted(Cluster cluster, Class strategyClass, Set<String> evictedTopologies, String... topoNames) {
Topologies topologies = cluster.getTopologies();
LOG.info("Evicted topos: {}", evictedTopologies);
Assert.assertTrue("evictedTopologies is null", evictedTopologies != null);
Assertions.assertNotNull(evictedTopologies, "evictedTopologies is null");
for (String topoName : topoNames) {
String errMsg = "topology " + topoName + " using " + strategyClass.getName();
TopologyDetails td = topologies.getByName(topoName);
Assert.assertTrue("Cannot find topology for topoName " + topoName, td != null);
Assertions.assertNotNull(td, "Cannot find topology for topoName " + topoName);
String topoId = td.getId();
Assert.assertTrue("evictedTopologies does not contain topoId " + topoId, evictedTopologies.contains(topoId));
Assertions.assertTrue(evictedTopologies.contains(topoId), "evictedTopologies does not contain topoId " + topoId);
}
}

public static void assertTopologiesNotBeenEvicted(Cluster cluster, Class strategyClass, Set<String> evictedTopologies, String... topoNames) {
Topologies topologies = cluster.getTopologies();
LOG.info("Evicted topos: {}", evictedTopologies);
Assert.assertTrue("evictedTopologies is null", evictedTopologies != null);
Assertions.assertNotNull(evictedTopologies, "evictedTopologies is null");
for (String topoName : topoNames) {
String errMsg = "topology " + topoName + " using " + strategyClass.getName();
TopologyDetails td = topologies.getByName(topoName);
Assert.assertTrue("Cannot find topology for topoName " + topoName, td != null);
Assertions.assertNotNull(td, "Cannot find topology for topoName " + topoName);
String topoId = td.getId();
Assert.assertTrue("evictedTopologies contains topoId " + topoId, !evictedTopologies.contains(topoId));
Assertions.assertFalse(evictedTopologies.contains(topoId), "evictedTopologies contains topoId " + topoId);
}
}

public static void assertStatusSuccess(Cluster cluster, String topoId) {
Assert.assertTrue("topology " + topoId + " in unsuccessful status: " + cluster.getStatus(topoId),
isStatusSuccess(cluster.getStatus(topoId)));
Assertions.assertTrue(isStatusSuccess(cluster.getStatus(topoId)), "topology " + topoId + " in unsuccessful status: " + cluster.getStatus(topoId));
}

public static boolean isStatusSuccess(String status) {
Expand Down

0 comments on commit 349980f

Please sign in to comment.