verifyHealthFailureAfterThreshold(containerDesc.healthConfig.unhealthyThreshold, containerDesc, container);
@Test public void testHealthCheckWithHttpAndDefaultPortThresholds() throws Throwable { // Create health config and a container to check the health for ContainerDescription containerDesc = createContainerDescription(); containerDesc.documentSelfLink = UriUtils.buildUriPath( ContainerDescriptionService.FACTORY_LINK, "mockDescId"); containerDesc.healthConfig = new HealthConfig(); containerDesc.healthConfig.protocol = RequestProtocol.HTTP; containerDesc.healthConfig.httpMethod = Action.GET; containerDesc.healthConfig.urlPath = TestHealthService.SELF_LINK; containerDesc = doPost(containerDesc, ContainerDescriptionService.FACTORY_LINK); ContainerState container = createContainerStateNoAddress(containerDesc.documentSelfLink); container.powerState = PowerState.RUNNING; container = doPost(container, ContainerFactoryService.SELF_LINK); verifyHealthFailureAfterThreshold(3, containerDesc, container); // Start a test service to ping for health check TestHealthService pingService = new TestHealthService(); URI pingServiceUri = UriUtils.buildUri(host, TestHealthService.SELF_LINK); host.startService(Operation.createPost(pingServiceUri), pingService); waitForServiceAvailability(TestHealthService.SELF_LINK); verifyHealthSuccessAfterThreshold(3, containerDesc, container); }
@Test public void testHealthCheckWithCommand() throws Throwable { // Create health config and a container to check the health for String mockContainerDescriptionLink = UriUtils.buildUriPath( ContainerDescriptionService.FACTORY_LINK, "mockDescId"); ContainerDescription containerDesc = createContainerDescription(); containerDesc.documentSelfLink = mockContainerDescriptionLink; containerDesc.healthConfig.healthyThreshold = 1; containerDesc.healthConfig.protocol = RequestProtocol.COMMAND; containerDesc.healthConfig.command = "echo"; containerDesc = doPost(containerDesc, ContainerDescriptionService.FACTORY_LINK); ContainerState container = createContainerStateNoAddress(mockContainerDescriptionLink); container.adapterManagementReference = UriUtils.buildPublicUri(host, MockDockerAdapterService.SELF_LINK); container.powerState = PowerState.RUNNING; container = doPost(container, ContainerFactoryService.SELF_LINK); verifyHealthFailureAfterThreshold(containerDesc.healthConfig.unhealthyThreshold, containerDesc, container); MockDockerAdapterService dockerAdapterService = new MockDockerAdapterService(); host.startService(Operation.createPost(UriUtils.buildUri(host, MockDockerAdapterService.class)), dockerAdapterService); waitForServiceAvailability(MockDockerAdapterService.SELF_LINK); verifyHealthSuccessAfterThreshold(containerDesc.healthConfig.healthyThreshold, containerDesc, container); }
doPatch(containerDesc, containerDesc.documentSelfLink); verifyHealthFailureAfterThreshold(containerDesc.healthConfig.unhealthyThreshold, containerDesc, container);