用于wiremock的chaostolkit驱动程序

chaoswm的Python项目详细描述


chaostolkit wiremock

image

WireMock服务API的混沌工具包驱动程序

软件包安装

要从pypi.org安装软件包,请执行以下操作:

pip install chaoswm

从源安装

为了使用它,您的环境中需要Python3.5+。 下载项目后,将cd放入其中并运行:

pip install -r requirements.txt
pip install -r requirements_dev.txt
make clean && make test && make install

配置

可以在实验全局设置中配置以下键 配置部分,在“wiremock”键下:

  • host:wiremock服务器主机
  • 端口:wiremock服务器端口
  • contextPath:wiremock服务器的contextPath(可选)
  • timeout:接受的超时(默认为1秒)
  • down:由down操作使用的delaydistribution部分

配置示例:

{
    "configuration": {
        "wiremock": {
            "host": "localhost",
            "port": 8080,
            "contextPath": "/wiremock",
            "timeout": 10,
            "down": {
                "type": "lognormal",
                "median": 3000,
                "sigma": 0.2
            }
        }
    }
}

导出操作

添加映射列表:

{
  "method": [
    {
      "type": "action",
      "name": "adding a mapping",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "add_mapping",
          "arguments": [{
              "request": {
                  "method": "GET",
                  "url": "/some/thing"
              },
              "response": {
                  "status": 200,
                  "body": "Hello world!",
                  "headers": {
                      "Content-Type": "text/plain"
                  }
              } 
          }]
      }
    }
  ]
}

删除映射列表:

{
  "method": [
    {
      "type": "action",
      "name": "deleting a mapping",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "delete_mapping",
          },
          "arguments": [{
              "method": "GET",
              "url": "/some/thing"
          }]
      }
  ]
}

添加全局固定延迟:

{
  "method": [
    {
      "type": "action",
      "name": "Adding a global fixed delay",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "global_fixed_delay"
          },
          "arguments": {
              "fixedDelay": 10
          }
      }
  ]
}

添加全局随机延迟:

{
  "method": [
    {
      "type": "action",
      "name": "Adding a global random delay",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "global_random_delay"
          },
          "arguments": {
            "delayDistribution": {
                "type": "lognormal",
                "median": 20,
                "sigma": 0.1
            }
          }
      }
  ]
}

向映射列表添加固定延迟:

{
  "method": [
    {
      "type": "action",
      "name": "Adding a fixed delay to a mapping",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "fixed_delay"
          },
          "arguments": {[{
                  "method": "GET",
                  "url": "/some/thing"
              }],
              "fixedDelayMilliseconds": 100
          }
      }
  ]
}

如果映射列表中的 映射必须延迟,以下操作可能有用:

{
  "method": [
    {
      "type": "action",
      "name": "Adding a fixed delay to a set of mappings",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "fixed_delay_to_many_mappings"
          },
          "arguments": {[{
                "method": "GET",
                "url": "/some/thing",
              },{
                "method": "POST",
                "url": "/some/thing/else",
              }],
              "fixedDelayMilliseconds": 100
          }
      }
  ]
}

向映射列表添加随机延迟:

{
  "method": [
    {
      "type": "action",
      "name": "Adding a random delay to a mapping",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "random_delay"
          },
          "arguments": {[{
                  "method": "GET",
                  "url": "/some/thing",
              }],
              "delayDistribution": {
                  "type": "lognormal",
                  "median": 80,
                  "sigma": 0.4
              }
          }
      }
  ]
}

将chunkeddribbledelay添加到映射列表:

{
  "method": [
    {
      "type": "action",
      "name": "Adding a ChunkedDribbleDelay to a mapping",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "chunked_dribble_delay"
          },
          "arguments": {[{
                "method": "GET",
                "url": "/some/thing",
              }],
              "chunkedDribbleDelay": {
                  "numberOfChunks": 5,
                  "totalDuration": 1000
              }
          }
      }
  ]
}

把映射列表取下来(重分布延迟)。这个动作 将使用 配置部分:

{
  "method": [
    {
      "type": "action",
      "name": "Taking a mapping down",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "down"
          },
          "arguments": [{
              "method": "GET",
              "url": "/some/thing",
          }]
      }
  ]
}

重新获取映射列表:

{
  "method": [
    {
      "type": "action",
      "name": "Taking a mapping down",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "up"
          },
          "arguments": [{
              "method": "GET",
              "url": "/some/thing",
          }]
      }
  ]
}

重置wiremock服务器(删除所有映射):

{
  "method": [
    {
      "type": "action",
      "name": "Taking a mapping down",
      "provider": {
          "type": "python",
          "module": "chaoswm.actions",
          "func": "reset"
      }
    }
  ]
}

发现

你可以使用混沌工具箱来发现 分机:

$ chaos discover chaostoolkit-wiremock  --no-install

学分

此包是用 Cookiecutteraudreyr/cookiecutter-pypackage 项目模板。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何克服带有空值的不可空bean级验证   “此行有多个标记”的authenticateUser上的java MySQLConnection错误   java处理Jackson异常   java Netbeans编辑器如何知道文件在撤消后不会被修改?   目标C相当于Java的ArrayList   java当需要int时,可以将short传递给方法调用吗?   drawString()方法上的java MouseListener   java服务器socket是执行此操作的最佳选项   java需要单个匹配bean,但找到了2:org。springframework。网状物servlet。mvc。方法注释。RequestMappingHandlerMapping   如何在Java中执行Windows命令?   安卓应用程序的java文件主机   java将所有spring引导属性都设置在内。将yml文件转换为系统属性   Java邮件中的html内联链接在邮件客户端中不起作用   Java二进制文件的bazel版本控制   java如何在自定义ListView中使用Intent   java(Spring MVC+Hibernate 4+Test 4)自动连线DAO返回NULL   java一次add()调用可以在Solr服务器中索引多少文档?   java如何获取Avro GenericRecord大小