reiabreu commented on code in PR #8709: URL: https://github.com/apache/storm/pull/8709#discussion_r3464001779
########## storm-server/src/test/java/org/apache/storm/scheduler/IsolationSchedulerTest.java: ########## @@ -0,0 +1,114 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version + * 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +package org.apache.storm.scheduler; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.apache.storm.Constants; +import org.apache.storm.metric.StormMetricsRegistry; +import org.apache.storm.scheduler.blacklist.TestUtilsForBlacklistScheduler; +import org.apache.storm.scheduler.resource.normalization.ResourceMetrics; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Unit tests for {@link IsolationScheduler}. + */ +public class IsolationSchedulerTest { + + private static SupervisorDetails mkSupervisor(String id, String host, int numPorts) { + List<Number> ports = new ArrayList<>(); + for (int i = 0; i < numPorts; i++) { + ports.add(i); + } + Map<String, Double> resources = new HashMap<>(); + resources.put(Constants.COMMON_CPU_RESOURCE_NAME, 400.0); + resources.put(Constants.COMMON_TOTAL_MEMORY_RESOURCE_NAME, 4096.0); + return new SupervisorDetails(id, host, null, ports, resources); + } + + private static Cluster mkCluster(Map<String, SupervisorDetails> supervisors, Topologies topologies) { + INimbus iNimbus = new TestUtilsForBlacklistScheduler.INimbusTest(); + ResourceMetrics resourceMetrics = new ResourceMetrics(new StormMetricsRegistry()); + return new Cluster(iNimbus, resourceMetrics, supervisors, new HashMap<String, SchedulerAssignmentImpl>(), + topologies, new HashMap<String, Object>()); + } + + @SuppressWarnings("unchecked") + private static LinkedList<IsolationScheduler.HostAssignableSlots> hostAssignableSlots( Review Comment: @rzo1 if you are happy with the test as it is, we can also merge it. -- 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]
