From 87c63a1821f630f63e64aacd154e2302147316c6 Mon Sep 17 00:00:00 2001 From: mrproliu <741550557@qq.com> Date: Tue, 13 Jun 2023 13:19:49 +0000 Subject: [PATCH] Fix current usage value of process CPU and sync CLI (#89) --- pkg/profiling/continuous/checker/process_cpu.go | 2 +- test/e2e/base/env | 4 ++-- .../expected/metrics-has-value-labeld.yml | 4 +++- .../http_avg_response_time/expected/query-policy.yml | 4 +++- .../http_avg_response_time/expected/trigger-task.yml | 1 + .../http_error_rate/expected/metrics-has-value-labeld.yml | 4 +++- .../continuous/http_error_rate/expected/query-policy.yml | 4 +++- .../continuous/http_error_rate/expected/trigger-task.yml | 1 + .../continuous/process_cpu/expected/metrics-has-value.yml | 6 ++++-- .../continuous/process_cpu/expected/query-policy.yml | 4 +++- .../continuous/process_cpu/expected/trigger-task.yml | 1 + .../process_thread_count/expected/metrics-has-value.yml | 6 ++++-- .../process_thread_count/expected/query-policy.yml | 4 +++- .../process_thread_count/expected/trigger-task.yml | 1 + .../task/network/envoy/expected/metrics-has-value-label.yml | 4 +++- .../task/network/envoy/expected/metrics-has-value.yml | 4 +++- .../task/network/expected/metrics-has-value-label.yml | 6 ++++-- .../profiling/task/network/expected/metrics-has-value.yml | 4 +++- 18 files changed, 46 insertions(+), 18 deletions(-) diff --git a/pkg/profiling/continuous/checker/process_cpu.go b/pkg/profiling/continuous/checker/process_cpu.go index ef7de27d..c1209185 100644 --- a/pkg/profiling/continuous/checker/process_cpu.go +++ b/pkg/profiling/continuous/checker/process_cpu.go @@ -47,7 +47,7 @@ func (r *ProcessCPUChecker) Init(config *base.ContinuousConfig) error { if err != nil { return 0, err } - return percent * 100, nil + return percent, nil }, v3.ContinuousProfilingTriggeredMonitorType_ProcessCPU) return nil } diff --git a/test/e2e/base/env b/test/e2e/base/env index 62c59f99..28cd9f0b 100644 --- a/test/e2e/base/env +++ b/test/e2e/base/env @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -SW_CTL_COMMIT=f3eed66ee2ff330e3218fdc995b6f9952901e37c -SW_OAP_COMMIT=d88d887a32f791d0670e4e8d5c2fd615126234cf +SW_CTL_COMMIT=6b2eb0011e38b630db6af7203db215806bd141ed +SW_OAP_COMMIT=43668b7655ce4c5a95b87267be4c3b962d1eea38 SW_KUBERNETES_COMMIT_SHA=0f3ec68e5a7e1608cec8688716b848ed15e971e5 SW_AGENT_GO_COMMIT=216f122d942cb683f48578d3014cc5ea83637582 diff --git a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/metrics-has-value-labeld.yml b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/metrics-has-value-labeld.yml index 8ba301b7..c57e8dda 100644 --- a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/metrics-has-value-labeld.yml +++ b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/metrics-has-value-labeld.yml @@ -18,6 +18,8 @@ value: {{- contains .value }} - key: {{ notEmpty .key }} - value: {{ ge .value 1 }} + value: + value: {{ ge .value.value 1 }} + isemptyvalue: false {{- end }} {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/query-policy.yml b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/query-policy.yml index dbab1733..5ad340fc 100644 --- a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/query-policy.yml +++ b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/query-policy.yml @@ -21,4 +21,6 @@ count: 1 urilist: - /provider - uriregex: null \ No newline at end of file + uriregex: null + triggeredcount: {{ ge (index . 0).triggeredcount 1 }} + lasttriggertimestamp: {{ ge (index . 0).lasttriggertimestamp 1 }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/trigger-task.yml b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/trigger-task.yml index 367e1650..1d923cd0 100644 --- a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/trigger-task.yml +++ b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/trigger-task.yml @@ -33,6 +33,7 @@ uripath: /provider threshold: 50000 current: {{ ge (index .continuousprofilingcauses 0).uri.current 1 }} + message: {{ notEmpty (index .continuousprofilingcauses 0).message }} targettype: NETWORK createtime: {{ ge .createtime 1 }} {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_error_rate/expected/metrics-has-value-labeld.yml b/test/e2e/cases/profiling/continuous/http_error_rate/expected/metrics-has-value-labeld.yml index 8ba301b7..c57e8dda 100644 --- a/test/e2e/cases/profiling/continuous/http_error_rate/expected/metrics-has-value-labeld.yml +++ b/test/e2e/cases/profiling/continuous/http_error_rate/expected/metrics-has-value-labeld.yml @@ -18,6 +18,8 @@ value: {{- contains .value }} - key: {{ notEmpty .key }} - value: {{ ge .value 1 }} + value: + value: {{ ge .value.value 1 }} + isemptyvalue: false {{- end }} {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_error_rate/expected/query-policy.yml b/test/e2e/cases/profiling/continuous/http_error_rate/expected/query-policy.yml index ad24cf51..29b8a170 100644 --- a/test/e2e/cases/profiling/continuous/http_error_rate/expected/query-policy.yml +++ b/test/e2e/cases/profiling/continuous/http_error_rate/expected/query-policy.yml @@ -21,4 +21,6 @@ count: 1 urilist: - /provider - uriregex: null \ No newline at end of file + uriregex: null + triggeredcount: {{ ge (index . 0).triggeredcount 1 }} + lasttriggertimestamp: {{ ge (index . 0).lasttriggertimestamp 1 }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_error_rate/expected/trigger-task.yml b/test/e2e/cases/profiling/continuous/http_error_rate/expected/trigger-task.yml index 9424a82f..0deadf1c 100644 --- a/test/e2e/cases/profiling/continuous/http_error_rate/expected/trigger-task.yml +++ b/test/e2e/cases/profiling/continuous/http_error_rate/expected/trigger-task.yml @@ -33,6 +33,7 @@ uripath: /provider threshold: 1000 current: {{ ge (index .continuousprofilingcauses 0).uri.current 1 }} + message: {{ notEmpty (index .continuousprofilingcauses 0).message }} targettype: NETWORK createtime: {{ ge .createtime 1 }} {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_cpu/expected/metrics-has-value.yml b/test/e2e/cases/profiling/continuous/process_cpu/expected/metrics-has-value.yml index d9c49854..6cee6032 100644 --- a/test/e2e/cases/profiling/continuous/process_cpu/expected/metrics-has-value.yml +++ b/test/e2e/cases/profiling/continuous/process_cpu/expected/metrics-has-value.yml @@ -15,5 +15,7 @@ {{- contains . }} - key: {{ notEmpty .key }} - value: {{ ge .value 1 }} -{{- end }} \ No newline at end of file + value: + value: {{ ge .value.value 1 }} + isemptyvalue: false +{{- end }} diff --git a/test/e2e/cases/profiling/continuous/process_cpu/expected/query-policy.yml b/test/e2e/cases/profiling/continuous/process_cpu/expected/query-policy.yml index 8e8ed394..e9e74da1 100644 --- a/test/e2e/cases/profiling/continuous/process_cpu/expected/query-policy.yml +++ b/test/e2e/cases/profiling/continuous/process_cpu/expected/query-policy.yml @@ -20,4 +20,6 @@ period: 10 count: 3 urilist: [] - uriregex: null \ No newline at end of file + uriregex: null + triggeredcount: {{ ge (index . 0).triggeredcount 1 }} + lasttriggertimestamp: {{ ge (index . 0).lasttriggertimestamp 1 }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_cpu/expected/trigger-task.yml b/test/e2e/cases/profiling/continuous/process_cpu/expected/trigger-task.yml index 13c94edb..710a2f54 100644 --- a/test/e2e/cases/profiling/continuous/process_cpu/expected/trigger-task.yml +++ b/test/e2e/cases/profiling/continuous/process_cpu/expected/trigger-task.yml @@ -31,6 +31,7 @@ threshold: 1000 current: {{ ge (index .continuousprofilingcauses 0).singlevalue.current 1 }} uri: null + message: {{ notEmpty (index .continuousprofilingcauses 0).message }} targettype: ON_CPU createtime: {{ ge .createtime 1 }} {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_thread_count/expected/metrics-has-value.yml b/test/e2e/cases/profiling/continuous/process_thread_count/expected/metrics-has-value.yml index d9c49854..6cee6032 100644 --- a/test/e2e/cases/profiling/continuous/process_thread_count/expected/metrics-has-value.yml +++ b/test/e2e/cases/profiling/continuous/process_thread_count/expected/metrics-has-value.yml @@ -15,5 +15,7 @@ {{- contains . }} - key: {{ notEmpty .key }} - value: {{ ge .value 1 }} -{{- end }} \ No newline at end of file + value: + value: {{ ge .value.value 1 }} + isemptyvalue: false +{{- end }} diff --git a/test/e2e/cases/profiling/continuous/process_thread_count/expected/query-policy.yml b/test/e2e/cases/profiling/continuous/process_thread_count/expected/query-policy.yml index 5e4a7303..72dc733c 100644 --- a/test/e2e/cases/profiling/continuous/process_thread_count/expected/query-policy.yml +++ b/test/e2e/cases/profiling/continuous/process_thread_count/expected/query-policy.yml @@ -20,4 +20,6 @@ period: 10 count: 3 urilist: [] - uriregex: null \ No newline at end of file + uriregex: null + triggeredcount: {{ ge (index . 0).triggeredcount 1 }} + lasttriggertimestamp: {{ ge (index . 0).lasttriggertimestamp 1 }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_thread_count/expected/trigger-task.yml b/test/e2e/cases/profiling/continuous/process_thread_count/expected/trigger-task.yml index 8c7a4027..2423ac42 100644 --- a/test/e2e/cases/profiling/continuous/process_thread_count/expected/trigger-task.yml +++ b/test/e2e/cases/profiling/continuous/process_thread_count/expected/trigger-task.yml @@ -31,6 +31,7 @@ threshold: 500 current: {{ ge (index .continuousprofilingcauses 0).singlevalue.current 1 }} uri: null + message: {{ notEmpty (index .continuousprofilingcauses 0).message }} targettype: ON_CPU createtime: {{ ge .createtime 1 }} {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/envoy/expected/metrics-has-value-label.yml b/test/e2e/cases/profiling/task/network/envoy/expected/metrics-has-value-label.yml index a4becdf8..8093415b 100644 --- a/test/e2e/cases/profiling/task/network/envoy/expected/metrics-has-value-label.yml +++ b/test/e2e/cases/profiling/task/network/envoy/expected/metrics-has-value-label.yml @@ -18,6 +18,8 @@ value: {{- contains .value }} - key: {{ notEmpty .key }} - value: {{ ge .value 1 }} + value: + value: {{ ge .value.value 1 }} + isemptyvalue: false {{- end }} {{- end }} diff --git a/test/e2e/cases/profiling/task/network/envoy/expected/metrics-has-value.yml b/test/e2e/cases/profiling/task/network/envoy/expected/metrics-has-value.yml index d9c49854..2c3aa36a 100644 --- a/test/e2e/cases/profiling/task/network/envoy/expected/metrics-has-value.yml +++ b/test/e2e/cases/profiling/task/network/envoy/expected/metrics-has-value.yml @@ -15,5 +15,7 @@ {{- contains . }} - key: {{ notEmpty .key }} - value: {{ ge .value 1 }} + value: + value: {{ ge .value.value 1 }} + isemptyvalue: false {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/expected/metrics-has-value-label.yml b/test/e2e/cases/profiling/task/network/expected/metrics-has-value-label.yml index a4becdf8..c57e8dda 100644 --- a/test/e2e/cases/profiling/task/network/expected/metrics-has-value-label.yml +++ b/test/e2e/cases/profiling/task/network/expected/metrics-has-value-label.yml @@ -18,6 +18,8 @@ value: {{- contains .value }} - key: {{ notEmpty .key }} - value: {{ ge .value 1 }} + value: + value: {{ ge .value.value 1 }} + isemptyvalue: false {{- end }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/expected/metrics-has-value.yml b/test/e2e/cases/profiling/task/network/expected/metrics-has-value.yml index d9c49854..2c3aa36a 100644 --- a/test/e2e/cases/profiling/task/network/expected/metrics-has-value.yml +++ b/test/e2e/cases/profiling/task/network/expected/metrics-has-value.yml @@ -15,5 +15,7 @@ {{- contains . }} - key: {{ notEmpty .key }} - value: {{ ge .value 1 }} + value: + value: {{ ge .value.value 1 }} + isemptyvalue: false {{- end }} \ No newline at end of file