forked from TencentBlueKing/bk-nodeman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: 重启/重载/升级 Agent 后增加功能检测步骤 (closed TencentBlueKing#1338)
- Loading branch information
1 parent
d21c3c3
commit ae320dc
Showing
7 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
37 changes: 37 additions & 0 deletions
37
apps/backend/components/collections/agent_new/check_agent_ability.py
This file contains 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,37 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-节点管理(BlueKing-BK-NODEMAN) available. | ||
Copyright (C) 2017-2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
|
||
from apps.node_man import constants, models | ||
from apps.utils.files import PathHandler | ||
|
||
from .base import AgentCommonData, AgentExecuteScriptService | ||
|
||
|
||
class CheckAgentAbilityService(AgentExecuteScriptService): | ||
@property | ||
def script_name(self): | ||
return "check_agent_ability" | ||
|
||
def get_script_content(self, data, common_data: AgentCommonData, host: models.Host) -> str: | ||
""" | ||
获取脚本内容 | ||
:param data: | ||
:param common_data: | ||
:param host: 主机对象 | ||
:return: 脚本内容 | ||
""" | ||
path_handler: PathHandler = PathHandler(host.os_type) | ||
ctl_exe_name: str = ("gse_agent", "gse_agent.exe")[host.os_type == constants.OsType.WINDOWS] | ||
general_node_type: str = self.get_general_node_type(host.node_type) | ||
setup_path: str = common_data.host_id__ap_map[host.bk_host_id].get_agent_config(host.os_type)["setup_path"] | ||
agent_path: str = path_handler.join(setup_path, general_node_type, "bin", ctl_exe_name) | ||
|
||
return f"{agent_path} --version" |
This file contains 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 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 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
42 changes: 42 additions & 0 deletions
42
apps/backend/tests/components/collections/agent_new/test_check_agent_ability.py
This file contains 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,42 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-节点管理(BlueKing-BK-NODEMAN) available. | ||
Copyright (C) 2017-2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
|
||
import base64 | ||
|
||
from apps.backend.components.collections.agent_new import components | ||
from common.api import JobApi | ||
|
||
from . import base | ||
from .test_restart import RestartTestCase | ||
|
||
|
||
class CheckAgentAbilityTestCase(RestartTestCase): | ||
@classmethod | ||
def get_default_case_name(cls) -> str: | ||
return "测试Agent功能成功" | ||
|
||
def component_cls(self): | ||
return components.CheckAgentAbilityComponent | ||
|
||
def tearDown(self) -> None: | ||
record = self.job_api_mock_client.call_recorder.record | ||
fast_execute_script_query_params = record[JobApi.fast_execute_script][0].args[0] | ||
self.assertEqual( | ||
"c:\\gse\\agent\\bin\\gse_agent.exe --version", | ||
base64.b64decode(fast_execute_script_query_params["script_content"]).decode(), | ||
) | ||
|
||
|
||
# | ||
class PollingResultFailedTestCase(base.JobFailedBaseTestCase, CheckAgentAbilityTestCase): | ||
@classmethod | ||
def get_default_case_name(cls) -> str: | ||
return "测试失败 Agent 功能失败" |
This file contains 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,3 @@ | ||
--- | ||
feature: | ||
- "重启/重载/升级 Agent 后增加功能检测步骤 (closed #1338)" |