public <T> ReportedConfigurations add(ReportedConfigurationType type, T actual, T expected, boolean inSync) { String actualValue = Objects.toString(actual, null); String expectedValue = Objects.toString(expected, null); reportedConfigurationList.add(new ReportedConfiguration(type, actualValue, expectedValue, inSync)); return this; }
private ReportedConfiguration reportEqualSwitchType() { return new ReportedConfiguration(ReportedConfigurationType.SWITCH_TYPE, SwitchType.LEGACY, SwitchType.LEGACY, true); }
private List<ReportedConfiguration> createBasicAndQosReportedConfigurations() { return addReportedConfigurations(createBasicReportedConfigurations(), new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_LINK_SHARE), new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_REAL_TIME), new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_UPPER_LIMIT) ); }
private List<ReportedConfiguration> reportQos(boolean allInSync) { return Arrays.asList(new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_LINK_SHARE, ifaceQos.getOutAverageLinkshare(), null, allInSync), new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_UPPER_LIMIT, ifaceQos.getOutAverageUpperlimit(), null, allInSync), new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_REAL_TIME, ifaceQos.getOutAverageRealtime(), null, allInSync)); }
private ReportedConfiguration defaultRouteReportedConfiguration(boolean expectedValue) { return new ReportedConfiguration(ReportedConfigurationType.DEFAULT_ROUTE, iface.isIpv4DefaultRoute(), expectedValue, Objects.equals(iface.isIpv4DefaultRoute(), expectedValue)); }
private ReportedConfiguration reportedEqualMtu() { return new ReportedConfiguration( ReportedConfigurationType.MTU, iface.getMtu(), network.getMtu(), true); }
private ReportedConfiguration reporteEqualBridged() { return new ReportedConfiguration(ReportedConfigurationType.BRIDGED, iface.isBridged(), network.isVmNetwork(), true); }
private ReportedConfiguration reportEqualVLAN() { return new ReportedConfiguration(ReportedConfigurationType.VLAN, iface.getVlanId(), network.getVlanId(), true); }
@Test public void testReportConfigurationsOnHostWhenSwitchTypeIsOutOfSync() { cluster.setRequiredSwitchTypeForCluster(SwitchType.OVS); ReportedConfigurations reportedConfigurations = createTestedInstance().reportConfigurationsOnHost(); assertThat(reportedConfigurations.isNetworkInSync(), is(false)); List<ReportedConfiguration> reportedConfigurationList = reportedConfigurations.getReportedConfigurationList(); ReportedConfiguration expectedReportedConfiguration = new ReportedConfiguration(ReportedConfigurationType.SWITCH_TYPE, SwitchType.LEGACY, SwitchType.OVS, false); assertThat(reportedConfigurationList.contains(expectedReportedConfiguration), is(true)); }
defaultRouteReportedConfiguration(false), new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_LINK_SHARE, null, networkQos.getOutAverageLinkshare(), false), new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_REAL_TIME, null, networkQos.getOutAverageRealtime(), false), new ReportedConfiguration(ReportedConfigurationType.OUT_AVERAGE_UPPER_LIMIT, null, networkQos.getOutAverageUpperlimit(),
@Test public void testReportConfigurationsOnHostWhenDefaultRouteDiffers() { //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 has default route role NetworkInSyncWithVdsNetworkInterface testedInstance = createTestedInstanceWithSameNonQosValues(true); ReportedConfigurations reportedConfigurations = testedInstance.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()), "192.168.1.1,2001:0db8:85a3:0000:0000:8a2e:0370:7334", true), new ReportedConfiguration(ReportedConfigurationType.DEFAULT_ROUTE, false, true, false) ); assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true)); assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size())); }
@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())); }
@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())); }
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(),