-
Notifications
You must be signed in to change notification settings - Fork 139
Enable monitor testing in CI #12643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Enable monitor testing in CI #12643
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d2c5eb7
Enable monitor testing in CI
IvanKavaldzhiev e7cc8a8
Add missing test configuration in values.yaml
IvanKavaldzhiev 0c98e00
Remove unneeded properties and run helm test without filters
IvanKavaldzhiev d199872
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev 39c62f9
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev f9bdee2
Resolve PR comments
IvanKavaldzhiev 90d9b9a
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev 80709a7
Resolve PR comments
IvanKavaldzhiev 7865229
Fix and enrich unit tests
IvanKavaldzhiev 89b60cc
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev 37f6a59
Disable rest, restjava and web3 tests and fix variable naming
IvanKavaldzhiev 6b826e7
Add sleep in monitor test pod, so that logs can be fetched
IvanKavaldzhiev 559ba81
Revert sleep
IvanKavaldzhiev 7c1f053
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev 59980e7
Add hook-failed annotation for monitor pod
IvanKavaldzhiev ba90516
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev 8413456
Override hook-delete-policty in correct place
IvanKavaldzhiev 84bb955
Merge remote-tracking branch 'origin/main' into 11990-test-monitor-in-ci
IvanKavaldzhiev ed35867
Revert test disabling for rest, rest-java and web3
IvanKavaldzhiev e54429f
Update hook delete policy for rest-test
IvanKavaldzhiev 7ef2445
Update hook-delete-policy for restjava-test
IvanKavaldzhiev f9fa043
Update hook-delete-policy for web3-test
IvanKavaldzhiev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| { | ||
| "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 Prometheus Publish/Subscribe Metrics Increasing", | ||
| "event": [ | ||
| { | ||
| "listen": "test", | ||
| "script": { | ||
| "exec": [ | ||
| "const baseUrl = pm.environment.get(\"baseUrl\");", | ||
| "const url = baseUrl + \"/actuator/prometheus\";", | ||
| "const numCalls = 4;", | ||
| "const intervalMs = 3000;", | ||
| "", | ||
| "function getMetricValue(body, metricName) {", | ||
| " const regex = new RegExp(`^${metricName}(?:\\\\{[^\\\\}]*\\\\})?\\\\s+([\\\\d.E+-]+)`, \"m\");", | ||
| " const matches = body.match(regex);", | ||
| " return matches ? parseFloat(matches[1]) : null;", | ||
| "}", | ||
| "", | ||
| "function collectMetrics(body) {", | ||
| " return {", | ||
| " subscribe: getMetricValue(body, \"hiero_mirror_monitor_subscribe_duration_seconds\"),", | ||
| " publish: getMetricValue(body, \"hiero_mirror_monitor_publish_duration_seconds\")", | ||
| " };", | ||
| "}", | ||
| "", | ||
| "let samples = [];", | ||
| "samples.push(collectMetrics(pm.response.text()));", | ||
| "", | ||
| "let callCount = 1;", | ||
| "", | ||
| "function nextCall() {", | ||
| " if (callCount < numCalls) {", | ||
steven-sheehy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| " setTimeout(() => {", | ||
| " pm.sendRequest(url, (err, res) => {", | ||
| " if (err) {", | ||
| " console.error(err);", | ||
| " } else {", | ||
| " samples.push(collectMetrics(res.text()));", | ||
| " }", | ||
| " callCount++;", | ||
| " nextCall();", | ||
| " });", | ||
| " }, intervalMs);", | ||
| " } else {", | ||
| " validateMetrics();", | ||
| " }", | ||
| "}", | ||
| "", | ||
| "function validateMetrics() {", | ||
| " pm.test(\"Should have collected \" + numCalls + \" samples\", () => {", | ||
| " pm.expect(samples.length).to.equal(numCalls);", | ||
| " });", | ||
| "", | ||
| " const metrics = [\"subscribe\", \"publish\"];", | ||
| " ", | ||
| " metrics.forEach(metric => {", | ||
| " pm.test(`${metric} duration should be increasing`, () => {", | ||
| " for (let i = 1; i < samples.length; i++) {", | ||
| " const prev = samples[i-1][metric];", | ||
| " const curr = samples[i][metric];", | ||
| " pm.expect(curr, `Sample ${i+1} (${curr}) should be greater than sample ${i} (${prev}) for ${metric}`).to.be.above(prev);", | ||
| " }", | ||
| " });", | ||
| " });", | ||
| "}", | ||
| "", | ||
| "if (pm.response.code === 200) {", | ||
| " nextCall();", | ||
| "} else {", | ||
| " pm.test(\"Initial request failed\", () => {", | ||
| " pm.expect.fail(`Status code ${pm.response.code}`);", | ||
| " });", | ||
| "}" | ||
| ], | ||
| "type": "text/javascript", | ||
| "packages": {}, | ||
| "requests": {} | ||
| } | ||
| } | ||
| ], | ||
| "request": { | ||
| "method": "GET", | ||
| "header": [], | ||
| "url": { | ||
| "raw": "{{baseUrl}}/actuator/prometheus", | ||
| "host": ["{{baseUrl}}"], | ||
| "path": ["actuator", "prometheus"] | ||
| } | ||
| }, | ||
| "response": [] | ||
| } | ||
| ], | ||
| "variable": [ | ||
| { | ||
| "key": "baseUrl", | ||
| "value": "http://localhost:8082" | ||
| } | ||
| ] | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
charts/hedera-mirror-monitor/templates/tests/configmap.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.