Skip to content

Commit

Permalink
Merge pull request #1910 from loadimpact/release/v0.31.1
Browse files Browse the repository at this point in the history
Release notes and bump version for v0.31.1
  • Loading branch information
mstoykov authored Mar 17, 2021
2 parents 67e33ab + e9d8349 commit cbad181
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: ${{ needs.configure.outputs.version }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
steps:
- name: Download source code archive
run: curl -fsSL "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/archive/${VERSION}.tar.gz" -o "${VERSION}.tar.gz"
Expand Down
2 changes: 1 addition & 1 deletion lib/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

// Version contains the current semantic version of k6.
const Version = "0.31.0"
const Version = "0.31.1"

// VersionDetails can be set externally as part of the build process
var VersionDetails = "" // nolint:gochecknoglobals
Expand Down
69 changes: 69 additions & 0 deletions lib/netext/httpext/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ import (
"testing"
"time"

"github.com/mccutchen/go-httpbin/httpbin"
"github.com/oxtoacart/bpool"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v3"

"github.com/loadimpact/k6/lib"
"github.com/loadimpact/k6/lib/metrics"
"github.com/loadimpact/k6/stats"
)

Expand Down Expand Up @@ -280,3 +284,68 @@ func BenchmarkWrapDecompressionError(b *testing.B) {
_ = wrapDecompressionError(err)
}
}

func TestTrailFailed(t *testing.T) {
t.Parallel()
srv := httptest.NewTLSServer(httpbin.New().Handler())
defer srv.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
samples := make(chan stats.SampleContainer, 10)
logger := logrus.New()
logger.Level = logrus.DebugLevel
state := &lib.State{
Options: lib.Options{
RunTags: &stats.SampleTags{},
SystemTags: &stats.DefaultSystemTagSet,
},
Transport: srv.Client().Transport,
Samples: samples,
Logger: logger,
BPool: bpool.NewBufferPool(2),
}
ctx = lib.WithState(ctx, state)

testCases := map[string]struct {
responseCallback func(int) bool
failed null.Bool
}{
"null responsecallback": {responseCallback: nil, failed: null.NewBool(false, false)},
"unexpected response": {responseCallback: func(int) bool { return false }, failed: null.NewBool(true, true)},
"expected response": {responseCallback: func(int) bool { return true }, failed: null.NewBool(false, true)},
}
for name, testCase := range testCases {
responseCallback := testCase.responseCallback
failed := testCase.failed

t.Run(name, func(t *testing.T) {
req, _ := http.NewRequest("GET", srv.URL, nil)
preq := &ParsedHTTPRequest{
Req: req,
URL: &URL{u: req.URL, URL: srv.URL},
Body: new(bytes.Buffer),
Timeout: 10 * time.Millisecond,
ResponseCallback: responseCallback,
}
res, err := MakeRequest(ctx, preq)

require.NoError(t, err)
assert.NotNil(t, res)
assert.Len(t, samples, 1)
sample := <-samples
trail := sample.(*Trail)
require.Equal(t, failed, trail.Failed)

var httpReqFailedSampleValue null.Bool
for _, s := range sample.GetSamples() {
if s.Metric.Name == metrics.HTTPReqFailed.Name {
httpReqFailedSampleValue.Valid = true
if s.Value == 1.0 {
httpReqFailedSampleValue.Bool = true
}
}
}
require.Equal(t, failed, httpReqFailedSampleValue)
})
}
}
2 changes: 1 addition & 1 deletion lib/netext/httpext/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (t *transport) measureAndEmitMetrics(unfReq *unfinishedRequest) *finishedRe
finalTags := stats.IntoSampleTags(&tags)
trail.SaveSamples(finalTags)
if t.responseCallback != nil {
trail.Failed.SetValid(true)
trail.Failed.Valid = true
if failed == 1 {
trail.Failed.Bool = true
}
Expand Down
3 changes: 3 additions & 0 deletions release notes/v0.31.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
k6 v0.31.1 is a patch release with a single bugfix.

The bugfix is about the cloud output and the new `http_req_failed` metric in k6 v0.31.0. Due to additional state being used for its transport to the k6 cloud, and a misunderstanding of what a functional call from a library dependency does, the `http_req_failed` values were always set to `1`. This did not affect any other output or the end of test summary. ([#1908](https://github.com/loadimpact/k6/issues/1908))

0 comments on commit cbad181

Please sign in to comment.