diff --git a/internal/benchrunner/runners/common/packages.go b/internal/benchrunner/runners/common/packages.go new file mode 100644 index 0000000000..0a3b64e669 --- /dev/null +++ b/internal/benchrunner/runners/common/packages.go @@ -0,0 +1,11 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package common + +import "path/filepath" + +func DataStreamPath(packageRoot, dataStream string) string { + return filepath.Join(packageRoot, "data_stream", dataStream) +} diff --git a/internal/benchrunner/runners/common/runid.go b/internal/benchrunner/runners/common/runid.go new file mode 100644 index 0000000000..01dc4618f4 --- /dev/null +++ b/internal/benchrunner/runners/common/runid.go @@ -0,0 +1,11 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package common + +import "github.com/google/uuid" + +func NewRunID() string { + return uuid.New().String() +} diff --git a/internal/benchrunner/runners/rally/runner.go b/internal/benchrunner/runners/rally/runner.go index 3b9cbb506c..67202b8fff 100644 --- a/internal/benchrunner/runners/rally/runner.go +++ b/internal/benchrunner/runners/rally/runner.go @@ -27,7 +27,6 @@ import ( "github.com/elastic/elastic-package/internal/stack" - "github.com/google/uuid" "gopkg.in/yaml.v3" "github.com/elastic/elastic-integration-corpus-generator-tool/pkg/genlib" @@ -36,6 +35,7 @@ import ( "github.com/elastic/elastic-package/internal/benchrunner" "github.com/elastic/elastic-package/internal/benchrunner/reporters" + "github.com/elastic/elastic-package/internal/benchrunner/runners/common" "github.com/elastic/elastic-package/internal/configuration/locations" "github.com/elastic/elastic-package/internal/elasticsearch" "github.com/elastic/elastic-package/internal/logger" @@ -244,7 +244,7 @@ func (r *runner) setUp() error { rallyCorpusDir := locationManager.RallyCorpusDir() r.ctxt.Logs.Folder.Local = rallyCorpusDir r.ctxt.Logs.Folder.Agent = RallyCorpusAgentDir - r.ctxt.Test.RunID = createRunID() + r.ctxt.Test.RunID = common.NewRunID() outputDir, err := servicedeployer.CreateOutputDir(locationManager, r.ctxt.Test.RunID) if err != nil { @@ -282,7 +282,7 @@ func (r *runner) setUp() error { dataStreamManifest, err := packages.ReadDataStreamManifest( filepath.Join( - getDataStreamPath(r.options.PackageRootPath, r.scenario.DataStream.Name), + common.DataStreamPath(r.options.PackageRootPath, r.scenario.DataStream.Name), packages.DataStreamManifestFile, ), ) @@ -1188,14 +1188,6 @@ func waitUntilTrue(fn func() (bool, error), timeout time.Duration) (bool, error) } } -func createRunID() string { - return uuid.New().String() -} - -func getDataStreamPath(packageRoot, dataStream string) string { - return filepath.Join(packageRoot, "data_stream", dataStream) -} - func generateRallyTrack(dataStream, indexTemplateBody, corpusFileName string, corpusDocsCount uint64, isTSDB bool) ([]byte, error) { t := template.New("rallytrack") diff --git a/internal/benchrunner/runners/stream/runner.go b/internal/benchrunner/runners/stream/runner.go index 563665ab70..ce91b004b6 100644 --- a/internal/benchrunner/runners/stream/runner.go +++ b/internal/benchrunner/runners/stream/runner.go @@ -20,7 +20,6 @@ import ( "github.com/elastic/elastic-package/internal/packages/installer" - "github.com/google/uuid" "gopkg.in/yaml.v3" "github.com/elastic/elastic-integration-corpus-generator-tool/pkg/genlib" @@ -29,6 +28,7 @@ import ( "github.com/elastic/elastic-package/internal/benchrunner" "github.com/elastic/elastic-package/internal/benchrunner/reporters" + "github.com/elastic/elastic-package/internal/benchrunner/runners/common" "github.com/elastic/elastic-package/internal/elasticsearch" "github.com/elastic/elastic-package/internal/logger" "github.com/elastic/elastic-package/internal/multierror" @@ -107,7 +107,7 @@ func (r *runner) setUp() error { r.runtimeDataStreams = make(map[string]string) - r.ctxt.Test.RunID = createRunID() + r.ctxt.Test.RunID = common.NewRunID() pkgManifest, err := packages.ReadPackageManifestFromPackageRoot(r.options.PackageRootPath) if err != nil { @@ -133,7 +133,7 @@ func (r *runner) setUp() error { var err error dataStreamManifest, err := packages.ReadDataStreamManifest( filepath.Join( - getDataStreamPath(r.options.PackageRootPath, scenario.DataStream.Name), + common.DataStreamPath(r.options.PackageRootPath, scenario.DataStream.Name), packages.DataStreamManifestFile, ), ) @@ -629,11 +629,3 @@ func waitUntilTrue(fn func() (bool, error), timeout time.Duration) (bool, error) } } } - -func createRunID() string { - return uuid.New().String() -} - -func getDataStreamPath(packageRoot, dataStream string) string { - return filepath.Join(packageRoot, "data_stream", dataStream) -} diff --git a/internal/benchrunner/runners/system/runner.go b/internal/benchrunner/runners/system/runner.go index 3393949587..7d58576156 100644 --- a/internal/benchrunner/runners/system/runner.go +++ b/internal/benchrunner/runners/system/runner.go @@ -17,7 +17,6 @@ import ( "strings" "time" - "github.com/google/uuid" "gopkg.in/yaml.v3" "github.com/elastic/elastic-integration-corpus-generator-tool/pkg/genlib" @@ -26,6 +25,7 @@ import ( "github.com/elastic/elastic-package/internal/benchrunner" "github.com/elastic/elastic-package/internal/benchrunner/reporters" + "github.com/elastic/elastic-package/internal/benchrunner/runners/common" "github.com/elastic/elastic-package/internal/configuration/locations" "github.com/elastic/elastic-package/internal/elasticsearch" "github.com/elastic/elastic-package/internal/kibana" @@ -136,7 +136,7 @@ func (r *runner) setUp() error { serviceLogsDir := locationManager.ServiceLogDir() r.ctxt.Logs.Folder.Local = serviceLogsDir r.ctxt.Logs.Folder.Agent = ServiceLogsAgentDir - r.ctxt.Test.RunID = createRunID() + r.ctxt.Test.RunID = common.NewRunID() outputDir, err := servicedeployer.CreateOutputDir(locationManager, r.ctxt.Test.RunID) if err != nil { @@ -173,7 +173,7 @@ func (r *runner) setUp() error { logger.Debug("deleting old data in data stream...") dataStreamManifest, err := packages.ReadDataStreamManifest( filepath.Join( - getDataStreamPath(r.options.PackageRootPath, r.scenario.DataStream.Name), + common.DataStreamPath(r.options.PackageRootPath, r.scenario.DataStream.Name), packages.DataStreamManifestFile, ), ) @@ -994,11 +994,3 @@ func waitUntilTrue(fn func() (bool, error), timeout time.Duration) (bool, error) } } } - -func createRunID() string { - return uuid.New().String() -} - -func getDataStreamPath(packageRoot, dataStream string) string { - return filepath.Join(packageRoot, "data_stream", dataStream) -}