Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit f4388cb

Browse files
pmacikweb-flow
authored andcommitted
Compare various KPIs to the threshold values and fail if any is exceeded (#1271)
Signed-off-by: Pavel Macík <[email protected]> Signed-off-by: Pavel Macík <[email protected]>
1 parent 7ae0d7d commit f4388cb

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

make/common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ endef
144144

145145
YQ = $(shell pwd)/bin/yq
146146
yq:
147-
$(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4@v4.9.8)
147+
$(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4@v4.26.1)
148148

149149
KUBECTL_SLICE = $(shell pwd)/bin/kubectl-slice
150150
kubectl-slice:

make/performance.mk

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ OPENSHIFT_API ?=
77
OPENSHIFT_USERNAME ?=
88
OPENSHIFT_PASSWORD ?=
99

10+
TEST_PERFORMANCE_AVG_MEMORY ?= 150 # value in MiB
11+
TEST_PERFORMANCE_MAX_MEMORY ?= 200 # valie in MiB
12+
TEST_PERFORMANCE_AVG_CPU ?= 20 # value in millicores of vCPU
13+
TEST_PERFORMANCE_MAX_CPU ?= 100 # value in millicores of vCPU
14+
1015
.PHONY: test-performance-setup
1116
## Setup OpenShift cluster for performance test
1217
test-performance-setup:
@@ -29,4 +34,18 @@ test-performance-collect-kpi:
2934
test-performance-artifacts:
3035
$(Q)echo "Gathering performance test artifacts"
3136
$(Q)mkdir -p $(TEST_PERFORMANCE_ARTIFACTS) \
32-
&& cp -rvf $(TEST_PERFORMANCE_OUTPUT_DIR) $(TEST_PERFORMANCE_ARTIFACTS)/
37+
&& cp -rvf $(TEST_PERFORMANCE_OUTPUT_DIR) $(TEST_PERFORMANCE_ARTIFACTS)/
38+
39+
.PHONY: test-performance-thresholds
40+
# Compare various KPIs to the threshold values and fail if any threshold is exceeded
41+
test-performance-thresholds: yq
42+
@echo Evaluating KPI:
43+
@$(YQ) eval '.kpi[] | select(.name == "usage")' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml
44+
@echo "Checking if average value of memory "$$($(YQ) eval '(.kpi[] | select(.name == "usage").metrics.[] | select(.name == "Memory_MiB").average)' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml)" < $(TEST_PERFORMANCE_AVG_MEMORY) MiB"
45+
@[ $$($(YQ) eval '(.kpi[] | select(.name == "usage").metrics.[] | select(.name == "Memory_MiB").average) < $(TEST_PERFORMANCE_AVG_MEMORY)' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml) == "true" ]
46+
@echo "Checking if maximal value of memory "$$($(YQ) eval '(.kpi[] | select(.name == "usage").metrics.[] | select(.name == "Memory_MiB").maximum)' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml)" < $(TEST_PERFORMANCE_MAX_MEMORY) MiB"
47+
@[ $$($(YQ) eval '(.kpi[] | select(.name == "usage").metrics.[] | select(.name == "Memory_MiB").maximum) < $(TEST_PERFORMANCE_MAX_MEMORY)' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml) == "true" ]
48+
@echo "Checking if average value of CPU "$$($(YQ) eval '(.kpi[] | select(.name == "usage").metrics.[] | select(.name == "CPU_millicores").average)' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml)" < $(TEST_PERFORMANCE_AVG_CPU) milicores of vCPU"
49+
@[ $$($(YQ) eval '(.kpi[] | select(.name == "usage").metrics.[] | select(.name == "CPU_millicores").average) < $(TEST_PERFORMANCE_AVG_CPU)' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml) == "true" ]
50+
@echo "Checking if maximal value of CPU "$$($(YQ) eval '(.kpi[] | select(.name == "usage").metrics.[] | select(.name == "CPU_millicores").maximum)' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml)" < $(TEST_PERFORMANCE_MAX_CPU) milicores of vCPU"
51+
@[ $$($(YQ) eval '(.kpi[] | select(.name == "usage").metrics.[] | select(.name == "CPU_millicores").maximum) < $(TEST_PERFORMANCE_MAX_CPU)' $(TEST_PERFORMANCE_OUTPUT_DIR)/results/kpi.yaml) == "true" ]

0 commit comments

Comments
 (0)