Skip to content

Commit

Permalink
Merge branch 'master' into new-schedulers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić authored and imiric committed Mar 9, 2020
1 parent 9cb4ed0 commit d1f14a3
Show file tree
Hide file tree
Showing 31 changed files with 353 additions and 183 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
deps:
docker:
- image: circleci/golang:1.13
- image: circleci/golang:1.14
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand All @@ -23,7 +23,7 @@ jobs:
test:
docker:
- image: circleci/golang:1.13
- image: circleci/golang:1.14
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
test-prev-golang:
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.13
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand All @@ -67,7 +67,7 @@ jobs:
build-docker-images:
docker:
- image: circleci/golang:1.13
- image: circleci/golang:1.14
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
build-linux-packages:
docker:
- image: circleci/golang:1.13
- image: circleci/golang:1.14
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand Down
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Use this template for reporting bugs. Please search existing issues first.
labels: bug
---

<!--- Provide a general summary of the issue in the Title above -->

## Environment
<!--- Provide as much information about your environment as possible: output from `k6 version`,
OCI runtime and image information if using containers, cloud execution environment, etc. -->
- k6 version:
- OS and version:
- Docker version and image, if applicable:


## Expected Behavior
<!--- Tell us what should happen -->


## Actual Behavior
<!--- Tell us what happens instead of the expected behavior -->


## Steps to Reproduce the Problem
<!--- Provide the exact commands, environment variables and relevant script(s) to reproduce this bug. -->

1.
2.
3.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: k6 Community Forum
url: https://community.k6.io/
about: Please ask and answer questions here.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feat_req.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Use this template for suggesting new features.
labels: feature
---

<!--- Provide a general summary of the feature in the Title above -->

## Feature Description
<!--- Describe the feature in detail: what benefits it would have, which problem it would solve, use cases, examples, etc. -->


## Suggested Solution (optional)
<!--- Any implementation suggestions you might have: technical details, design tradeoffs, API proposals, etc. -->
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ RUN apk --no-cache add git
RUN CGO_ENABLED=0 go install -a -trimpath -ldflags "-s -w -X github.com/loadimpact/k6/lib/consts.VersionDetails=$(date -u +"%FT%T%z")/$(git describe --always --long --dirty)"

FROM alpine:3.10
RUN apk add --no-cache ca-certificates
RUN apk add --no-cache ca-certificates && \
adduser -D -u 12345 -g 12345 k6
COPY --from=builder /go/bin/k6 /usr/bin/k6

USER 12345
ENTRYPOINT ["k6"]
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 48 additions & 51 deletions README.md

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Support

Types of questions and where to ask:

