Skip to content

Commit

Permalink
Use a number for versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
codebien committed Apr 5, 2023
1 parent 763b154 commit fdc5307
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cloudapi/config.go
Expand Up @@ -28,7 +28,7 @@ type Config struct {
TestRunDetails null.String `json:"testRunDetails" envconfig:"K6_CLOUD_TEST_RUN_DETAILS"`
NoCompress null.Bool `json:"noCompress" envconfig:"K6_CLOUD_NO_COMPRESS"`
StopOnError null.Bool `json:"stopOnError" envconfig:"K6_CLOUD_STOP_ON_ERROR"`
UseVersion2 null.Bool `json:"useVersion2" envconfig:"K6_CLOUD_USE_VERSION_2"`
APIVersion null.Int `json:"apiVersion" envconfig:"K6_CLOUD_API_VERSION"`

MaxMetricSamplesPerPackage null.Int `json:"maxMetricSamplesPerPackage" envconfig:"K6_CLOUD_MAX_METRIC_SAMPLES_PER_PACKAGE"`

Expand Down Expand Up @@ -150,7 +150,7 @@ func NewConfig() Config {
MetricPushConcurrency: null.NewInt(1, false),
MaxMetricSamplesPerPackage: null.NewInt(100000, false),
Timeout: types.NewNullDuration(1*time.Minute, false),
UseVersion2: null.NewBool(false, false),
APIVersion: null.NewInt(1, false),
// Aggregation is disabled by default, since AggregationPeriod has no default value
// but if it's enabled manually or from the cloud service, those are the default values it will use:
AggregationCalcInterval: types.NewNullDuration(3*time.Second, false),
Expand Down Expand Up @@ -202,8 +202,8 @@ func (c Config) Apply(cfg Config) Config {
if cfg.Timeout.Valid {
c.Timeout = cfg.Timeout
}
if cfg.UseVersion2.Valid {
c.UseVersion2 = cfg.UseVersion2
if cfg.APIVersion.Valid {
c.APIVersion = cfg.APIVersion
}
if cfg.MaxMetricSamplesPerPackage.Valid {
c.MaxMetricSamplesPerPackage = cfg.MaxMetricSamplesPerPackage
Expand Down
2 changes: 1 addition & 1 deletion cloudapi/config_test.go
Expand Up @@ -34,7 +34,7 @@ func TestConfigApply(t *testing.T) {
NoCompress: null.NewBool(true, true),
StopOnError: null.NewBool(true, true),
Timeout: types.NewNullDuration(5*time.Second, true),
UseVersion2: null.NewBool(true, true),
APIVersion: null.NewInt(2, true),
MaxMetricSamplesPerPackage: null.NewInt(2, true),
MetricPushInterval: types.NewNullDuration(1*time.Second, true),
MetricPushConcurrency: null.NewInt(3, true),
Expand Down
2 changes: 1 addition & 1 deletion cmd/tests/cmd_run_test.go
Expand Up @@ -1987,7 +1987,7 @@ func TestCloudOutputV2(t *testing.T) {
srv := getCloudMetricsServer(t, 123)
ts := getSingleFileTestState(t, script, cliFlags, 0)
ts.Env["K6_CLOUD_HOST"] = srv.URL
ts.Env["K6_CLOUD_USE_VERSION_2"] = "true"
ts.Env["K6_CLOUD_API_VERSION"] = "2"
ts.Env["K6_CLOUD_TOKEN"] = "fake-token"

cmd.ExecuteWithGlobalState(ts.GlobalState)
Expand Down
4 changes: 2 additions & 2 deletions output/cloud/output.go
Expand Up @@ -212,13 +212,13 @@ func (out *Output) Start() error {
"projectId": out.config.ProjectID,
"duration": out.duration,
"referenceId": out.referenceID,
"outputv2": out.config.UseVersion2,
"apiVersion": out.config.APIVersion.Int64,
}).Debug("Started!")
return nil
}

func (out *Output) startBackgroundProcesses() error {
if out.config.UseVersion2.Bool {
if out.config.APIVersion.Int64 == 2 {
var err error
out.outv2, err = expv2.New(out.logger, out.config)
if err != nil {
Expand Down

0 comments on commit fdc5307

Please sign in to comment.