Пример #1
0
def FILE_MANAGER_TYPE_ERR_CASE():
    NOT_EXIST_TYPE = "NOT_EXIST_TYPE"
    MANAGER_GET_EXCEPTION = Exception("exc")

    return ComponentTestCase(
        name="push_local_files manager type err case",
        inputs={
            "biz_cc_id": "biz_cc_id",
            "job_local_files": "job_local_files",
            "job_target_ip_list": "job_target_ip_list",
            "job_target_account": "job_target_account",
            "job_target_path": "job_target_path",
        },
        parent_data={
            "executor": "executor",
            "project_id": "project_id"
        },
        execute_assertion=ExecuteAssertion(
            success=False,
            outputs={
                "ex_data":
                "can not get file manager for type: {}\n err: {}".format(
                    NOT_EXIST_TYPE, MANAGER_GET_EXCEPTION)
            },
        ),
        schedule_assertion=None,
        patchers=[
            Patcher(target=ENVIRONMENT_VAR_GET, return_value=NOT_EXIST_TYPE),
            Patcher(target=FACTORY_GET_MANAGER,
                    side_effect=MANAGER_GET_EXCEPTION),
        ],
    )
Пример #2
0
def FILE_MANAGER_TYPE_ERR_CASE():
    NOT_EXIST_TYPE = 'NOT_EXIST_TYPE'
    MANAGER_GET_EXCEPTION = Exception('exc')

    return ComponentTestCase(
        name='push_local_files manager type err case',
        inputs={
            'biz_cc_id': 'biz_cc_id',
            'job_local_files': 'job_local_files',
            'job_target_ip_list': 'job_target_ip_list',
            'job_target_account': 'job_target_account',
            'job_target_path': 'job_target_path'
        },
        parent_data={
            'executor': 'executor',
            'project_id': 'project_id'
        },
        execute_assertion=ExecuteAssertion(
            success=False,
            outputs={
                'ex_data':
                'can not get file manager for type: {}\n err: {}'.format(
                    NOT_EXIST_TYPE, MANAGER_GET_EXCEPTION)
            }),
        schedule_assertion=None,
        patchers=[
            Patcher(target=ENVIRONMENT_VAR_GET, return_value=NOT_EXIST_TYPE),
            Patcher(target=FACTORY_GET_MANAGER,
                    side_effect=MANAGER_GET_EXCEPTION)
        ])
Пример #3
0
def FILE_MANAGER_NOT_CONFIG_CASE():
    return ComponentTestCase(
        name='push_local_files file manager not config case',
        inputs={
            'biz_cc_id': 'biz_cc_id',
            'job_local_files': 'job_local_files',
            'job_target_ip_list': 'job_target_ip_list',
            'job_target_account': 'job_target_account',
            'job_target_path': 'job_target_path'
        },
        parent_data={
            'executor': 'executor',
            'project_id': 'project_id'
        },
        execute_assertion=ExecuteAssertion(
            success=False,
            outputs={
                'ex_data':
                'File Manager configuration error, contact administrator please.'
            }),
        schedule_assertion=None,
        patchers=[Patcher(target=ENVIRONMENT_VAR_GET, return_value=None)])
Пример #4
0
def FILE_MANAGER_NOT_CONFIG_CASE():
    return ComponentTestCase(
        name="push_local_files file manager not config case",
        inputs={
            "biz_cc_id": "biz_cc_id",
            "job_local_files": "job_local_files",
            "job_target_ip_list": "job_target_ip_list",
            "job_target_account": "job_target_account",
            "job_target_path": "job_target_path",
        },
        parent_data={
            "executor": "executor",
            "project_id": "project_id"
        },
        execute_assertion=ExecuteAssertion(
            success=False,
            outputs={
                "ex_data":
                "File Manager configuration error, contact administrator please."
            }),
        schedule_assertion=None,
        patchers=[Patcher(target=ENVIRONMENT_VAR_GET, return_value=None)],
    )
