Skip to content

Commit

Permalink
output/cloud: Adjust tests for working with v2
Browse files Browse the repository at this point in the history
  • Loading branch information
codebien committed May 30, 2023
1 parent fd2797a commit b09dc72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
7 changes: 4 additions & 3 deletions output/cloud/expv2/metrics_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ func newMetricsClient(logger logrus.FieldLogger, host string, token string) (*me
if host == "" {
return nil, errors.New("host is required")
}
if token == "" {
return nil, errors.New("token is required")
}
// TODO:
//if token == "" {
//return nil, errors.New("token is required")
//}
return &metricsClient{
httpClient: &http.Client{Timeout: 5 * time.Second},
logger: logger,
Expand Down
14 changes: 4 additions & 10 deletions output/cloud/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"go.k6.io/k6/metrics"
"go.k6.io/k6/output"
cloudv2 "go.k6.io/k6/output/cloud/expv2"
cloudv1 "go.k6.io/k6/output/cloud/v1"
"gopkg.in/guregu/null.v3"
)

Expand Down Expand Up @@ -99,7 +98,7 @@ func TestOutputCreateTestWithConfigOverwrite(t *testing.T) {
"reference_id": "cloud-create-test",
"config": {
"metricPushInterval": "10ms",
"aggregationPeriod": "30ms"
"aggregationPeriod": "40s"
}
}`)
case "/v1/tests/cloud-create-test":
Expand All @@ -126,7 +125,7 @@ func TestOutputCreateTestWithConfigOverwrite(t *testing.T) {
require.NoError(t, out.Start())

assert.Equal(t, types.NullDurationFrom(10*time.Millisecond), out.config.MetricPushInterval)
assert.Equal(t, types.NullDurationFrom(30*time.Millisecond), out.config.AggregationPeriod)
assert.Equal(t, types.NullDurationFrom(40*time.Second), out.config.AggregationPeriod)

// Assert that it overwrites only the provided values
expTimeout := types.NewNullDuration(60*time.Second, false)
Expand Down Expand Up @@ -179,23 +178,18 @@ func TestOutputStartVersionedOutputV2(t *testing.T) {
assert.True(t, ok)
}

func TestOutputStartVersionedOutputV1(t *testing.T) {
func TestOutputStartVersionedOutputV1Error(t *testing.T) {
t.Parallel()

o := Output{
referenceID: "123",
config: cloudapi.Config{
APIVersion: null.IntFrom(1),
// Here, we are enabling but silencing the related async op
MetricPushInterval: types.NullDurationFrom(1 * time.Hour),
},
}

err := o.startVersionedOutput()
require.NoError(t, err)

_, ok := o.versionedOutput.(*cloudv1.Output)
assert.True(t, ok)
assert.ErrorContains(t, err, "not supported anymore")
}

func TestOutputStartWithReferenceID(t *testing.T) {
Expand Down

0 comments on commit b09dc72

Please sign in to comment.