Skip to content

Commit

Permalink
Merge branch 'main' into bgazzard/fix-clean-start
Browse files Browse the repository at this point in the history
  • Loading branch information
Dartoxian committed Dec 18, 2023
2 parents 197381f + 5d74d16 commit e8c38e6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,21 @@ func CreateLogsAggregator(
}
if found {
logrus.Debugf("Found existing logs aggregator; cannot start a new one.")
logsAggregatorObj, _, err := getLogsAggregatorObjectAndContainerId(ctx, dockerManager)
logsAggregatorObj, containerId, err := getLogsAggregatorObjectAndContainerId(ctx, dockerManager)
if err != nil {
return nil, nil, stacktrace.Propagate(err, "An error occurred getting existing logs aggregator.")
}
return logsAggregatorObj, nil, nil
removeCtx := context.Background()
removeLogsAggregatorContainerFunc := func() {
if err := dockerManager.RemoveContainer(removeCtx, containerId); err != nil {
logrus.Errorf(
"Something failed while trying to remove the logs aggregator container with ID '%v'. Error was:\n%v",
containerId,
err)
logrus.Errorf("ACTION REQUIRED: You'll need to manually remove the logs aggregator server with Docker container ID '%v'!!!!!!", containerId)
}
}
return logsAggregatorObj, removeLogsAggregatorContainerFunc, nil
}

logsAggregatorNetwork, err := shared_helpers.GetEngineAndLogsComponentsNetwork(ctx, dockerManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ package user_support_constants

import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http"
"net/http/cookiejar"
"testing"
)

const (
safariUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
userAgentHeaderKey = "User-Agent"
)

func TestValidUrls(t *testing.T) {
for _, url := range urlsToValidateInTest {
jar, err := cookiejar.New(nil)
Expand All @@ -22,7 +28,11 @@ func TestValidUrls(t *testing.T) {
client := &http.Client{
Jar: jar,
}
resp, err := client.Get(url)
req, err := http.NewRequest(http.MethodGet, url, nil)
require.NoError(t, err, "Got an unexpected error while creating a new GET request with URL '%v'", url)
// Adding the User-Agent header because it's mandatory for sending a request to Twitter
req.Header.Set(userAgentHeaderKey, safariUserAgent)
resp, err := client.Do(req)
assert.NoError(t, err, "Got an unexpected error checking url '%v'", url)
assert.True(t, isValidReturnCode(resp.StatusCode), "URL '%v' returned unexpected status code: '%d'", url, resp.StatusCode)
assert.NoError(t, err, "Got an unexpected error checking url '%v'", url)
Expand Down

0 comments on commit e8c38e6

Please sign in to comment.