Skip to content

Commit

Permalink
tsdb parsing handles uint (grafana#11969)
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-d authored and rhnasc committed Apr 12, 2024
1 parent bf3f4d6 commit 281ed4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/storage/stores/shipper/indexshipper/tsdb/identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func ParseSingleTenantTSDBPath(p string) (id SingleTenantTSDBIdentifier, ok bool
return
}

checksum, err := strconv.ParseInt(elems[4], 16, 32)
checksum, err := strconv.ParseUint(elems[4], 16, 32)
if err != nil {
return
}
Expand Down
27 changes: 19 additions & 8 deletions pkg/storage/stores/shipper/indexshipper/tsdb/identifier_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tsdb

import (
"fmt"
"math"
"testing"
"time"

Expand All @@ -9,11 +11,10 @@ import (

func TestParseSingleTenantTSDBPath(t *testing.T) {
for _, tc := range []struct {
desc string
input string
id SingleTenantTSDBIdentifier
parent string
ok bool
desc string
input string
id SingleTenantTSDBIdentifier
ok bool
}{
{
desc: "simple_works",
Expand All @@ -24,8 +25,18 @@ func TestParseSingleTenantTSDBPath(t *testing.T) {
Through: 10,
Checksum: 255,
},
parent: "parent",
ok: true,
ok: true,
},
{
desc: "uint32_max_checksum_works",
input: fmt.Sprintf("1-compactor-1-10-%x.tsdb", math.MaxUint32),
id: SingleTenantTSDBIdentifier{
TS: time.Unix(1, 0),
From: 1,
Through: 10,
Checksum: math.MaxUint32,
},
ok: true,
},
{
desc: "wrong uploader name",
Expand All @@ -45,8 +56,8 @@ func TestParseSingleTenantTSDBPath(t *testing.T) {
} {
t.Run(tc.desc, func(t *testing.T) {
id, ok := ParseSingleTenantTSDBPath(tc.input)
require.Equal(t, tc.id, id)
require.Equal(t, tc.ok, ok)
require.Equal(t, tc.id, id)
})
}
}

0 comments on commit 281ed4f

Please sign in to comment.