Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
b7a6f15f
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b7a6f15f
编写于
9月 29, 2020
作者:
V
Vladimir Chebotarev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added test for GZIP in S3 storage.
上级
698768ad
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
82 addition
and
0 deletion
+82
-0
tests/integration/test_storage_s3/test.py
tests/integration/test_storage_s3/test.py
+82
-0
未找到文件。
tests/integration/test_storage_s3/test.py
浏览文件 @
b7a6f15f
import
gzip
import
json
import
logging
import
os
import
random
import
StringIO
import
threading
import
helpers.client
...
...
@@ -57,6 +59,11 @@ def prepare_s3_bucket(cluster):
minio_client
.
make_bucket
(
cluster
.
minio_restricted_bucket
)
def
put_s3_file_content
(
cluster
,
bucket
,
filename
,
data
):
buf
=
StringIO
.
StringIO
(
data
)
cluster
.
minio_client
.
put_object
(
bucket
,
filename
,
buf
,
len
(
data
))
# Returns content of given S3 file as string.
def
get_s3_file_content
(
cluster
,
bucket
,
filename
):
# type: (ClickHouseCluster, str) -> str
...
...
@@ -344,3 +351,78 @@ def test_infinite_redirect(cluster):
exception_raised
=
True
finally
:
assert
exception_raised
def
test_storage_s3_get_gzip
(
cluster
):
bucket
=
cluster
.
minio_bucket
instance
=
cluster
.
instances
[
"dummy"
]
filename
=
"test_get_gzip.bin"
name
=
"test_get_gzip"
data
=
[
"Sophia Intrieri,55"
,
"Jack Taylor,71"
,
"Christopher Silva,66"
,
"Clifton Purser,35"
,
"Richard Aceuedo,43"
,
"Lisa Hensley,31"
,
"Alice Wehrley,1"
,
"Mary Farmer,47"
,
"Samara Ramirez,19"
,
"Shirley Lloyd,51"
,
"Santos Cowger,0"
,
"Richard Mundt,88"
,
"Jerry Gonzalez,15"
,
"Angela James,10"
,
"Norman Ortega,33"
,
""
]
buf
=
StringIO
.
StringIO
()
compressed
=
gzip
.
GzipFile
(
fileobj
=
buf
,
mode
=
"wb"
)
compressed
.
write
(
"
\n
"
.
join
(
data
))
compressed
.
close
()
put_s3_file_content
(
cluster
,
bucket
,
filename
,
buf
.
getvalue
())
try
:
run_query
(
instance
,
"CREATE TABLE {} (name String, id UInt32) ENGINE = S3('http://{}:{}/{}/{}', 'CSV', 'gzip')"
.
format
(
name
,
cluster
.
minio_host
,
cluster
.
minio_port
,
bucket
,
filename
))
run_query
(
instance
,
"SELECT sum(id) FROM {}"
.
format
(
name
)).
splitlines
()
==
[
"565"
]
finally
:
run_query
(
instance
,
"DROP TABLE {}"
.
format
(
name
))
def
test_storage_s3_put_gzip
(
cluster
):
bucket
=
cluster
.
minio_bucket
instance
=
cluster
.
instances
[
"dummy"
]
filename
=
"test_put_gzip.bin"
name
=
"test_put_gzip"
data
=
[
"'Joseph Tomlinson',5"
,
"'Earnest Essary',44"
,
"'Matha Pannell',24"
,
"'Michael Shavers',46"
,
"'Elias Groce',38"
,
"'Pamela Bramlet',50"
,
"'Lewis Harrell',49"
,
"'Tamara Fyall',58"
,
"'George Dixon',38"
,
"'Alice Walls',49"
,
"'Paula Mais',24"
,
"'Myrtle Pelt',93"
,
"'Sylvia Naffziger',18"
,
"'Amanda Cave',83"
,
"'Yolanda Joseph',89"
]
try
:
run_query
(
instance
,
"CREATE TABLE {} (name String, id UInt32) ENGINE = S3('http://{}:{}/{}/{}', 'CSV', 'gzip')"
.
format
(
name
,
cluster
.
minio_host
,
cluster
.
minio_port
,
bucket
,
filename
))
run_query
(
instance
,
"INSERT INTO {} VALUES ({})"
.
format
(
name
,
"),("
.
join
(
data
)))
buf
=
StringIO
.
StringIO
(
get_s3_file_content
(
cluster
,
bucket
,
filename
))
f
=
gzip
.
GzipFile
(
fileobj
=
buf
,
mode
=
"rb"
)
uncompressed_content
=
f
.
read
()
assert
sum
([
int
(
i
.
split
(
','
)[
1
])
for
i
in
uncompressed_content
.
splitlines
()
])
==
708
finally
:
run_query
(
instance
,
"DROP TABLE {}"
.
format
(
name
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录