postman批量下发业务

本文详细介绍了网络配置中各类参数的设置,包括线路约束、服务质量(QoS)参数、伪线(PW)配置等,深入探讨了如何通过精确的配置实现网络资源的有效管理和优化,提升网络传输效率。

{
    "input": {
        "id": {{eline_id}},
        "name": {{eline_name}},
        "user-label": {{user_label}},
        "admin-status": "admin-up",
        "operate-status": "operate-up",
        "parent-ncd-id": "parent-ncd-id",
        "snc-type": "simple",
        "ingress-end-points": [{
            "id": {{ingress_id}},
            "ne-id": "openflow:3",
            "ltp-id": 3,
            "role": "master",
            "access-action": "Keep",
            "access-type": "Dot1Q",
            "dot1q-vlan-bitmap": {{vlan_id}},
            "qos": {
                "qos-a2z-cir": "2000",
                "qos-a2z-cbs": "250",
                "qos-a2z-pir": "3000",
                "qos-a2z-pbs": "375",
                "qos-z2a-cir": "2000",
                "qos-z2a-cbs": "250",
                "qos-z2a-pir": "3000",
                "qos-z2a-pbs": "375",
                "qos-belonged-id": {{ingress_qos_id}}
            }
        }],
        "egress-end-points": [{
            "id": {{egress_id}},
            "ne-id": "openflow:1",
            "ltp-id": 3,
            "role": "master",
            "access-action": "Keep",
            "access-type": "Dot1Q",
            "dot1q-vlan-bitmap": {{vlan_id}},
            "qos": {
                "qos-a2z-cir": "2000",
                "qos-a2z-cbs": "250",
                "qos-a2z-pir": "3000",
                "qos-a2z-pbs": "375",
                "qos-z2a-cir": "2000",
                "qos-z2a-cbs": "250",
                "qos-z2a-pir": "3000",
                "qos-z2a-pbs": "375",
                "qos-belonged-id": {{egress_qos_id}}
            }
        }],
        "calculate-constraint": {
            "work-calculate-constraint": {
                "explicit-include-ne": {
                    "explicit-include-ne-list": [{
                        "ne-id": "openflow:220249841762774"
                    }]
                },
                "explicit-include-link": {
                    "explicit-include-link-list": [{
                        "link-id": 149
                    }]
                }
            }
        },
        "pw": [{
            "encaplate-type": "cep-mpls",
            "ctrl-word-support": "nonsupport",
            "sn-support": "nonsupport",
            "vccv-type": "nonsupport",
            "conn-ack-type": "none",
            "admin-status": "admin-up",
            "operate-status": "operate-up",
            "id": {{pw_id}},
            "name": {{pw_name}},
            "index": {{index_id}},
            "ingress-ne-id": "openflow:3",
            "source-ip": "10.0.51.149",
            "egress-ne-id": "openflow:1",
            "destination-ip": "10.0.51.146",
            "role": "master",
            "route": [{
                "id": {{pw_id}},
                "name": {{route_name}},
                "snc-id": {{pw_id}},
                "layer-rate": "pw",
                "xc": [{
                    "ne-id": "openflow:3",
                    "ingress-ltp-id": 3,
                    "egress-ltp-id": 3
                }, {
                    "ne-id": "openflow:1",
                    "ingress-ltp-id": 3,
                    "egress-ltp-id": 3
                }]
            }]
        }]
    }
}

### 如何使用 Postman 批量发起请求 Postman 是一个强大的 API 测试工具,支持批量发起请求。以下是关于如何使用 Postman 批量发起请求的详细说明。 #### 1. 使用集合(Collection)和环境变量 首先需要创建一个包含多个请求的集合(Collection)。每个请求可以设置不同的参数、路径或请求头信息。通过这种方式,可以轻松管理多个请求[^1]。 - **创建集合**:在 Postman 中点击 `New` -> `Collection`,然后为集合命名。 - **添加请求到集合**:在集合中添加多个请求,并配置每个请求的具体参数和 URL。 #### 2. 配置环境变量 为了动态调整请求中的参数,可以使用环境变量。例如,如果需要发送带有不同用户 ID 的请求,可以通过环境变量实现动态替换[^2]。 ```javascript pm.environment.set("userId", "12345"); ``` 在请求 URL 或 Body 中引用环境变量时,使用以下格式: ``` http://example.com/api/users/{{userId}} ``` #### 3. 使用 Newman 进行命令行批量执行 Postman 提供了一个命令行工具 Newman,可以用来运行集合并批量发起请求。安装 Newman 后,可以在命令行中运行以下命令: ```bash newman run your-collection.json -e your-environment.json ``` 其中: - `your-collection.json` 是你的 Postman 集合文件。 - `your-environment.json` 是你的环境变量文件。 通过 Newman,可以自动化运行集合中的所有请求,并生成详细的测试报告。 #### 4. 并发请求的最佳实践 如果需要同时发起多个请求以模拟并发场景,可以在 Postman 的测试脚本中编写逻辑来控制请求的执行顺序。例如,在 `Tests` 标签页中添加以下代码: ```javascript pm.sendRequest({ url: 'https://example.com/api/data', method: 'GET', header: { 'Content-Type': 'application/json' } }, function (err, response) { console.log(response.text()); }); ``` 此外,为了确保请求的正确性,可以添加断言检查响应内容[^3]: ```javascript pm.test('返回数据是 books', () => { pm.expect(pm.response.text()).to.include('books'); }); ``` #### 5. 注意事项 - 确保服务器能够处理大量的并发请求,避免对服务器造成过大的压力。 - 如果请求需要登录验证,记得在请求头中添加 `Authorization` 字段,或者通过 Cookie 管理 Session 信息[^1]。 ```python import requests # 示例:通过 Python 脚本发送带 Session 的请求 session = requests.Session() session.headers.update({'Authorization': 'Bearer YOUR_TOKEN'}) response = session.get('https://example.com/api/endpoint') print(response.text) ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值