/*
* 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.runtime.clusterframework.types;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class ResourceProfileTest {
@Test
public void testMatchRequirement() throws Exception {
ResourceProfile rp1 = new ResourceProfile(1.0, 100, 100, 100);
ResourceProfile rp2 = new ResourceProfile(1.0, 200, 200, 200);
ResourceProfile rp3 = new ResourceProfile(2.0, 100, 100, 100);
ResourceProfile rp4 = new ResourceProfile(2.0, 200, 200, 200);
assertFalse(rp1.isMatching(rp2));
assertTrue(rp2.isMatching(rp1));
assertFalse(rp1.isMatching(rp3));
assertTrue(rp3.isMatching(rp1));
assertFalse(rp2.isMatching(rp3));
assertFalse(rp3.isMatching(rp2));
assertTrue(rp4.isMatching(rp1));
assertTrue(rp4.isMatching(rp2));
assertTrue(rp4.isMatching(rp3));
assertTrue(rp4.isMatching(rp4));
}
@Test
public void testUnknownMatchesUnknown() {
assertTrue(ResourceProfile.UNKNOWN.isMatching(ResourceProfile.UNKNOWN));
}
}