- How do I? -- the Discourse forum at [community.k6.io](https://community.k6.io/) or [Stack Overflow](https://stackoverflow.com/questions/tagged/k6) (use tags: k6, javascript, load-testing)
- I got this error, why? -- [community.k6.io](https://community.k6.io/) or [Stack Overflow](https://stackoverflow.com/questions/tagged/k6)
- I got this error and I'm sure it's a bug -- [open a new issue](https://github.com/loadimpact/k6/issues), if there isn't one for this specific bug already
- I have an idea/request -- search the [GitHub issues](https://github.com/loadimpact/k6/issues) to see if it was already requested and give the issue a :+1: if so. If it wasn't, search [community.k6.io](https://community.k6.io/) or post a forum thread to discuss the idea with the developers before creating a GitHub issue.
- Why do you? -- [community.k6.io](https://community.k6.io/) or [Slack](https://k6.io/slack)
- When will you? -- [community.k6.io](https://community.k6.io/) or [Slack](https://k6.io/slack)

If your questions are about any of the commercial Load Impact services like managed cloud execution and Load Impact Insights, you can contact <[email protected]> or write in the `#loadimpact` channel in [Slack](https://k6.io/slack).
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
# specific to go
VERSION: "%APPVEYOR_REPO_TAG_NAME:v=%"
GOPATH: c:\gopath
GOVERSION: 1.13
GOVERSION: 1.14
GOMAXPROCS: 2
CGO_ENABLED: '0'
GOARCH: amd64
Expand Down
2 changes: 1 addition & 1 deletion cmd/login_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ This will set the default token used when just "k6 run -o cloud" is passed.`,
}

if res.Token == "" {
return errors.New(`Your account has no API token, please generate one: "https://app.loadimpact.com/account/token".`)
return errors.New(`your account has no API token, please generate one at https://app.k6.io/account/api-token`)
}

newCloudConf.Token = null.StringFrom(res.Token)
Expand Down
Binary file added github-hr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion js/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ func (b *Bundle) instantiate(rt *goja.Runtime, init *InitContext) error {
_ = module.Set("exports", exports)
rt.Set("module", module)

rt.Set("__ENV", b.Env)
env := make(map[string]string, len(b.Env))
for key, value := range b.Env {
env[key] = value
}
rt.Set("__ENV", env)
rt.Set("console", common.Bind(rt, newConsole(), init.ctxPtr))

*init.ctxPtr = common.WithRuntime(context.Background(), rt)
Expand Down
42 changes: 42 additions & 0 deletions js/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,48 @@ func TestBundleEnv(t *testing.T) {
}
}

func TestBundleNotSharable(t *testing.T) {
data := `
export default function() {
if (__ITER == 0) {
if (typeof __ENV.something !== "undefined") {
throw new Error("invalid something: " + __ENV.something + " should be undefined");
}
__ENV.something = __VU;
} else if (__ENV.something != __VU) {
throw new Error("invalid something: " + __ENV.something+ " should be "+ __VU);
}
}
`
b1, err := getSimpleBundle("/script.js", data)
if !assert.NoError(t, err) {
return
}

b2, err := NewBundleFromArchive(b1.makeArchive(), lib.RuntimeOptions{})
if !assert.NoError(t, err) {
return
}

bundles := map[string]*Bundle{"Source": b1, "Archive": b2}
vus, iters := 10, 1000
for name, b := range bundles {
b := b
t.Run(name, func(t *testing.T) {
for i := 0; i < vus; i++ {
bi, err := b.Instantiate()
bi.Runtime.Set("__VU", i)
require.NoError(t, err)
for j := 0; j < iters; j++ {
bi.Runtime.Set("__ITER", j)
_, err := bi.Default(goja.Undefined())
assert.NoError(t, err)
}
}
})
}
}

func TestBundleMakeArchive(t *testing.T) {
testCases := []struct {
cm lib.CompatibilityMode
Expand Down
2 changes: 1 addition & 1 deletion js/modules/k6/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (h *HTTP) parseBatchRequest(
}

case map[string]interface{}:
// Handling of {method: "GET", url: "http://test.loadimpact.com"}
// Handling of {method: "GET", url: "https://test.k6.io"}
if murl, ok := data["url"]; !ok {
return nil, fmt.Errorf("batch request %q doesn't have an url key", key)
} else if reqURL, err = ToURL(murl); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions js/modules/k6/http/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ func checkErrorCode(t testing.TB, tags *stats.SampleTags, code int, msg string)
if msg == "" {
assert.False(t, ok)
} else {
assert.Equal(t, msg, errorMsg)
assert.Contains(t, errorMsg, msg)
}
errorCodeStr, ok := tags.Get("error_code")
if code == 0 {
Expand Down Expand Up @@ -1693,7 +1693,7 @@ func TestErrorCodes(t *testing.T) {
{
name: "Bad location redirect",
expectedErrorCode: 1000,
expectedErrorMsg: "failed to parse Location header \"h\\t:/\": parse h\t:/: net/url: invalid control character in URL", //nolint: lll
expectedErrorMsg: "failed to parse Location header \"h\\t:/\": ",
script: `let res = http.request("GET", "HTTPBIN_URL/bad-location-redirect");`,
},
{
Expand Down Expand Up @@ -1730,7 +1730,7 @@ func TestErrorCodes(t *testing.T) {
_, err := common.RunString(rt,
sr(testCase.script+"\n"+fmt.Sprintf(`
if (res.status != %d) { throw new Error("wrong status: "+ res.status);}
if (res.error != %q) { throw new Error("wrong error: '" + res.error + "'");}
if (res.error.indexOf(%q, 0) === -1) { throw new Error("wrong error: '" + res.error + "'");}
if (res.error_code != %d) { throw new Error("wrong error_code: "+ res.error_code);}
`, testCase.status, testCase.expectedErrorMsg, testCase.expectedErrorCode)))
if testCase.expectedScriptError == "" {
Expand Down
5 changes: 4 additions & 1 deletion js/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ func (r *Runner) newVU(samplesOut chan<- stats.SampleContainer) (*VU, error) {
vu.Runtime.Set("console", common.Bind(vu.Runtime, vu.Console, vu.Context))
common.BindToGlobal(vu.Runtime, map[string]interface{}{
"open": func() {
common.Throw(vu.Runtime, errors.New("\"open\" function is only available to the init code (aka global scope), see https://docs.k6.io/docs/test-life-cycle for more information"))
common.Throw(vu.Runtime, errors.New(
`The "open()" function is only available to init code (aka the global scope), see `+
` https://k6.io/docs/using-k6/test-life-cycle for more information`,
))
},
})

Expand Down
16 changes: 9 additions & 7 deletions js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ func testSetupDataHelper(t *testing.T, data string) {
})
}
}

func TestSetupDataReturnValue(t *testing.T) {
testSetupDataHelper(t, `
export let options = { setupTimeout: "1s", teardownTimeout: "1s" };
Expand Down Expand Up @@ -410,6 +411,7 @@ func TestSetupDataNoReturn(t *testing.T) {
}
};`)
}

func TestRunnerIntegrationImports(t *testing.T) {
t.Run("Modules", func(t *testing.T) {
modules := []string{
Expand Down Expand Up @@ -513,7 +515,7 @@ func TestVURunContext(t *testing.T) {
}

func TestVURunInterrupt(t *testing.T) {
//TODO: figure out why interrupt sometimes fails... data race in goja?
// TODO: figure out why interrupt sometimes fails... data race in goja?
if isWindows {
t.Skip()
}
Expand Down Expand Up @@ -550,7 +552,7 @@ func TestVURunInterrupt(t *testing.T) {
}

func TestVURunInterruptDoesntPanic(t *testing.T) {
//TODO: figure out why interrupt sometimes fails... data race in goja?
// TODO: figure out why interrupt sometimes fails... data race in goja?
if isWindows {
t.Skip()
}
Expand Down Expand Up @@ -582,7 +584,7 @@ func TestVURunInterruptDoesntPanic(t *testing.T) {
for i := 0; i < 1000; i++ {
wg.Add(1)
newCtx, newCancel := context.WithCancel(ctx)
var ch = make(chan struct{})
ch := make(chan struct{})
go func() {
defer wg.Done()
close(ch)
Expand Down Expand Up @@ -878,7 +880,7 @@ func TestVUIntegrationHosts(t *testing.T) {
}

func TestVUIntegrationTLSConfig(t *testing.T) {
var unsupportedVersionErrorMsg = "remote error: tls: handshake failure"
unsupportedVersionErrorMsg := "remote error: tls: handshake failure"
for _, tag := range build.Default.ReleaseTags {
if tag == "go1.12" {
unsupportedVersionErrorMsg = "tls: no supported versions satisfy MinVersion and MaxVersion"
Expand Down Expand Up @@ -1009,11 +1011,11 @@ func TestVUIntegrationOpenFunctionError(t *testing.T) {
vu, err := r.NewVU(make(chan stats.SampleContainer, 100))
assert.NoError(t, err)
err = vu.RunOnce(context.Background())
assert.EqualError(t, err, "GoError: \"open\" function is only available to the init code (aka global scope), see https://docs.k6.io/docs/test-life-cycle for more information")
assert.Error(t, err)
assert.Contains(t, err.Error(), "only available to init code")
}

func TestVUIntegrationCookiesReset(t *testing.T) {

tb := httpmultibin.NewHTTPMultiBin(t)
defer tb.Cleanup()

Expand Down Expand Up @@ -1312,7 +1314,7 @@ func TestHTTPRequestInInitContext(t *testing.T) {
}

func TestInitContextForbidden(t *testing.T) {
var table = [...][3]string{
table := [...][3]string{
{
"http.request",
`import http from "k6/http";
Expand Down
2 changes: 1 addition & 1 deletion lib/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// Version contains the current semantic version of k6.
var Version = "0.26.0" //nolint:gochecknoglobals
var Version = "0.26.1" //nolint:gochecknoglobals

// VersionDetails can be set externally as part of the build process
var VersionDetails = "" // nolint:gochecknoglobals
Expand Down
2 changes: 1 addition & 1 deletion loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var (
`local directory (-v /local/path/:/inside/docker/path) containing ` +
`your script and modules so that they're accessible by k6 from ` +
`inside of the container, see ` +
`https://docs.k6.io/v1.0/docs/modules#section-using-local-modules-with-docker.`
`https://k6.io/docs/using-k6/modules#using-local-modules-with-docker`
errNoLoaderMatched = errors.New("no loader matched")
)

Expand Down
Binary file removed logo.png
Binary file not shown.
1 change: 1 addition & 0 deletions logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions release notes/v0.26.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
k6 v0.26.1 is here! This is a minor release that supports the rebranding of LoadImpact to k6, the new [k6.io website](https://k6.io/), and the new [k6 cloud service](https://k6.io/cloud)! :tada:

In practical terms, all that it means for k6 is that the URLs for cloud tests will point to https://app.k6.io, instead of https://app.loadimpact.com. The old URLs (and old k6 versions) will still continue to work - for the next 3 months the old app and the new one would work in parallel, and after that period the old app will redirect to the new one. Nothing changes in regards to the k6 open source project and our commitment to it!

You can find more information about the rebranding in our blog post about it: https://k6.io/blog/load-impact-rebranding-to-k6

# Changes in this release compared to v0.26.0:

* Fix how HTTP request timeouts are specified internally. This is not a bug in current k6 releases, it only affects k6 if it is compiled with Go 1.14, which at this time is still not officially released. (#1261)
* Improve the official docker image to use an unprivileged user. Thanks, @funkypenguin! (#1314)
* Fix the unintentional sharing of `__ENV` between VUs, which could result in data races and crashes of k6. (#1329)
* Update cloud URLs to point to https://app.k6.io instead of https://app.loadimpact.com. (#1335)
4 changes: 2 additions & 2 deletions samples/http_2.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import http from "k6/http";
import { check } from "k6";

export default function() {
check(http.get("https://www.bbc.co.uk/"), {
export default function () {
check(http.get("https://test-api.k6.io/"), {
"status is 200": (r) => r.status == 200,
"protocol is HTTP/2": (r) => r.proto == "HTTP/2.0",
});
Expand Down
4 changes: 2 additions & 2 deletions samples/http_get.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import http from 'k6/http';

export default function() {
const response = http.get("http://test.loadimpact.com");
export default function () {
const response = http.get("https://test-api.k6.io/");
};
Loading

0 comments on commit d1f14a3

Please sign in to comment.