Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
private static final String FILESYSTEM_WRITABLE_TEST = "filesystem.writable.test";
private static final String READONLY_FILESYSTEM_ERROR = "Read-only file system";
private static final String BACKUP_ROUTER_EXCLUDED_TESTS = "gateways_check.py";
private static final String INTERNAL_LB_EXCLUDED_TESTS = "dhcp_check.py,dns_check.py";
/**
* Used regex to ensure that the value that will be passed to the VR is an acceptable value
*/
Expand Down Expand Up @@ -1616,6 +1617,9 @@ private SetMonitorServiceCommand createMonitorServiceCommand(DomainRouterVO rout
excludedTests = excludedTests.isEmpty() ? BACKUP_ROUTER_EXCLUDED_TESTS : excludedTests + "," + BACKUP_ROUTER_EXCLUDED_TESTS;
}
}
if (router.getRole() == Role.INTERNAL_LB_VM) {
excludedTests = excludedTests.isEmpty() ? INTERNAL_LB_EXCLUDED_TESTS : excludedTests + "," + INTERNAL_LB_EXCLUDED_TESTS;
}

command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED, excludedTests);
command.setHealthChecksConfig(routerHealthCheckConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import com.cloud.user.dao.UserDao;
import com.cloud.user.dao.UserStatisticsDao;
import com.cloud.user.dao.UserStatsLogDao;
import com.cloud.agent.api.routing.SetMonitorServiceCommand;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineManager;
Expand All @@ -91,6 +92,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.nullable;
Expand Down Expand Up @@ -354,6 +356,28 @@ public void checkLogrotateTimerPatternTestMatchesWithRegex(){
Assert.assertTrue(result);
}

@Test
public void testInternalLbRouterExcludesDhcpAndDnsHealthChecks() throws Exception {
DomainRouterVO router = Mockito.mock(DomainRouterVO.class);
when(router.getId()).thenReturn(1L);
when(router.getInstanceName()).thenReturn("r-1-VM");
when(router.getDataCenterId()).thenReturn(1L);
when(router.getIsRedundantRouter()).thenReturn(false);
when(router.getRole()).thenReturn(VirtualRouter.Role.INTERNAL_LB_VM);
when(_routerControlHelper.getRouterControlIp(1L)).thenReturn("169.254.0.1");

java.lang.reflect.Method method = VirtualNetworkApplianceManagerImpl.class.getDeclaredMethod(
"createMonitorServiceCommand", DomainRouterVO.class, List.class, boolean.class, boolean.class, Map.class);
method.setAccessible(true);
SetMonitorServiceCommand command = (SetMonitorServiceCommand) method.invoke(
virtualNetworkApplianceManagerImpl, router, null, true, true, null);

String excluded = command.getAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED);
Assert.assertNotNull(excluded);
Assert.assertTrue("Internal LB VM should exclude dhcp and dns health checks, got: " + excluded,
excluded.contains("dhcp_check.py") && excluded.contains("dns_check.py"));
}

@Test
public void testFinalizeNetworkRulesForNetwork() {
Long guestNetworkId = 10L;
Expand Down
Loading