grafana / k6 Goto Github PK
View Code? Open in Web Editor NEWA modern load testing tool, using Go and JavaScript - https://k6.io
License: GNU Affero General Public License v3.0
A modern load testing tool, using Go and JavaScript - https://k6.io
License: GNU Affero General Public License v3.0
Based on experience with current load generator scripting we know users have a need to customize the HTTP client behavior, this card details what options we need.
HTTP Options (set globally)
HTTP options (local, request functions)
Imported from https://trello.com/c/5ISLT75I/115-http-options
check("name", () => /* ... */);
Imported from https://trello.com/c/jW4KQLOw/109-simplified-one-check-syntax
export let options = {
thresholds: {
http_req_duration: ["avg<=100"], // 100ms
}
}
Imported from https://trello.com/c/rD9GoW9R/103-thresholds
After playing around with remote controlling k6 from another process I've discovered some things that's missing or would ease the integration considerably.
v1/quit
?) to kill speedboat when it's time to stop the test and tear down output plugins and similar.v1/run
endpoint that would work as we discussed earlier. This would be the way to send the javascript scenario + config in a POST-request to a process started in a way as described above.These are thoughts based on last weeks testing/discovery coding and are not finalized suggestions. Hoping for a good discussion.
The interface for streaming metrics to the cloud services seems to match the intended use of output plugins. It might not be a 100% match, which is why we need to discuss it further (here). Some points to clarify:
Authentication. I'm thinking the plugin can look for credentials in a file or in environment variables, like tools interacting with AWS do.
How do we transport the data most effectively? Client-to-cloud streaming (chunking in HTTP/1 parlance), periodic batching with POST requests or something I don't know about in HTTP/2?
Imported from https://trello.com/c/0Rzly0xL/90-output-plugin-kcs-metrics-streaming
Imported from https://trello.com/c/82UnP6nB/96-module-crypto
Started testing Speedboat now and are writing things down as I go. It's both questions and suggestions in a mix.
Since I'm not that involved in the project many of the things might be already known.
So far I've tested the Docker case and will continue with running Speedboat using go
on the system and add thoughts about that as well.
import { test } from 'speedboat'
should be import { check } ...
?"For more information, see the included tutorials."
)docker run --net=host -v /path/to/local/test_file.js:/load_test.js loadimpact/speedboat run /load_test.js
options like -d 0 / --duration 0
is converted to 0 seconds
and the tests quits immediately.--net=host
does not work the same way when running Docker on Mac you'll need to expose the ports manually using the -p
flag.
-p 6565:6565
, -d 60s
and navigated to http://127.0.0.1:6565
and get a "Site cannot be reached" error in Chrome.Side note: Installed Go on OSX using binary .pkg installer
$GOPATH/src/github.com/loadimpact/speedboat
and trying to run make
/make build
I'll have to manually install some go libs:
0
gives panic error panic: runtime error: makeslice: len out of range ] 0s / 0s
Manipulation API
Traversal API
Misc API
Imported from https://trello.com/c/1XvRjs9A/89-implement-more-of-the-jquery-api
Imported from https://trello.com/c/NiS6gUHI/108-unit-tests
Imported from https://trello.com/c/oGjjQIP3/114-colors
Right now, the simple
runner will error all outstanding requests, while the js
runner can ignore it (imagine if someone did a while(true) {}
…)
Imported from https://trello.com/c/5Ehq1Qi0/122-handle-context-cancellation-better
We need some good, instructive and functional script examples
Imported from https://trello.com/c/Ft2pGnSe/93-scripting-examples
Checklist
Imported from https://trello.com/c/cNVU86AL/110-ssl-support-and-auth-for-the-api
We need a (Slate-powered?) reference documentation for the scripting API
Imported from https://trello.com/c/ixpCG8LD/95-script-api-reference
Right now, we don't process tags locally inside k6 - it'd mean duplicating data for every possible combination of tags, which would result in an unreasonable amount of RAM usage for longer tests, especially tests containing a lot of URLs.
Unfortunately, this means thresholds become limited to querying full metrics, which isn't a useful level of granularity for many use cases.
The current workaround is to declare custom metrics, copy samples off requests into these, and set thresholds on these metrics instead:
let res = http.get("...");
myMetric.add(res.timings.duration);
check(res, {
"status is 200": (res) => res.status === 200,
})
While this produces correct results, I don't like this approach, because:
It's verbose. Gone is the elegant simplicity of:
check(http.get("..."), {
"status is 200": (res) => res.status === 200,
});
It clutters the output with useless metrics. Bad for UX. We could make a way to mark metrics as "hidden" here (perhaps by prefixing the name with an _
or something of the sort), but more importantly...
It encourages users to resort to the seemingly simpler solution of:
check(http.get("..."), {
"status is 200": (res) => res.status === 200,
"time is <100ms": (res) => res.timings.duration < 1000,
})
Coupled with a raised -a
/--acceptance
, this may produce seemingly correct results with a single k6 instance. However:
-a
/--acceptance
is a blunt instrument. It silences all failures up to a certain point, and is meant to cover for sporadic errors or dropped packets. Outliers in performance are by nature more common, and tuning acceptance up to cover for this will bury legitimate issues with the application being tested.-a
/--acceptance
, thus perpetuating the above. Thresholds don't have this problem, as they are by nature distributed, and can work against a database.Don't encourage users to shoot themselves in the foot.
What I want to do is to instantiate submetrics or derived metrics, using an InfluxDB-like syntax to filter out only certain tags. Let's assume we're using a parameter to http.<method>()
to add the "kind" tag to requests that should be special-cased - for instance, a login endpoint.
export let options = {
thresholds: {
"http_req_duration{kind:}": "avg <= 100",
"http_req_duration{kind:login}": "avg <= 1000",
}
}
With these two thresholds set, the engine will figure out to create two hidden metrics called http_req_duration{kind:}
(where sample.Tags["kind"] == ""
) and http_req_duration{kind:login}
(where sample.Tags["kind"] == "login"
). No explicit custom metrics required.
Feedback from engineering candidate Diego:
I seem to be running into problems when trying to interact with the v1 API, which in turn seems to cause the Ember front-end to display a "An error occurred." message.
It looks like all requests on the v1 API seem to be failing - both trying to fetch http://127.0.0.1:6565/v1/xxx and k6 commands that rely on the endpoints (for example "$ k6 stats") raise a panic on the lingering k6 instance. My scenario would be:
1) launching a k6 run for a script, pausing it when completes via the
lingering flag:
$ docker run --rm --net=host -v /tmp/scripts/localhost.js:/myscript.js loadimpact/k6:latest run -u 1 -d 1s -l /myscript.js
(execution is fine - http requests are made, etc and pauses when the specified amount of time passed)
2) launching a request for the v1 api, via HTTP or command
2.1) launch another command on another shell (ex. stats)
-----
$ docker run --rm --net=host loadimpact/k6:latest stats
time="2016-12-17T15:26:47Z" level=error msg=Error error="unexpected end of JSON input"
unexpected end of JSON input
2.2) panic on the other shell with the k6 run
2016/12/17 15:26:47 [Recovery] panic recovered:
GET /v1/metrics HTTP/1.1
Host: 127.0.0.1:6565
Accept-Encoding: gzip
User-Agent: Go-http-client/1.1
interface conversion: interface {} is nil, not *lib.Engine
/usr/local/go/src/runtime/panic.go:458 (0x431883)
gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/usr/local/go/src/runtime/iface.go:201 (0x414c2f)
panicdottype: panic(&TypeAssertionError{iface.string(), haveString, want.string(), ""})
/go/src/github.com/loadimpact/k6/api/common/context.go:37 (0x59151e)
GetEngine: return ctx.Value(ctxKeyEngine).(*lib.Engine)
(...)
Along with launch of k6.io marketing site, we want to plug in a developer-friendly, inviting and useful documentation framework.
Let's start by discussing our options in terms of good and potential frameworks to leverage. What other open source projects or public documentation will be useful as reference to model our site from?
Checklist
Imported from https://trello.com/c/GKPwLLr1/120-hosted-k6-documentation
Different metric types have different variables. Right now, we're just setting inactive variables to null
, but that means you can do avg<0.5
for rate metric by accident and get a threshold that always silently fails if there's also a threshold on a trend metric defined in your test.
Imported from https://trello.com/c/EkSvX9rr/112-separate-threshold-vms-by-metric-type
Imported from https://trello.com/c/ne1YecF8/126-custom-metrics
Right now, every runner has its own HTTP client code, including separate, identical requests
and errors
metrics + submission code for them.
Initial response duration spikes are collected at least when testing loadimpact.com.
Imported from https://trello.com/c/mSdpLjRd/117-dns-lookup-produces-duration-spike
JS-file:
import { Counter, Rate } from "k6/metrics";
import http from "k6/http";
import https from "jadaja/http";
:
:
:
yields:
time="2016-12-01T22:15:55Z" level=error msg="Couldn't create a runner" error="Error: open /go/src/github.com/loadimpact/k6/js/lib/jadaja/http.js: no such file or directory"
Error: open /go/src/github.com/loadimpact/k6/js/lib/jadaja/http.js: no such file or directory
Davids-MacBook:samples davidrosen$
when file jadaja/http.js
is missing.
Imported from https://trello.com/c/MX84A4Jp/111-improved-error-message-when-missing-import-file
This needs to be fixed and merged before we can release: robertkrimen/otto#205
We CANNOT release with a hard dependency on an external binary + a Node runtime.
Imported from https://trello.com/c/eG7k6Is3/91-get-otto-pull-205-merged
All these zeroes in http_req_connecting
…
Checklist
Imported from https://trello.com/c/r24TQPLf/105-better-flow-control-for-test-scripts
This one:
// To protect against directory traversal, prevent loading of files outside the root (pwd) dir
Why? Because above all it makes using the app harder
There are also other arguments against it:
Are we aiming to make an app that is safe from local exploits? That is a tall order. Right now, there are likely other, equally serious local exploits that we would have to start working on, if our aim is to provide a "secure" app. I question whether this feature alone makes much of a difference to a determined attacker. I think it is much better to avoid all security concerns inside our app and focus on the core functionality of generating traffic and measuring stuff.
There exists simple-to-use external functionality that provides the same level of security, or better (chroot).
The WIP document specifying the protocol/API:
https://loadimpact.quip.com/08WVAPpFVbfG
Tasks
Imported from https://trello.com/c/QbNxMPku/98-spec-api-for-cloud-integration
https://www.w3.org/TR/hr-time/
Checklist
Imported from https://trello.com/c/6wyslOop/121-implement-window-performance
Imported from https://trello.com/c/wRUf1Gbf/101-rework-cli-ui-ux
Needed to handle display in the web UI
Imported from https://trello.com/c/ABerXvwQ/123-tag-metrics-with-groups
After playing around with remote controlling k6 from another process I've discovered some things that's missing or would ease the integration considerably.
v1/quit
?) to kill speedboat when it's time to stop the test and tear down output plugins and similar.v1/run
endpoint that would work as we discussed earlier. This would be the way to send the javascript scenario + config in a POST-request to a process started in a way as described above.These are thoughts based on last weeks testing/discovery coding and are not finalized suggestions. Hoping for a good discussion.
Imported from https://trello.com/c/G5sdTlC4/86-full-k6-control-from-api
We need something that can be deterministically issued across multiple processes - no race conditions.
Imported from https://trello.com/c/AQNHjdUI/107-make-group-ids-uuids-or-something
We need a way to define test stages with VU ramps. Should be exposed as a timeline in the API, and a loop in the engine should continously work the current state towards the desired state.
Imported from https://trello.com/c/rD7ZdNyy/125-implement-stages
Imported from https://trello.com/c/0TkNzbgC/119-look-into-source-maps
Metrics
Tags
Imported from https://trello.com/c/x0XHOp8D/106-more-built-in-metrics
Create installers and packages that make it simple to install k6 for a large set of users
Imported from https://trello.com/c/rrMtv2Op/92-installers-packaging
I accidentally let a commit that removes the static file serving into develop, adding it back ASAP.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.