!192 fix test_ai_block_io fail

From: @tong_1001 
Reviewed-by: @hyz2024, @znzjugod 
Signed-off-by: @znzjugod
This commit is contained in:
openeuler-ci-bot 2024-12-31 03:20:32 +00:00 committed by Gitee
commit d65453dccd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,91 @@
From 874daf9627c74aa31f1063c250b5477b2eb322e8 Mon Sep 17 00:00:00 2001
From: shixuantong <shixuantong1@huawei.com>
Date: Sat, 28 Dec 2024 11:31:23 +0800
Subject: [PATCH] fix test_ai_block_io fail
---
selftest/test/test_ai_block_io.py | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/selftest/test/test_ai_block_io.py b/selftest/test/test_ai_block_io.py
index c36fef5..58ab096 100644
--- a/selftest/test/test_ai_block_io.py
+++ b/selftest/test/test_ai_block_io.py
@@ -12,9 +12,9 @@
import unittest
import numpy as np
-from sentryPlugins.ai_threshold_slow_io_detection.threshold import AbsoluteThreshold, BoxplotThreshold, NSigmaThreshold
-from sentryPlugins.ai_threshold_slow_io_detection.sliding_window import (NotContinuousSlidingWindow,
- ContinuousSlidingWindow, MedianSlidingWindow)
+from sentryPlugins.ai_block_io.threshold import AbsoluteThreshold, BoxplotThreshold, NSigmaThreshold
+from sentryPlugins.ai_block_io.sliding_window import (NotContinuousSlidingWindow,
+ ContinuousSlidingWindow, MedianSlidingWindow)
def _get_boxplot_threshold(data_list: list, parameter):
@@ -98,11 +98,11 @@ class Test(unittest.TestCase):
for data in data_list1:
boxplot_threshold.push_latest_data_to_queue(data)
result = not_continuous.is_slow_io_event(data)
- self.assertFalse(result[0])
+ self.assertFalse(result[0][0])
self.assertEqual(23.75, boxplot_threshold.get_threshold())
boxplot_threshold.push_latest_data_to_queue(24)
result = not_continuous.is_slow_io_event(24)
- self.assertFalse(result[0])
+ self.assertFalse(result[0][0])
boxplot_threshold.push_latest_data_to_queue(25)
result = not_continuous.is_slow_io_event(25)
self.assertTrue(result[0])
@@ -110,7 +110,7 @@ class Test(unittest.TestCase):
for data in data_list2:
boxplot_threshold.push_latest_data_to_queue(data)
result = not_continuous.is_slow_io_event(data)
- self.assertFalse(result[0])
+ self.assertFalse(result[0][0])
self.assertEqual(25.625, boxplot_threshold.get_threshold())
def test_continuous_sliding_window(self):
@@ -121,14 +121,14 @@ class Test(unittest.TestCase):
for data in data_list:
boxplot_threshold.push_latest_data_to_queue(data)
result = continuous.is_slow_io_event(data)
- self.assertFalse(result[0])
+ self.assertFalse(result[0][0])
self.assertEqual(23.75, boxplot_threshold.get_threshold())
# 没有三个异常点
- self.assertFalse(continuous.is_slow_io_event(25)[0])
+ self.assertFalse(continuous.is_slow_io_event(25)[0][0])
# 不连续的三个异常点
- self.assertFalse(continuous.is_slow_io_event(25)[0])
+ self.assertFalse(continuous.is_slow_io_event(25)[0][0])
# 连续的三个异常点
- self.assertTrue(continuous.is_slow_io_event(25)[0])
+ self.assertTrue(continuous.is_slow_io_event(25)[0][0])
def test_median_sliding_window(self):
median = MedianSlidingWindow(5, 3)
@@ -137,7 +137,7 @@ class Test(unittest.TestCase):
absolute_threshold.set_threshold(24.5)
data_list = [24, 24, 24, 25, 25]
for data in data_list:
- self.assertFalse(median.is_slow_io_event(data)[0])
+ self.assertFalse(median.is_slow_io_event(data)[0][0])
self.assertTrue(median.is_slow_io_event(25)[0])
def test_parse_collect_data(self):
@@ -147,8 +147,8 @@ class Test(unittest.TestCase):
"flush": [9.0, 10.0, 11.0, 12.0],
"discard": [13.0, 14.0, 15.0, 16.0],
}
- from io_data import BaseData
- from data_access import _get_io_stage_data
+ from sentryPlugins.ai_block_io.io_data import BaseData
+ from sentryPlugins.ai_block_io.data_access import _get_io_stage_data
io_data = _get_io_stage_data(collect)
self.assertEqual(
--
2.27.0

View File

@ -4,7 +4,7 @@
Summary: System Inspection Framework Summary: System Inspection Framework
Name: sysSentry Name: sysSentry
Version: 1.0.2 Version: 1.0.2
Release: 66 Release: 67
License: Mulan PSL v2 License: Mulan PSL v2
Group: System Environment/Daemons Group: System Environment/Daemons
Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz
@ -88,11 +88,15 @@ Patch75: change-status-of-period-task-and-sort-mod-file.patch
Patch76: uniform-avg_block_io-log-and-ai_block_io-log.patch Patch76: uniform-avg_block_io-log-and-ai_block_io-log.patch
Patch77: set-logrotate.patch Patch77: set-logrotate.patch
Patch78: hbm_online_repair-add-unload-driver.patch Patch78: hbm_online_repair-add-unload-driver.patch
Patch79: fix-test_ai_block_io-fail.patch
BuildRequires: cmake gcc-c++ BuildRequires: cmake gcc-c++
BuildRequires: python3 python3-setuptools BuildRequires: python3 python3-setuptools
BuildRequires: json-c-devel BuildRequires: json-c-devel
BuildRequires: chrpath BuildRequires: chrpath
# for test
BuildRequires: python3-numpy python3-pytest
Requires: pyxalarm = %{version} Requires: pyxalarm = %{version}
%description %description
@ -260,6 +264,9 @@ cat SENTRY_FILES | grep -v register_xalarm.* | grep -v sentry_notify.* > SENTRY
mv SENTRY_FILES.tmp SENTRY_FILES mv SENTRY_FILES.tmp SENTRY_FILES
popd popd
%check
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -m pytest selftest/test/
%pre %pre
%post %post
@ -393,6 +400,12 @@ rm -rf %{buildroot}
%attr(0550,root,root) %{python3_sitelib}/syssentry/bmc_alarm.py %attr(0550,root,root) %{python3_sitelib}/syssentry/bmc_alarm.py
%changelog %changelog
* Sat Dec 28 2024 shixuantong <shixuantong@huawei.com> - 1.0.2-67
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix test_ai_block_io fail
* Wed Dec 18 2024 luckky <guodashun1@huawei.com> - 1.0.2-66 * Wed Dec 18 2024 luckky <guodashun1@huawei.com> - 1.0.2-66
- Type:bugfix - Type:bugfix
- CVE:NA - CVE:NA