diff --git a/.circleci/config.yml b/.circleci/config.yml index 50778ff2c23..3a890b49d95 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 @@ -178,11 +165,7 @@ workflows: filters: tags: only: /.*/ - - test-go110: - filters: - tags: - only: /.*/ - - test-go112: + - test-prev-golang: filters: tags: only: /.*/ diff --git a/README.md b/README.md index 76b1ab20e9b..36b07a787ed 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/appveyor.yml b/appveyor.yml index 1af6f7e4dfe..a77cbd34499 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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: @@ -21,10 +23,26 @@ 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 @@ -32,6 +50,7 @@ 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 @@ -39,6 +58,7 @@ build_script: test_script: - cd %APPVEYOR_BUILD_FOLDER% + - go version - go test ./... deploy_script: diff --git a/cmd/config_consolidation_test.go b/cmd/config_consolidation_test.go index ce7933c175f..bfcf726f77b 100644 --- a/cmd/config_consolidation_test.go +++ b/cmd/config_consolidation_test.go @@ -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 { diff --git a/cmd/root.go b/cmd/root.go index e5f5d558485..2ee71c81156 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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 diff --git a/core/engine_test.go b/core/engine_test.go index 3153dd96b64..fe81be047a1 100644 --- a/core/engine_test.go +++ b/core/engine_test.go @@ -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); }; @@ -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) { diff --git a/js/modules/k6/http/request_test.go b/js/modules/k6/http/request_test.go index 8519bcaaaf5..39ebeb2b61e 100644 --- a/js/modules/k6/http/request_test.go +++ b/js/modules/k6/http/request_test.go @@ -24,7 +24,6 @@ import ( "bytes" "context" "fmt" - "go/build" "io/ioutil" "net/http" "net/http/cookiejar" @@ -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) { @@ -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", diff --git a/js/modules/k6/marshalling_test.go b/js/modules/k6/marshalling_test.go index 6e8420a03f5..22e552a34f8 100644 --- a/js/modules/k6/marshalling_test.go +++ b/js/modules/k6/marshalling_test.go @@ -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") @@ -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]); }); @@ -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, }) diff --git a/js/modules/k6/ws/ws_test.go b/js/modules/k6/ws/ws_test.go index 5d65d2cdcda..98a07faef77 100644 --- a/js/modules/k6/ws/ws_test.go +++ b/js/modules/k6/ws/ws_test.go @@ -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 3000 || ellapsed < 500) { + throw new Error ("setTimeout occurred after " + ellapsed + "ms, expected 500