Skip to content

Commit 68e3ec0

Browse files
authored
Merge pull request #166 from OpenLiberty/staging
Merge staging to prod - Version update mphealth 3.1 (#162)
2 parents 9edba5c + 1d3e4a4 commit 68e3ec0

File tree

14 files changed

+302
-142
lines changed

14 files changed

+302
-142
lines changed

Diff for: .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: bash ./tools/pr-checker/checker.sh ${{ github.repository }} ${{ github.event.pull_request.number }} | tee checker.log
2424
- id: Lint-Code-Base
2525
if: always()
26-
uses: github/super-linter@v3
26+
uses: github/super-linter@v3.17.0
2727
env:
2828
VALIDATE_ALL_CODEBASE: false
2929
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: README.adoc

+152-95
Large diffs are not rendered by default.

Diff for: finish/pom.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@
3131
<!-- tag::microprofile[] -->
3232
<artifactId>microprofile</artifactId>
3333
<!-- end::microprofile[] -->
34-
<version>4.0.1</version>
34+
<version>4.1</version>
3535
<type>pom</type>
3636
<scope>provided</scope>
3737
</dependency>
3838
<!-- For tests -->
3939
<dependency>
4040
<groupId>org.junit.jupiter</groupId>
4141
<artifactId>junit-jupiter</artifactId>
42-
<version>5.7.1</version>
42+
<version>5.8.1</version>
4343
<scope>test</scope>
4444
</dependency>
4545
<dependency>
4646
<groupId>org.apache.cxf</groupId>
4747
<artifactId>cxf-rt-rs-client</artifactId>
48-
<version>3.4.3</version>
48+
<version>3.4.5</version>
4949
<scope>test</scope>
5050
</dependency>
5151
<dependency>
5252
<groupId>org.apache.cxf</groupId>
5353
<artifactId>cxf-rt-rs-extension-providers</artifactId>
54-
<version>3.4.3</version>
54+
<version>3.4.5</version>
5555
<scope>test</scope>
5656
</dependency>
5757
<dependency>
@@ -74,7 +74,7 @@
7474
<plugin>
7575
<groupId>org.apache.maven.plugins</groupId>
7676
<artifactId>maven-war-plugin</artifactId>
77-
<version>3.3.1</version>
77+
<version>3.3.2</version>
7878
</plugin>
7979
<!-- Plugin to run unit tests -->
8080
<plugin>
@@ -86,7 +86,7 @@
8686
<plugin>
8787
<groupId>io.openliberty.tools</groupId>
8888
<artifactId>liberty-maven-plugin</artifactId>
89-
<version>3.3.4</version>
89+
<version>3.5.1</version>
9090
</plugin>
9191
<!-- Plugin to run functional tests -->
9292
<plugin>

Diff for: finish/resources/CustomConfigSource2.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"config_ordinal":700,
3+
"io_openliberty_guides_inventory_inMaintenance":true
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// tag::copyright[]
2+
/*******************************************************************************
3+
* Copyright (c) 2022 IBM Corporation and others.
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/legal/epl-v10.html
8+
*
9+
* Contributors:
10+
* IBM Corporation - Initial implementation
11+
*******************************************************************************/
12+
// end::copyright[]
13+
// tag::InventoryStartupCheck[]
14+
package io.openliberty.guides.inventory;
15+
16+
import java.lang.management.ManagementFactory;
17+
import com.sun.management.OperatingSystemMXBean;
18+
import javax.enterprise.context.ApplicationScoped;
19+
import org.eclipse.microprofile.health.Startup;
20+
import org.eclipse.microprofile.health.HealthCheck;
21+
import org.eclipse.microprofile.health.HealthCheckResponse;
22+
23+
// tag::Startup[]
24+
@Startup
25+
// end::Startup[]
26+
@ApplicationScoped
27+
public class InventoryStartupCheck implements HealthCheck {
28+
29+
@Override
30+
public HealthCheckResponse call() {
31+
OperatingSystemMXBean bean = (com.sun.management.OperatingSystemMXBean)
32+
ManagementFactory.getOperatingSystemMXBean();
33+
double cpuUsed = bean.getSystemCpuLoad();
34+
String cpuUsage = String.valueOf(cpuUsed);
35+
return HealthCheckResponse.named(InventoryResource.class
36+
.getSimpleName() + " Startup Check")
37+
.withData("cpu used", cpuUsage)
38+
.status(cpuUsed < 0.95).build();
39+
}
40+
}
41+
42+
// end::InventoryStartupCheck[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// tag::copyright[]
2+
/*******************************************************************************
3+
* Copyright (c) 2022 IBM Corporation and others.
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/legal/epl-v10.html
8+
*
9+
* Contributors:
10+
* IBM Corporation - Initial implementation
11+
*******************************************************************************/
12+
// end::copyright[]
13+
// tag::SystemStartupCheck[]
14+
package io.openliberty.guides.system;
15+
16+
import java.lang.management.ManagementFactory;
17+
import com.sun.management.OperatingSystemMXBean;
18+
import javax.enterprise.context.ApplicationScoped;
19+
import org.eclipse.microprofile.health.Startup;
20+
import org.eclipse.microprofile.health.HealthCheck;
21+
import org.eclipse.microprofile.health.HealthCheckResponse;
22+
23+
// tag::Startup[]
24+
@Startup
25+
// end::Startup[]
26+
@ApplicationScoped
27+
public class SystemStartupCheck implements HealthCheck {
28+
29+
@Override
30+
public HealthCheckResponse call() {
31+
OperatingSystemMXBean bean = (com.sun.management.OperatingSystemMXBean)
32+
ManagementFactory.getOperatingSystemMXBean();
33+
double cpuUsed = bean.getSystemCpuLoad();
34+
String cpuUsage = String.valueOf(cpuUsed);
35+
return HealthCheckResponse.named(SystemResource.class
36+
.getSimpleName() + " Startup Check")
37+
.withData("cpu used", cpuUsage)
38+
.status(cpuUsed < 0.95).build();
39+
}
40+
}
41+
42+
// end::SystemStartupCheck[]

Diff for: finish/src/main/liberty/config/server.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<feature>mpConfig-2.0</feature>
88
<feature>mpRestClient-2.0</feature>
99
<!-- tag::mpHealth[] -->
10-
<feature>mpHealth-3.0</feature>
10+
<feature>mpHealth-3.1</feature>
1111
<!-- end::mpHealth[] -->
1212
</featureManager>
1313

Diff for: finish/src/main/webapp/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ <h2>Eclipse MicroProfile</h2>
3030
<p>
3131
For more information about the features used in this application, see the Open Liberty documentation:
3232
<ul>
33-
<li><a href="https://openliberty.io/docs/ref/feature/#microProfile-4.0.html" target="_blank" rel="noopener noreferrer">MicroProfile 4.0</a></li>
33+
<li><a href="https://openliberty.io/docs/ref/feature/#microProfile-4.1.html" target="_blank" rel="noopener noreferrer">MicroProfile 4.1</a></li>
3434
<li><a href="https://openliberty.io/docs/ref/feature/#jaxrs-2.1.html" target="_blank" rel="noopener noreferrer">Java RESTful Services 2.1</a></li>
3535
<li><a href="https://openliberty.io/docs/ref/feature/#jsonp-1.1.html" target="_blank" rel="noopener noreferrer">JavaScript Object Notation Processing 1.1</a></li>
3636
<li><a href="https://openliberty.io/docs/ref/feature/#cdi-2.0.html" target="_blank" rel="noopener noreferrer">Contexts and Dependency Injection 2.0</a></li>
3737
<li><a href="https://openliberty.io/docs/ref/feature/#mpConfig-2.0.html" target="_blank" rel="noopener noreferrer">MicroProfile Config 2.0</a></li>
3838
<li><a href="https://openliberty.io/docs/ref/feature/#mpRestClient-2.0.html" target="_blank" rel="noopener noreferrer">MicroProfile Rest Client 2.0</a></li>
39-
<li><a href="https://openliberty.io/docs/ref/feature/#mpHealth-3.0.html" target="_blank" rel="noopener noreferrer">MicroProfile Health 3.0</a></li>
39+
<li><a href="https://openliberty.io/docs/ref/feature/#mpHealth-3.1.html" target="_blank" rel="noopener noreferrer">MicroProfile Health 3.1</a></li>
4040
</ul>
4141
</p>
4242
</div>

Diff for: finish/src/test/java/it/io/openliberty/guides/health/HealthIT.java

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// tag::copyright[]
22
/*******************************************************************************
3-
* Copyright (c) 2018, 2019 IBM Corporation and others.
3+
* Copyright (c) 2018, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v1.0
66
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@
1515

1616
import static org.junit.jupiter.api.Assertions.assertEquals;
1717

18+
import java.beans.Transient;
1819
import java.util.HashMap;
1920

2021
import javax.json.JsonArray;
@@ -31,24 +32,34 @@ public class HealthIT {
3132
private String HEALTH_ENDPOINT = "health";
3233
private String READINESS_ENDPOINT = "health/ready";
3334
private String LIVENES_ENDPOINT = "health/live";
35+
private String STARTUP_ENDPOINT = "health/started";
3436

3537
@BeforeEach
3638
public void setup() {
3739
endpointData = new HashMap<String, String>();
3840
}
3941

4042
@Test
41-
// tag::testIfServicesAreUp[]
42-
public void testIfServicesAreUp() {
43-
endpointData.put("SystemResource Readiness Check", "UP");
43+
// tag::testStartup[]
44+
public void testStartup() {
45+
endpointData.put("InventoryResource Startup Check", "UP");
46+
endpointData.put("SystemResource Startup Check", "UP");
47+
48+
servicesStates = HealthITUtil.connectToHealthEnpoint(200, STARTUP_ENDPOINT);
49+
checkStates(endpointData, servicesStates);
50+
}
51+
// end::testStartup[]
52+
53+
@Test
54+
// tag::testLiveness[]
55+
public void testLiveness() {
4456
endpointData.put("SystemResource Liveness Check", "UP");
45-
endpointData.put("InventoryResource Readiness Check", "UP");
4657
endpointData.put("InventoryResource Liveness Check", "UP");
4758

48-
servicesStates = HealthITUtil.connectToHealthEnpoint(200, HEALTH_ENDPOINT);
59+
servicesStates = HealthITUtil.connectToHealthEnpoint(200, LIVENES_ENDPOINT);
4960
checkStates(endpointData, servicesStates);
5061
}
51-
// end::testIfServicesAreUp[]
62+
// end::testLiveness[]
5263

5364
@Test
5465
// tag::testReadiness[]
@@ -62,23 +73,14 @@ public void testReadiness() {
6273
// end::testReadiness[]
6374

6475
@Test
65-
// tag::testLiveness[]
66-
public void testLiveness() {
76+
// tag::testHealth[]
77+
public void testHealth() {
78+
endpointData.put("SystemResource Startup Check", "UP");
6779
endpointData.put("SystemResource Liveness Check", "UP");
68-
endpointData.put("InventoryResource Liveness Check", "UP");
69-
70-
servicesStates = HealthITUtil.connectToHealthEnpoint(200, LIVENES_ENDPOINT);
71-
checkStates(endpointData, servicesStates);
72-
}
73-
// end::testLiveness[]
74-
75-
@Test
76-
// tag::testIfInventoryServiceIsDown[]
77-
public void testIfInventoryServiceIsDown() {
7880
endpointData.put("SystemResource Readiness Check", "UP");
79-
endpointData.put("SystemResource Liveness Check", "UP");
80-
endpointData.put("InventoryResource Readiness Check", "UP");
81+
endpointData.put("InventoryResource Startup Check", "UP");
8182
endpointData.put("InventoryResource Liveness Check", "UP");
83+
endpointData.put("InventoryResource Readiness Check", "UP");
8284

8385
servicesStates = HealthITUtil.connectToHealthEnpoint(200, HEALTH_ENDPOINT);
8486
checkStates(endpointData, servicesStates);
@@ -89,7 +91,7 @@ public void testIfInventoryServiceIsDown() {
8991
servicesStates = HealthITUtil.connectToHealthEnpoint(503, HEALTH_ENDPOINT);
9092
checkStates(endpointData, servicesStates);
9193
}
92-
// end::testIfInventoryServiceIsDown[]
94+
// end::testHealth[]
9395

9496
private void checkStates(HashMap<String, String> testData, JsonArray servStates) {
9597
testData.forEach((service, expectedState) -> {

Diff for: finish/src/test/java/it/io/openliberty/guides/health/HealthITUtil.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// tag::comment[]
1+
// tag::copyright[]
22
/*******************************************************************************
3-
* Copyright (c) 2018, 2019 IBM Corporation and others.
3+
* Copyright (c) 2018, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v1.0
66
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
99
* Contributors:
1010
* IBM Corporation - Initial implementation
1111
*******************************************************************************/
12-
// end::comment[]
12+
// end::copyright[]
1313
// tag::HealthTestUtil[]
1414
package it.io.openliberty.guides.health;
1515

@@ -32,8 +32,10 @@ public class HealthITUtil {
3232

3333
private static String port;
3434
private static String baseUrl;
35-
public static final String INV_MAINTENANCE_FALSE = "io_openliberty_guides_inventory_inMaintenance\":false";
36-
public static final String INV_MAINTENANCE_TRUE = "io_openliberty_guides_inventory_inMaintenance\":true";
35+
public static final String INV_MAINTENANCE_FALSE = "io_openliberty_guides_inventory_"
36+
+ "inMaintenance\":false";
37+
public static final String INV_MAINTENANCE_TRUE = "io_openliberty_guides_inventory_"
38+
+ "inMaintenance\":true";
3739

3840
static {
3941
port = System.getProperty("default.http.port");
@@ -72,7 +74,8 @@ public static void changeInventoryProperty(String oldValue, String newValue) {
7274
+ "/resources/CustomConfigSource.json";
7375
BufferedReader reader = new BufferedReader(new FileReader(new File(fileName)));
7476
String line = "";
75-
String oldContent = "", newContent = "";
77+
String oldContent = "";
78+
String newContent = "";
7679
while ((line = reader.readLine()) != null) {
7780
oldContent += line + "\r\n";
7881
}

Diff for: scripts/testApp.sh

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ set -euxo pipefail
99

1010
# LMP 3.0+ goals are listed here: https://github.com/OpenLiberty/ci.maven#goals
1111

12+
sed -i 's/0.9/1.1/' ../finish/src/main/java/io/openliberty/guides/system/SystemLivenessCheck.java
13+
sed -i 's/0.95/1.1/' ../finish/src/main/java/io/openliberty/guides/system/SystemStartupCheck.java
14+
sed -i 's/0.9/1.1/' ../finish/src/main/java/io/openliberty/guides/inventory/InventoryLivenessCheck.java
15+
sed -i 's/0.95/1.1/' ../finish/src/main/java/io/openliberty/guides/inventory/InventoryStartupCheck.java
16+
1217
## Rebuild the application
1318
# package - Take the compiled code and package it in its distributable format.
1419
# liberty:create - Create a Liberty server.
@@ -27,6 +32,11 @@ mvn -Dhttp.keepAlive=false \
2732
# liberty:stop - Stop a Liberty server.
2833
# failsafe:verify - Verifies that the integration tests of an application passed.
2934
mvn liberty:start
35+
36+
sleep 20
37+
38+
curl http://localhost:9080/health | jq
39+
3040
mvn -Dhttp.keepAlive=false \
3141
-Dmaven.wagon.http.pool=false \
3242
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \

Diff for: start/pom.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@
2929
<dependency>
3030
<groupId>org.eclipse.microprofile</groupId>
3131
<artifactId>microprofile</artifactId>
32-
<version>4.0.1</version>
32+
<version>4.1</version>
3333
<type>pom</type>
3434
<scope>provided</scope>
3535
</dependency>
3636
<!-- For tests -->
3737
<dependency>
3838
<groupId>org.junit.jupiter</groupId>
3939
<artifactId>junit-jupiter</artifactId>
40-
<version>5.7.1</version>
40+
<version>5.8.1</version>
4141
<scope>test</scope>
4242
</dependency>
4343
<dependency>
4444
<groupId>org.apache.cxf</groupId>
4545
<artifactId>cxf-rt-rs-client</artifactId>
46-
<version>3.4.3</version>
46+
<version>3.4.5</version>
4747
<scope>test</scope>
4848
</dependency>
4949
<dependency>
5050
<groupId>org.apache.cxf</groupId>
5151
<artifactId>cxf-rt-rs-extension-providers</artifactId>
52-
<version>3.4.3</version>
52+
<version>3.4.5</version>
5353
<scope>test</scope>
5454
</dependency>
5555
<dependency>
@@ -72,7 +72,7 @@
7272
<plugin>
7373
<groupId>org.apache.maven.plugins</groupId>
7474
<artifactId>maven-war-plugin</artifactId>
75-
<version>3.3.1</version>
75+
<version>3.3.2</version>
7676
</plugin>
7777
<!-- Plugin to run unit tests -->
7878
<plugin>
@@ -84,7 +84,7 @@
8484
<plugin>
8585
<groupId>io.openliberty.tools</groupId>
8686
<artifactId>liberty-maven-plugin</artifactId>
87-
<version>3.3.4</version>
87+
<version>3.5.1</version>
8888
</plugin>
8989
<!-- Plugin to run functional tests -->
9090
<plugin>

Diff for: start/src/main/liberty/config/server.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<feature>cdi-2.0</feature>
77
<feature>mpConfig-2.0</feature>
88
<feature>mpRestClient-2.0</feature>
9-
<feature>mpHealth-3.0</feature>
9+
<feature>mpHealth-3.1</feature>
1010
</featureManager>
1111

1212
<variable name="default.http.port" defaultValue="9080"/>

0 commit comments

Comments
 (0)