1"use strict";(self.webpackChunkddosify_landing_v_3=self.webpackChunkddosify_landing_v_3||[]).push([[4905],{69190:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>u,frontMatter:()=>o,metadata:()=>a,toc:()=>d});var t=s(85893),i=s(11151);const o={sidebar_position:10},r="\u2728 Examples",a={id:"ddosify/examples",title:"\u2728 Examples",description:"Example 1: Cookie Support",source:"@site/docs/ddosify/examples.md",sourceDirName:"ddosify",slug:"/ddosify/examples",permalink:"/docs/ddosify/examples",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:10,frontMatter:{sidebar_position:10},sidebar:"tutorialSidebar",previous:{title:"\ud83d\udcc1 Test Data Set",permalink:"/docs/ddosify/test-data-set"},next:{title:"\ud83d\udee0\ufe0f Troubleshooting",permalink:"/docs/ddosify/troubleshooting"}},c={},d=[{value:"Example 1: Cookie Support",id:"example-1-cookie-support",level:2},{value:"Example 2: Success Criteria",id:"example-2-success-criteria",level:2}];function l(e){const n={a:"a",code:"code",details:"details",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",summary:"summary",...(0,i.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"-examples",children:"\u2728 Examples"}),"\n",(0,t.jsx)(n.h2,{id:"example-1-cookie-support",children:"Example 1: Cookie Support"}),"\n",(0,t.jsxs)(n.p,{children:["Ddosify Engine supports cookies. If the engine mode is ",(0,t.jsx)(n.code,{children:"distict-user"})," or ",(0,t.jsx)(n.code,{children:"repeated-user"})," the engine will store the cookies in a cookie jar and use them in the next request. If the engine mode is ",(0,t.jsx)(n.code,{children:"ddosify"})," which is default, the engine will not use the cookies in the cookie jar. You can enable and disable custom / initial cookies with ",(0,t.jsx)(n.code,{children:"enabled"})," key in the ",(0,t.jsx)(n.code,{children:"cookie_jar"})," section of the config file. See ",(0,t.jsx)(n.a,{href:"/docs/ddosify/cookies",children:"Cookies"})," for more information."]}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["Create a Ddosify configuration file called: ",(0,t.jsx)(n.code,{children:"config.json"})]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",children:'{\n "iteration_count": 100,\n "load_type": "waved",\n "engine_mode": "distinct-user",\n "duration": 5,\n "steps": [\n {\n "id": 1,\n "name": "Get Servers",\n "url": "https://app.servdown.com/servers/",\n "method": "GET",\n "timeout": 10,\n "others": {},\n "capture_env": {\n "CSRFTOKEN": { "from": "cookies", "cookie_name": "csrftoken" }\n }\n },\n {\n "id": 2,\n "name": "Login",\n "url": "https://app.servdown.com/accounts/login/?next=/",\n "method": "POST",\n "timeout": 10,\n "headers": {\n "Content-Type": "application/x-www-form-urlencoded"\n },\n "payload": "[email protected]&password=PasssChange&csrfmiddlewaretoken={{CSRFTOKEN}}",\n "others": {\n "disable-redirect": false\n }\n }
1\n ],\n "output": "stdout",\n "cookie_jar": {\n "enabled": true,\n "cookies": [\n {\n "name": "platform",\n "value": "web",\n "domain": "httpbin.ddosify.com",\n "path": "/",\n "expires": "Thu, 16 Mar 2023 09:24:02 GMT",\n "http_only": true,\n "secure": false\n }\n ]\n }\n}\n'})}),"\n",(0,t.jsxs)(n.ol,{start:"2",children:["\n",(0,t.jsx)(n.li,{children:"Run the engine with the following command:"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"ddosify -config config.json --debug\n"})}),"\n",(0,t.jsxs)(n.p,{children:["In the first step we are getting the CSRF token from the server response cookie and storing it in the environment variable ",(0,t.jsx)(n.code,{children:"CSRFTOKEN"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:["In the second step we are using the ",(0,t.jsx)(n.code,{children:"CSRFTOKEN"})," variable to replace the CSRF token in the payload. In this example, we are using ",(0,t.jsx)(n.code,{children:"x-www-form-urlencoded"})," as the content type, so the we set ",(0,t.jsx)(n.code,{children:"email"}),", ",(0,t.jsx)(n.code,{children:"password"})," and ",(0,t.jsx)(n.code,{children:"csrfmiddlewaretoken"})," fields in the payload. The ",(0,t.jsx)(n.code,{children:"csrfmiddlewaretoken"})," field is replaced with the ",(0,t.jsx)(n.code,{children:"CSRFTOKEN"})," captured variable."]}),"\n",(0,t.jsxs)(n.p,{children:["We also set an initial cookie (",(0,t.jsx)(n.code,{children:"platform"}),") in the ",(0,t.jsx)(n.code,{children:"cookie_jar"})," section of the config file. The engine will also store the cookies in the cookie jar and use them in the requests."]}),"\n",(0,t.jsx)(n.h2,{id:"example-2-success-criteria",children:"Example 2: Success Criteria"}),"\n",(0,t.jsxs)(n.p,{children:["Ddosify engine supports success criteria. You can set a success criteria for the entire test based on server or assertion errors. If the success criteria is not met the engine will stop the test based on ",(0,t.jsx)(n.code,{children:"abort"})," and ",(0,t.jsx)(n.code,{children:"delay"})," keywords. If you set ",(0,t.jsx)(n.code,{children:"abort"})," to ",(0,t.jsx)(n.code,{children:"true"})," the engine will stop the test immediately after ",(0,t.jsx)(n.code,{children:"delay"})," seconds. If you set ",(0,t.jsx)(n.code,{children:"abort"})," to ",(0,t.jsx)(n.code,{children:"false"})," the engine will not stop the test. See ",(0,t.jsx)(n.a,{href:"/docs/ddosify/assertion#success-criteria-pass--fail",children:"Success Criteria"})," for more information."]}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["Create a Ddosify configuration file called: ",(0,t.jsx)(n.code,{children:"config.json"})]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",children:'{\n "iteration_count": 20,\n "debug": false,\n "load_type": "linear",\n "duration": 2,\n "output": "stdout",\n "success_criterias": [\n {\n "rule": "fail_count < 5",\n "abort": false,\n "delay": 0\n },\n {\n "rule": "fail_count_perc < 0.1",\n "abort": true,\n "delay": 1\n },\n {\n "rule": "p90(iteration_duration) < 220",\n "abort": false\n }\n ],\n "steps": [\n {\n "id": 1,\n "url": "https://httpbin.ddosify.com/json",\n "method": "GET",\n "timeout": 5,\n "assertion": [\n "equals(status_code, 201)",\n "equals(json_path(\\"quoteResponse.result.0.ask\\"), 130.74)"\n ]\n },\n {\n "id": 2,\n "url": "https://httpbin.ddosify.com/status/500",\n "method": "GET",\n "timeout": 5,\n "assertion": [\n "in(status_code, [413,403])",\n "less_than(response_time, 100)"\n ]\n }\n ]\n}\n'})}),"\n",(0,t.jsxs)(n.ol,{start:"2",children:["\n",(0,t.jsx)(n.li,{children:"Run the engine with the following command:"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"ddosify -config config.json\n"})}),"\n",(0,t.jsxs)(n.details,{children:["\n ",(0,t.jsx)(n.summary,{children:" Example Output"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"\u2699\ufe0f Initializing... \n\ud83d\udd25 Engine fired.\n\n\ud83d\uded1 CTRL+C to gracefully stop.\n\u2714\ufe0f Successful Ru
1n: 0 0% \u274c Failed Run: 12 100% \u23f1\ufe0f Avg. Duration: 0.00000s\n\u2714\ufe0f Successful Run: 0 0% \u274c Failed Run: 20 100% \u23f1\ufe0f Avg. Duration: 0.00000s\n\n## RESULT\n\n1. Step 1\n\n---\n\nSuccess Count: 0 (0%)\nFailed Count: 20 (100%)\n\nDurations (Avg):\nDNS :0.0029s\nConnection :0.0389s\nTLS :0.0269s\nRequest Write :0.0000s\nServer Processing :0.1304s\nResponse Read :0.0001s\nTotal :0.1992s\n\nStatus Code (Message) :Count\n200 (OK) :20\n\nAssertion Error Distribution:\nCondition: equals(status_code, 201)\nFail Count: 20\nReceived:\nequals(status_code,201) : [false]\nstatus_code : [200]\nReason: expression evaluated to false\n\n2. Step 2\n\n---\n\nSuccess Count: 0 (0%)\nFailed Count: 20 (100%)\n\nDurations (Avg):\nDNS :0.0016s\nConnection :0.0578s\nTLS :0.0470s\nRequest Write :0.0000s\nServer Processing :0.1297s\nResponse Read :0.0000s\nTotal :0.2361s\n\nStatus Code (Message) :Count\n500 (Internal Server Error) :20\n\nAssertion Error Distribution:\nCondition: in(status_code, [413,403])\nFail Count: 20\nReceived:\nstatus_code : [500]\nin(status_code,[413,403]) : [false]\nReason: expression evaluated to fal
1se\n\n Condition: less_than(response_time, 100)\n Fail Count: 20\n Received:\n less_than(response_time,100) : [false]\n response_time : [397 392 399 129 130]\n Reason: expression evaluated to false\n\nTest Status: Failed\n\nRule: fail_count < 5\nReceived:\nfail_count: 20\n\nRule: fail_count_perc < 0.1\nReceived:\nfail_count_perc: 1\n\nRule: p90(iteration_duration) < 220\nReceived:\niteration_duration: [257 258 258 258 259 259 260 260 261 262 263 388 390 526 654 662 793 795 800 822]\np90(iteration_duration): 795\nexit status 1\n\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["In this example, we are using the ",(0,t.jsx)(n.code,{children:"fail_count"}),", ",(0,t.jsx)(n.code,{children:"fail_count_perc"})," and ",(0,t.jsx)(n.code,{children:"p90(iteration_duration)"})," success criteria. The engine will stop the test if any of the success criteria is not met. In this example, the engine will stop the test because the ",(0,t.jsx)(n.code,{children:"fail_count"})," is ",(0,t.jsx)(n.code,{children:"20"})," which is greater than ",(0,t.jsx)(n.code,{children:"5"}),", ",(0,t.jsx)(n.code,{children:"fail_count_perc"})," is ",(0,t.jsx)(n.code,{children:"1"})," which is greater than ",(0,t.jsx)(n.code,{children:"0.1"})," and ",(0,t.jsx)(n.code,{children:"p90(iteration_duration)"})," is ",(0,t.jsx)(n.code,{children:"795"})," which is greater than ",(0,t.jsx)(n.code,{children:"220"}),"."]})]})}function u(e={}){const{wrapper:n}={...(0,i.a)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(l,{...e})}):l(e)}},11151:(e,n,s)=>{s.d(n,{Z:()=>a,a:()=>r});var t=s(67294);const i={},o=t.createContext(i);function r(e){const n=t.useContext(o);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),t.createElement(o.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.