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
15 changes: 14 additions & 1 deletion spec/src/main/asciidoc/protocol-wireformat.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2016-2021 Eclipse Microprofile Contributors:
// Copyright (c) 2016-2025 Eclipse Microprofile Contributors:
// See overview.adoc
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -200,6 +200,19 @@ https://github.com/eclipse/microprofile-config[MicroProfile Config] configuratio
`mp.health.disable-default-procedures` to `true`. This allows the application to process and
display only the user-defined health check procedures.

=== Disabling individual health checks
Comment thread
pgunapal marked this conversation as resolved.

If you need to disable any of the included health checks procedures, you can include the `mp.health.disabled.checks` https://github.com/eclipse/microprofile-config[MicroProfile Config] configuration property which expects an array of the fully
qualified classnames of the `HealthCheck` implementations. For instance:

```properties
mp.health.disabled.checks=org.acme.MyHealthCheck,org.myorg.CustomHealthCheck2
```

This might be particularly useful if the same application deploys in different environments
with different requirements. The configuration can disable health checks which are not
or potentially even can cause problems dynamically, without the need to recompile the whole
application to remove the health check implementation.

== Security

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 Contributors to the Eclipse Foundation
* Copyright (c) 2020-2025 Contributors to the Eclipse Foundation
*
* See the NOTICES file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -37,11 +37,11 @@
/**
Comment thread
pgunapal marked this conversation as resolved.
* @author Martin Stefanko
*/
public class ConfigTest extends TCKBase {
public class DefaultEmptyResponseConfigTest extends TCKBase {

@Deployment
public static Archive getDeployment() {
return createWarFileWithClasses(ConfigTest.class.getSimpleName())
return createWarFileWithClasses(DefaultEmptyResponseConfigTest.class.getSimpleName())
.addAsManifestResource(new StringAsset("mp.health.default.readiness.empty.response=UP"),
"microprofile-config.properties");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICES file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/

package org.eclipse.microprofile.health.tck;

import static org.eclipse.microprofile.health.tck.DeploymentUtils.createWarFileWithClasses;

import org.eclipse.microprofile.health.tck.deployment.SuccessfulLiveness;
import org.eclipse.microprofile.health.tck.deployment.SuccessfulReadiness;
import org.eclipse.microprofile.health.tck.deployment.SuccessfulStartup;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.testng.Assert;
import org.testng.annotations.Test;

import jakarta.json.JsonArray;
import jakarta.json.JsonObject;

/**
* @author Martin Stefanko
*/
public class DisableHealthChecksConfigTest extends TCKBase {

private static final String SINGLE_CLASSNAME = "single-classname";
private static final String MULTIPLE_CLASSNAME = "multiple-classname";

@Deployment(name = SINGLE_CLASSNAME)
public static Archive getDeploymentSingleClassnameCheck() {
return createWarFileWithClasses(SINGLE_CLASSNAME, SuccessfulLiveness.class)
.addAsManifestResource(
new StringAsset("mp.health.disabled.checks=" + SuccessfulLiveness.class.getName()),
"microprofile-config.properties");
}

/**
* Verifies that disabling single health check with full class name is respected.
*/
@Test
@OperateOnDeployment(SINGLE_CLASSNAME)
@RunAsClient
public void testSingleHealthCheckDisabledWithClassname() {
assertNumberOfChecksPresent(0, "Didn't expect any checks");
}

@Deployment(name = MULTIPLE_CLASSNAME)
public static Archive getDeploymentMultipleClassnameCheck() {
return createWarFileWithClasses(MULTIPLE_CLASSNAME, SuccessfulLiveness.class, SuccessfulReadiness.class,
SuccessfulStartup.class)
.addAsManifestResource(
new StringAsset("mp.health.disabled.checks=" + SuccessfulLiveness.class.getName() + ","
+ SuccessfulReadiness.class.getName()),
"microprofile-config.properties");
}

/**
* Verifies that disabling multiple health checks with full class name is respected.
*/
@Test
@OperateOnDeployment(MULTIPLE_CLASSNAME)
@RunAsClient
public void testMultipleHealthCheckDisabledWithClassname() {
assertNumberOfChecksPresent(1, "Expected only one check");
}

private void assertNumberOfChecksPresent(int expected, String message) {
Response response = getUrlHealthContents();

// status code
Assert.assertEquals(response.getStatus(), 200);

JsonObject json = readJson(response);

// response size
JsonArray checks = json.getJsonArray("checks");
Assert.assertEquals(checks.size(), expected, message);

assertOverallSuccess(json);
}
}