Skip to content
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

修复监控插件失败无异常输出的问题 #6985

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def send_request(self, request_body, data, client):
if not response["result"]:
message = monitor_handle_api_error("monitor.create_shield", request_body, response)
self.logger.error(message)
data.outputs.ex_data = message
shield_id = ""
ret_flag = False
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ def get_module_id_list_by_name(bk_biz_id, username, set_list, service_template_l
execute_assertion=ExecuteAssertion(
success=False,
outputs={
"ex_data": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2020-09-28 11:18:58",'
'"bk_biz_id":2,"category":"scope","cycle_config":{"begin_time":"","end_time":"","day_list":[],'
'"week_list":[],"type":1},"description":"shield by bk_sops","dimension_config":'
'{"scope_type":"node","target":[{"bk_obj_id":"module","bk_inst_id":1},{"bk_obj_id":"module",'
'"bk_inst_id":2},{"bk_obj_id":"module","bk_inst_id":3},{"bk_obj_id":"module","bk_inst_id":4},'
'{"bk_obj_id":"module","bk_inst_id":5}],"metric_id":["bk_monitor.system.load.load5",'
'"bk_monitor.system.cpu_summary.usage"]},"end_time":"2020-09-28 11:18:58","notice_config":{},'
'"shield_notice":false}',
"shield_id": "",
"message": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2020-09-28 11:18:58",'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
Patcher,
)

from pipeline_plugins.components.collections.sites.open.monitor.alarm_shield.v1_2 import (
MonitorAlarmShieldComponent,
)
from pipeline_plugins.components.collections.sites.open.monitor.alarm_shield.v1_2 import MonitorAlarmShieldComponent


class MonitorAlarmShieldComponentTest(TestCase, ComponentTestMixin):
Expand Down Expand Up @@ -141,16 +139,27 @@ def get_module_id_list_by_name(bk_biz_id, username, set_list, service_template_l
execute_assertion=ExecuteAssertion(
success=False,
outputs={
"ex_data": "调用监控平台(Monitor)接口monitor.create_shield返回失败,"
" error=create shield fail, "
'params={"begin_time":"2020-09-28 11:18:58","bk_biz_id":2,"category":"scope",'
'"cycle_config":{"begin_time":"","end_time":"","day_list":[],"week_list":[],"type":1},'
'"description":"shield by bk_sops","dimension_config":{"scope_type":"node",'
'"target":[{"bk_obj_id":"module","bk_inst_id":1},{"bk_obj_id":"module","bk_inst_id":2},'
'{"bk_obj_id":"module","bk_inst_id":3},{"bk_obj_id":"module","bk_inst_id":4},'
'{"bk_obj_id":"module","bk_inst_id":5}],'
'"metric_id":["bk_monitor.system.load.load5","bk_monitor.system.cpu_summary.usage"]},'
'"end_time":"2020-09-28 11:18:58","notice_config":{},"shield_notice":false}',
"shield_id": "",
"message": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2020-09-28 11:18:58",'
'"bk_biz_id":2,"category":"scope","cycle_config":{"begin_time":"","end_time":"","day_list":[],'
'"week_list":[],"type":1},"description":"shield by bk_sops","dimension_config":'
'{"scope_type":"node","target":[{"bk_obj_id":"module","bk_inst_id":1},{"bk_obj_id":"module",'
'"bk_inst_id":2},{"bk_obj_id":"module","bk_inst_id":3},{"bk_obj_id":"module","bk_inst_id":4},'
'{"bk_obj_id":"module","bk_inst_id":5}],"metric_id":["bk_monitor.system.load.load5",'
'"bk_monitor.system.cpu_summary.usage"]},"end_time":"2020-09-28 11:18:58","notice_config":{},'
'"shield_notice":false}',
"message": "调用监控平台(Monitor)接口monitor.create_shield返回失败,"
" error=create shield fail, "
'params={"begin_time":"2020-09-28 11:18:58","bk_biz_id":2,"category":"scope",'
'"cycle_config":{"begin_time":"","end_time":"","day_list":[],"week_list":[],"type":1},'
'"description":"shield by bk_sops","dimension_config":{"scope_type":"node",'
'"target":[{"bk_obj_id":"module","bk_inst_id":1},{"bk_obj_id":"module","bk_inst_id":2},'
'{"bk_obj_id":"module","bk_inst_id":3},{"bk_obj_id":"module","bk_inst_id":4},'
'{"bk_obj_id":"module","bk_inst_id":5}],'
'"metric_id":["bk_monitor.system.load.load5","bk_monitor.system.cpu_summary.usage"]},'
'"end_time":"2020-09-28 11:18:58","notice_config":{},"shield_notice":false}',
},
),
schedule_assertion=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

from django.test import TestCase
from mock import MagicMock

from pipeline.component_framework.test import (
ComponentTestMixin,
ComponentTestCase,
Call,
CallAssertion,
ComponentTestCase,
ComponentTestMixin,
ExecuteAssertion,
Call,
Patcher,
)

from pipeline_plugins.components.collections.sites.open.monitor.alarm_shield_strategy.v1_1 import (
MonitorAlarmShieldStrategyComponent,
)
Expand Down Expand Up @@ -113,6 +113,12 @@ def __init__(self):
execute_assertion=ExecuteAssertion(
success=False,
outputs={
"ex_data": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2019-11-04 00:00:00",'
'"bk_biz_id":2,"category":"strategy","cycle_config":{"begin_time":"","end_time":"","day_list":'
'[],"week_list":[],"type":1},"description":"shield by bk_sops","dimension_config":{"id":"123",'
'"scope_type":"ip","target":[{"ip":"127.0.0.1","bk_cloud_id":0},{"ip":"127.0.0.2",'
'"bk_cloud_id":1}]},"end_time":"2019-11-05 00:00:00","notice_config":{},"shield_notice":false}',
"shield_id": "",
"message": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2019-11-04 00:00:00",'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
specific language governing permissions and limitations under the License.
"""
from django.test import TestCase
from mock import MagicMock
from pipeline.component_framework.test import (
ComponentTestMixin,
Call,
CallAssertion,
ComponentTestCase,
ComponentTestMixin,
ExecuteAssertion,
CallAssertion,
Call,
Patcher,
)
from mock import MagicMock

from pipeline_plugins.components.collections.sites.open.monitor.alarm_shield_strategy.v1_2 import (
MonitorAlarmShieldStrategyComponent,
Expand Down Expand Up @@ -112,6 +112,14 @@ def __init__(self):
execute_assertion=ExecuteAssertion(
success=False,
outputs={
"ex_data": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2019-11-04 00:00:00",'
'"bk_biz_id":2,"category":"strategy","cycle_config":{"begin_time":"","end_time":"","day_list":'
'[],"week_list":[],"type":1},"description":"shield by bk_sops","dimension_config":{"id":"123",'
'"dimension_conditions":[{"condition":"and","key":"bk_biz_id","method":"eq","value":["1","2"],'
'"name":"bk_biz_id"}],' # noqa
'"scope_type":"ip","target":[{"ip":"127.0.0.1","bk_cloud_id":0},{"ip":"127.0.0.2",'
'"bk_cloud_id":1}]},"end_time":"2019-11-05 00:00:00","notice_config":{},"shield_notice":false}',
"shield_id": "",
"message": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2019-11-04 00:00:00",'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@

from django.test import TestCase
from mock import MagicMock

from pipeline.component_framework.test import (
ComponentTestMixin,
ComponentTestCase,
Call,
CallAssertion,
ComponentTestCase,
ComponentTestMixin,
ExecuteAssertion,
Call,
Patcher,
)
from pipeline_plugins.components.collections.sites.open.monitor.alarm_shield.v1_0 import MonitorAlarmShieldComponent

from pipeline_plugins.components.collections.sites.open.monitor.alarm_shield.v1_0 import (
MonitorAlarmShieldComponent,
)


class MonitorAlarmShieldComponentTest(TestCase, ComponentTestMixin):
Expand Down Expand Up @@ -138,6 +140,15 @@ def get_module_id_list_by_name(bk_biz_id, username, set_list, service_template_l
execute_assertion=ExecuteAssertion(
success=False,
outputs={
"ex_data": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2020-09-28 11:18:58",'
'"bk_biz_id":2,"category":"scope","cycle_config":{"begin_time":"","end_time":"","day_list":[],'
'"week_list":[],"type":1},"description":"shield by bk_sops","dimension_config":'
'{"scope_type":"node","target":[{"bk_obj_id":"module","bk_inst_id":1},{"bk_obj_id":"module",'
'"bk_inst_id":2},{"bk_obj_id":"module","bk_inst_id":3},{"bk_obj_id":"module","bk_inst_id":4},'
'{"bk_obj_id":"module","bk_inst_id":5}],"metric_id":["bk_monitor.system.load.load5",'
'"bk_monitor.system.cpu_summary.usage"]},"end_time":"2020-09-28 11:18:58","notice_config":{},'
'"shield_notice":false}',
"shield_id": "",
"message": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2020-09-28 11:18:58",'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

from django.test import TestCase
from mock import MagicMock

from pipeline.component_framework.test import (
ComponentTestMixin,
ComponentTestCase,
Call,
CallAssertion,
ComponentTestCase,
ComponentTestMixin,
ExecuteAssertion,
Call,
Patcher,
)

from pipeline_plugins.components.collections.sites.open.monitor.alarm_shield_strategy.v1_0 import (
MonitorAlarmShieldStrategyComponent,
)
Expand Down Expand Up @@ -117,6 +117,12 @@ def __init__(self):
execute_assertion=ExecuteAssertion(
success=False,
outputs={
"ex_data": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2019-11-04 00:00:00",'
'"bk_biz_id":2,"category":"strategy","cycle_config":{"begin_time":"","end_time":"","day_list":'
'[],"week_list":[],"type":1},"description":"shield by bk_sops","dimension_config":{"id":"123",'
'"scope_type":"ip","target":[{"ip":"127.0.0.1","bk_cloud_id":0},{"ip":"127.0.0.2",'
'"bk_cloud_id":1}]},"end_time":"2019-11-05 00:00:00","notice_config":{},"shield_notice":false}',
"shield_id": "",
"message": "调用监控平台(Monitor)接口monitor.create_shield返回失败, error=create shield fail, "
'params={"begin_time":"2019-11-04 00:00:00",'
Expand Down