Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d2c5eb7
Enable monitor testing in CI
IvanKavaldzhiev Dec 18, 2025
e7cc8a8
Add missing test configuration in values.yaml
IvanKavaldzhiev Dec 18, 2025
0c98e00
Remove unneeded properties and run helm test without filters
IvanKavaldzhiev Dec 19, 2025
d199872
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev Dec 19, 2025
39c62f9
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev Dec 22, 2025
f9bdee2
Resolve PR comments
IvanKavaldzhiev Dec 22, 2025
90d9b9a
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev Dec 29, 2025
80709a7
Resolve PR comments
IvanKavaldzhiev Dec 29, 2025
7865229
Fix and enrich unit tests
IvanKavaldzhiev Dec 29, 2025
89b60cc
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev Dec 30, 2025
37f6a59
Disable rest, restjava and web3 tests and fix variable naming
IvanKavaldzhiev Dec 30, 2025
6b826e7
Add sleep in monitor test pod, so that logs can be fetched
IvanKavaldzhiev Dec 30, 2025
559ba81
Revert sleep
IvanKavaldzhiev Jan 2, 2026
7c1f053
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev Jan 5, 2026
59980e7
Add hook-failed annotation for monitor pod
IvanKavaldzhiev Jan 5, 2026
ba90516
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev Jan 6, 2026
8413456
Override hook-delete-policty in correct place
IvanKavaldzhiev Jan 6, 2026
84bb955
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev Jan 7, 2026
ed35867
Revert test disabling for rest, rest-java and web3
IvanKavaldzhiev Jan 7, 2026
e54429f
Update hook delete policy for rest-test
IvanKavaldzhiev Jan 7, 2026
7ef2445
Update hook-delete-policy for restjava-test
IvanKavaldzhiev Jan 7, 2026
f9fa043
Update hook-delete-policy for web3-test
IvanKavaldzhiev Jan 7, 2026
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
38 changes: 37 additions & 1 deletion .github/workflows/acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ jobs:
env:
HIERO_MIRROR_IMPORTER_BLOCK_NODES_0_HOST: 'block-node-1.${SOLO_NAMESPACE}.svc.cluster.local'
SPRING_PROFILES_ACTIVE: 'blocknode'
monitor:
env:
HIERO_MIRROR_MONITOR_HEALTH_RELEASE_FAILWHENINACTIVE: "true"
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
enabled: true
rest:
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
restjava:
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
test:
cucumberTags: "@acceptance and not @ethereum and not @ethcall and not @crud"
annotations:
Expand All @@ -184,10 +199,28 @@ jobs:
web3:
env:
HIERO_MIRROR_WEB3_OPCODE_TRACER_ENABLED: "true"
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
EOF

else
cat <<EOF > mirror.yaml
monitor:
env:
HIERO_MIRROR_MONITOR_HEALTH_RELEASE_FAILWHENINACTIVE: "true"
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
enabled: true
rest:
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
restjava:
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
Expand All @@ -200,6 +233,9 @@ jobs:
web3:
env:
HIERO_MIRROR_WEB3_OPCODE_TRACER_ENABLED: "true"
test:
annotations:
helm.sh/hook-delete-policy: before-hook-creation
EOF
fi

Expand All @@ -215,7 +251,7 @@ jobs:
- name: Run acceptance tests
run: |
helm test "${HELM_RELEASE_NAME}" -n "${SOLO_NAMESPACE}" --logs \
--filter name="${HELM_RELEASE_NAME}-mirror-acceptance" --timeout 20m | tee output_log.txt
--timeout 20m | tee output_log.txt

- name: Run k6 tests
if: ${{ matrix.stream-type != 'BLOCK' }}
Expand Down
44 changes: 44 additions & 0 deletions charts/hedera-mirror-monitor/postman.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"info": {
"_postman_id": "e015390f-8007-4371-8703-0b9ad853f718",
"name": "Monitor API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "25186531"
},
"item": [
{
"name": "Check Cluster Health",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});"
],
"type": "text/javascript",
"packages": {},
"requests": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/actuator/health/cluster",
"host": ["{{baseUrl}}"],
"path": ["actuator", "health", "cluster"]
}
},
"response": []
}
],
"variable": [
{
"key": "baseUrl",
"value": "http://localhost:8082"
}
]
}
15 changes: 15 additions & 0 deletions charts/hedera-mirror-monitor/templates/tests/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: Apache-2.0

