| #!/bin/env python |
| # -*- coding: utf-8 -*- |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| ############################################################################ |
| # |
| # @file test_sys_precision.py |
| # @date 2015/02/04 15:26:21 |
| # @brief This file is a test file for palo data loading and verifying. |
| # |
| ############################################################################# |
| |
| """ |
| 测试数据精度 |
| """ |
| |
| import time |
| from data import precision as DATA |
| from lib import palo_config |
| from lib import palo_client |
| from lib import util |
| |
| config = palo_config.config |
| LOG = palo_client.LOG |
| L = palo_client.L |
| |
| broker_info = palo_config.broker_info |
| |
| |
| def setup_module(): |
| """ |
| setUp |
| """ |
| global client |
| client = palo_client.get_client(config.fe_host, config.fe_query_port, user=config.fe_user, |
| password=config.fe_password, http_port=config.fe_http_port) |
| |
| |
| def test_float_precision(): |
| """ |
| { |
| "title": "test_sys_precision.test_float_precision", |
| "describe": "测试float数据类型的精度", |
| "tag": "function,p1" |
| } |
| """ |
| """ |
| 测试float数据类型的精度 |
| """ |
| database_name, table_name, index_name = util.gen_num_format_name_list() |
| LOG.info(L('', database_name=database_name, \ |
| table_name=table_name, index_name=index_name)) |
| client.clean(database_name) |
| client.create_database(database_name) |
| client.create_table(table_name, DATA.schema_1, keys_desc='AGGREGATE KEY (K1)') |
| |
| time.sleep(1) |
| |
| assert client.show_tables(table_name) |
| assert client.get_index(table_name) |
| |
| data_desc_list = palo_client.LoadDataInfo(DATA.file_path, table_name) |
| ret = client.batch_load(util.get_label(), data_desc_list, is_wait=True, broker=broker_info) |
| assert ret |
| |
| ret = client.verify(DATA.expected_data_file_list, table_name) |
| assert ret |
| client.clean(database_name) |
| |
| |
| def test_double_precision(): |
| """ |
| { |
| "title": "test_sys_precision.test_double_precision", |
| "describe": "测试double数据类型的精度", |
| "tag": "function,p1" |
| } |
| """ |
| """ |
| 测试double数据类型的精度 |
| """ |
| database_name, table_name, index_name = util.gen_num_format_name_list() |
| LOG.info(L('', database_name=database_name, \ |
| table_name=table_name, index_name=index_name)) |
| client.clean(database_name) |
| client.create_database(database_name) |
| client.create_table(table_name, DATA.schema_2, keys_desc='AGGREGATE KEY (K1)') |
| |
| time.sleep(1) |
| |
| assert client.show_tables(table_name) |
| assert client.get_index(table_name) |
| |
| data_desc_list = palo_client.LoadDataInfo(DATA.file_path, table_name) |
| ret = client.batch_load(util.get_label(), data_desc_list, is_wait=True, broker=broker_info) |
| assert ret |
| |
| ret = client.verify(DATA.expected_data_file_list, table_name) |
| assert ret |
| client.clean(database_name) |
| |
| |