Skip to content

Commit 7f4a339

Browse files
authored
Don't require Elasticsearch for static tests (#1716)
1 parent 752a30d commit 7f4a339

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

cmd/testrunner.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
"github.com/elastic/elastic-package/internal/cobraext"
1919
"github.com/elastic/elastic-package/internal/common"
20+
"github.com/elastic/elastic-package/internal/elasticsearch"
2021
"github.com/elastic/elastic-package/internal/install"
2122
"github.com/elastic/elastic-package/internal/kibana"
2223
"github.com/elastic/elastic-package/internal/packages"
@@ -296,13 +297,18 @@ func testTypeCommandActionFactory(runner testrunner.TestRunner) cobraext.Command
296297

297298
variantFlag, _ := cmd.Flags().GetString(cobraext.VariantFlagName)
298299

299-
esClient, err := stack.NewElasticsearchClientFromProfile(profile)
300-
if err != nil {
301-
return fmt.Errorf("can't create Elasticsearch client: %w", err)
302-
}
303-
err = esClient.CheckHealth(cmd.Context())
304-
if err != nil {
305-
return err
300+
var esAPI *elasticsearch.API
301+
if testType != "static" {
302+
// static tests do not need a running Elasticsearch
303+
esClient, err := stack.NewElasticsearchClientFromProfile(profile)
304+
if err != nil {
305+
return fmt.Errorf("can't create Elasticsearch client: %w", err)
306+
}
307+
err = esClient.CheckHealth(cmd.Context())
308+
if err != nil {
309+
return err
310+
}
311+
esAPI = esClient.API
306312
}
307313

308314
var kibanaClient *kibana.Client
@@ -336,7 +342,7 @@ func testTypeCommandActionFactory(runner testrunner.TestRunner) cobraext.Command
336342
TestFolder: folder,
337343
PackageRootPath: packageRootPath,
338344
GenerateTestResult: generateTestResult,
339-
API: esClient.API,
345+
API: esAPI,
340346
KibanaClient: kibanaClient,
341347
DeferCleanup: deferCleanup,
342348
ServiceVariant: variantFlag,

0 commit comments

Comments
 (0)