Skip to content

Commit b9676e4

Browse files
committed
fix TestGCSMultipart, fix #1028
1 parent 7a1a9de commit b9676e4

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

test/integration/gcs_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package main
44

55
import (
6+
cryptoRand "crypto/rand"
67
"fmt"
78
"math/rand"
89
"testing"
@@ -45,9 +46,17 @@ func TestGCSMultipart(t *testing.T) {
4546

4647
env.queryWithNoError(t, r, "CREATE DATABASE IF NOT EXISTS "+dbName)
4748
env.queryWithNoError(t, r, "CREATE TABLE IF NOT EXISTS "+dbName+".big (key UInt64, value String) ENGINE=MergeTree() ORDER BY key")
48-
// ~30MB of incompressible data, so the tar stream exceeds multipart_upload_min_size
49-
// and splits into multiple chunk_size parts
50-
env.queryWithNoError(t, r, "INSERT INTO "+dbName+".big SELECT number, randomString(1000) FROM numbers(30000)")
49+
// ~30MB of random data (LZ4-incompressible on disk) generated on the Go side, so the
50+
// tar stream exceeds multipart_upload_min_size and splits into multiple chunk_size parts
51+
batch, err := env.ch.GetConn().PrepareBatch(t.Context(), "INSERT INTO "+dbName+".big")
52+
r.NoError(err)
53+
value := make([]byte, 1000)
54+
for i := range 30000 {
55+
_, err = cryptoRand.Read(value)
56+
r.NoError(err)
57+
r.NoError(batch.Append(uint64(i), string(value)))
58+
}
59+
r.NoError(batch.Send())
5160

5261
execCmd(fmt.Sprintf("clickhouse-backup -c %s create --tables=%s.* %s", cfgPath, dbName, backupName))
5362
out := execCmd(fmt.Sprintf("clickhouse-backup -c %s upload %s", cfgPath, backupName))

0 commit comments

Comments
 (0)