Пример #5
0
    "result": False,
    "code": 1,
    "message": "fail",
    "data": {}
})

ADD_HOST_LOCK_SUCCESS_CASE = ComponentTestCase(
    name="add host lock success case",
    inputs={"cc_host_ip": "1.1.1.1;2.2.2.2"},
    parent_data={
        "executor": "executor_token",
        "biz_cc_id": 2,
        "biz_supplier_account": 0,
        "language": "中文"
    },
    execute_assertion=ExecuteAssertion(success=True, outputs={}),
    schedule_assertion=None,
    execute_call_assertion=[
        CallAssertion(func=CC_GET_IPS_INFO_BY_STR,
                      calls=[Call("executor_token", 2, "1.1.1.1;2.2.2.2")]),
        CallAssertion(func=ADD_HOST_LOCK_SUCCESS_CLIENT.cc.add_host_lock,
                      calls=[Call({"id_list": [1, 2]})]),
    ],
    # add patch
    patchers=[
        Patcher(target=GET_CLIENT_BY_USER,
                return_value=ADD_HOST_LOCK_SUCCESS_CLIENT),
        Patcher(
            target=CC_GET_IPS_INFO_BY_STR,
            return_value={
                "result": True,
Пример #6
0
                                         'result': True,
                                     })
# test case
SAVE_CRON_FAIL_CASE = ComponentTestCase(
    name='save cron call failed case',
    inputs={
        'job_cron_job_id': 1,
        'job_cron_name': 'job_cron_name',
        'job_cron_expression': '0 0/5 * * * ?',
        'job_cron_status': 1,
    },
    parent_data={
        'executor': 'executor',
        'biz_cc_id': 1
    },
    execute_assertion=ExecuteAssertion(success=False,
                                       outputs={'ex_data': 'save_cron fail'}),
    schedule_assertion=None,
    execute_call_assertion=[
        CallAssertion(func=SAVE_CRON_CALL_FAIL_CLIENT.job.save_cron,
                      calls=[
                          Call({
                              'bk_biz_id': 1,
                              'bk_job_id': 1,
                              'cron_name': 'job_cron_name',
                              'cron_expression': '0 0/5 * * * ?'
                          })
                      ]),
    ],
    patchers=[
        Patcher(target=GET_CLIENT_BY_USER,
                return_value=SAVE_CRON_CALL_FAIL_CLIENT),
Пример #7
0
def SUCCESS_CASE():

    SUCCESS_RESULT = {'result': True, 'data': {'job_id': 12345}}
    SUCCESS_ESB_CLIENT = MagicMock()
    SUCCESS_MANAGER = MagicMock()
    SUCCESS_MANAGER.push_files_to_ips = MagicMock(return_value=SUCCESS_RESULT)

    return ComponentTestCase(
        name='push_local_files success case',
        inputs={
            'biz_cc_id': 'biz_cc_id',
            'job_local_files': [{
                'tag': 'tag_1'
            }, {
                'tag': 'tag_2'
            }],
            'job_target_ip_list': 'job_target_ip_list',
            'job_target_account': 'job_target_account',
            'job_target_path': 'job_target_path'
        },
        parent_data={
            'executor': 'executor',
            'project_id': 'project_id'
        },
        execute_assertion=ExecuteAssertion(
            success=True,
            outputs={
                'job_inst_id': SUCCESS_RESULT['data']['job_id'],
                'job_inst_url': 'url_token'
            }),
        schedule_assertion=ScheduleAssertion(
            success=True,
            outputs={
                'job_inst_id': SUCCESS_RESULT['data']['job_id'],
                'job_inst_url': 'url_token'
            },
            callback_data={
                'status': 3,
                'job_instance_id': 12345
            },
            schedule_finished=True),
        execute_call_assertion=[
            CallAssertion(func=GET_CLIENT_BY_USER, calls=[Call('executor')]),
            CallAssertion(
                func=CC_GET_IPS_INFO_BY_STR,
                calls=[Call('executor', 'biz_cc_id', 'job_target_ip_list')]),
            CallAssertion(func=SUCCESS_MANAGER.push_files_to_ips,
                          calls=[
                              Call(esb_client=SUCCESS_ESB_CLIENT,
                                   bk_biz_id='biz_cc_id',
                                   file_tags=['tag_1', 'tag_2'],
                                   target_path='job_target_path',
                                   ips=[{
                                       'ip': '1.1.1.1',
                                       'bk_cloud_id': 0
                                   }],
                                   account='job_target_account',
                                   callback_url='callback_url')
                          ])
        ],
        patchers=[
            Patcher(target=ENVIRONMENT_VAR_GET, return_value='a_type'),
            Patcher(target=FACTORY_GET_MANAGER, return_value=SUCCESS_MANAGER),
            Patcher(target=GET_CLIENT_BY_USER,
                    return_value=SUCCESS_ESB_CLIENT),
            Patcher(target=CC_GET_IPS_INFO_BY_STR,
                    return_value={
                        'ip_result': [{
                            'InnerIP': '1.1.1.1',
                            'Source': 0
                        }]
                    }),
            Patcher(target=GET_NODE_CALLBACK_URL, return_value='callback_url'),
            Patcher(target=GET_JOB_INSTANCE_URL, return_value='url_token')
        ])
Пример #8
0
def CALLBACK_FAIL_CASE():

    CALLBACK_FAIL_RESULT = {'result': True, 'data': {'job_id': 12345}}
    CALLBACK_FAIL_ESB_CLIENT = MagicMock()
    CALLBACK_FAIL_MANAGER = MagicMock()
    CALLBACK_FAIL_MANAGER.push_files_to_ips = MagicMock(
        return_value=CALLBACK_FAIL_RESULT)

    return ComponentTestCase(
        name='push_local_files callback fail case',
        inputs={
            'biz_cc_id': 'biz_cc_id',
            'job_local_files': [{
                'tag': 'tag_1'
            }, {
                'tag': 'tag_2'
            }],
            'job_target_ip_list': 'job_target_ip_list',
            'job_target_account': 'job_target_account',
            'job_target_path': 'job_target_path'
        },
        parent_data={
            'executor': 'executor',
            'project_id': 'project_id'
        },
        execute_assertion=ExecuteAssertion(
            success=True,
            outputs={
                'job_inst_id': CALLBACK_FAIL_RESULT['data']['job_id'],
                'job_inst_url': 'url_token'
            }),
        schedule_assertion=ScheduleAssertion(
            success=False,
            outputs={
                'job_inst_id': CALLBACK_FAIL_RESULT['data']['job_id'],
                'job_inst_url': 'url_token',
                'ex_data': {
                    'exception_msg':
                    u"任务执行失败,<a href='{}' target='_blank'>"
                    u"前往作业平台(JOB)查看详情</a>".format('url_token'),
                    'show_ip_log':
                    True,
                    'task_inst_id':
                    12345
                }
            },
            callback_data={
                'status': 4,
                'job_instance_id': 12345
            },
            schedule_finished=False),
        execute_call_assertion=[
            CallAssertion(func=GET_CLIENT_BY_USER, calls=[Call('executor')]),
            CallAssertion(
                func=CC_GET_IPS_INFO_BY_STR,
                calls=[Call('executor', 'biz_cc_id', 'job_target_ip_list')]),
            CallAssertion(func=CALLBACK_FAIL_MANAGER.push_files_to_ips,
                          calls=[
                              Call(esb_client=CALLBACK_FAIL_ESB_CLIENT,
                                   bk_biz_id='biz_cc_id',
                                   file_tags=['tag_1', 'tag_2'],
                                   target_path='job_target_path',
                                   ips=[{
                                       'ip': '1.1.1.1',
                                       'bk_cloud_id': 0
                                   }],
                                   account='job_target_account',
                                   callback_url='callback_url')
                          ])
        ],
        patchers=[
            Patcher(target=ENVIRONMENT_VAR_GET, return_value='a_type'),
            Patcher(target=FACTORY_GET_MANAGER,
                    return_value=CALLBACK_FAIL_MANAGER),
            Patcher(target=GET_CLIENT_BY_USER,
                    return_value=CALLBACK_FAIL_ESB_CLIENT),
            Patcher(target=CC_GET_IPS_INFO_BY_STR,
                    return_value={
                        'ip_result': [{
                            'InnerIP': '1.1.1.1',
                            'Source': 0
                        }]
                    }),
            Patcher(target=GET_NODE_CALLBACK_URL, return_value='callback_url'),
            Patcher(target=GET_JOB_INSTANCE_URL, return_value='url_token')
        ])
Пример #9
0
def SUCCESS_CASE():

    SUCCESS_RESULT = {"result": True, "data": {"job_id": 12345}}
    SUCCESS_ESB_CLIENT = MagicMock()
    SUCCESS_MANAGER = MagicMock()
    SUCCESS_MANAGER.push_files_to_ips = MagicMock(return_value=SUCCESS_RESULT)

    return ComponentTestCase(
        name="push_local_files success case",
        inputs={
            "biz_cc_id":
            "biz_cc_id",
            "job_local_files": [
                {
                    "response": {
                        "result": True,
                        "tag": "tag_1"
                    }
                },
                {
                    "response": {
                        "result": True,
                        "tag": "tag_2"
                    }
                },
            ],
            "job_target_ip_list":
            "1.1.1.1",
            "job_target_account":
            "job_target_account",
            "job_target_path":
            "job_target_path",
        },
        parent_data={
            "executor": "executor",
            "project_id": "project_id"
        },
        execute_assertion=ExecuteAssertion(
            success=True,
            outputs={
                "job_inst_id": SUCCESS_RESULT["data"]["job_id"],
                "job_inst_url": "url_token"
            }),
        schedule_assertion=ScheduleAssertion(
            success=True,
            outputs={
                "job_inst_id": SUCCESS_RESULT["data"]["job_id"],
                "job_inst_url": "url_token"
            },
            callback_data={
                "status": 3,
                "job_instance_id": 12345
            },
            schedule_finished=True,
        ),
        execute_call_assertion=[
            CallAssertion(func=GET_CLIENT_BY_USER, calls=[Call("executor")]),
            CallAssertion(
                func=CC_GET_IPS_INFO_BY_STR,
                calls=[
                    Call(username="******",
                         biz_cc_id="biz_cc_id",
                         ip_str="1.1.1.1",
                         use_cache=False)
                ],
            ),
            CallAssertion(
                func=SUCCESS_MANAGER.push_files_to_ips,
                calls=[
                    Call(
                        esb_client=SUCCESS_ESB_CLIENT,
                        bk_biz_id="biz_cc_id",
                        file_tags=["tag_1", "tag_2"],
                        target_path="job_target_path",
                        ips=[{
                            "ip": "1.1.1.1",
                            "bk_cloud_id": 0
                        }],
                        account="job_target_account",
                        callback_url="callback_url",
                    )
                ],
            ),
        ],
        patchers=[
            Patcher(target=ENVIRONMENT_VAR_GET, return_value="a_type"),
            Patcher(target=FACTORY_GET_MANAGER, return_value=SUCCESS_MANAGER),
            Patcher(target=GET_CLIENT_BY_USER,
                    return_value=SUCCESS_ESB_CLIENT),
            Patcher(target=GET_NODE_CALLBACK_URL, return_value="callback_url"),
            Patcher(target=GET_JOB_INSTANCE_URL, return_value="url_token"),
            Patcher(target=CC_GET_IPS_INFO_BY_STR,
                    return_value={
                        "ip_result": [{
                            "InnerIP": "1.1.1.1",
                            "Source": 0
                        }]
                    }),
        ],
    )
Пример #10
0
    }]
    return module_id


# test case
ALTER_BILL_FAIL_CASE = ComponentTestCase(
    name="create shield fail case",
    inputs=INPUT_DATA,
    parent_data={"executor": "executor", "biz_cc_id": 2},
    execute_assertion=ExecuteAssertion(
        success=False,
        outputs={
            "shield_id": "",
            "message": '调用监控平台(Monitor)接口monitor.create_shield返回失败, 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}, error=create shield fail',
        },
    ),
    schedule_assertion=None,
    execute_call_assertion=[
        CallAssertion(
            func=CREATE_SHIELD_FAIL_CLIENT.add_shield,
            calls=[
                Call(
                    **{
                        "begin_time": "2020-09-28 11:18:58",
                        "bk_biz_id": 2,
Пример #11
0
            }]
        },
    ],
    "invalid_ip": []
}

# test case
# 没有输入规则 修改主机名不成功的案例
NO_INPUT_RULE_CHANGE_HOST_PROPERTY_FAIL_CASE = ComponentTestCase(
    name="no input rule change host property fail case",
    inputs=INPUT_DATA_NO_RULE,
    parent_data={
        "executor": "executor",
        "biz_cc_id": 1
    },
    execute_assertion=ExecuteAssertion(success=False,
                                       outputs={"ex_data": "请选择至少一种规则"}),
    schedule_assertion=None,
    patchers=[
        Patcher(target=CC_GET_IPS_INFO_BY_STR,
                return_value=CC_GET_IPS_INFO_BY_STR_VALUE)
    ],
)

# 查询集群的属性值失败的案例
FIND_SET_BATCH_FAIL_CHANGE_HOST_PROPERTY_FAIL_CASE = ComponentTestCase(
    name="find set batch fail change host property fail case",
    inputs=INPUT_DATA,
    parent_data={
        "executor": "executor",
        "biz_cc_id": 1
    },
Пример #12
0
    "pipeline_plugins.components.collections.sites.open.wechat_work.wechat_work_send_message.v1_0.requests.post"  # noqa
)

# test  cases

WEBHOOK_NOT_CONFIG_CASE = ComponentTestCase(
    name="webhook not config test case",
    inputs={
        "wechat_work_chat_id": "@all",
        "message_content": "haha",
        "wechat_work_mentioned_members": "",
        "msgtype": "text",
    },
    parent_data={},
    execute_assertion=ExecuteAssertion(
        success=False, outputs={"ex_data": "WechatWork send message URL is not config, contact admin please"}
    ),
    schedule_assertion=None,
    patchers=[Patcher(target=ENVIRONMENT_VAIRABLES_GET, return_value=None)],
)

EMPTY_CHAT_ID_CASE = ComponentTestCase(
    name="empty chat id case",
    inputs={
        "wechat_work_chat_id": "",
        "message_content": "haha",
        "wechat_work_mentioned_members": "",
        "msgtype": "text",
    },
    parent_data={},
    execute_assertion=ExecuteAssertion(success=False, outputs={"ex_data": "会话 ID 不能为空"}),
Пример #13
0
    "meta": {
        "callback_url": "callback_url"
    },
}
INPUTS = {
    "bk_verifier": "tester, tester1",
    "bk_approve_title": "this is a test",
    "bk_notify_title": "title",
    "bk_approve_content": "test content",
}

CREATE_APPROVE_TICKET_FAIL_CASE = ComponentTestCase(
    name="create approve ticket fail case",
    inputs=INPUTS,
    parent_data=COMMON_PARENT,
    execute_assertion=ExecuteAssertion(
        success=False, outputs={"ex_data": "create ticket fail"}),
    execute_call_assertion=[
        CallAssertion(
            func=CREAT_TICKET_FAIL_RETURN_CLIENT.create_ticket,
            calls=[Call(**CREAT_TICKET_CALL)],
        )
    ],
    schedule_assertion=None,
    patchers=[
        Patcher(target=GET_CLIENT_BY_USER,
                return_value=CREAT_TICKET_FAIL_RETURN_CLIENT),
        Patcher(target=BK_HANDLE_API_ERROR, return_value="create ticket fail"),
        Patcher(target=GET_NODE_CALLBACK_URL, return_value="callback_url"),
    ],
)
Пример #14
0
         "bk_module_name": "test",
         "bk_module_type": "",
         "operator": "",
         "bk_bak_operator": "",
     }],
     "cc_template_break_line":
     "",
 },
 parent_data=COMMON_PARENT,
 execute_assertion=ExecuteAssertion(
     success=True,
     outputs={
         "module_update_success": [{
             "cc_module_select_text": "set>module",
             "bk_module_name": "test",
             "bk_module_type": "",
             "operator": "",
             "bk_bak_operator": "",
         }],
         "module_update_failed": [],
     },
 ),
 schedule_assertion=ScheduleAssertion(success=True,
                                      schedule_finished=True,
                                      outputs={}),
 patchers=[
     Patcher(target=GET_CLIENT_BY_USER,
             return_value=UPDATE_MODULE_SUCCESS_CLIENT),
     Patcher(target=CC_GET_CLIENT_BY_USER,
             return_value=UPDATE_MODULE_SUCCESS_CLIENT),
 ],
