Skip to content

Commit

Permalink
test (gradle-plugin/it) : Add E2E test to verify SpringBootHealthChec…
Browse files Browse the repository at this point in the history
…kEnricher detects management health probe endpoints

Related to eclipse-jkube#2665

Add gradle integration test to verify that SpringBootHealthCheckEnricher
adds `/actuator/health/readiness` for readiness probe and
`/actuator/health/liveness` for liveness probe when
`management.health.probes.enabled` property is enabled in
application.properties

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Jun 7, 2024
1 parent 64e498e commit a2c2943
Show file tree
Hide file tree
Showing 6 changed files with 434 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
plugins {
id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}"
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}"
id 'org.springframework.boot' version '2.7.17'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}

group = 'org.eclipse.jkube.integration.tests.gradle'
version = '0.0.1-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
}

kubernetes {
offline = true
}
openshift {
offline = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "9779"
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: spring-boot-managementhealthprobes
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/version: "@ignore@"
name: spring-boot-managementhealthprobes
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: spring-boot-managementhealthprobes
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: spring-boot-managementhealthprobes
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/version: "@ignore@"
name: spring-boot-managementhealthprobes
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: spring-boot-managementhealthprobes
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
template:
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: spring-boot-managementhealthprobes
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/version: "@ignore@"
name: spring-boot-managementhealthprobes
spec:
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
image: gradle/spring-boot-managementhealthprobes:latest
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /actuator/health/liveness
port: 8080
scheme: HTTP
initialDelaySeconds: 180
successThreshold: 1
name: spring-boot
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 9779
name: prometheus
protocol: TCP
- containerPort: 8778
name: jolokia
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /actuator/health/readiness
port: 8080
scheme: HTTP
initialDelaySeconds: 10
successThreshold: 1
securityContext:
privileged: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "9779"
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
app.openshift.io/vcs-ref: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: spring-boot-managementhealthprobes
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/version: "@ignore@"
name: spring-boot-managementhealthprobes
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: spring-boot-managementhealthprobes
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
app.openshift.io/vcs-ref: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: spring-boot-managementhealthprobes
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/version: "@ignore@"
name: spring-boot-managementhealthprobes
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
app: spring-boot-managementhealthprobes
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
strategy:
rollingParams:
timeoutSeconds: 3600
type: Rolling
template:
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
app.openshift.io/vcs-ref: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: spring-boot-managementhealthprobes
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/version: "@ignore@"
name: spring-boot-managementhealthprobes
spec:
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: spring-boot-managementhealthprobes:latest
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /actuator/health/liveness
port: 8080
scheme: HTTP
initialDelaySeconds: 180
successThreshold: 1
name: spring-boot
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 9779
name: prometheus
protocol: TCP
- containerPort: 8778
name: jolokia
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /actuator/health/readiness
port: 8080
scheme: HTTP
initialDelaySeconds: 10
successThreshold: 1
securityContext:
privileged: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- spring-boot
from:
kind: ImageStreamTag
name: spring-boot-managementhealthprobes:latest
type: ImageChange
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
app.openshift.io/vcs-ref: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: spring-boot-managementhealthprobes
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: spring-boot-managementhealthprobes
app.kubernetes.io/version: "@ignore@"
name: spring-boot-managementhealthprobes
spec:
port:
targetPort: 8080
to:
kind: Service
name: spring-boot-managementhealthprobes
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube.it.gradle.spring.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2019 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at:
#
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

management.health.probes.enabled=true
Loading

0 comments on commit a2c2943

Please sign in to comment.