use of com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs in project photon-model by vmware.
the class TestAzureEnumerationTask method validateVirtualNetworkGateways.
/**
* Validates that the Gateway information discovered from Azure has been propagated to the
* NetworkState custom properties.
*/
private void validateVirtualNetworkGateways(AzureNicSpecs nicSpecs) throws Throwable {
if (this.isMock) {
return;
}
// Query all network states in the system
Map<String, NetworkState> networkStatesMap = ProvisioningUtils.getResourceStates(this.host, NetworkService.FACTORY_LINK, NetworkState.class);
AtomicBoolean isGatewayFound = new AtomicBoolean(false);
networkStatesMap.values().forEach(networkState -> {
if (networkState.name.contains(nicSpecs.network.name)) {
List<SubnetState> subnetStates = getSubnetStates(this.host, networkState);
assertFalse(subnetStates.isEmpty());
subnetStates.stream().filter(subnetState -> AzureConstants.GATEWAY_SUBNET_NAME.equalsIgnoreCase(subnetState.name)).forEach(subnetState -> {
this.host.log(Level.INFO, "Validating gateway for network" + "(name %s, id: %s)", networkState.name, networkState.id);
assertNotNull("Custom properties are null.", networkState.customProperties);
assertNotNull("Virtual gateway property not found.", networkState.customProperties.get(ComputeProperties.FIELD_VIRTUAL_GATEWAY));
assertNotNull("SubnetState custom properties are null.", subnetState.customProperties);
assertEquals("Gateway SubnetState is not marked currectly with " + "infrastructure use custom property.", Boolean.TRUE.toString(), subnetState.customProperties.get(ComputeProperties.INFRASTRUCTURE_USE_PROP_NAME));
isGatewayFound.set(true);
});
}
});
assertTrue("Gateway custom property was not found at all.", isGatewayFound.get());
}
Aggregations