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.
---