From d9096994411f0b2703baddf46c9d70317d444763 Mon Sep 17 00:00:00 2001 From: Tiago Queiroz Date: Thu, 19 Sep 2024 20:18:44 -0400 Subject: [PATCH] Read Kibana version to build dashboard export folder (#5564) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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Ă  * Fetch Kibana version upon initial connection --------- Co-authored-by: Paolo ChilĂ  Co-authored-by: Craig MacKenzie Co-authored-by: Shaunak Kashyap --- pkg/testing/define/define.go | 2 +- testing/integration/beats_serverless_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/testing/define/define.go b/pkg/testing/define/define.go index ec371467268..3d83b60267d 100644 --- a/pkg/testing/define/define.go +++ b/pkg/testing/define/define.go @@ -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) diff --git a/testing/integration/beats_serverless_test.go b/testing/integration/beats_serverless_test.go index c26dee97bb2..c8f875559cd 100644 --- a/testing/integration/beats_serverless_test.go +++ b/testing/integration/beats_serverless_test.go @@ -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)