{{ if .Values.test.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
annotations: {{- toYaml .Values.test.annotations | nindent 4 }}
labels: {{- include "hedera-mirror-monitor.labels" . | nindent 4 }}
app.kubernetes.io/name: {{ include "hedera-mirror-monitor.name" . }}-test
name: {{ include "hedera-mirror-monitor.fullname" . }}-test
namespace: {{ include "hedera-mirror-monitor.namespace" . }}
data:
postman.json: |-
{{- .Values.test.postman | b64dec | default (.Files.Get "postman.json") | nindent 4 }}
{{- end -}}
47 changes: 47 additions & 0 deletions charts/hedera-mirror-monitor/templates/tests/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: Apache-2.0

{{ if .Values.test.enabled -}}
apiVersion: v1
kind: Pod
metadata:
annotations: {{- toYaml .Values.test.annotations | nindent 4 }}
labels: {{- include "hedera-mirror-monitor.labels" . | nindent 4 }}
app.kubernetes.io/name: {{ include "hedera-mirror-monitor.name" . }}-test
name: {{ include "hedera-mirror-monitor.fullname" . }}-test
namespace: {{ include "hedera-mirror-monitor.namespace" . }}
spec:
containers:
- name: test
image: "{{ .Values.test.image.repository }}:{{ .Values.test.image.tag }}"
imagePullPolicy: {{ .Values.test.image.pullPolicy }}
args:
- run
- /test/postman.json
- --env-var
- baseUrl=http://{{ include "hedera-mirror-monitor.fullname" . }}:{{ .Values.service.port }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
readOnlyRootFilesystem: true
volumeMounts:
- name: monitor-test
mountPath: /test
readOnly: true
imagePullSecrets: {{ toYaml .Values.test.image.pullSecrets | nindent 4 }}
priorityClassName: {{ .Values.test.priorityClassName }}
restartPolicy: Never
securityContext:
fsGroup: 1000
runAsGroup: 1000
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
terminationGracePeriodSeconds: 1
volumes:
- name: monitor-test
configMap:
defaultMode: 420
name: {{ include "hedera-mirror-monitor.fullname" . }}-test
{{- end -}}
14 changes: 14 additions & 0 deletions charts/hedera-mirror-monitor/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,20 @@ serviceMonitor:

terminationGracePeriodSeconds: 60

test:
annotations:
helm.sh/hook: test-success
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
helm.sh/hook-weight: "30"
enabled: false
image:
pullPolicy: IfNotPresent
pullSecrets: []
repository: postman/newman
tag: 6.1.3-alpine
postman: "" # Custom postman.json in base64 encoding
priorityClassName: ""

tolerations: []

updateStrategy:
Expand Down
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ monitor.
| ----------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `hiero.mirror.monitor.health.release.cacheExpiry` | 30s | The amount of time to cache cluster release health status |
| `hiero.mirror.monitor.health.release.enabled` | false | Whether to enable cluster release health check |
| `hiero.mirror.monitor.health.release.failWhenInactive` | false | Whether to enable Status.DOWN when publisher or subscriber metric rates go to zero. |
| `hiero.mirror.monitor.mirrorNode.grpc.host` | "" | The hostname of the mirror node's gRPC API |
| `hiero.mirror.monitor.mirrorNode.grpc.port` | 5600 | The port of the mirror node's gRPC API |
| `hiero.mirror.monitor.mirrorNode.rest.host` | "" | The hostname of the mirror node's REST API |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

private static final Mono<Health> UNKNOWN = health(Status.UNKNOWN, "Publishing is inactive");
private static final Mono<Health> UP = health(Status.UP, "");
private static final Mono<Health> DOWN = health(Status.DOWN, "");

private final ReleaseHealthProperties releaseHealthProperties;
private final MirrorSubscriber mirrorSubscriber;
private final RestApiClient restApiClient;
private final TransactionGenerator transactionGenerator;
Expand All @@ -47,25 +49,26 @@
: Mono.just(health));
}

// Returns unknown if all publish scenarios aggregated rate has dropped to zero, otherwise returns an empty flux
// Returns down or unknown if all publish scenarios aggregated rate has dropped to zero, otherwise returns an empty
// flux
private Mono<Health> publishing() {
return transactionGenerator
.scenarios()
.map(Scenario::getRate)
.reduce(0.0, (c, n) -> c + n)
.filter(sum -> sum <= 0)
.flatMap(n -> UNKNOWN);
.flatMap(n -> getHealthForZeroRate());

Check notice on line 60 in monitor/src/main/java/org/hiero/mirror/monitor/health/ClusterHealthIndicator.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/main/java/org/hiero/mirror/monitor/health/ClusterHealthIndicator.java#L60

Unused lambda parameter 'n' should be unnamed.
}

// Returns up if any subscription is running and its rate is above zero, otherwise returns unknown
// Returns up if any subscription is running and its rate is above zero, otherwise returns down or unknown
private Mono<Health> subscribing() {
return mirrorSubscriber
.getSubscriptions()
.map(Scenario::getRate)
.reduce(0.0, (cur, next) -> cur + next)
.filter(sum -> sum > 0)
.flatMap(n -> UP)
.switchIfEmpty(UNKNOWN);
.switchIfEmpty(getHealthForZeroRate());
}

private Mono<Health> restNetworkStakeHealth() {
Expand Down Expand Up @@ -98,4 +101,8 @@
return health(status, statusMessage);
});
}

