Skip to content

Commit d79a61c

Browse files
authored
Fix TestBatchAppendRows work different on cloud (#1251)
1 parent bd0ade6 commit d79a61c

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

tests/batch_block_test.go

+3-17
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package tests
1919

2020
import (
21-
"sync/atomic"
2221
"testing"
2322

2423
"github.com/ClickHouse/clickhouse-go/v2"
@@ -32,14 +31,7 @@ import (
3231
func TestBatchAppendRows(t *testing.T) {
3332
te, err := GetTestEnvironment(testSet)
3433
require.NoError(t, err)
35-
blocksRead := atomic.Uint64{}
3634
opts := ClientOptionsFromEnv(te, clickhouse.Settings{})
37-
opts.Debug = true
38-
opts.Debugf = func(format string, args ...interface{}) {
39-
if format == "[batch.appendRowsBlocks] blockNum = %d" {
40-
blocksRead.Store(uint64(args[0].(int))) // store the last block number read from rows
41-
}
42-
}
4335

4436
conn, err := GetConnectionWithOptions(&opts)
4537
require.NoError(t, err)
@@ -49,19 +41,14 @@ func TestBatchAppendRows(t *testing.T) {
4941
// given we have two tables and a million rows in the source table
5042
var tables = []string{"source", "target"}
5143
for _, table := range tables {
52-
require.NoError(t, conn.Exec(context.Background(), "create table if not exists "+table+" (number1 Int, number2 String, number3 Tuple(String, Int), number4 DateTime) engine = MergeTree() order by tuple()"))
44+
require.NoError(t, conn.Exec(context.Background(), "create table if not exists "+table+" (number1 Int, number2 String, number3 Tuple(String, Int), number4 DateTime) engine = Memory()"))
5345
defer conn.Exec(context.Background(), "drop table if exists "+table)
5446
}
5547

5648
require.NoError(t, conn.Exec(ctx, "INSERT INTO source SELECT number, 'string', tuple('foo', number), now() FROM system.numbers LIMIT 1000000"))
5749

5850
// when we create a batch with direct data block access 10 times
59-
60-
selectCtx := clickhouse.Context(ctx, clickhouse.WithSettings(clickhouse.Settings{
61-
"max_block_size": 1000,
62-
}))
63-
64-
sourceRows, err := conn.Query(selectCtx, "SELECT * FROM source")
51+
sourceRows, err := conn.Query(ctx, "SELECT * FROM source")
6552
require.NoError(t, err)
6653
defer sourceRows.Close()
6754

@@ -75,6 +62,5 @@ func TestBatchAppendRows(t *testing.T) {
7562
require.NoError(t, row.Err())
7663
var count uint64
7764
require.NoError(t, row.Scan(&count))
78-
assert.Equal(t, uint64(1000000), count)
79-
assert.Equal(t, uint64(999), blocksRead.Load())
65+
assert.Equal(t, 1000000, int(count))
8066
}

0 commit comments

Comments
 (0)