Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit de744a0

Browse files
mdelapenyamergify-bot
authored andcommitted
fix: check if kibana version is a commit (#1047)
(cherry picked from commit 05ab18f)
1 parent cf76cd6 commit de744a0

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

e2e/_suites/fleet/ingest_manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func InitializeIngestManagerTestSuite(ctx *godog.TestSuiteContext) {
123123
}
124124

125125
profileEnv["kibanaDockerNamespace"] = "kibana"
126-
if strings.HasPrefix(kibanaVersion, "pr") {
126+
if strings.HasPrefix(kibanaVersion, "pr") || e2e.IsCommit(kibanaVersion) {
127127
// because it comes from a PR
128128
profileEnv["kibanaDockerNamespace"] = "observability-ci"
129129
}

e2e/utils.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"os"
1515
"path"
1616
"path/filepath"
17+
"regexp"
1718
"strings"
1819
"time"
1920

@@ -522,6 +523,13 @@ func getBucketSearchNextPageParam(jsonParsed *gabs.Container) string {
522523
return "&pageToken=" + nextPageToken
523524
}
524525

526+
// IsCommit returns true if the string matches commit format
527+
func IsCommit(s string) bool {
528+
re := regexp.MustCompile(`\b[0-9a-f]{5,40}\b`)
529+
530+
return re.MatchString(s)
531+
}
532+
525533
func processBucketSearchPage(jsonParsed *gabs.Container, currentPage int, bucket string, prefix string, object string) (string, error) {
526534
items := jsonParsed.Path("items").Children()
527535

e2e/utils_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,22 @@ func TestGetGCPBucketCoordinates_Snapshots(t *testing.T) {
313313
})
314314
}
315315

316+
func TestIsCommit(t *testing.T) {
317+
t.Run("Returns true with commits", func(t *testing.T) {
318+
assert.True(t, IsCommit("abcdef1234"))
319+
assert.True(t, IsCommit("a12345"))
320+
assert.True(t, IsCommit("abcdef1"))
321+
})
322+
323+
t.Run("Returns false with non-commits", func(t *testing.T) {
324+
assert.False(t, IsCommit("master"))
325+
assert.False(t, IsCommit("7.x"))
326+
assert.False(t, IsCommit("7.12.x"))
327+
assert.False(t, IsCommit("7.11.x"))
328+
assert.False(t, IsCommit("pr12345"))
329+
})
330+
}
331+
316332
func TestProcessBucketSearchPage_CommitFound(t *testing.T) {
317333
// retrieving last element in commits.json
318334
object := "024b732844d40bdb2bf806480af2b03fcb8fbdbe/elastic-agent/elastic-agent-8.0.0-SNAPSHOT-darwin-x86_64.tar.gz"

0 commit comments

Comments
 (0)