Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    atrekyinee
    @artekyinee_twitter
    hi all, does anyone know how to tell artillery to use inline variables (declared in config) to be used in sequence not by random?
    or it’s possible only via payload?
    tried to add «order» : «sequence» to variables but it did not work (variables taken random)
    Ghost
    @ghost~5cc08ba2d73408ce4fbe92be
    Hi, is it possible with artillery to set query paramaters of socket.io connection as variables from payload .csv files?
    Vitalii Makarets
    @mandelbroo

    @ghost~5cc08ba2d73408ce4fbe92be currently it's not possible https://spectrum.chat/artillery-io/general/is-it-possible-to-have-a-socketio-query-with-random-number-for-each-connect~d01e5441-2640-4527-943d-8c639a320c37

    @hassy "It's not possible at the moment, we'll file it as a bug (query is only evaluated once)"

    ravidio
    @ravidio
    Hello, need a bit of help with artillery. I'm trying to GET a url then parse the response to get all links and loop and get those to. I think what I need is a way to loop over captured regexp values. anyone know if this is possible to achieve?
    jwingo1015
    @jwingo1015
    hey im having a couple of issues. the -log argument doesnt log any info in the console. also i have two request in my yaml file but artillery is only running the first request only. can someone please advise me what i am doing wrong?
    jwingo1015
    @jwingo1015
    Is there any other examples of the requestParam
    Ivan Wong
    @iwong3
    Hey guys! I was wondering if there was any way to generate an artillery report without opening the browser.. artillery report <file>
    eka-putra
    @whitehorse0

    Hi @jwingo1015 have you seen this part ? https://artillery.io/docs/http-reference/#logging

    and if i do, write the test scenario in .yml file, and it's work. https://artillery.io/docs/getting-started/#running-the-test

    eka-putra
    @whitehorse0
    @jwingo1015 and i've a few example
    // login.test.yml
    config:
      processor: './processor.js'
     ...
    scenarios:
      - name: 'Login success'
        flow:
        - post:
            url: '/login'
            beforeRequest: setLoginQuery
            afterResponse: logRes
    
    
    // processor.js
    module.exports = {
    
      setLoginQuery (requestParams, context, ee, next) {
        requestParams.json = {
            username: 'admin',
            password: 'secret'
        }
        return next()
      },
    
      logRes (requestParams, response, context, ee, next) {
        // I use this only for debugging
        console.log(`response body : ${JSON.stringify(response.body)}`)
        return next()
      }
    }
    jwingo1015
    @jwingo1015
    @whitehorse0 thanks
    is there a way to create an array of ids capture from the response body of a loop of request?
    eka-putra
    @whitehorse0

    capture to capturing an array ?
    I don't think it supports it for now.

    And I don't know your reason for having to only use capture :-/

    capturewritten in the documentation The capture element must always have an as attribute which names the value for use in subsequent requests
    which value will also be stored in the variables (as a string)

    and the same thing when we use
    Inline variables https://artillery.io/docs/script-reference/#inline-variables
    or
    function-steps-in-a-flowhttps://artillery.io/docs/http-reference/#function-steps-in-a-flow

    For alternative, we can handle it using "hooks", if you've read this section, https://artillery.io/docs/http-reference/#advanced-writing-custom-logic-in-javascript
    explanation about processor, like the example I gave above.

    jwingo1015
    @jwingo1015
    are we able to loop the request and the function associated with that request?
    eka-putra
    @whitehorse0

    yes you can, have you tried it @jwingo1015?
    just like before, you only have to do the loop.

    I hope I did not misunderstand your question :-/

    jwingo1015
    @jwingo1015
    @whitehorse0 i tried it and it started an endless request even though the count was only 2
    eka-putra
    @whitehorse0
    Could you please give us a demo/sample code to check this?
    jwingo1015
    @jwingo1015
    • loop:
      - function: "ecommerceProdJson"
      - post:
          url: "/ecommerce/stores/{{ store_id }}/products"
      count: 2
          capture:
              json: "$.id"
              as: "product_id"
          body: "{{ productJson }}"
          headers: 
            authorization: "apikey {{ api_key }}"
          expect:
              - statusCode: 200
    eka-putra
    @whitehorse0

    nah not really, I don't think that's good, even though it's not an error, but it will break our expect.
    You must store the id in config.variabel, not from the function process.
    https://artillery.io/docs/script-reference/#inline-variables

    and there are case examples that are a little close
    https://artillery.io/docs/http-reference/#looping-through-an-array

    but this value is set static.

    eka-putra
    @whitehorse0

    if I were, it would be like this

    // product.test.yml
    scenarios:
      - name: 'Fetch product store'
        flow:
        - log: "Get list store"
        - get:
            url: '/ecommerce/stores/'
            afterResponse: extractStoreData
    
        - loop:
            - log: "Get product list of storeIds: {{ $loopElement }}"
            - get:
                url: '/ecommerce/stores/{{ $loopElement }}/products'
                afterResponse: extractProductData
    
            - loop:
                - log: "Get detail product of storeId: {{ storeId }} with productId: {{ $loopElement }}"
                - get:
                    url: '/ecommerce/stores/{{ storeId }}/products/{{ $loopElement }}'
              over: productIds
    
          over: storeIds
    
    // processor.js
    module.exports = {
      extractStoreData (requestParams, response, context, ee, next) {
        if (response.statusCode === 200) {
            const res = JSON.parse(res.body) // if body contain as string we should parse to json object
            const ids = []
    
            // assume we only take 3 store data only
            for (let i = 0; i < 3; i++) {
              const store = res[i];
              ids.push(store.id)
            }
    
            // now we stored in the variables (as an array of string id)
            ctx.vars['storeIds'] = ids
        }
        return next()
      },
    
      extractProductData (requestParams, response, context, ee, next) {
        if (response.statusCode === 200) {
            ...
    
            // now we stored in the variables (as an array of string id)
            ctx.vars['productIds'] = ids
            ctx.vars['storeId'] = ctx.vars['$loopElement']
        }
        return next()
      }
    }

    Thats all variables we can handle on context context.vars['variable-name'].

    jwingo1015
    @jwingo1015
    @whitehorse0 thanks for your reply but i am trying to create multiple products for one store. So i wanted to loop the function that I created that creates different json bodies for the post call.
    eka-putra
    @whitehorse0
    @jwingo1015 oh, sorry i missed it. so you want to post to create product with different json body ?
    I think you only need to create data object in an array with length from number of loops. Then you call the data object from processor base on index of loop,
    you can catch it with ctx.vars['$loopElement'].
    jwingo1015
    @jwingo1015
    yes trying to run a post request with different products around 10 times
    jwingo1015
    @jwingo1015
    also can i put the pass the count to the function that is creating the different json objects?
    the count amount
    eka-putra
    @whitehorse0

    @jwingo1015 yes you can.

    And following from the example case you gave above:

    // product.test.yml
    scenarios:
      - name: 'trying to create multiple products for one store'
        flow:
          - loop:
            - post:
                url: "/ecommerce/stores/{{ store_id }}/products"
                headers:
                  authorization: "apikey {{ api_key }}"
                beforeRequest: "setPostQuery"
                expect:
                  - statusCode: 200
            count: 100
    
    // processor.js
    const data = require('./data.json') // your sample data object in an array
    
    module.exports = {
      setPostQuery (req, ctx, ee, next) {
        // ctx.vars['$loopCount'] is 1 - 100
    
        // so, i recommend to using `$loopElement` to get index of count. ( 0 - 99)
       // because array index starting from 0 in javascript 
        req.json = data[ctx.vars['$loopElement']] 
        return next()
      }
    }

    don't forget to read this: https://artillery.io/docs/http-reference/#looping-through-a-number-of-requests

    joshpzero
    @joshpzero
    Hey guys how do I capture the length of an array of json
    tarun0909
    @tarun0909
    Hi guys, new to artillery and not able to understand how this rampto works exactly?
    As an example: take this below scenario
    - duration: 10
      arrivalRate: 5
      rampTo: 10
    How exactly here rampto will work?
    🔊🔊🔊 FYI for all those who might have come across this channel recently -- Artillery's Gitter channel has been retired. Please join the Artillery community on Spectrum - https://spectrum.chat/artillery-io
    ChappieG
    @ChappieG

    Hello,

    I am after some advice on measuring latency on a chain of requests.

    Our system will upload a json payload to an S3 bucket, this will trigger an AWS event to invoke a Lambda and start up a state machine. The first Lambda will get the contents of the json from the S3 and then send it off to an API and wait for a response.

    My test has been to upload a json file to the S3 bucket in a beforeScenario and then invoke the first lambda function using a plugin for Artillery. However, my tests only seem to return the response from the lambda and I seem to get the latency percentiles back from the lambda but not the API it fires off. Is there a way to measure the Lambda API calls after invoking the lambda function?

    Many Thanks

    tarun0909
    @tarun0909
    Hello, Is there any way I can automate generation of OAuth 2.0 token via javascript code and use it in the artillery scripts.
    dhiraj
    @dhirajshinde121083

    Hello every one i am new to artillery just struggling with some issue, maybe simple but not able to fix after spending hours on this following is code i dont see any message is emitted from loop written in artillery yaml file -------------server.js-----------------------------
    var io = require('socket.io')(3000);
    io.on('connection', function (socket) {
    socket.on('chat', function (data) {
    console.log(data);
    });
    });
    ------------artillery yml file ---------------------
    config:
    target: 'http://abcxyz.com:3000'
    phases:

    - duration: 10
      arrivalCount: 2

    payload:
    path: "./final_vehicle2.csv"
    fields:

              - "vehicle"
              - "id"
      order: "sequence"

    processor: "./random.js"
    scenarios:

    • engine: socketio
      flow:
      • function: "setMsg"
      • loop:
        • emit:
          channel: 'chat'
          data: " {{ vehicle }} have {{ id }} look {{ $loopCount }}"
          over: resultsss
          -------------------processor---------------------------------------
          'use strict';
          const pg = require('pg');
          var pool = new pg.Pool({ user:'postgres',database:'postgres',password:'xxxx',port: 5432});

    module.exports = { setMsg : setMsg };
    function setMsg(context,ee,done){
    var allPos = [];
    pool.connect((err,client,done)=>{
    if(err){
    console.log(err);
    }
    else{
    var vehicle_id = context.vars.id;
    pool.query("select latitude,longitude,datetime,speed from tracklog_history where vehicle_id="+ vehicle_id + " limit 500" ).then(res => {
    res.rows.forEach(function(item){
    let eachPos = { 'latitude' : item.latitude ,'longitude' : item.latitude ,'datetime' : item.latitude ,'speed' : item.latitude };
    allPos.push(eachPos);
    });
    context.vars['resultsss'] = [...allPos];
    return done();
    });
    }
    });
    return done();
    }
    --------------------final_vehicle2.csv file---------------------------------------------------
    MH01CV1213,380
    MH01CV1214,270

    dhiraj
    @dhirajshinde121083
    how do i set context.var.results as an array of elements in my processor and pass it to artillery yaml file to loop over
    dhiraj
    @dhirajshinde121083
    @whitehorse0

    @whitehorse0 hi maybe you can help me to get rid of this issue i am having as i have seen same issue resolved earlier by you in above case ------------server.js-----------------------------
    var io = require('socket.io')(3000);
    io.on('connection', function (socket) {
    socket.on('chat', function (data) {
    console.log(data);
    });
    });
    ------------artillery yml file ---------------------
    config:
    target: 'http://abcxyz.com:3000'
    phases:

    • duration: 10
      arrivalCount: 2

    payload:
    path: "./final_vehicle2.csv"
    fields:

          - "vehicle"
          - "id"

    order: "sequence"

    processor: "./random.js"
    scenarios:

    engine: socketio
    flow:
        function: "setMsg"
        loop:
            emit:
            channel: 'chat'
            data: " {{ vehicle }} have {{ id }} look {{ $loopCount }}"
            over: resultsss
            -------------------processor---------------------------------------
            'use strict';
            const pg = require('pg');
            var pool = new pg.Pool({ user:'postgres',database:'postgres',password:'xxxx',port: 5432});

    module.exports = { setMsg : setMsg };
    function setMsg(context,ee,done){
    var allPos = [];
    pool.connect((err,client,done)=>{
    if(err){
    console.log(err);
    }
    else{
    var vehicle_id = context.vars.id;
    pool.query("select latitude,longitude,datetime,speed from tracklog_history where vehicle_id="+ vehicle_id + " limit 500" ).then(res => {
    res.rows.forEach(function(item){
    let eachPos = { 'latitude' : item.latitude ,'longitude' : item.latitude ,'datetime' : item.latitude ,'speed' : item.latitude };
    allPos.push(eachPos);
    });
    context.vars['resultsss'] = [...allPos];
    return done();
    });
    }
    });
    return done();
    }
    --------------------final_vehicle2.csv file---------------------------------------------------
    MH01CV1213,380
    MH01CV1214,270

    eka-putra
    @whitehorse0

    @dhirajshinde121083
    Similarly, a scenario definition can have a beforeScenario/afterScenario attribute, which will make the functions specified run for every request in the scenario. The function signature is the same as for function hooks https://artillery.io/docs/http-reference/#function-steps-in-a-flow

    And for this case, have you tried "beforeRequest:" hooks, to tells Artillery to run the setMsg function before the request is made ???

    Hasitha_Waruna
    @hasithawaruna
    Hi all,
    Is there a way to attach a JPG/PNG file to request body payload? I need to attach a jpg file to the below 'photo' parameter. without this param, I couldn't get any valid response. Please suggest if there is any proper way to do this. Thank you.
    EX:
    scenarios:
    flow:
    post: url: "/users/uploadPhoto" json: token: "sampleEmail" password: "samplePassword photo: "Sample JPG file"
    manoj nn
    @nnmanu_twitter
    If there is a loop for one api out of many inside scenario and flow then not reading the data serially from the csv file.It stops after reading first value.Can someone give me the solution for the same
    ChappieG
    @ChappieG
    I am involving a Lambda function using Artillery - I was hoping from the Invoke I could obtain the json response to use in a further request. Is this possible on an invoke? My example below doesn't capture anything, the expects plugin also doesn't work even though I get response codes. I am using the "artillery-engine-lambda" plugin to invoke but it doesn't
    mention anything about capturing responses. My config is set in a separate file.
    scenarios:
      - name: "Invoke Request"
        engine: "lambda"
        flow:
          - invoke:
              invocationType: "RequestResponse"
              payload:
                json:
                  s3Ref: "{{ s3Ref }}"
                  urn: "{{ urn }}"
                  key: "{{ key }}"
              logType: "Tail"
              capture:
                json: "$.data"
                as: "data"
              expect:
                - statusCode: 200
    michyliao
    @michyliao_twitter
    hi all, for ws engine, is there a way to receive since in my scenarios - it depends on a value that is given back during the workflow? TIA
    michyliao
    @michyliao_twitter
    or is there a way to fail a ws scenario if the data that was sent is wrong?
    ChappieG
    @ChappieG
    Hello, Is it possible to upload a file to s3 using the file upload plugin
    Lillypot
    @Lillypot

    Hi -- Can you help me get the url within the setJSONBody please -- I have tried below authentication but this code seems to pickup my second target details such as the Api Key. how do I get the url recognised as part of the json post?

    function setJSONBody(requestParams, context, ee, next) {
    requestParams.uri = 'https://joobo.co.com/taccess/v1/authenticate';
    requestParams.json = {
    userName: 'Catt',
    password: 'frustrated'
    }
    return next()
    }
    function getToken (requestParams, response, context, ee, next) {
    // This extracts the token
    console.log(response body : ${JSON.stringify(response.body)})
    var token = response.body['id-token'];
    context.vars['authToken'] = token;
    console.log('authToken:', token);
    return next()
    }

    michyliao
    @michyliao_twitter
    has anyone worked with authenticated ws? not sure how to do this since there is no response options
    michyliao
    @michyliao_twitter

    has anyone worked with authenticated ws? not sure how to do this since there is no response options

    \ how does one keep 1 ws request for the vu to go through the scenario instead of opening up separate requests for each flow

    eka-putra
    @whitehorse0

    repost

    🔊🔊🔊 FYI for all those who might have come across this channel recently -- Artillery's Gitter channel has been retired. Please join the Artillery community on Spectrum - https://spectrum.chat/artillery-io
    Lillypot
    @Lillypot
    @anupash Hi did you manage to resolve your onetime authentication and if so how... I have the same problem and I don't know how to do one time auth.
    DBiles
    @DBiles
    Using this as a starter for some loading testing and continuing to get this error Plugin aws-sigv4 specified but module artillery-plugin-aws-sigv4 could not be found (MODULE_NOT_FOUND)
    {
        "config": {
            "plugins": {
                "aws-sigv4": {
                    "serviceName": "execute-api"
                }
            },
            "target": "some-site.com",
            "phases": [{
                "duration": 120,
                "arrivalRate": 5
            }],
            "defaults": {
                "headers": {
                    "Content-Type": "application/json"
                }
            }
        },
        "scenarios":[{
            "flow": [{
                "get": {
                    "url": "/"
                }
            }]
        }]
    }
    Can any shed some light