How to use the k6/http.get function in k6

To help you get started, we’ve selected a few k6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kyma-project / kyma / tests / perf / components / serverless / perf-test-serverless.js View on Github external
functionNames.forEach(function (functionName) {
    let url = `https://${functionName}.${__ENV.CLUSTER_DOMAIN_NAME}`
    let tags = {
      'testName': functionName,
    }
    let res = http.get(url, { 'tags': tags })

    // report custom trend
    // same as http_req_duration but without function execution time
    httpReqDurationNoFunc.add(res.timings.duration - funcDelay);
    // same as http_req_waiting but without function execution time
    httpReqWaitingNoFunc.add(res.timings.waiting - funcDelay)

    check(res, {
      "status was 200": (r) => r.status == 200,
    }, tags);
  });
};
github jembi / openhim-core-js / performance / transactionsWithoutFilters.js View on Github external
function makeGetRequest () {
  const response = http.get(
    // Have to limit transactions to 100 as request times out for all transactions
    `${BASE_URL}/transactions?filterLimit=100`,
    {
      headers: Object.assign(getTestAuthHeaders(), {
        Accept: 'application/json',
        'Content-Type': 'apllication/json'
      }),
      tags: {
        name: 'Transactions without filters'
      }
    }
  )

  check(response, {
    'status code is 200': r => r.status === 200
  })
github poetapp / frost-api / tests / stress / getTokens.js View on Github external
export default (token) => {
  const url = `${FROST_HOST}/tokens`
  const params =  { headers: { 'Content-Type': 'application/json', token } }
  const res = http.get(url, params)

  check(res, {
    'status 200': (r) => r.status === 200
  })

  sleep(1)
}
github grafana / grafana / devenv / docker / loadtest / modules / client.js View on Github external
get(url, params) {
    params = params || {};
    this.beforeRequest(params);
    this.onBeforeRequest(params);
    return http.get(this.url + url, params);
  }
github poetapp / node / tests / stress / createWorks.js View on Github external
export default () => {

  const requestClaim = http.get(`${CLAIM_HOST}`)

  const url = `${NODE_HOST}/works`
  const payload = requestClaim.body
  const params =  { headers: { 'Content-Type': 'application/json' } }
  const work = http.post(url, payload, params)

  check(work, {
    'status 202': (r) => r.status === 202
  })

  sleep(1 + parseInt(DELAY_GET_WORK))

  const id = JSON.parse(work.request.body).id
  const urlGetWork = `${NODE_HOST}/works/${id}`
  const res = http.get(urlGetWork)
github poetapp / frost-api / tests / stress / getWorks.js View on Github external
export default (token) => {
  const url = `${FROST_HOST}/works`
  const params =  { headers: { 'Content-Type': 'application/json', token } }
  const res = http.get(url, params)

  check(res, {
    'status 200': (r) => r.status === 200
  })

  sleep(1)
}
github poetapp / frost-api / tests / stress / getProfile.js View on Github external
export default (token) => {
  const url = `${FROST_HOST}/accounts/profile`
  const params =  { headers: { 'Content-Type': 'application/json', token } }
  const res = http.get(url, params)

  check(res, {
    'status 200': (r) => r.status === 200
  })

  sleep(1)
}
github Squidex / squidex / backend / tools / k6 / get-clients.js View on Github external
export default function (data) {
    const url = `${variables.serverUrl}/api/apps/${variables.appName}/clients`;

    const response = http.get(url, {
        headers: {
            Authorization: `Bearer ${data.token}`
        }
    });

    check(response, {
        'is status 200': (r) => r.status === 200,
    });
}
github jembi / openhim-core-js / performance / metrics.js View on Github external
function getMetricsByMinute() {
  const res = http.get(
    `${BASE_URL}/metrics/timeseries/minute?startDate=2017-12-01T10:00:00.000Z&endDate=2017-12-01T11:00:00.000Z`,
    {
      headers: Object.assign(getTestAuthHeaders(), {
        Accept: 'application/json'
      }),
      tags: {
        name: 'All metrics by minute'
      }
    }
  )
  check(res, {
    'status code is 200': r => r.status === 200
  })
}
github jembi / openhim-core-js / performance / volume.js View on Github external
function makeGetRequest() {
  const response = http.get(
    `${BASE_URL}/body`,
    {
      headers: {
        Accept: 'application/json',
        'Accept-Encoding': 'identity',
        Authorization: 'Basic cGVyZm9ybWFuY2U6cGVyZm9ybWFuY2U='
      },
      tags: {
        name: 'Get request'
      }
    }
  )
  check(response, {
    'status code is 200': r => r.status === 200
  })
}