Resolves CHRLY-H. Add debug statement to investigate #28

This commit is contained in:
ErickSkrauch 2021-02-07 16:47:21 +01:00
parent 60774b6b72
commit 3bf6872f3e
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
2 changed files with 39 additions and 9 deletions

View File

@ -9,6 +9,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/getsentry/raven-go"
"github.com/mediocregopher/radix.v2/pool" "github.com/mediocregopher/radix.v2/pool"
"github.com/mediocregopher/radix.v2/redis" "github.com/mediocregopher/radix.v2/redis"
"github.com/mediocregopher/radix.v2/util" "github.com/mediocregopher/radix.v2/util"
@ -204,6 +205,19 @@ func findMojangUuidByUsername(username string, conn util.Cmder) (string, bool, e
data, _ := response.Str() data, _ := response.Str()
parts := strings.Split(data, ":") parts := strings.Split(data, ":")
// Temporary debug statement to investigate https://github.com/elyby/chrly/issues/28
if len(parts) < 2 {
raven.Capture(raven.NewPacketWithExtra(
"mojangUsernameToUuid hash contains corrupted data",
raven.Extra{
"rawValue": "hello world",
"username": "this is username",
},
), map[string]string{})
return "", false, nil
}
timestamp, _ := strconv.ParseInt(parts[1], 10, 64) timestamp, _ := strconv.ParseInt(parts[1], 10, 64)
storedAt := time.Unix(timestamp, 0) storedAt := time.Unix(timestamp, 0)
if storedAt.Add(time.Hour * 24 * 30).Before(now()) { if storedAt.Add(time.Hour * 24 * 30).Before(now()) {

View File

@ -360,6 +360,7 @@ func (suite *redisTestSuite) TestGetUuid() {
} }
func (suite *redisTestSuite) TestStoreUuid() { func (suite *redisTestSuite) TestStoreUuid() {
suite.RunSubTest("store uuid", func() {
now = func() time.Time { now = func() time.Time {
return time.Date(2020, 04, 21, 02, 10, 16, 0, time.UTC) return time.Date(2020, 04, 21, 02, 10, 16, 0, time.UTC)
} }
@ -371,6 +372,21 @@ func (suite *redisTestSuite) TestStoreUuid() {
suite.Require().False(resp.IsType(redis.Nil)) suite.Require().False(resp.IsType(redis.Nil))
str, _ := resp.Str() str, _ := resp.Str()
suite.Require().Equal(str, "d3ca513eb3e14946b58047f2bd3530fd:1587435016") suite.Require().Equal(str, "d3ca513eb3e14946b58047f2bd3530fd:1587435016")
})
suite.RunSubTest("store empty uuid", func() {
now = func() time.Time {
return time.Date(2020, 04, 21, 02, 10, 16, 0, time.UTC)
}
err := suite.Redis.StoreUuid("Mock", "")
suite.Require().Nil(err)
resp := suite.cmd("HGET", "hash:mojang-username-to-uuid", "mock")
suite.Require().False(resp.IsType(redis.Nil))
str, _ := resp.Str()
suite.Require().Equal(str, ":1587435016")
})
} }
func (suite *redisTestSuite) TestPing() { func (suite *redisTestSuite) TestPing() {