Skip to content

Commit

Permalink
Merge pull request #966 from loadimpact/prepare-v0.24.0
Browse files Browse the repository at this point in the history
Release k6 v0.24.0
  • Loading branch information
na-- authored Mar 20, 2019
2 parents 1568213 + 5573c66 commit f597e5f
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 102 deletions.
41 changes: 12 additions & 29 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
lint:
docker:
- image: circleci/golang:1.11.5
- image: circleci/golang:1.12
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand All @@ -11,9 +11,11 @@ jobs:
- run:
name: Check dependencies
command: |
go version
export PATH="$GOPATH/bin:$PATH"
mkdir -p "$GOPATH/bin"
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep version
dep status
dep ensure -update -dry-run
- run:
Expand All @@ -27,7 +29,7 @@ jobs:
test:
docker:
- image: circleci/golang:1.11.5
- image: circleci/golang:1.12
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand All @@ -36,6 +38,7 @@ jobs:
- run:
name: Run tests and code coverage
command: |
go version
export GOMAXPROCS=4
export PATH=$GOPATH/bin:$PATH
echo "mode: set" > coverage.txt
Expand All @@ -47,41 +50,25 @@ jobs:
bash <(curl -s https://codecov.io/bash)
test-go110:
test-prev-golang:
docker:
- image: circleci/golang:1.10.8
- image: circleci/golang:1.11
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
steps:
- checkout
- run:
name: Run tests and code coverage
name: Run tests with previous Go version
command: |
go version
export GOMAXPROCS=4
export PATH=$GOPATH/bin:$PATH
go test -race -timeout 600s ./...
test-go112:
docker:
- image: circleci/golang:1.12.0
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
steps:
- checkout
- run:
name: Run tests and code coverage
command: |
export GOMAXPROCS=4
export PATH=$GOPATH/bin:$PATH
for pkg in $(go list ./... | grep -v vendor); do
go test -race -timeout 600s $pkg
done
build-docker-images:
docker:
- image: circleci/golang:1.11.5
- image: circleci/golang:1.12
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand Down Expand Up @@ -125,7 +112,7 @@ jobs:
build-linux-packages:
docker:
- image: circleci/golang:1.11.5
- image: circleci/golang:1.12
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
Expand Down Expand Up @@ -178,11 +165,7 @@ workflows:
filters:
tags:
only: /.*/
- test-go110:
filters:
tags:
only: /.*/
- test-go112:
- test-prev-golang:
filters:
tags:
only: /.*/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ If there isn't an official package for your operating system or architecture, or

### Build from source

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](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (1.10 or newer). Follow these instructions:
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](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (1.11 or newer). Follow these instructions:

- Run `go get github.com/loadimpact/k6` which will:
- git clone the repo and put the source in `$GOPATH/src/github.com/loadimpact/k6`
Expand Down
28 changes: 24 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ environment:
# specific to go
VERSION: "%APPVEYOR_REPO_TAG_NAME:v=%"
GOPATH: c:\gopath
GOVERSION: 1.12.1
GOMAXPROCS: 2
CGO_ENABLED: '0'
GOARCH: amd64
BINTRAY_KEY:
Expand All @@ -21,24 +23,42 @@ environment:
install:
- choco install wixtoolset pandoc -y
- refreshenv
# ensure wix is available in PATH
- set PATH=%WIX%\bin;%PATH%
# specific to go
- set PATH=%GOPATH%\bin;%PATH%
# ensure wix and go are available in PATH
- set PATH=C:\go\bin;%GOPATH%\bin;%WIX%\bin;%PATH%
- ps: |
Remove-Item 'C:\go' -Recurse -Force -ErrorAction Ignore
Remove-Item 'C:\go-x86' -Recurse -Force -ErrorAction Ignore
Write-Host "Downloading..."
$goDistPath = "$env:TEMP\go" + $env:GOVERSION + ".windows-amd64.zip"
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/go/go" + $env:GOVERSION + ".windows-amd64.zip", $goDistPath)
Write-Host "Unpacking..."
7z x $goDistPath -oC:\gotmp-x64 | Out-Null
[IO.Directory]::Move('C:\gotmp-x64\go', 'C:\go')
Remove-Item 'C:\gotmp-x64' -Recurse -Force
del $goDistPath
Write-Host "Testing..."
- go version
- echo "NumCores:%NUMBER_OF_PROCESSORS%"
- systeminfo


# build msi artifacts
build_script:
# In case of non tag build, mock a version
- if "%APPVEYOR_REPO_TAG%" == "false" (set VERSION="0.0.1")
- pandoc -s -f markdown -t rtf -o packaging\LICENSE.rtf LICENSE.md
- go version
- go build -a -ldflags "-s -w" -o packaging\k6.exe
- cd packaging
- candle.exe -arch x64 -dVERSION=%VERSION% k6.wxs
- light.exe -ext WixUIExtension k6.wixobj

test_script:
- cd %APPVEYOR_BUILD_FOLDER%
- go version
- go test ./...

deploy_script:
Expand Down
2 changes: 1 addition & 1 deletion cmd/config_consolidation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func runTestCase(
flagSet := newFlagSet()
defer resetStickyGlobalVars()
flagSet.SetOutput(testOutput{t})
flagSet.PrintDefaults()
//flagSet.PrintDefaults()

cliErr := flagSet.Parse(testCase.options.cli)
if testCase.expected.cliParseError {
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (

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

// Banner contains the ASCII-art banner with the k6 logo and stylized website URL
//TODO: make these into methods, only the version needs to be a variable
Expand Down
10 changes: 5 additions & 5 deletions core/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,20 +840,20 @@ func TestEmittedMetricsWhenScalingDown(t *testing.T) {
export let options = {
systemTags: ["iter", "vu", "url"],
// Start with 2 VUs for 2 second and then quickly scale down to 1 for the next 2s and then quit
// Start with 2 VUs for 4 seconds and then quickly scale down to 1 for the next 4s and then quit
vus: 2,
vusMax: 2,
stages: [
{ duration: "2s", target: 2 },
{ duration: "1s", target: 1 },
{ duration: "4s", target: 2 },
{ duration: "1s", target: 1 },
{ duration: "3s", target: 1 },
],
};
export default function () {
console.log("VU " + __VU + " starting iteration #" + __ITER);
http.get("HTTPBIN_IP_URL/bytes/15000");
sleep(1.7);
sleep(3.1);
http.get("HTTPBIN_IP_URL/bytes/15000");
console.log("VU " + __VU + " ending iteration #" + __ITER);
};
Expand Down Expand Up @@ -913,7 +913,7 @@ func TestEmittedMetricsWhenScalingDown(t *testing.T) {
durationCount := float64(getMetricCount(collector, metrics.IterationDuration.Name))
assert.Equal(t, 3.0, durationCount)
durationSum := getMetricSum(collector, metrics.IterationDuration.Name)
assert.InDelta(t, 1.7, durationSum/(1000*durationCount), 0.1)
assert.InDelta(t, 3.35, durationSum/(1000*durationCount), 0.25)
}

func TestMinIterationDuration(t *testing.T) {
Expand Down
10 changes: 1 addition & 9 deletions js/modules/k6/http/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"bytes"
"context"
"fmt"
"go/build"
"io/ioutil"
"net/http"
"net/http/cookiejar"
Expand Down Expand Up @@ -1348,13 +1347,6 @@ func TestErrorCodes(t *testing.T) {
state.Options.Throw = null.BoolFrom(false)
defer tb.Cleanup()
sr := tb.Replacer.Replace
var badLocationRedirectMsg = "first path segment in URL cannot contain colon"
for _, tag := range build.Default.ReleaseTags {
if tag == "go1.12" {
badLocationRedirectMsg = "net/url: invalid control character in URL"
break
}
}

// Handple paths with custom logic
tb.Mux.HandleFunc("/digest-auth/failure", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -1424,7 +1416,7 @@ func TestErrorCodes(t *testing.T) {
script: `let res = http.request("GET", "HTTPBIN_URL/bad-location-redirect");`,
expectedScriptError: sr(
"GoError: Get HTTPBIN_URL/bad-location-redirect: failed to parse Location header" +
" \"h\\t:/\": parse h\t:/: " + badLocationRedirectMsg),
" \"h\\t:/\": parse h\t:/: net/url: invalid control character in URL"),
},
{
name: "Missing protocol",
Expand Down
6 changes: 3 additions & 3 deletions js/modules/k6/marshalling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestSetupDataMarshalling(t *testing.T) {
export function setup() {
let res = http.get("HTTPBIN_URL/html");
let html_selection = html.parseHTML(res.body);
let html_selection = html.parseHTML(res.body);
let ws_res = ws.connect("ws://HTTPBIN_DOMAIN:HTTPBIN_PORT/ws-echo", function(socket){
socket.on("open", function() {
socket.send("test")
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestSetupDataMarshalling(t *testing.T) {
first_properties.
filter(element => typeof(first[element]) === "object").
forEach(function(element) {
diff_object_properties(name+"."+element,
diff_object_properties(name+"."+element,
first[element],
second[element]);
});
Expand All @@ -122,7 +122,7 @@ func TestSetupDataMarshalling(t *testing.T) {
require.NoError(t, err)

err = runner.SetOptions(lib.Options{
SetupTimeout: types.NullDurationFrom(1 * time.Second),
SetupTimeout: types.NullDurationFrom(5 * time.Second),
Hosts: tb.Dialer.Hosts,
})

Expand Down
4 changes: 2 additions & 2 deletions js/modules/k6/ws/ws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ func TestSession(t *testing.T) {
socket.close();
}, 500);
});
if (ellapsed > 2000 || ellapsed < 500) {
throw new Error ("setTimeout occurred after " + ellapsed + "ms, expected 500<T<2000");
if (ellapsed > 3000 || ellapsed < 500) {
throw new Error ("setTimeout occurred after " + ellapsed + "ms, expected 500<T<3000");
}
`)
assert.NoError(t, err)
Expand Down
36 changes: 23 additions & 13 deletions js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
"net"
"net/http"
"os"
"runtime"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -530,33 +532,41 @@ func TestVURunContext(t *testing.T) {
}

func TestVURunInterrupt(t *testing.T) {
//TODO: figure out why interrupt sometimes fails... data race in goja?
if runtime.GOOS == "windows" {
t.Skip()
}

r1, err := New(&lib.SourceData{
Filename: "/script.js",
Data: []byte(`
export default function() { while(true) {} }
`),
}, afero.NewMemMapFs(), lib.RuntimeOptions{})
if !assert.NoError(t, err) {
return
}
r1.SetOptions(lib.Options{Throw: null.BoolFrom(true)})
require.NoError(t, err)
require.NoError(t, r1.SetOptions(lib.Options{Throw: null.BoolFrom(true)}))

r2, err := NewFromArchive(r1.MakeArchive(), lib.RuntimeOptions{})
if !assert.NoError(t, err) {
return
}

require.NoError(t, err)
testdata := map[string]*Runner{"Source": r1, "Archive": r2}
for name, r := range testdata {
name, r := name, r
t.Run(name, func(t *testing.T) {
vu, err := r.newVU(make(chan stats.SampleContainer, 100))
if !assert.NoError(t, err) {
return
}
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
samples := make(chan stats.SampleContainer, 100)
defer close(samples)
go func() {
for range samples {
}
}()

vu, err := r.newVU(samples)
require.NoError(t, err)

err = vu.RunOnce(ctx)
assert.EqualError(t, err, "context cancelled at /script.js:1:1(1)")
assert.Error(t, err)
assert.True(t, strings.HasPrefix(err.Error(), "context cancelled at "))
})
}
}
Expand Down
Loading

0 comments on commit f597e5f

Please sign in to comment.