use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenDnsConfigurationResolverOutOfSync.
@Test
public void testReportConfigurationsOnHostWhenDnsConfigurationResolverOutOfSync() {
iface.setIpv4DefaultRoute(true);
// cannot use initIpv4ConfigurationBootProtocol because of 'randomized tests' technique.
iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP);
IPv4Address address = new IPv4Address();
address.setBootProtocol(Ipv4BootProtocol.DHCP);
testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address));
network.setDnsResolverConfiguration(sampleDnsResolverConfiguration2);
ReportedConfigurations reportedConfigurations = createTestedInstanceWithSameNonQosValues(true).reportConfigurationsOnHost();
assertThat(reportedConfigurations.isNetworkInSync(), is(false));
List<ReportedConfiguration> reportedConfigurationList = reportedConfigurations.getReportedConfigurationList();
List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations(combineReportedConfigurations(createBasicReportedConfigurations(), reportQos(true)), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), /*ipv4Address*/
address.getBootProtocol().name(), true), new ReportedConfiguration(ReportedConfigurationType.DNS_CONFIGURATION, addressesAsString(sampleDnsResolverConfiguration.getNameServers()), addressesAsString(network.getDnsResolverConfiguration().getNameServers()), false), new ReportedConfiguration(ReportedConfigurationType.DEFAULT_ROUTE, true, true, true));
assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true));
assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size()));
}
use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenIpv4BootProtocolNotStatic.
@Test
public void testReportConfigurationsOnHostWhenIpv4BootProtocolNotStatic() {
initIpv4ConfigurationBootProtocolAddress(Ipv4BootProtocol.NONE, false);
initIpv4ConfigurationBootProtocolNetmask(Ipv4BootProtocol.NONE, false);
initIpv4ConfigurationBootProtocolGateway(Ipv4BootProtocol.NONE, false);
NetworkInSyncWithVdsNetworkInterface testedInstanceWithSameNonQosValues = createTestedInstanceWithSameNonQosValues();
List<ReportedConfiguration> reportedConfigurationList = testedInstanceWithSameNonQosValues.reportConfigurationsOnHost().getReportedConfigurationList();
IPv4Address primaryAddress = this.testedNetworkAttachment.getIpConfiguration().getIpv4PrimaryAddress();
List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations(createBasicAndQosReportedConfigurations(), defaultRouteReportedConfiguration(false), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), primaryAddress.getBootProtocol().name(), true));
assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true));
assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size()));
}
use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NetworkInSyncWithVdsNetworkInterfaceTest method testDnsResolverConfigurationInSyncWithHostWhenDhcpIsUsed.
@Test
public void testDnsResolverConfigurationInSyncWithHostWhenDhcpIsUsed() {
iface.setIpv4DefaultRoute(false);
network.setDnsResolverConfiguration(sampleDnsResolverConfiguration2);
testedNetworkAttachment.setDnsResolverConfiguration(null);
iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP);
IPv4Address address = new IPv4Address();
address.setBootProtocol(Ipv4BootProtocol.DHCP);
testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address));
assertThat(createTestedInstance(true, sampleDnsResolverConfiguration).isNetworkInSync(), is(false));
}
use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NetworkInSyncWithVdsNetworkInterfaceTest method testDnsResolverConfiguration.
private void testDnsResolverConfiguration(DnsResolverConfiguration vdsDnsResolver, DnsResolverConfiguration networkDnsResolver, DnsResolverConfiguration attachmentDnsResolver, boolean expectedInSync) {
iface.setIpv4DefaultRoute(true);
// cannot use initIpv4ConfigurationBootProtocol because of 'randomized tests' technique.
iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP);
IPv4Address address = new IPv4Address();
address.setBootProtocol(Ipv4BootProtocol.DHCP);
testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address));
network.setDnsResolverConfiguration(networkDnsResolver);
testedNetworkAttachment.setDnsResolverConfiguration(attachmentDnsResolver);
assertThat(createTestedInstance(true, vdsDnsResolver).isNetworkInSync(), is(expectedInSync));
}
use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenIpv4BootProtocolStatic.
private void testReportConfigurationsOnHostWhenIpv4BootProtocolStatic(boolean syncAddress, boolean syncNetmask, boolean syncGateway) {
initIpv4ConfigurationBootProtocolAddress(Ipv4BootProtocol.STATIC_IP, syncAddress);
initIpv4ConfigurationBootProtocolNetmask(Ipv4BootProtocol.STATIC_IP, syncNetmask);
initIpv4ConfigurationBootProtocolGateway(Ipv4BootProtocol.STATIC_IP, syncGateway);
NetworkInSyncWithVdsNetworkInterface testedInstanceWithSameNonQosValues = createTestedInstanceWithSameNonQosValues();
List<ReportedConfiguration> reportedConfigurationList = testedInstanceWithSameNonQosValues.reportConfigurationsOnHost().getReportedConfigurationList();
IPv4Address primaryAddress = this.testedNetworkAttachment.getIpConfiguration().getIpv4PrimaryAddress();
List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations(createBasicAndQosReportedConfigurations(), defaultRouteReportedConfiguration(false), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), primaryAddress.getBootProtocol().name(), true), new ReportedConfiguration(ReportedConfigurationType.IPV4_NETMASK, iface.getIpv4Subnet(), primaryAddress.getNetmask(), syncNetmask), new ReportedConfiguration(ReportedConfigurationType.IPV4_ADDRESS, iface.getIpv4Address(), primaryAddress.getAddress(), syncAddress), new ReportedConfiguration(ReportedConfigurationType.IPV4_GATEWAY, iface.getIpv4Gateway(), primaryAddress.getGateway(), syncGateway));
for (ReportedConfiguration expectedReportedConfiguration : expectedReportedConfigurations) {
assertThat("expected configuration not reported:" + expectedReportedConfiguration, reportedConfigurationList.contains(expectedReportedConfiguration), is(true));
}
assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size()));
}
Aggregations