Skip to content

Commit 3d69369

Browse files
authored
Merge branch 'main' into dependabot/go_modules/github.com/elastic/gosigar-0.14.3
2 parents 0cb4624 + 775e020 commit 3d69369

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

internal/pkg/core/backoff/backoff_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
type factory func(<-chan struct{}) Backoff
1616

1717
func TestCloseChannel(t *testing.T) {
18-
init := 2 * time.Millisecond
18+
init := time.Second
1919
max := 5 * time.Second
2020

2121
tests := map[string]factory{
@@ -32,7 +32,7 @@ func TestCloseChannel(t *testing.T) {
3232
c := make(chan struct{})
3333
b := f(c)
3434
close(c)
35-
assert.False(t, b.Wait())
35+
assert.False(t, b.Wait(), "should return false because the channel shuld get closed faster than the next wait duration")
3636
})
3737
}
3838
}
@@ -59,7 +59,7 @@ func TestUnblockAfterInit(t *testing.T) {
5959

6060
startedAt := time.Now()
6161
assert.True(t, WaitOnError(b, errors.New("bad bad")))
62-
assert.True(t, time.Now().Sub(startedAt) >= init)
62+
assert.True(t, time.Since(startedAt) >= init)
6363
})
6464
}
6565
}
@@ -87,7 +87,7 @@ func TestNextWait(t *testing.T) {
8787

8888
startedAt := time.Now()
8989
b.Wait()
90-
waitDuration := time.Now().Sub(startedAt)
90+
waitDuration := time.Since(startedAt)
9191
nextWait := b.NextWait()
9292

9393
t.Logf("actualWait: %s startWait: %s nextWait: %s", waitDuration, startWait, nextWait)

testing/integration/container_cmd_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"testing"
1515
"time"
1616

17+
"github.com/google/uuid"
1718
"github.com/stretchr/testify/require"
1819

1920
"github.com/elastic/elastic-agent-libs/kibana"
@@ -41,7 +42,7 @@ func TestContainerCMD(t *testing.T) {
4142
require.NoError(t, err)
4243

4344
createPolicyReq := kibana.AgentPolicy{
44-
Name: fmt.Sprintf("test-policy-enroll-%d", time.Now().Unix()),
45+
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
4546
Namespace: info.Namespace,
4647
Description: "test policy for agent enrollment",
4748
MonitoringEnabled: []kibana.MonitoringEnabledOption{

testing/integration/delay_enroll_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"testing"
1414
"time"
1515

16+
"github.com/google/uuid"
1617
"github.com/stretchr/testify/require"
1718

1819
"github.com/elastic/elastic-agent-libs/kibana"
@@ -44,7 +45,7 @@ func TestDelayEnroll(t *testing.T) {
4445
// name. This policy does not contain any integration.
4546
t.Log("Enrolling agent in Fleet with a test policy")
4647
createPolicyReq := kibana.AgentPolicy{
47-
Name: fmt.Sprintf("test-policy-enroll-%d", time.Now().Unix()),
48+
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
4849
Namespace: info.Namespace,
4950
Description: "test policy for agent enrollment",
5051
MonitoringEnabled: []kibana.MonitoringEnabledOption{

testing/integration/logs_ingestion_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"context"
1212
"encoding/json"
1313
"fmt"
14-
"math/rand"
1514
"net/http"
1615
"net/http/httputil"
1716
"os"
@@ -22,6 +21,7 @@ import (
2221
"text/template"
2322
"time"
2423

24+
"github.com/google/uuid"
2525
"github.com/stretchr/testify/assert"
2626
"github.com/stretchr/testify/require"
2727

@@ -57,7 +57,7 @@ func TestLogIngestionFleetManaged(t *testing.T) {
5757
// name. This policy does not contain any integration.
5858
t.Log("Enrolling agent in Fleet with a test policy")
5959
createPolicyReq := kibana.AgentPolicy{
60-
Name: fmt.Sprintf("test-policy-enroll-%d", time.Now().Unix()),
60+
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
6161
Namespace: info.Namespace,
6262
Description: "test policy for agent enrollment",
6363
MonitoringEnabled: []kibana.MonitoringEnabledOption{
@@ -253,8 +253,9 @@ func testFlattenedDatastreamFleetPolicy(
253253
policy kibana.PolicyResponse,
254254
) {
255255
dsType := "logs"
256-
dsNamespace := cleanString(fmt.Sprintf("%snamespace%d", t.Name(), rand.Uint64()))
257-
dsDataset := cleanString(fmt.Sprintf("%s-dataset", t.Name()))
256+
id := uuid.New().String()
257+
dsNamespace := cleanString(fmt.Sprintf("namespace-%s", id))
258+
dsDataset := cleanString(fmt.Sprintf("dataset-%s", id))
258259
numEvents := 60
259260

260261
// tempDir is not deleted to help with debugging issues

0 commit comments

Comments
 (0)