Github user srdo commented on a diff in the pull request:
https://github.com/apache/storm/pull/2477#discussion_r158337979
--- Diff:
storm-server/src/test/java/org/apache/storm/scheduler/resource/strategies/scheduling/TestDefaultResourceAwareStrategy.java
---
@@ -65,11 +67,33 @@
private static int currentTime = 1450418597;
+
+ private static class TestDNSToSwitchMapping implements
DNSToSwitchMapping {
+ private final Map<String, String> result;
+
+ public TestDNSToSwitchMapping(Map<String, SupervisorDetails> ...
racks) {
+ Map<String, String> ret = new HashMap<>();
+ for (int rackNum = 0; rackNum < racks.length; rackNum++) {
+ String rack = "rack-" + rackNum;
+ for (SupervisorDetails sup : racks[rackNum].values()) {
+ ret.put(sup.getHost(), rack);
+ }
+ }
+ result = Collections.unmodifiableMap(ret);
+ }
+
+ @Override
+ public Map<String, String> resolve(List<String> names) {
+ return result;
+ }
+ };
+
/**
* test if the scheduling logic for the DefaultResourceAwareStrategy
is correct
*/
@Test
public void testDefaultResourceAwareStrategySharedMemory() {
+ NormalizedResources.resetResourceNames();
--- End diff --
Isn't it better to put this in `@Before` or `@After` (or ideally a
`TestRule`)? I think it's likely we'll forget to copy this to new tests.
---