[ https://issues.apache.org/jira/browse/FLINK-7878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16240414#comment-16240414 ]
ASF GitHub Bot commented on FLINK-7878: --------------------------------------- Github user tillrohrmann commented on a diff in the pull request: https://github.com/apache/flink/pull/4911#discussion_r149096804 --- Diff: flink-core/src/test/java/org/apache/flink/api/common/operators/ResourceSpecTest.java --- @@ -0,0 +1,144 @@ +/* + * 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.flink.api.common.operators; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +public class ResourceSpecTest { + + @Test + public void testIsValid() throws Exception { + ResourceSpec rs = new ResourceSpec(1.0, 100); + assertTrue(rs.isValid()); + + rs = new ResourceSpec(1.0, 100, new ResourceSpec.Resource("GPU", 1)); + assertTrue(rs.isValid()); + + rs = new ResourceSpec(1.0, 100, new ResourceSpec.Resource("GPU", -1)); + assertFalse(rs.isValid()); + } + + @Test + public void testLessThanOrEqual() throws Exception { + ResourceSpec rs1 = new ResourceSpec(1.0, 100); + ResourceSpec rs2 = new ResourceSpec(1.0, 100); + assertTrue(rs1.lessThanOrEqual(rs2)); + assertTrue(rs2.lessThanOrEqual(rs1)); + + rs2 = new ResourceSpec(1.0, 100, new ResourceSpec.Resource("FPGA", 1)); + assertTrue(rs1.lessThanOrEqual(rs2)); + assertFalse(rs2.lessThanOrEqual(rs1)); + + rs1 = new ResourceSpec(1.0, 100, new ResourceSpec.Resource("FPGA", 2)); --- End diff -- reusing variable names makes things harder to follow in a tests. Thus, I would recommend introducing a fresh name. > Extend the resource type user can define in ResourceSpec > -------------------------------------------------------- > > Key: FLINK-7878 > URL: https://issues.apache.org/jira/browse/FLINK-7878 > Project: Flink > Issue Type: Improvement > Components: DataSet API, DataStream API > Reporter: shuai.xu > Assignee: shuai.xu > Labels: flip-6 > > Now, flink only support user define how much CPU and MEM used in an operator, > but now the resource in a cluster is various. For example, an application for > image processing may need GPU, some others may need FPGA. > Only CPU and MEM is not enough, and the resource type is becoming more and > more, so we need to make the ResourSpec extendible. -- This message was sent by Atlassian JIRA (v6.4.14#64029)