Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
9a90da8a
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9a90da8a
编写于
9月 30, 2019
作者:
A
Adam Berlin
提交者:
Adam Berlin
10月 02, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract shared library for making assertions about rows.
上级
cb1ebf73
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
135 addition
and
88 deletion
+135
-88
contrib/pg_upgrade/test/integration/Makefile
contrib/pg_upgrade/test/integration/Makefile
+3
-1
contrib/pg_upgrade/test/integration/greenplum_five_to_greenplum_six_upgrade_test_suite.c
...tion/greenplum_five_to_greenplum_six_upgrade_test_suite.c
+4
-0
contrib/pg_upgrade/test/integration/scenarios/heap_table.c
contrib/pg_upgrade/test/integration/scenarios/heap_table.c
+36
-49
contrib/pg_upgrade/test/integration/scenarios/subpartitioned_heap_table.c
...de/test/integration/scenarios/subpartitioned_heap_table.c
+18
-38
contrib/pg_upgrade/test/integration/utilities/row-assertions.c
...ib/pg_upgrade/test/integration/utilities/row-assertions.c
+50
-0
contrib/pg_upgrade/test/integration/utilities/row-assertions.h
...ib/pg_upgrade/test/integration/utilities/row-assertions.h
+24
-0
未找到文件。
contrib/pg_upgrade/test/integration/Makefile
浏览文件 @
9a90da8a
...
...
@@ -51,8 +51,10 @@ test_dependencies = bdd-library/upgrade-bdd.o \
$(scenario_objs)
\
$(CMOCKERY_OBJS)
debugging_flags
=
-Og
-g
greenplum_five_to_greenplum_six_upgrade_test_suite.t
:
greenplum_five_to_greenplum_six_upgrade_test_suite.o $(test_dependencies)
$(CC)
$(CFLAGS)
$^
$(libpq_pgport)
$(LDFLAGS)
-o
$@
$(CC)
$(CFLAGS)
$
(debugging_flags)
$
^
$(libpq_pgport)
$(LDFLAGS)
-o
$@
clean
:
rm
-f
$(OBJS)
$(EXS)
contrib/pg_upgrade/test/integration/greenplum_five_to_greenplum_six_upgrade_test_suite.c
浏览文件 @
9a90da8a
...
...
@@ -13,12 +13,16 @@
#include "utilities/gpdb6-cluster.h"
#include "utilities/test-helpers.h"
#include "utilities/row-assertions.h"
static
void
setup
(
void
**
state
)
{
resetGpdbFiveDataDirectories
();
resetGpdbSixDataDirectories
();
matcher
=
NULL
;
match_failed
=
NULL
;
}
static
void
...
...
contrib/pg_upgrade/test/integration/scenarios/heap_table.c
浏览文件 @
9a90da8a
...
...
@@ -19,70 +19,56 @@
#include "heap_table.h"
#include "utilities/row-assertions.h"
typedef
struct
UserData
{
int
id
;
char
*
name
;
}
User
;
}
User
;
static
bool
users_match
(
const
User
*
expected_user
,
const
User
*
actual_user
)
users_match
(
void
*
expected
,
void
*
actual
)
{
return
expected_user
->
id
==
actual_user
->
id
&&
strncmp
(
expected_user
->
name
,
actual_user
->
name
,
strlen
(
expected_user
->
name
))
==
0
;
}
User
*
expected_user
=
(
User
*
)
expected
;
User
*
actual_user
=
(
User
*
)
actual
;
typedef
struct
Rows
{
int
size
;
User
rows
[
10
];
}
Rows
;
return
expected_user
->
id
==
actual_user
->
id
&&
strncmp
(
expected_user
->
name
,
actual_user
->
name
,
strlen
(
expected_user
->
name
))
==
0
;
}
static
void
assert_rows_contain_users
(
const
Rows
*
expected_rows
,
const
Rows
*
rows
)
{
bool
found
=
false
;
user_match_failed
(
void
*
expected
)
{
User
*
expected_user
=
(
User
*
)
expected
;
for
(
int
j
=
0
;
j
<
expected_rows
->
size
;
++
j
)
{
found
=
false
;
const
User
*
expected_user
=
&
expected_rows
->
rows
[
j
];
for
(
int
i
=
0
;
i
<
rows
->
size
;
++
i
)
{
const
User
*
current_user
=
&
rows
->
rows
[
i
];
if
(
users_match
(
expected_user
,
current_user
))
{
found
=
true
;
break
;
}
}
assert_true
(
found
);
}
assert_true
(
found
);
printf
(
"==========> expected {.id=%d, .name=%s}
\n
"
,
expected_user
->
id
,
expected_user
->
name
);
}
static
void
extract_user_rows
(
PGresult
*
result
,
Rows
*
rows
)
static
Rows
*
extract_user_rows
(
PGresult
*
result
)
{
int
number_of_rows
=
PQntuples
(
result
);
int
number_of_rows
=
PQntuples
(
result
);
Rows
*
rows
=
calloc
(
1
,
sizeof
(
Rows
));
const
int
i_id
=
PQfnumber
(
result
,
"id"
);
const
int
i_name
=
PQfnumber
(
result
,
"name"
);
for
(
int
i
=
0
;
i
<
number_of_rows
;
i
++
)
{
User
*
user
=
&
rows
->
rows
[
i
]
;
User
*
user
=
calloc
(
1
,
sizeof
(
User
))
;
user
->
id
=
atoi
(
PQgetvalue
(
result
,
i
,
i_id
));
user
->
name
=
PQgetvalue
(
result
,
i
,
i_name
);
user
->
name
=
strdup
(
PQgetvalue
(
result
,
i
,
i_name
));
rows
->
rows
[
i
]
=
user
;
}
rows
->
size
=
number_of_rows
;
return
rows
;
}
static
void
...
...
@@ -173,22 +159,20 @@ heapTableShouldHaveDataUpgradedToSixCluster()
executeQuery
(
connection
,
"set search_path to five_to_six_upgrade;"
);
PGresult
*
result
=
executeQuery
(
connection
,
"select * from users;"
);
Rows
rows
=
{};
extract_user_rows
(
result
,
&
rows
);
Rows
*
rows
=
extract_user_rows
(
result
);
assert_int_equal
(
3
,
rows
.
size
);
assert_int_equal
(
3
,
rows
->
size
);
const
Rows
expected_users
=
{
User
jane
=
{.
id
=
1
,.
name
=
"Jane"
};
User
john
=
{.
id
=
2
,.
name
=
"John"
};
User
joe
=
{.
id
=
3
,.
name
=
"Joe"
};
const
Rows
expected_users
=
{
.
size
=
3
,
.
rows
=
{
{.
id
=
1
,.
name
=
"Jane"
},
{.
id
=
2
,.
name
=
"John"
},
{.
id
=
3
,.
name
=
"Joe"
}
}
.
rows
=
{
&
jane
,
&
john
,
&
joe
}
};
assert_rows
_contain_users
(
&
expected_users
,
&
row
s
);
assert_rows
(
rows
,
expected_user
s
);
PQfinish
(
connection
);
}
...
...
@@ -241,6 +225,9 @@ createHeapTableWithDataInFiveCluster(void)
void
test_a_heap_table_with_data_can_be_upgraded
(
void
**
state
)
{
matcher
=
users_match
;
match_failed
=
user_match_failed
;
given
(
createHeapTableWithDataInFiveCluster
);
when
(
anAdministratorPerformsAnUpgrade
);
then
(
heapTableShouldHaveDataUpgradedToSixCluster
);
...
...
contrib/pg_upgrade/test/integration/scenarios/subpartitioned_heap_table.c
浏览文件 @
9a90da8a
...
...
@@ -13,20 +13,17 @@
#include "utilities/upgrade-helpers.h"
#include "utilities/test-helpers.h"
#include "utilities/query-helpers.h"
#include "utilities/row-assertions.h"
#include "subpartitioned_heap_table.h"
typedef
struct
UserData
{
int
id
;
int
age
;
}
User
;
typedef
struct
RowsData
{
int
size
;
User
*
users
[
10
];
}
Rows
;
static
Rows
*
extract_rows
(
PGresult
*
result
)
...
...
@@ -44,7 +41,7 @@ extract_rows(PGresult *result)
user
->
id
=
atoi
(
PQgetvalue
(
result
,
i
,
id_column_index
));
user
->
age
=
atoi
(
PQgetvalue
(
result
,
i
,
age_column_index
));
rows
->
user
s
[
i
]
=
user
;
rows
->
row
s
[
i
]
=
user
;
}
rows
->
size
=
number_of_rows
;
...
...
@@ -66,45 +63,25 @@ queryForRows(char *queryString)
}
static
bool
users_match
(
User
*
first_user
,
User
*
second_user
)
users_match
(
void
*
expected
,
void
*
actual
)
{
User
*
first_user
=
(
User
*
)
expected
;
User
*
second_user
=
(
User
*
)
actual
;
return
first_user
->
age
==
second_user
->
age
&&
first_user
->
id
==
second_user
->
id
;
}
static
bool
row_in
(
User
*
expected_user
,
Rows
*
actual_rows
)
static
void
match_failed_for_user
(
void
*
expected_row
)
{
for
(
int
i
=
0
;
i
<
actual_rows
->
size
;
i
++
)
{
User
*
current_user
=
actual_rows
->
users
[
i
];
User
*
expected_user
=
(
User
*
)
expected_row
;
if
(
users_match
(
current_user
,
expected_user
))
return
true
;
}
return
false
;
printf
(
"==============> expected {.id=%d, .age=%d} to be in actual rows
\n
"
,
expected_user
->
id
,
expected_user
->
age
);
}
static
void
assert_row_in
(
User
*
expected_user
,
Rows
*
actual_rows
)
{
bool
found
=
row_in
(
expected_user
,
actual_rows
);
if
(
!
found
)
printf
(
"==============> expected {.id=%d, .age=%d} to be in actual rows
\n
"
,
expected_user
->
id
,
expected_user
->
age
);
assert_true
(
found
);
}
static
void
assert_rows
(
Rows
*
actual_rows
,
Rows
expected_rows
)
{
for
(
int
i
=
0
;
i
<
expected_rows
.
size
;
i
++
)
assert_row_in
(
expected_rows
.
users
[
i
],
actual_rows
);
}
static
void
aSubpartitionedHeapTableHasDataInAGpdbFiveCluster
(
void
)
...
...
@@ -129,6 +106,9 @@ anAdministratorPerformsAnUpgrade(void)
static
void
theSubpartitionShouldExistWithDataInTheGpdbSixCluster
(
void
)
{
matcher
=
users_match
;
match_failed
=
match_failed_for_user
;
Rows
*
rows_in_partition_a
=
queryForRows
(
"select id, age from users_1_prt_partition_id_2_prt_subpartition_age_first"
);
Rows
*
rows_in_partition_b
=
queryForRows
(
"select id, age from users_1_prt_partition_id_2_prt_subpartition_age_second"
);
...
...
@@ -137,19 +117,19 @@ theSubpartitionShouldExistWithDataInTheGpdbSixCluster(void)
assert_rows
(
rows_in_partition_a
,
(
Rows
)
{
.
size
=
1
,
.
user
s
=
{
&
expected_user
}
.
row
s
=
{
&
expected_user
}
});
assert_rows
(
rows_in_partition_b
,
(
Rows
)
{
.
size
=
1
,
.
user
s
=
{
&
other_expected_user
}
.
row
s
=
{
&
other_expected_user
}
});
Rows
*
all_rows
=
queryForRows
(
"select id, age from users;"
);
assert_rows
(
all_rows
,
(
Rows
)
{
.
size
=
2
,
.
user
s
=
{
&
expected_user
,
&
other_expected_user
}
.
row
s
=
{
&
expected_user
,
&
other_expected_user
}
});
}
...
...
contrib/pg_upgrade/test/integration/utilities/row-assertions.c
0 → 100644
浏览文件 @
9a90da8a
#include "stdbool.h"
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <stdio.h>
#include "cmockery.h"
#include "row-assertions.h"
bool
(
*
matcher
)(
void
*
expected
,
void
*
actual
);
void
(
*
match_failed
)(
void
*
expected
);
static
bool
row_in
(
void
*
expected_user
,
Rows
*
actual_rows
)
{
for
(
int
i
=
0
;
i
<
actual_rows
->
size
;
i
++
)
{
void
*
current_user
=
actual_rows
->
rows
[
i
];
if
(
matcher
(
current_user
,
expected_user
))
return
true
;
}
return
false
;
}
static
void
assert_row_in
(
void
*
expected_row
,
Rows
*
actual_rows
)
{
bool
found
=
row_in
(
expected_row
,
actual_rows
);
if
(
!
found
)
match_failed
(
expected_row
);
assert_true
(
found
);
}
void
assert_rows
(
Rows
*
actual_rows
,
Rows
expected_rows
)
{
if
(
matcher
==
NULL
)
printf
(
"expected matcher() function to be configured, was NULL"
);
if
(
match_failed
==
NULL
)
printf
(
"expected match_failed() function to be configured, was NULL"
);
for
(
int
i
=
0
;
i
<
expected_rows
.
size
;
i
++
)
assert_row_in
(
expected_rows
.
rows
[
i
],
actual_rows
);
}
contrib/pg_upgrade/test/integration/utilities/row-assertions.h
0 → 100644
浏览文件 @
9a90da8a
#ifndef PG_UPGRADE_TEST_UTILITIES_ROW_ASSERTIONS_H
#define PG_UPGRADE_TEST_UTILITIES_ROW_ASSERTIONS_H
#include "stdbool.h"
typedef
struct
RowsData
{
int
size
;
void
*
rows
[
10
];
}
Rows
;
/*
* Extension points
*/
extern
bool
(
*
matcher
)(
void
*
expected
,
void
*
actual
);
extern
void
(
*
match_failed
)(
void
*
expected
);
/*
* Library function
*/
extern
void
assert_rows
(
Rows
*
actual_rows
,
Rows
expected_rows
);
#endif
/* PG_UPGRADE_TEST_UTILITIES_ROW_ASSERTIONS_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录