k6 | modern load testing tool , using Go | Continuous Deployment library

 by   k6io Go Version: v0.33.0 License: AGPL-3.0

kandi X-RAY | k6 Summary

kandi X-RAY | k6 Summary

k6 is a Go library typically used in Devops, Continuous Deployment, Nodejs, Docker applications. k6 has no bugs, it has no vulnerabilities, it has a Strong Copyleft License and it has medium support. You can download it from GitHub.

A modern load testing tool for developers and testers in the DevOps era. Download · Install · Documentation · Community. k6 is a modern load testing tool, building on our years of experience in the load and performance testing industry. It provides a clean, approachable scripting API, local and cloud execution, and flexible configuration. This is how load testing should look in the 21st century.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              k6 has a medium active ecosystem.
              It has 12830 star(s) with 639 fork(s). There are 197 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 270 open issues and 865 have been closed. On average issues are closed in 76 days. There are 34 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of k6 is v0.33.0

            kandi-Quality Quality

              k6 has 0 bugs and 0 code smells.

            kandi-Security Security

              k6 has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              k6 code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              k6 is licensed under the AGPL-3.0 License. This license is Strong Copyleft.
              Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.

            kandi-Reuse Reuse

              k6 releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              It has 59169 lines of code, 2291 functions and 359 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of k6
            Get all kandi verified functions for this library.

            k6 Key Features

            No Key Features are available at this moment for k6.

            k6 Examples and Code Snippets

            No Code Snippets are available at this moment for k6.

            Community Discussions

            QUESTION

            Why does gcc -march=znver1 restrict uint64_t vectorization?
            Asked 2022-Apr-10 at 02:47

            I'm trying to make sure gcc vectorizes my loops. It turns out, that by using -march=znver1 (or -march=native) gcc skips some loops even though they can be vectorized. Why does this happen?

            In this code, the second loop, which multiplies each element by a scalar is not vectorised:

            ...

            ANSWER

            Answered 2022-Apr-10 at 02:47

            The default -mtune=generic has -mprefer-vector-width=256, and -mavx2 doesn't change that.

            znver1 implies -mprefer-vector-width=128, because that's all the native width of the HW. An instruction using 32-byte YMM vectors decodes to at least 2 uops, more if it's a lane-crossing shuffle. For simple vertical SIMD like this, 32-byte vectors would be ok; the pipeline handles 2-uop instructions efficiently. (And I think is 6 uops wide but only 5 instructions wide, so max front-end throughput isn't available using only 1-uop instructions). But when vectorization would require shuffling, e.g. with arrays of different element widths, GCC code-gen can get messier with 256-bit or wider.

            And vmovdqa ymm0, ymm1 mov-elimination only works on the low 128-bit half on Zen1. Also, normally using 256-bit vectors would imply one should use vzeroupper afterwards, to avoid performance problems on other CPUs (but not Zen1).

            I don't know how Zen1 handles misaligned 32-byte loads/stores where each 16-byte half is aligned but in separate cache lines. If that performs well, GCC might want to consider increasing the znver1 -mprefer-vector-width to 256. But wider vectors means more cleanup code if the size isn't known to be a multiple of the vector width.

            Ideally GCC would be able to detect easy cases like this and use 256-bit vectors there. (Pure vertical, no mixing of element widths, constant size that's am multiple of 32 bytes.) At least on CPUs where that's fine: znver1, but not bdver2 for example where 256-bit stores are always slow due to a CPU design bug.

            You can see the result of this choice in the way it vectorizes your first loop, the memset-like loop, with a vmovdqu [rdx], xmm0. https://godbolt.org/z/E5Tq7Gfzc

            So given that GCC has decided to only use 128-bit vectors, which can only hold two uint64_t elements, it (rightly or wrongly) decides it wouldn't be worth using vpsllq / vpaddd to implement qword *5 as (v<<2) + v, vs. doing it with integer in one LEA instruction.

            Almost certainly wrongly in this case, since it still requires a separate load and store for every element or pair of elements. (And loop overhead since GCC's default is not to unroll except with PGO, -fprofile-use. SIMD is like loop unrolling, especially on a CPU that handles 256-bit vectors as 2 separate uops.)

            I'm not sure exactly what GCC means by "not vectorized: unsupported data-type". x86 doesn't have a SIMD uint64_t multiply instruction until AVX-512, so perhaps GCC assigns it a cost based on the general case of having to emulate it with multiple 32x32 => 64-bit pmuludq instructions and a bunch of shuffles. And it's only after it gets over that hump that it realizes that it's actually quite cheap for a constant like 5 with only 2 set bits?

            That would explain GCC's decision-making process here, but I'm not sure it's exactly the right explanation. Still, these kinds of factors are what happen in a complex piece of machinery like a compiler. A skilled human can easily make smarter choices, but compilers just do sequences of optimization passes that don't always consider the big picture and all the details at the same time.

            -mprefer-vector-width=256 doesn't help: Not vectorizing uint64_t *= 5 seems to be a GCC9 regression

            (The benchmarks in the question confirm that an actual Zen1 CPU gets a nearly 2x speedup, as expected from doing 2x uint64 in 6 uops vs. 1x in 5 uops with scalar. Or 4x uint64_t in 10 uops with 256-bit vectors, including two 128-bit stores which will be the throughput bottleneck along with the front-end.)

            Even with -march=znver1 -O3 -mprefer-vector-width=256, we don't get the *= 5 loop vectorized with GCC9, 10, or 11, or current trunk. As you say, we do with -march=znver2. https://godbolt.org/z/dMTh7Wxcq

            We do get vectorization with those options for uint32_t (even leaving the vector width at 128-bit). Scalar would cost 4 operations per vector uop (not instruction), regardless of 128 or 256-bit vectorization on Zen1, so this doesn't tell us whether *= is what makes the cost-model decide not to vectorize, or just the 2 vs. 4 elements per 128-bit internal uop.

            With uint64_t, changing to arr[i] += arr[i]<<2; still doesn't vectorize, but arr[i] <<= 1; does. (https://godbolt.org/z/6PMn93Y5G). Even arr[i] <<= 2; and arr[i] += 123 in the same loop vectorize, to the same instructions that GCC thinks aren't worth it for vectorizing *= 5, just different operands, constant instead of the original vector again. (Scalar could still use one LEA). So clearly the cost-model isn't looking as far as final x86 asm machine instructions, but I don't know why arr[i] += arr[i] would be considered more expensive than arr[i] <<= 1; which is exactly the same thing.

            GCC8 does vectorize your loop, even with 128-bit vector width: https://godbolt.org/z/5o6qjc7f6

            Source https://stackoverflow.com/questions/71811588

            QUESTION

            How to convert a decimal into it's time equivalent as part of a function?
            Asked 2022-Mar-26 at 09:48

            I'm running into an issue when trying to compare data across two sheets to find discrepancies - specifically when it comes to comparing start and end times.

            Right now, the "IF" statement in my screenshot is executing perfectly, except when a time is involved - it's reading those cells as decimals instead (but only sometimes).

            I've tried formatting these cells (on the raw data AND on this "Discrepancies" report sheet) so that they are displayed as a "HH:MM am/pm" time, but the sheet is still comparing the decimal values.

            Is there anything that I can add to this function to account for a compared value being a time instead of text, and having that text be compared for any discrepancies? I cannot add or change anything to the raw data sheets, the only thing I can edit is the formula seen in the screenshot I provided.

            See the highlighted cells in my screenshot - this is the issue I keep running into. As you can see, there are SOME cells (the non-highlighted ones) that are executing as intended, but I'm unsure why this isn't the case for the whole spreadsheet when I've formatted everything the same way using the exact same formula across the whole sheet.

            For example, the values in cell N2 is "8:00 AM" on both sheets, so the formula should just display "8:00 AM" in that cell (and NOT be highlighted) since there is no discrepancy in the cells between both sheets it's comparing. But instead, it's showing both times as a decimal with the slightest difference between them and is suggesting a difference where there technically isn't (or shouldn't be) one.

            Please help!

            Screenshot of original spreadsheet for reference

            ---EDIT (added the below):

            Here is a view-only version of a SAMPLE SHEET that displays the issue I'm having: https://docs.google.com/spreadsheets/d/1BdSQGsCajB3kOnYxzM3sl-0o3iTvR3ABdHpnzYRXjpA/edit?usp=sharing

            On the sample sheet, the only cells that are performing as intended are C2, E2, G2, I2, K2, K6, or any cells that contain text like "Closed". Any of the other cells that have a time in both raw data tabs appears to be pulling the serial numbers for those times instead of correctly formatting it into "HH:mm AM/PM".

            A quick tour of how the SAMPLE SHEET is set up:

            1. User enters raw data into the "MicrositeRawData" and "SalesforceRawData" tabs.
            2. Data is pulled from the "SalesforceRawData" tab into the "CleanedUpSalesforceData" tab using a QUERY that matches the UNIQUE ID's from the "MicrositeRawData" sheet, so that it essentially creates a tab that's in the same order and accounts for any extraneous data between the tabs (keep in mind this is a sample sheet and that the original sheet I'm using includes a lot more data which causes a mismatch of rows between the sheets which makes the QUERY necessary).
            3. The "DISCREPANCIES" tab then compares the data between the "MicrositeRawData" and "CleanedUpSalesforceData" tabs. If the data is the same, it simply copies the data from the "MicrositeRawData" cell. But if the data is NOT the same, it lists the values from both sheets and is conditionally formatted to highlight those cells in yellow.
            4. If there is data on the "MicrositeRawData" tab that is NOT included on the "SalesforceRawData" tab, the "DISCREPANCIES" tab will notate that and highlight the "A" cell in pink instead of yellow (as demonstrated in "A5").
            ...

            ANSWER

            Answered 2022-Mar-26 at 09:48

            QUESTION

            How to drag data to next line?
            Asked 2022-Mar-14 at 07:47

            Good afternoon,

            I have a table where column A has the customer's data and column B has the customer's name. In columns C to L have the invoice information for that customer. I would like to get a vba code for when there is data in column A and B, create a row above the total and drag 1 row down the invoice information, looking like this:

            A2 and B2 with the customer's code and name;

            C3:L8 with customer invoice information;

            Line nine: Total line (I already have this code)

            ...

            ANSWER

            Answered 2022-Mar-14 at 07:47

            Before you read this keep in mind the last time i actively programmed is like 4 years ago. Means the code is messy, not optimized, blah blah blah

            So as requested to get a list like this:

            to a format like this:

            you can use the following code snippet. The "CommandButton1_Click()" function is only there because I use it as my trigger from a userform. the "adjustList" method can be called from wherever you like.

            Basically I read all the customer data blocks into two dimensional arrays and clear the cells. After all entries are collected in the array and all cells are clear i write the data into the cells again with the requested format.

            Also as requested this function can handle entries independent of how many rows they contain per customer, as shown in my screenshots.

            Source https://stackoverflow.com/questions/71425972

            QUESTION

            How to run curl commands with k6 docker image in gitlab yml
            Asked 2022-Mar-09 at 09:42

            I want to run a curl request as a pre-request script for my K6 load tests. Here is my YML file:

            ...

            ANSWER

            Answered 2022-Mar-09 at 09:42

            The k6 Docker image runs as an unprivileged user, which is why you're not able to install curl and jq.

            I would suggest you to build your own custom image using loadimpact/k6 as base, or to build an image from another base that copies the k6 binary with COPY --from=loadimpact/k6:latest /usr/bin/k6 /usr/bin/k6, install anything you need in it and run that image in CI instead.

            Source https://stackoverflow.com/questions/71398895

            QUESTION

            Fast CRC with PCLMULQDQ *NOT* reflected
            Asked 2022-Mar-07 at 15:47

            I'm trying to write a PCLMULQDQ-optimized CRC-32 implementation. The specific CRC-32 variant is for one that I don't own, but am trying to support in library form. In crcany model form, it has the following parameters:

            width=32 poly=0xaf init=0xffffffff refin=false refout=false xorout=0x00000000 check=0xa5fd3138 (Omitted residue which I believe is 0x00000000 but honestly don't know what it is)

            A basic non-table-based/bitwise implementation of the algorithm (as generated by crcany) is:

            ...

            ANSWER

            Answered 2022-Mar-07 at 15:47

            I have 6 sets of code for 16, 32, 64 bit crc, non-reflected and reflected here. The code is setup for Visual Studio. Comments have been added to the constants which were missing from Intel's github site.

            https://github.com/jeffareid/crc

            32 bit non-relfected is here:

            https://github.com/jeffareid/crc/tree/master/crc32f

            You'll need to change the polynomial in crc32fg.cpp, which generates the constants. The polynomial you want is actually:

            Source https://stackoverflow.com/questions/71328336

            QUESTION

            How to wait first post issue and use while loop in k6 load test scripts?
            Asked 2022-Feb-19 at 11:38

            I have two post request. This post request should run until the response is "createdIsCompleted" == false .I m taking createdIsCompleted response from second post isssue. So how can I run two requests in while loop. By the way, I have to wait first post issue before the second post issue should be run...I know there is no await operator in k6. But I want to learn alternative ways. This while loop not working as I want. The response still returns "createdIsCompleted" == true

            ...

            ANSWER

            Answered 2022-Feb-19 at 11:38

            By the way, I have to wait first post issue before the second post issue should be run...I know there is no await operator in k6

            K6 currently has only blocking calls so each post will finish fully before the next one starts.

            On the loop question you have two(three) problems:

            • createdISCompleted is unitialized, so the while loop will never be run as it's not false.
            • you have big S in the declaration but then you have small s in the while loop.
            • you have break at the end of the loop which means it will always exit after the first iteration.

            Source https://stackoverflow.com/questions/71183857

            QUESTION

            Excel formula to split an amount per year depending on expenditure days within a date range
            Asked 2022-Jan-24 at 22:32

            I am in the process of building a formula to split a total cost (in column J) based on start and end expenditure periods that can vary from 2021 to 2031. Based on the days between the expenditure period dates (column M), I managed to work out to split the cost using the formulas below up to 2023 but it is not consistent and at times incorrect.

            In cell P5 I have the following formula. For year 2021, I seem to get the correct split result. =IF($K5>AS5,0,$J5/$M5*(AS5-$K5))

            In cell Q5, I have the following formula. For year 2022, I seem to get the correct spit as well =MIN(IF(SUM($N5:P5)>=$J5,0,IF($L5>=AS5,$J5/$M5*(AS5-AR5),$J5/$M5*($L5-MAX(AR5,$K5)))),K5)

            However, I don't get the right result in cell Q6 which has the same formula but different dates =MIN(IF(SUM($N6:P6)>=$J6,0,IF($L6>=AS6,$J6/$M6*(AS6-AR6),$J6/$M6*($L6-MAX(AR6,$K6)))),K6)

            Cell R6 shouldn't return any result because it is out of date range. This is where things get mixed up.

            Note that from column AR to BC, it is all year end dates from 2020 to 2031 as shown below.

            Is there a better way to tackle this sort of formula as I seem to get dragged into a long and unreliable way of doing this.

            ...

            ANSWER

            Answered 2022-Jan-24 at 22:32

            Here single function(♣) that will create a series of pro-rata multipliers (of appropriate length) for any given start/end date:

            EDIT: see end of soln for extended version per OP comment to original soln...

            SINGLE FUNCTION

            Source https://stackoverflow.com/questions/70814384

            QUESTION

            k6 redirects localhost to loopback
            Asked 2022-Jan-21 at 09:08

            I'm on a Mac and I'm attempting to run my k6 script against http://localhost:4200 (angular app) locally.

            The angular app is running and I can access it via the browser and using curl.

            My k6 script has the base URL set to http://localhost:4200. However, all requests are being made to http://127.0.0.1:4200 instead which is denied by MacOS.

            How do I force k6 to NOT rewrite localhost to the loopback address?

            EDIT

            Adding various outputs of curl -vv.

            localhost:4200

            ...

            ANSWER

            Answered 2022-Jan-21 at 06:45

            There is no application listening on port 4200 for your IPv4 address 127.0.0.1. 127.0.0.1 is the IPv4 loopback address. When k6 makes a request to localhost, this hostname resolves to the IPv4 127.0.0.1.

            However, your application seems to be listening on port 4200 for your IPv6 address ::1. ::1 is the IPv6 loopback address. curl resolves the hostname localhost to its IPv6 address.

            How are you binding your application to the port? Usually, when binding to all interfaces of a host, you'd use the special IP address 0.0.0.0.

            I see a potential solutions:

            • Make your application bind to IPv4 and IPv6, usually done by binding to address 0.0.0.0.
            • Change your k6 script to connect to IPv6 ::1 directly
            • Specify --dns "policy=preferIPv6" or add dns:{policy:"preferIPv6"} to your options (since 0.29.0)
            • Disable IPv6 in your OS. This is a drastic change and I wouldn't recommend it
            • Change your hosts file to resolve localhost to the IPv4 address

            Source https://stackoverflow.com/questions/70749407

            QUESTION

            k6 how to restart testing service between scenarios
            Asked 2021-Dec-21 at 19:09

            I am running a load test with k6, which tests my service with 6 scenarios. I am running my service with docker-compose and I want to restart my service between each scenario. I couldn't find a built-in method for this so I added a function to restart the service and added some code to call that function at the start of each scenario ( I declared a counter for each scenario with initial value 0 and call the restart function only when the counter is 1). but the function is getting called per VU, not as I expected. Is there any solution for this?

            Thanks in advance

            ...

            ANSWER

            Answered 2021-Dec-21 at 19:09

            It sounds like you are not executing the scenarios in parallel (as I would expect from k6 scenarios), but rather in sequence.

            There isn't anything builtin in k6, but why not have a simple shell script which performs the following steps in order:

            Source https://stackoverflow.com/questions/70430947

            QUESTION

            error pops on run cmd: K6_PROMETHEUS_REMOTE_URL=http://172.21.2.29:9090/api/v1/write ./k6 run main_smoke_test.js -o output-prometheus-remote
            Asked 2021-Dec-05 at 10:50

            I installed k6 v0.35.0, go 1.17.3, xk6@latest, Prometheus 2.32.0-beta.0, xk6-output-prometheus-remote@latest, and try to run k6 script, but I got below error:

            error image

            I want to know whether k6 open source can save test result in Prometheus?

            ...

            ANSWER

            Answered 2021-Dec-05 at 10:50

            You are trying to execute a command with syntax used in Linux/POSIX shells in Microsoft's PowerShell. PowerShell uses different syntax to set environment variables for commands.

            To set an environment variable in PowerShell, you have to execute a separate command before running your actual command.

            Source https://stackoverflow.com/questions/70181086

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install k6

            If there isn't an official package for your operating system or architecture, or if you don't want to install a custom repository, you can easily grab a pre-built binary from the GitHub Releases page. Once you download and unpack the release, you can optionally copy the k6 binary it contains somewhere in your PATH, so you are able to run k6 from any location on your system.
            k6 is written in Go, so it's just a single statically-linked executable and very easy to build and distribute. To build from source you need Git and Go (1.16 or newer). Follow these instructions:.
            Run go get go.k6.io/k6 which will: git clone the repo and put the source in $GOPATH/src/go.k6.io/k6 build a k6 binary and put it in $GOPATH/bin
            Make sure you have $GOPATH/bin in your PATH (or copy the k6 binary somewhere in your PATH), so you are able to run k6 from any location.
            Tada, you can now run k6 using k6 run script.js
            Beyond the init code and the required VU stage (i.e. the default function), which is code run for each VU, k6 also supports test wide setup and teardown stages, like many other testing frameworks and tools. The setup and teardown functions, like the default function, need to be exported. But unlike the default function, setup and teardown are only called once for a test - setup() is called at the beginning of the test, after the init stage but before the VU stage (default function), and teardown() is called at the end of a test, after the last VU iteration (default function) has finished executing. This is also supported in the distributed cloud execution mode via k6 cloud.

            Support

            To get help about usage, report bugs, suggest features, and discuss k6 with other users see SUPPORT.md.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/k6io/k6.git

          • CLI

            gh repo clone k6io/k6

          • sshUrl

            git@github.com:k6io/k6.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link