Skip to content

Commit

Permalink
fix: 修复差量同步主机忽略内网IP变更场景 (closed #2504)
Browse files Browse the repository at this point in the history
  • Loading branch information
Huayeaaa committed Dec 6, 2024
1 parent 3083e1a commit d3cc1ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/mock_data/views_mkd/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
],
"retention": 1,
}
# 因为MockClient中接口数据定义死了,如需调用使用深拷贝后update原数据
# 因为MockClient中接口数据定义死了,如需调用使用,深拷贝后update原数据
JOB_REINSTALL_REQUEST_PARAMS = {
"job_type": constants.JobType.REINSTALL_AGENT,
"hosts": [
Expand Down
9 changes: 7 additions & 2 deletions apps/node_man/tests/test_views/test_job_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from apps.mock_data.common_unit import host
from apps.mock_data.views_mkd import job
from apps.node_man import constants
from apps.node_man.models import Host
from apps.node_man.models import Host, IdentityData
from apps.node_man.tests.utils import MockClient, Subscription
from apps.utils.unittest.testcase import CustomAPITestCase, MockSuperUserMixin

Expand Down Expand Up @@ -107,13 +107,18 @@ def setUp(self) -> None:
},
bk_host_id=14110,
)
identify_data = copy.deepcopy(host.IDENTITY_MODEL_DATA)
identify_data["bk_host_id"] = 14110
IdentityData.objects.create(**identify_data)
return super().setUp()

@patch("apps.node_man.periodic_tasks.sync_cmdb_host.client_v2", MockClient)
@patch("apps.node_man.handlers.job.JobHandler.create_subscription", Subscription.create_subscription)
@patch("apps.node_man.periodic_tasks.sync_cmdb_host.client_v2", MockClient)
def test_install(self):
data = copy.deepcopy(job.JOB_REINSTALL_REQUEST_PARAMS)
data["hosts"][0]["inner_ip"] = "2.1.2.52"

response = self.client.post(path="/api/job/install/", data=data)
# 成功创建安装任务
self.assertEqual(response["result"], True)
self.assertEqual(type(response["data"]["job_id"]), int)

0 comments on commit d3cc1ad

Please sign in to comment.