Skip to content

Commit

Permalink
Ensure fleet-server-es hosts have a port number
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman committed May 24, 2024
1 parent 86cf397 commit 20f4a25
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions testing/integration/fleetserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"context"
"crypto/tls"
"net/http"
"net/url"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -83,6 +84,23 @@ func TestInstallFleetServerBootstrap(t *testing.T) {

esHost, ok := os.LookupEnv("ELASTICSEARCH_HOST")
require.True(t, ok, "environment var ELASTICSEARCH_HOST is empty")
u, err := url.Parse(esHost)
require.NoError(t, err, "could not parse %q as a URL", esHost)
if u.Port() == "" {
switch u.Scheme {
case "":
u.Host += ":80"
u.Scheme = "http"
case "http":
u.Host += ":80"
case "https":
u.Host += ":443"
default:
require.Failf(t, "elasticsearch host has unknown scheme: %s", u.Scheme)
}
esHost = u.String()
}

t.Logf("fleet-server will enroll with es host: %q", esHost)

// Run `elastic-agent install` with fleet-server bootstrap options.
Expand Down

0 comments on commit 20f4a25

Please sign in to comment.