From d995685db86a78428aed2f6515baa35e8d8e48e2 Mon Sep 17 00:00:00 2001 From: Ryan Gang Date: Thu, 12 Dec 2024 13:02:59 +0530 Subject: [PATCH 1/4] chore: update dependencies in go.mod and go.sum - Bump tester-utils to v0.2.39 - Upgrade testify to v1.10.0 - Update color to v1.18.0 - Upgrade golang.org/x/sys to v0.28.0 --- go.mod | 8 ++++---- go.sum | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index c54092c..dd7624f 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,19 @@ module github.com/codecrafters-io/kafka-tester go 1.22.1 require ( - github.com/codecrafters-io/tester-utils v0.2.38 + github.com/codecrafters-io/tester-utils v0.2.39 github.com/google/uuid v1.6.0 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.17.0 // indirect + github.com/fatih/color v1.18.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.25.0 // indirect + golang.org/x/sys v0.28.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 5501395..4ef54bf 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,11 @@ -github.com/codecrafters-io/tester-utils v0.2.38 h1:rKxm02A4Ll6gGrwcsGKDHxZExjH4hMbtu2ra7r/E7Lk= -github.com/codecrafters-io/tester-utils v0.2.38/go.mod h1:VgP0WmmRsA8L1urWGMXPW4Zv5jcwHwR0LdKZ8ZAEFT4= +github.com/codecrafters-io/tester-utils v0.2.39 h1:az0p4nS0qFTbGcuVj0JaLGSRCCa7r9a72sug+QfKMYM= +github.com/codecrafters-io/tester-utils v0.2.39/go.mod h1:VgP0WmmRsA8L1urWGMXPW4Zv5jcwHwR0LdKZ8ZAEFT4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -15,12 +17,14 @@ github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= From 7a78ebee78bf26e4b57ada49aa6c7a13edbbad6c Mon Sep 17 00:00:00 2001 From: Ryan Gang Date: Thu, 12 Dec 2024 13:03:08 +0530 Subject: [PATCH 2/4] refactor: replace custom random integer function with tester-utils method --- protocol/common/constants.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/protocol/common/constants.go b/protocol/common/constants.go index 510c6ed..119819a 100644 --- a/protocol/common/constants.go +++ b/protocol/common/constants.go @@ -2,7 +2,6 @@ package common import ( "fmt" - "slices" "sort" "github.com/codecrafters-io/tester-utils/random" @@ -26,7 +25,7 @@ var ( TOPIC1_NAME = topic_names[0] TOPIC2_NAME = topic_names[1] TOPIC3_NAME = topic_names[2] - random_topic_uuids = getUniqueRandomIntegers(10, 99, 3) + random_topic_uuids = random.RandomUniqueInts(10, 100, 3) TOPIC1_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[0]) TOPIC2_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[1]) TOPIC3_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[2]) @@ -48,15 +47,3 @@ func GetSortedValues[T string](values []T) []T { }) return values } - -func getUniqueRandomIntegers(min, max, count int) []int { - randomInts := []int{} - for i := 0; i < count; i++ { - randomInt := random.RandomInt(min, max) - for slices.Contains(randomInts, randomInt) { - randomInt = random.RandomInt(min, max) - } - randomInts = append(randomInts, randomInt) - } - return randomInts -} From 0234e2fc99f0a2ede26ebcb2baa169173f42ee13 Mon Sep 17 00:00:00 2001 From: Ryan Gang Date: Thu, 12 Dec 2024 13:24:11 +0530 Subject: [PATCH 3/4] chore: update tester-utils dependency to v0.2.40 --- go.mod | 2 +- go.sum | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index dd7624f..b2e93c2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/codecrafters-io/kafka-tester go 1.22.1 require ( - github.com/codecrafters-io/tester-utils v0.2.39 + github.com/codecrafters-io/tester-utils v0.2.40 github.com/google/uuid v1.6.0 github.com/stretchr/testify v1.10.0 ) diff --git a/go.sum b/go.sum index 4ef54bf..a9a4d86 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,7 @@ -github.com/codecrafters-io/tester-utils v0.2.39 h1:az0p4nS0qFTbGcuVj0JaLGSRCCa7r9a72sug+QfKMYM= -github.com/codecrafters-io/tester-utils v0.2.39/go.mod h1:VgP0WmmRsA8L1urWGMXPW4Zv5jcwHwR0LdKZ8ZAEFT4= +github.com/codecrafters-io/tester-utils v0.2.40 h1:5YIQjgenDbLf5HH0hhqN0jumBGnbrjXdR0DryaKUu/I= +github.com/codecrafters-io/tester-utils v0.2.40/go.mod h1:VgP0WmmRsA8L1urWGMXPW4Zv5jcwHwR0LdKZ8ZAEFT4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -21,8 +19,6 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 703a05d926740d6865988809edcbddcc90ee4a3e Mon Sep 17 00:00:00 2001 From: Ryan Gang Date: Thu, 12 Dec 2024 13:25:29 +0530 Subject: [PATCH 4/4] refactor: update random topic UUID generation method --- protocol/common/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/common/constants.go b/protocol/common/constants.go index 119819a..1345869 100644 --- a/protocol/common/constants.go +++ b/protocol/common/constants.go @@ -25,7 +25,7 @@ var ( TOPIC1_NAME = topic_names[0] TOPIC2_NAME = topic_names[1] TOPIC3_NAME = topic_names[2] - random_topic_uuids = random.RandomUniqueInts(10, 100, 3) + random_topic_uuids = random.RandomInts(10, 100, 3) TOPIC1_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[0]) TOPIC2_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[1]) TOPIC3_UUID = fmt.Sprintf("00000000-0000-4000-8000-0000000000%02d", random_topic_uuids[2])