|
| 1 | +// |
| 2 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +// or more contributor license agreements. See the NOTICE file |
| 4 | +// distributed with this work for additional information |
| 5 | +// regarding copyright ownership. The ASF licenses this file |
| 6 | +// to you under the Apache License, Version 2.0 (the |
| 7 | +// "License"); you may not use this file except in compliance |
| 8 | +// with the License. You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, |
| 13 | +// software distributed under the License is distributed on an |
| 14 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +// KIND, either express or implied. See the License for the |
| 16 | +// specific language governing permissions and limitations |
| 17 | +// under the License. |
| 18 | +// |
| 19 | + |
| 20 | +package com.cloud.hypervisor.kvm.discoverer; |
| 21 | + |
| 22 | +import org.junit.Assert; |
| 23 | +import org.junit.Test; |
| 24 | +import org.junit.runner.RunWith; |
| 25 | +import org.mockito.Spy; |
| 26 | +import org.mockito.junit.MockitoJUnitRunner; |
| 27 | + |
| 28 | +@RunWith(MockitoJUnitRunner.class) |
| 29 | +public class LibvirtServerDiscovererTest { |
| 30 | + |
| 31 | + @Spy |
| 32 | + private LibvirtServerDiscoverer libvirtServerDiscoverer; |
| 33 | + |
| 34 | + @Test |
| 35 | + public void validateCompatibleOses() { |
| 36 | + validateCompatibleOs("Rocky Linux", "Rocky Linux", true); |
| 37 | + validateCompatibleOs("Rocky", "Rocky Linux", true); |
| 38 | + validateCompatibleOs("Red", "Red Hat Enterprise Linux", true); |
| 39 | + validateCompatibleOs("Oracle", "Oracle Linux Server", true); |
| 40 | + validateCompatibleOs("Rocky Linux", "Red Hat Enterprise Linux", true); |
| 41 | + validateCompatibleOs("AlmaLinux", "Red Hat Enterprise Linux", true); |
| 42 | + |
| 43 | + validateCompatibleOs("Windows", "Rocky Linux", false); |
| 44 | + validateCompatibleOs("SUSE", "Rocky Linux", false); |
| 45 | + } |
| 46 | + |
| 47 | + private void validateCompatibleOs(String hostOsInCluster, String hostOs, boolean expected) { |
| 48 | + if (expected) { |
| 49 | + Assert.assertTrue(libvirtServerDiscoverer.isHostOsCompatibleWithOtherHost(hostOsInCluster, hostOs)); |
| 50 | + } else { |
| 51 | + Assert.assertFalse(libvirtServerDiscoverer.isHostOsCompatibleWithOtherHost(hostOsInCluster, hostOs)); |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments