用于wiremock的chaostolkit驱动程序

chaostoolkit-wiremock的Python项目详细描述


chaostolkit wiremock

Build Statusimage

Chaos Toolkit用于WireMock的驱动程序。

软件包安装

从pypi.org安装软件包:

pip install -U chaostoolkit-wiremock

从源安装

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

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

配置

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

  • 主机: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_mappings",
        "arguments": {
          "mappings": [{
            "request": {
               "method": "GET",
               "url": "/hello"
            },
            "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_mappings",
        "arguments": {
          "filter": [{
             "method": "GET",
             "url": "/hello"
          }]
        }
      }
    }
  ]
}

添加全局固定延迟:

{
  "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": {
          "filter": [{
            "method": "GET",
            "url": "/hello1"
          }],
          "fixedDelayMilliseconds": 1000
        }
      }
    }
  ]
}

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

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

将chunkeddribbledelay添加到映射列表:

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

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

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

重新获取映射列表:

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

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

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

实验

驱动程序附带了一个实验目录,您可以在其中找到测试所有api的片段 针对在本地主机上侦听的wiremock服务器:8080。

发现

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

$ chaos discover chaostoolkit-wiremock  --no-install

学分

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

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

推荐PyPI第三方库


热门话题
java以编程方式从TableLayout中删除所有行   Java Web Sart Ubuntu12.1。加载资源(图像)   人们如何让Java SPNEGO客户端在Windows中工作?   java Eclipselink:ObjectArrayMapping和ClassDescriptor   控制台中带有引号/空格的java Javafx命名参数   java创建服务失败:找不到对象?   java Hazelcast:如何在测试期间禁用自动发现?   使用TuckyUrlRewriteFilter rermoteaddr的java块IP   javascript如何在angular 4中进行同步http调用   输入字符串的java排列   java Jenkins不是以Xrs Xmx2048m XX:MaxPermSize=512m(windows)开始的   AWS EMR上的java avro错误   java从两个ArrayList中提取特定连接的对象,组合这些相关对象并从子类中打印   java从主题中删除什么时间点消息?   谷歌像素设备上的java InvalidKeyException   java如何在执行测试后重建项目   java Android 2.2 readUTF()socket问题   按下安卓设备上的“后退”按钮后java Toast没有完成?