Пример #15
0
def PUSH_FILE_TO_IPS_FAIL_CASE():

    PUSH_FAIL_RESULT = {'result': False, 'message': 'msg token'}
    PUSH_FAIL_ESB_CLIENT = MagicMock()
    PUSH_FAIL_MANAGER = MagicMock()
    PUSH_FAIL_MANAGER.push_files_to_ips = MagicMock(
        return_value=PUSH_FAIL_RESULT)

    return ComponentTestCase(
        name='push_local_files manager call fail case',
        inputs={
            'biz_cc_id': 'biz_cc_id',
            'job_local_files': [{
                'tag': 'tag_1'
            }, {
                'tag': 'tag_2'
            }],
            'job_target_ip_list': 'job_target_ip_list',
            'job_target_account': 'job_target_account',
            'job_target_path': 'job_target_path'
        },
        parent_data={
            'executor': 'executor',
            'project_id': 'project_id'
        },
        execute_assertion=ExecuteAssertion(
            success=False, outputs={'ex_data': PUSH_FAIL_RESULT['message']}),
        schedule_assertion=None,
        execute_call_assertion=[
            CallAssertion(func=GET_CLIENT_BY_USER, calls=[Call('executor')]),
            CallAssertion(
                func=CC_GET_IPS_INFO_BY_STR,
                calls=[Call('executor', 'biz_cc_id', 'job_target_ip_list')]),
            CallAssertion(func=PUSH_FAIL_MANAGER.push_files_to_ips,
                          calls=[
                              Call(esb_client=PUSH_FAIL_ESB_CLIENT,
                                   bk_biz_id='biz_cc_id',
                                   file_tags=['tag_1', 'tag_2'],
                                   target_path='job_target_path',
                                   ips=[{
                                       'ip': '1.1.1.1',
                                       'bk_cloud_id': 0
                                   }],
                                   account='job_target_account',
                                   callback_url='callback_url')
                          ])
        ],
        patchers=[
            Patcher(target=ENVIRONMENT_VAR_GET, return_value='a_type'),
            Patcher(target=FACTORY_GET_MANAGER,
                    return_value=PUSH_FAIL_MANAGER),
            Patcher(target=GET_CLIENT_BY_USER,
                    return_value=PUSH_FAIL_ESB_CLIENT),
            Patcher(target=CC_GET_IPS_INFO_BY_STR,
                    return_value={
                        'ip_result': [{
                            'InnerIP': '1.1.1.1',
                            'Source': 0
                        }]
                    }),
            Patcher(target=GET_NODE_CALLBACK_URL, return_value='callback_url')
        ])
