|
3 | 3 | package main |
4 | 4 |
|
5 | 5 | import ( |
| 6 | + cryptoRand "crypto/rand" |
6 | 7 | "fmt" |
7 | 8 | "math/rand" |
8 | 9 | "testing" |
@@ -45,9 +46,17 @@ func TestGCSMultipart(t *testing.T) { |
45 | 46 |
|
46 | 47 | env.queryWithNoError(t, r, "CREATE DATABASE IF NOT EXISTS "+dbName) |
47 | 48 | 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()) |
51 | 60 |
|
52 | 61 | execCmd(fmt.Sprintf("clickhouse-backup -c %s create --tables=%s.* %s", cfgPath, dbName, backupName)) |
53 | 62 | out := execCmd(fmt.Sprintf("clickhouse-backup -c %s upload %s", cfgPath, backupName)) |
|
0 commit comments