From b09dc72f18c1fd378793c809c8027ff82a5c127f Mon Sep 17 00:00:00 2001 From: Ivan <2103732+codebien@users.noreply.github.com> Date: Wed, 24 May 2023 18:37:59 +0200 Subject: [PATCH] output/cloud: Adjust tests for working with v2 --- output/cloud/expv2/metrics_client.go | 7 ++++--- output/cloud/output_test.go | 14 ++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/output/cloud/expv2/metrics_client.go b/output/cloud/expv2/metrics_client.go index 09ec19f08586..276e0effe3e6 100644 --- a/output/cloud/expv2/metrics_client.go +++ b/output/cloud/expv2/metrics_client.go @@ -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, diff --git a/output/cloud/output_test.go b/output/cloud/output_test.go index f9eb52ff53a3..2961817168ef 100644 --- a/output/cloud/output_test.go +++ b/output/cloud/output_test.go @@ -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" ) @@ -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": @@ -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) @@ -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) {