Skip to content

Commit

Permalink
Read Kibana version to build dashboard export folder (#5564)
Browse files Browse the repository at this point in the history
* Read Kibana version to build dashboard export folder

TestBeatsServerless/TestSetupDashboards/export_dashboards checks for
the exported dashboards files, however the folder depends on the
Kibana version, the test is updated to read the Kibana version and
build the folder path using it.

* Update testing/integration/beats_serverless_test.go

Co-authored-by: Paolo Chilà <[email protected]>

* Fetch Kibana version upon initial connection

---------

Co-authored-by: Paolo Chilà <[email protected]>
Co-authored-by: Craig MacKenzie <[email protected]>
Co-authored-by: Shaunak Kashyap <[email protected]>
  • Loading branch information
4 people authored Sep 20, 2024
1 parent 3a66b5f commit d909699
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/testing/define/define.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func getKibanaClient() (*kibana.Client, error) {
Host: kibanaHost,
Username: kibanaUser,
Password: kibanaPass,
IgnoreVersion: true,
IgnoreVersion: false,
}, 0, "Elastic-Agent-Test-Define", version.GetDefaultVersion(), version.Commit(), version.BuildTime().String())
if err != nil {
return nil, fmt.Errorf("failed to create kibana client: %w", err)
Expand Down
4 changes: 3 additions & 1 deletion testing/integration/beats_serverless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ func (runner *BeatRunner) SubtestExportDashboards() {
runner.T().Logf("got output: %s", exportOut)
assert.NoError(runner.T(), err)

inFolder, err := os.ReadDir(filepath.Join(outDir, "/_meta/kibana/8/dashboard"))
// The folder matches the major version of Kibana, so we read it from the API
dashboardFolder := fmt.Sprintf("/_meta/kibana/%d/dashboard", runner.requirementsInfo.KibanaClient.GetVersion().Major)
inFolder, err := os.ReadDir(filepath.Join(outDir, dashboardFolder))
require.NoError(runner.T(), err)
runner.T().Logf("got log contents: %#v", inFolder)
require.NotEmpty(runner.T(), inFolder)
Expand Down

0 comments on commit d909699

Please sign in to comment.