Пример #16
0
 execute_assertion=ExecuteAssertion(
     success=False,
     outputs={
         "ex_data": ("调用作业平台(JOB)接口job.execute_job返回失败, params={params}, "
                     "error=message token").format(params=json.dumps({
                         "bk_scope_type":
                         "biz",
                         "bk_scope_id":
                         "1",
                         "bk_biz_id":
                         1,
                         "bk_job_id":
                         12345,
                         "global_vars": [
                             {
                                 "name": "key_1",
                                 "value": "value_1"
                             },
                             {
                                 "name": "key_2",
                                 "value": "value_2"
                             },
                             {
                                 "name":
                                 "key_3",
                                 "ip_list": [{
                                     "ip": "1.1.1.1",
                                     "bk_cloud_id": 1
                                 }, {
                                     "ip": "2.2.2.2",
                                     "bk_cloud_id": 1
                                 }],
                             },
                         ],
                         "bk_callback_url":
                         "url_token",
                     }))
     },
 ),
Пример #17
0
def PUSH_FILE_TO_IPS_FAIL_CASE():

    PUSH_FAIL_RESULT = {
        "result": False,
        "message": "msg token",
        "job_api": "api token",
        "response": {
            "result": False,
            "message": "msg token"
        },
        "kwargs": "kwargs token",
    }
    PUSH_FAIL_ESB_CLIENT = MagicMock()
    PUSH_FAIL_MANAGER = MagicMock()
    PUSH_FAIL_MANAGER.push_files_to_ips = MagicMock(
        return_value=PUSH_FAIL_RESULT)

    return ComponentTestCase(
        name="push_local_files manager call fail case",
        inputs={
            "biz_cc_id":
            "biz_cc_id",
            "job_local_files": [
                {
                    "response": {
                        "result": True,
                        "tag": "tag_1"
                    }
                },
                {
                    "response": {
                        "result": True,
                        "tag": "tag_2"
                    }
                },
            ],
            "job_target_ip_list":
            "1.1.1.1",
            "job_target_account":
            "job_target_account",
            "job_target_path":
            "job_target_path",
        },
        parent_data={
            "executor": "executor",
            "project_id": "project_id"
        },
        execute_assertion=ExecuteAssertion(
            success=False,
            outputs={
                "ex_data":
                '调用作业平台(JOB)接口api token返回失败, params="kwargs token", error=msg token'
            }),
        schedule_assertion=None,
        execute_call_assertion=[
            CallAssertion(func=GET_CLIENT_BY_USER, calls=[Call("executor")]),
            CallAssertion(
                func=CC_GET_IPS_INFO_BY_STR,
                calls=[
                    Call(username="******",
                         biz_cc_id="biz_cc_id",
                         ip_str="1.1.1.1",
                         use_cache=False)
                ],
            ),
            CallAssertion(
                func=PUSH_FAIL_MANAGER.push_files_to_ips,
                calls=[
                    Call(
                        esb_client=PUSH_FAIL_ESB_CLIENT,
                        bk_biz_id="biz_cc_id",
                        file_tags=["tag_1", "tag_2"],
                        target_path="job_target_path",
                        ips=[{
                            "ip": "1.1.1.1",
                            "bk_cloud_id": 0
                        }],
                        account="job_target_account",
                        callback_url="callback_url",
                    )
                ],
            ),
        ],
        patchers=[
            Patcher(target=ENVIRONMENT_VAR_GET, return_value="a_type"),
            Patcher(target=FACTORY_GET_MANAGER,
                    return_value=PUSH_FAIL_MANAGER),
            Patcher(target=GET_CLIENT_BY_USER,
                    return_value=PUSH_FAIL_ESB_CLIENT),
            Patcher(target=CC_GET_IPS_INFO_BY_STR,
                    return_value={
                        "ip_result": [{
                            "InnerIP": "1.1.1.1",
                            "Source": 0
                        }]
                    }),
            Patcher(target=GET_NODE_CALLBACK_URL, return_value="callback_url"),
        ],
    )