diff --git a/go.mod b/go.mod index 57c36246..4ae4409c 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/gesellix/couchdb-cluster-config/v17 v17.3.1 github.com/go-kit/log v0.2.1 github.com/golang/protobuf v1.5.3 - github.com/okeuday/erlang_go/v2 v2.0.5 + github.com/okeuday/erlang_go/v2 v2.0.6-develop.2 github.com/prometheus/client_golang v1.15.1 github.com/prometheus/client_model v0.4.0 github.com/prometheus/exporter-toolkit v0.10.0 diff --git a/go.sum b/go.sum index e5694df7..7f4e1e92 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/okeuday/erlang_go/v2 v2.0.5 h1:GLv90a/7KhQlDUngcgLyNhP3IbmKnFvA0p2Rq/nLoKc= -github.com/okeuday/erlang_go/v2 v2.0.5/go.mod h1:bUnKKmkI110+DM1rV59zPPqbcXp4yv18Fp2ofRwBmk4= +github.com/okeuday/erlang_go/v2 v2.0.6-develop.2 h1:0Rhl4TzmKMB9lWHIrLIpJWyN80dpQo6skDnjuj7SGr4= +github.com/okeuday/erlang_go/v2 v2.0.6-develop.2/go.mod h1:bUnKKmkI110+DM1rV59zPPqbcXp4yv18Fp2ofRwBmk4= 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/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= diff --git a/lib/couch-util_test.go b/lib/couch-util_test.go index 2b291d94..4ef77d8f 100644 --- a/lib/couch-util_test.go +++ b/lib/couch-util_test.go @@ -3,6 +3,9 @@ package lib import ( "encoding/json" "log" + "os" + "path/filepath" + "strings" "testing" ) @@ -36,3 +39,24 @@ func TestDecode2(t *testing.T) { t.Errorf("expected %s to contain %d tuples", b, numberOfShards) } } + +func TestDecode3(t *testing.T) { + example := filepath.Clean("../testdata/large_update_seq.txt") + data, err := os.ReadFile(example) + if err != nil { + t.Error(err) + } + updateSeq := strings.Trim(string(data), "\n\r ") + decoded, err := DecodeUpdateSeq(updateSeq) + if err != nil { + t.Error(err) + } + + log.Printf("decoded:\n%v\n", decoded) + + numberOfShards := 256 + if len(decoded) != numberOfShards { + b, _ := json.Marshal(decoded) + t.Errorf("expected %s to contain %d tuples", b, numberOfShards) + } +} diff --git a/testdata/large_update_seq.txt b/testdata/large_update_seq.txt new file mode 100644 index 00000000..6aca4779 --- /dev/null +++ b/testdata/large_update_seq.txt @@ -0,0 +1 @@ +g1AAAMsDeJzV3QfQHkUZAOAfEkQUDUVFVECQDgm3t3tbRGmCgihdQAVxKyE9IcEASQg1ShERRARUUJFgwYKIiCAWFEQEFTtIiRRBRJSuJn77v5vvm7vM3M14-e7fhZkwk5nMn4fd23vf3XffmzYyssbI5HFmZH89c56ebNRuh06feMg-B088YP6sieG30CQ5b8Y8PDfDdspce5zO5jh8NJqDde7MJDl_0jEz5to5M-S0SXrazHlGzpo1aYadO21kZGTNGeN7v46s6P1nRe-fKZPHqZEJszef3vu9tWlBlMV09f_gIWOWA2Z5CZMRajPLO8eQlpj_Aua_o5hxi88YxSBeZNyo1f-DGzBFS8x_APOfgJkB0wwVkjq9-n_wkEfm34D5N2BOOW8UYzQjDNVjhjEybZ-ZFwHzIjwzx94-iiF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