提交 92c36a45 编写于 作者: H Heikki Linnakangas

Move tests for gp_toolkit.__gp_ao* functions from TINC to main test suite.

上级 071d76b1
-- Run some basic tests on the gp_toolkit functions that deal with AO segfiles.
-- The exact output varies depending on cluster configuration and concurrent
-- activity in the system, so for most functions, we only do count(*). That
-- at least verifies that they don't crash.
-- Create test tables
--
-- We use DISTRIBUTED BY (c), and have the same c value in all the rows, to
-- put all the rows on the same segment. That way, the test output doesn't
-- depend on the number of segments.
DROP TABLE IF EXISTS toolkit_ao_test;
CREATE TABLE toolkit_ao_test (a INT, b INT, c INT)
WITH (appendonly=true) DISTRIBUTED BY (c);
INSERT INTO toolkit_ao_test SELECT i as a, i as b, 1 FROM generate_series(1,20) AS i;
UPDATE toolkit_ao_test SET b = 0 WHERE a = 1;
DELETE FROM toolkit_ao_test WHERE a = 2;
DROP TABLE IF EXISTS toolkit_aocs_test;
CREATE TABLE toolkit_aocs_test (a INT, b INT, C INT)
WITH (appendonly=true, orientation=column) DISTRIBUTED BY (c);
INSERT INTO toolkit_aocs_test SELECT i as a, i as b FROM generate_series(1,20) AS i;
UPDATE toolkit_aocs_test SET b = 0 WHERE a = 1;
DELETE FROM toolkit_aocs_test WHERE a = 2;
-- Investigate them with the gp_toolkit functions
SELECT count(*) FROM gp_toolkit.__gp_aoseg_history('toolkit_ao_test'::regclass);
count
-------
4
(1 row)
SELECT count(*) FROM gp_toolkit.__gp_aocsseg('toolkit_aocs_test'::regclass);
count
-------
3
(1 row)
SELECT count(*) FROM gp_toolkit.__gp_aocsseg_name('toolkit_aocs_test');
count
-------
3
(1 row)
SELECT count(*) FROM gp_toolkit.__gp_aocsseg_history('toolkit_aocs_test'::regclass);
count
-------
12
(1 row)
SELECT count(*) FROM gp_toolkit.__gp_aoseg_history('toolkit_ao_test'::regclass);
count
-------
4
(1 row)
SELECT * FROM gp_toolkit.__gp_aovisimap('toolkit_ao_test'::regclass);
tid | segno | row_num
-----+-------+---------
(0 rows)
SELECT * FROM gp_toolkit.__gp_aovisimap_name('toolkit_ao_test');
tid | segno | row_num
-----+-------+---------
(0 rows)
SELECT count(*) FROM gp_toolkit.__gp_aovisimap_hidden_info('toolkit_ao_test'::regclass);
count
-------
1
(1 row)
SELECT count(*) FROM gp_toolkit.__gp_aovisimap_hidden_info_name('toolkit_ao_test');
count
-------
1
(1 row)
SELECT * FROM gp_toolkit.__gp_aovisimap_entry('toolkit_ao_test'::regclass);
segno | first_row_num | hidden_tupcount | bitmap
-------+---------------+-----------------+--------
(0 rows)
SELECT * FROM gp_toolkit.__gp_aovisimap_entry_name('toolkit_ao_test');
segno | first_row_num | hidden_tupcount | bitmap
-------+---------------+-----------------+--------
(0 rows)
SELECT count(*) FROM gp_toolkit.__gp_aoseg_name('toolkit_ao_test');
count
-------
1
(1 row)
-- The same, but on the segments.
SELECT (t).* FROM (
SELECT gp_toolkit.__gp_aovisimap('toolkit_ao_test'::regclass) AS t FROM gp_dist_random('gp_id')
) AS x;
tid | segno | row_num
------------------+-------+---------
(33554432,32769) | 1 | 1
(33554432,32770) | 1 | 2
(2 rows)
SELECT (t).* FROM (
SELECT gp_toolkit.__gp_aovisimap_name('toolkit_ao_test') AS t FROM gp_dist_random('gp_id')
) AS x;
tid | segno | row_num
------------------+-------+---------
(33554432,32769) | 1 | 1
(33554432,32770) | 1 | 2
(2 rows)
SELECT (t).segno, (t).first_row_num, (t).hidden_tupcount >= 1 as hidden_tupcount_nonzero, (t).bitmap like '01%' as bitmap_starts_with_01 FROM (
SELECT gp_toolkit.__gp_aovisimap_entry('toolkit_ao_test'::regclass) AS t FROM gp_dist_random('gp_id')
) AS x;
segno | first_row_num | hidden_tupcount_nonzero | bitmap_starts_with_01
-------+---------------+-------------------------+-----------------------
1 | 0 | t | t
(1 row)
SELECT (t).segno, (t).first_row_num, (t).hidden_tupcount >= 1 as hidden_tupcount_nonzero, (t).bitmap like '01%' as bitmap_starts_with_01 FROM (
SELECT gp_toolkit.__gp_aovisimap_entry_name('toolkit_ao_test') AS t FROM gp_dist_random('gp_id')
) AS x;
segno | first_row_num | hidden_tupcount_nonzero | bitmap_starts_with_01
-------+---------------+-------------------------+-----------------------
1 | 0 | t | t
(1 row)
......@@ -78,14 +78,15 @@ test: partition_indexing parruleord
test: alter_table_ao ao_create_alter_valid_table subtransaction_limit oid_consistency udf_exception_blocks
ignore: icudp_full
test: resource_queue
test: resource_queue resource_queue_function
test: wrkloadadmin
# gp_toolkit performs a vacuum and checks that it truncated the relation. That
# might not happen if other backends are holding transactions open, preventing
# vacuum from removing dead tuples.
test: gp_toolkit
test: filespace trig auth_constraint role rle portals_updatable plpgsql_cache timeseries resource_queue_function pg_stat_last_operation gp_numeric_agg partindex_test partition_pruning_with_fn dsp runtime_stats
test: gp_toolkit_ao_funcs filespace trig auth_constraint role rle portals_updatable plpgsql_cache timeseries pg_stat_last_operation gp_numeric_agg partindex_test partition_pruning_with_fn dsp runtime_stats
# direct dispatch tests
test: direct_dispatch bfv_dd bfv_dd_multicolumn bfv_dd_types
......
-- Run some basic tests on the gp_toolkit functions that deal with AO segfiles.
-- The exact output varies depending on cluster configuration and concurrent
-- activity in the system, so for most functions, we only do count(*). That
-- at least verifies that they don't crash.
-- Create test tables
--
-- We use DISTRIBUTED BY (c), and have the same c value in all the rows, to
-- put all the rows on the same segment. That way, the test output doesn't
-- depend on the number of segments.
DROP TABLE IF EXISTS toolkit_ao_test;
CREATE TABLE toolkit_ao_test (a INT, b INT, c INT)
WITH (appendonly=true) DISTRIBUTED BY (c);
INSERT INTO toolkit_ao_test SELECT i as a, i as b, 1 FROM generate_series(1,20) AS i;
UPDATE toolkit_ao_test SET b = 0 WHERE a = 1;
DELETE FROM toolkit_ao_test WHERE a = 2;
DROP TABLE IF EXISTS toolkit_aocs_test;
CREATE TABLE toolkit_aocs_test (a INT, b INT, C INT)
WITH (appendonly=true, orientation=column) DISTRIBUTED BY (c);
INSERT INTO toolkit_aocs_test SELECT i as a, i as b FROM generate_series(1,20) AS i;
UPDATE toolkit_aocs_test SET b = 0 WHERE a = 1;
DELETE FROM toolkit_aocs_test WHERE a = 2;
-- Investigate them with the gp_toolkit functions
SELECT count(*) FROM gp_toolkit.__gp_aoseg_history('toolkit_ao_test'::regclass);
SELECT count(*) FROM gp_toolkit.__gp_aocsseg('toolkit_aocs_test'::regclass);
SELECT count(*) FROM gp_toolkit.__gp_aocsseg_name('toolkit_aocs_test');
SELECT count(*) FROM gp_toolkit.__gp_aocsseg_history('toolkit_aocs_test'::regclass);
SELECT count(*) FROM gp_toolkit.__gp_aoseg_history('toolkit_ao_test'::regclass);
SELECT * FROM gp_toolkit.__gp_aovisimap('toolkit_ao_test'::regclass);
SELECT * FROM gp_toolkit.__gp_aovisimap_name('toolkit_ao_test');
SELECT count(*) FROM gp_toolkit.__gp_aovisimap_hidden_info('toolkit_ao_test'::regclass);
SELECT count(*) FROM gp_toolkit.__gp_aovisimap_hidden_info_name('toolkit_ao_test');
SELECT * FROM gp_toolkit.__gp_aovisimap_entry('toolkit_ao_test'::regclass);
SELECT * FROM gp_toolkit.__gp_aovisimap_entry_name('toolkit_ao_test');
SELECT count(*) FROM gp_toolkit.__gp_aoseg_name('toolkit_ao_test');
-- The same, but on the segments.
SELECT (t).* FROM (
SELECT gp_toolkit.__gp_aovisimap('toolkit_ao_test'::regclass) AS t FROM gp_dist_random('gp_id')
) AS x;
SELECT (t).* FROM (
SELECT gp_toolkit.__gp_aovisimap_name('toolkit_ao_test') AS t FROM gp_dist_random('gp_id')
) AS x;
SELECT (t).segno, (t).first_row_num, (t).hidden_tupcount >= 1 as hidden_tupcount_nonzero, (t).bitmap like '01%' as bitmap_starts_with_01 FROM (
SELECT gp_toolkit.__gp_aovisimap_entry('toolkit_ao_test'::regclass) AS t FROM gp_dist_random('gp_id')
) AS x;
SELECT (t).segno, (t).first_row_num, (t).hidden_tupcount >= 1 as hidden_tupcount_nonzero, (t).bitmap like '01%' as bitmap_starts_with_01 FROM (
SELECT gp_toolkit.__gp_aovisimap_entry_name('toolkit_ao_test') AS t FROM gp_dist_random('gp_id')
) AS x;
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
DROP TABLE IF EXISTS foo;
CREATE TABLE foo (a INT, b INT) WITH (appendonly=true);
INSERT INTO foo SELECT i as a, i as b FROM generate_series(1,20) AS i;
UPDATE foo SET b = 0 WHERE a = 1;
DELETE FROM foo WHERE a = 2;
DROP TABLE IF EXISTS foocs;
CREATE TABLE foocs (a INT, b INT) WITH (appendonly=true, orientation=column);
INSERT INTO foocs SELECT i as a, i as b FROM generate_series(1,20) AS i;
UPDATE foocs SET b = 0 WHERE a = 1;
DELETE FROM foocs WHERE a = 2;
"""
Copyright (C) 2004-2015 Pivotal Software, Inc. All rights reserved.
This program and the accompanying materials are made available under
the terms of the 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.
"""
from mpp.models import MPPTestCase
from mpp.lib.PSQL import PSQL
import os
import sys
class UAOGPToolkitTestCase(MPPTestCase):
"""
Test suite to test the ao diagnostics function in there
gp_toolkit version.
"""
def get_oid(self, table_name):
s = PSQL.run_sql_command("SELECT oid from pg_class WHERE relname = '%s'" % table_name);
return int(s.splitlines()[3])
def get_utility_mode_port():
"""
Gets the port number/hostname combination of the
dbid with the id = name
"""
o = PSQL.run_sql_command("SELECT port FROM gp_segment_configuration WHERE dbid = 2").splitlines()[3]
return o
utility_port = get_utility_mode_port()
def has_zero_rows(self, sql, utility=False):
if not utility:
o = PSQL.run_sql_command(sql)
else:
o = PSQL.run_sql_command_utility_mode(sql, port=self.utility_port)
return o.find("(0 rows)") >= 0
def has_rows(self, sql, utility=False):
if not utility:
o = PSQL.run_sql_command(sql)
else:
o = PSQL.run_sql_command_utility_mode(sql, port=self.utility_port)
return (o.find("rows)") >= 0 and o.find("(0 rows)") < 0) or o.find("(1 row)") >= 0
def has_zero_rows(self, sql, utility=False):
if not utility:
o = PSQL.run_sql_command(sql)
else:
o = PSQL.run_sql_command_utility_mode(sql, port=self.utility_port)
return o.find("(0 rows)") >= 0
def test_ao_co_diagnostics(self):
base_dir = os.path.dirname(sys.modules[self.__class__.__module__].__file__)
setup_file = os.path.join(
base_dir, "gptoolkit_sql", "gptoolkit_setup.sql");
PSQL.run_sql_file(setup_file)
oid = self.get_oid('foo');
oidcs = self.get_oid('foocs');
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aoseg_history(%s)' % oid))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aocsseg(%s)' % oidcs))
self.assertTrue(self.has_rows("SELECT * FROM gp_toolkit.__gp_aocsseg_name('foocs')"))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aocsseg_history(%s)' % oidcs))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aoseg_history(%s)' % oid))
self.assertTrue(self.has_zero_rows('SELECT * FROM gp_toolkit.__gp_aovisimap(%s)' % oid))
self.assertTrue(self.has_zero_rows("SELECT * FROM gp_toolkit.__gp_aovisimap_name('foo')"))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aovisimap_hidden_info(%s)' % oid))
self.assertTrue(self.has_rows("SELECT * FROM gp_toolkit.__gp_aovisimap_hidden_info_name('foo')"))
self.assertTrue(self.has_zero_rows('SELECT * FROM gp_toolkit.__gp_aovisimap_entry(%s)' % oid))
self.assertTrue(self.has_zero_rows("SELECT * FROM gp_toolkit.__gp_aovisimap_entry_name('foo')"))
self.assertTrue(self.has_rows("SELECT * FROM gp_toolkit.__gp_aoseg_name('foo')"))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aoseg_history(%s)' % oid, True))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aocsseg(%s)' % oidcs, True))
self.assertTrue(self.has_rows("SELECT * FROM gp_toolkit.__gp_aocsseg_name('foocs')", True))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aocsseg_history(%s)' % oidcs, True))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aoseg_history(%s)' % oid, True))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aovisimap(%s)' % oid, True))
self.assertTrue(self.has_rows("SELECT * FROM gp_toolkit.__gp_aovisimap_name('foo')", True))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aovisimap_hidden_info(%s)' % oid, True))
self.assertTrue(self.has_rows("SELECT * FROM gp_toolkit.__gp_aovisimap_hidden_info_name('foo')", True))
self.assertTrue(self.has_rows('SELECT * FROM gp_toolkit.__gp_aovisimap_entry(%s)' % oid, True))
self.assertTrue(self.has_rows("SELECT * FROM gp_toolkit.__gp_aovisimap_entry_name('foo')", True))
self.assertTrue(self.has_rows("SELECT * FROM gp_toolkit.__gp_aoseg_name('foo')", True))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册