private Mono<Health> getHealthForZeroRate() {
return releaseHealthProperties.isFailWhenInactive() ? DOWN : UNKNOWN;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
private Duration cacheExpiry = Duration.ofSeconds(30);

private boolean enabled = false;

private boolean failWhenInactive = false;

Check warning on line 23 in monitor/src/main/java/org/hiero/mirror/monitor/health/ReleaseHealthProperties.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/main/java/org/hiero/mirror/monitor/health/ReleaseHealthProperties.java#L23

Avoid using redundant field initializer for 'failWhenInactive'

Check notice on line 23 in monitor/src/main/java/org/hiero/mirror/monitor/health/ReleaseHealthProperties.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/main/java/org/hiero/mirror/monitor/health/ReleaseHealthProperties.java#L23

Variable 'failWhenInactive' explicitly initialized to 'false' (default value for its type).
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,36 @@
@Mock
private TransactionGenerator transactionGenerator;

@Mock
private ReleaseHealthProperties releaseHealthProperties;

@InjectMocks
private ClusterHealthIndicator clusterHealthIndicator;

@ParameterizedTest
@CsvSource({
"1.0, 1.0, 200, UP", // healthy
"0.0, 1.0, 200, UNKNOWN", // publishing inactive
"1.0, 0.0, 200, UNKNOWN", // subscribing inactive
"0.0, 0.0, 200, UNKNOWN", // publishing and subscribing inactive
"1.0, 1.0, 400, UNKNOWN", // unknown network stake
"1.0, 1.0, 500, DOWN", // network stake down
"0.0, 0.0, 500, DOWN", // publishing and subscribing inactive and network stake down
"0.0, 1.0, 500, DOWN", // network stake down and publishing inactive
"1.0, 0.0, 500, DOWN", // network stake down and subscribing inactive
"1.0, 1.0, 200, UP, false", // healthy
"0.0, 1.0, 200, UNKNOWN, false", // publishing inactive
"1.0, 0.0, 200, UNKNOWN, false", // subscribing inactive
"0.0, 0.0, 200, UNKNOWN, false", // publishing and subscribing inactive
"1.0, 1.0, 400, UNKNOWN, false", // unknown network stake
"1.0, 1.0, 500, DOWN, false", // network stake down
"0.0, 0.0, 500, DOWN, false", // publishing and subscribing inactive and network stake down

Check notice on line 66 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L66

Don't use trailing comments.
"0.0, 1.0, 500, DOWN, false", // network stake down and publishing inactive

Check notice on line 67 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L67

Don't use trailing comments.
"1.0, 0.0, 500, DOWN, false", // network stake down and subscribing inactive

Check notice on line 68 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L68

Don't use trailing comments.
"1.0, 1.0, 200, UP, true", // healthy

Check notice on line 69 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L69

Don't use trailing comments.
"0.0, 1.0, 500, DOWN, true", // publishing inactive

Check notice on line 70 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L70

Don't use trailing comments.
"1.0, 0.0, 500, DOWN, true", // subscribing inactive

Check notice on line 71 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L71

Don't use trailing comments.
"0.0, 0.0, 500, DOWN, true", // publishing and subscribing inactive

Check notice on line 72 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L72

Don't use trailing comments.
"1.0, 1.0, 400, UNKNOWN, true", // unknown network stake

Check notice on line 73 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L73

Don't use trailing comments.
"1.0, 1.0, 500, DOWN, true", // network stake down

Check notice on line 74 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L74

Don't use trailing comments.
"0.0, 0.0, 500, DOWN, true", // publishing and subscribing inactive and network stake down

Check notice on line 75 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L75

Don't use trailing comments.
"0.0, 1.0, 500, DOWN, true", // network stake down and publishing inactive

Check notice on line 76 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L76

Don't use trailing comments.
"1.0, 0.0, 500, DOWN, true", // network stake down and subscribing inactive

Check notice on line 77 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L77

Annotation array values cannot contain trailing comma.

Check notice on line 77 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L77

Don't use trailing comments.
})
void health(double publishRate, double subscribeRate, int networkStatusCode, Status status) {
void health(

Check notice on line 79 in monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

monitor/src/test/java/org/hiero/mirror/monitor/health/ClusterHealthIndicatorTest.java#L79

Method MockitoSettings::health has 5 parameters (limit is 4)
double publishRate, double subscribeRate, int networkStatusCode, Status status, boolean failWhenInactive) {
when(releaseHealthProperties.isFailWhenInactive()).thenReturn(failWhenInactive);
when(transactionGenerator.scenarios()).thenReturn(Flux.just(publishScenario(publishRate)));
when(mirrorSubscriber.getSubscriptions()).thenReturn(Flux.just(subscribeScenario(subscribeRate)));
when(restApiClient.getNetworkStakeStatusCode())
Expand Down
Loading