Please upgrade your browser
This Elastic installation has strict security requirements enabled that your current browser does not meet.
`)
-
-func TestExtractRawInjectedMetadata(t *testing.T) {
- im, err := extractInjectedMetadata(sampleLoginPage)
- require.NoError(t, err)
- require.Equal(t, "7.15.1", im.Version)
-}
diff --git a/internal/kibana/status.go b/internal/kibana/status.go
new file mode 100644
index 0000000000..9644f4ea84
--- /dev/null
+++ b/internal/kibana/status.go
@@ -0,0 +1,56 @@
+// 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 kibana
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+
+ "github.com/pkg/errors"
+)
+
+const SNAPSHOT_SUFFIX = "-SNAPSHOT"
+
+type VersionInfo struct {
+ Number string `json:"number"`
+ BuildSnapshot bool `json:"build_snapshot"`
+}
+
+func (v VersionInfo) Version() string {
+ if v.BuildSnapshot {
+ return fmt.Sprintf("%s%s", v.Number, SNAPSHOT_SUFFIX)
+ }
+ return v.Number
+}
+
+func (v VersionInfo) IsSnapshot() bool {
+ return v.BuildSnapshot
+}
+
+type statusType struct {
+ Version VersionInfo `json:"version"`
+}
+
+// Version method returns the version of Kibana (Elastic stack)
+func (c *Client) Version() (VersionInfo, error) {
+ var version VersionInfo
+ statusCode, respBody, err := c.get(StatusAPI)
+ if err != nil {
+ return version, errors.Wrapf(err, "could not reach status endpoint")
+ }
+
+ if statusCode != http.StatusOK {
+ return version, fmt.Errorf("could not get status data; API status code = %d; response body = %s", statusCode, respBody)
+ }
+
+ var status statusType
+ err = json.Unmarshal(respBody, &status)
+ if err != nil {
+ return version, errors.Wrapf(err, "unmarshalling response failed (body: \n%s)", respBody)
+ }
+
+ return status.Version, nil
+}
diff --git a/internal/kibana/url_prefixes.go b/internal/kibana/url_prefixes.go
index c7b1d6f602..1dce4a4dcc 100644
--- a/internal/kibana/url_prefixes.go
+++ b/internal/kibana/url_prefixes.go
@@ -11,6 +11,9 @@ const (
// SavedObjectsAPI is the prefix for all Kibana Saved Objects API resources.
SavedObjectsAPI = "/api/saved_objects"
+ // StatusAPI is the prefix for Kibana Status API resource.
+ StatusAPI = "/api/status"
+
// FleetAPI is the prefix for all Kibana Fleet API resources.
FleetAPI = "/api/fleet"
)
diff --git a/internal/testrunner/runners/system/servicedeployer/custom_agent.go b/internal/testrunner/runners/system/servicedeployer/custom_agent.go
index 393faa89e5..e9232b86cb 100644
--- a/internal/testrunner/runners/system/servicedeployer/custom_agent.go
+++ b/internal/testrunner/runners/system/servicedeployer/custom_agent.go
@@ -61,7 +61,7 @@ func (d *CustomAgentDeployer) SetUp(inCtxt ServiceContext) (DeployedService, err
}
env := append(
- appConfig.StackImageRefs(stackVersion).AsEnv(),
+ appConfig.StackImageRefs(stackVersion.Version()).AsEnv(),
fmt.Sprintf("%s=%s", serviceLogsDirEnv, inCtxt.Logs.Folder.Local),
fmt.Sprintf("%s=%s", localCACertEnv, caCertPath),
)
diff --git a/internal/testrunner/runners/system/servicedeployer/kubernetes.go b/internal/testrunner/runners/system/servicedeployer/kubernetes.go
index 1e227b25da..4e67dc3093 100644
--- a/internal/testrunner/runners/system/servicedeployer/kubernetes.go
+++ b/internal/testrunner/runners/system/servicedeployer/kubernetes.go
@@ -156,7 +156,7 @@ func installElasticAgentInCluster() error {
return errors.Wrap(err, "can't read Kibana injected metadata")
}
- elasticAgentManagedYaml, err := getElasticAgentYAML(stackVersion)
+ elasticAgentManagedYaml, err := getElasticAgentYAML(stackVersion.Version())
if err != nil {
return errors.Wrap(err, "can't retrieve Kubernetes file for Elastic Agent")
}