-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest_prepare_release.py
More file actions
252 lines (233 loc) · 7.66 KB
/
test_prepare_release.py
File metadata and controls
252 lines (233 loc) · 7.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
import os
import uuid
from datetime import datetime
import pathlib2
from ..common_tool_methods import (
file_includes_line,
count_line_in_file,
run,
get_last_commit_message,
remove_cloned_code,
)
from ..prepare_release import (
update_release,
MULTI_EXTENSION_OUT,
MULTI_EXTENSION_SQL,
CONFIGURE,
CONFIGURE_IN,
CITUS_CONTROL,
CONFIG_PY,
ProjectParams,
)
github_token = os.getenv("GH_TOKEN")
BASE_PATH = (
pathlib2.Path(__file__).parents[2]
if os.getenv("BASE_PATH") is None
else os.getenv("BASE_PATH")
)
MAIN_BRANCH = "test-tools-scripts"
TEST_CHECKOUT_DIR = "citus_test"
resources_to_be_deleted = []
def initialize_env() -> str:
test_base_path_major = f"{BASE_PATH}/{uuid.uuid4()}"
remove_cloned_code(test_base_path_major)
if not os.path.exists(test_base_path_major):
run(f"git clone https://x-access-token:{github_token}@github.com/citusdata/citus.git {test_base_path_major}")
return test_base_path_major
def test_major_release():
test_base_path_major = initialize_env()
os.chdir(test_base_path_major)
run(f"git checkout {MAIN_BRANCH}")
resources_to_be_deleted.append(test_base_path_major)
previous_print_extension_changes = count_line_in_file(
test_base_path_major,
MULTI_EXTENSION_OUT,
"SELECT * FROM print_extension_changes();",
)
project_params = ProjectParams(
project_version="10.1.0",
project_name="citus",
main_branch=MAIN_BRANCH,
schema_version="",
)
update_release_return_value = update_release(
github_token=github_token,
project_params=project_params,
earliest_pr_date=datetime.strptime("2021.03.25 00:00", "%Y.%m.%d %H:%M"),
exec_path=test_base_path_major,
is_test=True,
)
run(f"git checkout {update_release_return_value.release_branch_name}")
assert file_includes_line(test_base_path_major, MULTI_EXTENSION_OUT, " 10.1.0")
assert file_includes_line(
test_base_path_major, CONFIGURE_IN, "AC_INIT([Citus], [10.1.0])"
)
assert file_includes_line(
test_base_path_major, CONFIGURE, "PACKAGE_VERSION='10.1.0'"
)
assert file_includes_line(
test_base_path_major, CONFIGURE, "PACKAGE_STRING='Citus 10.1.0'"
)
assert file_includes_line(
test_base_path_major,
CONFIGURE,
r"\`configure' configures Citus 10.1.0 to adapt to many kinds of systems.",
)
assert file_includes_line(
test_base_path_major,
CONFIGURE,
' short | recursive ) echo "Configuration of Citus 10.1.0:";;',
)
assert file_includes_line(
test_base_path_major, CONFIGURE, "PACKAGE_VERSION='10.1.0'"
)
assert (
get_last_commit_message(test_base_path_major)
== "Bump citus version to 10.1.0\n"
)
run(f"git checkout {update_release_return_value.upcoming_version_branch}")
assert file_includes_line(
test_base_path_major, CITUS_CONTROL, "default_version = '10.2-1'"
)
assert file_includes_line(
test_base_path_major,
MULTI_EXTENSION_OUT,
"-- Test downgrade to 10.1-1 from 10.2-1",
)
assert file_includes_line(
test_base_path_major,
MULTI_EXTENSION_OUT,
"ALTER EXTENSION citus UPDATE TO '10.1-1';",
)
assert (
count_line_in_file(
test_base_path_major,
MULTI_EXTENSION_OUT,
"ALTER EXTENSION citus UPDATE TO '10.2-1';",
)
== 2
)
assert file_includes_line(
test_base_path_major,
MULTI_EXTENSION_OUT,
"-- Should be empty result since upgrade+downgrade should be a no-op",
)
assert (
count_line_in_file(
test_base_path_major,
MULTI_EXTENSION_OUT,
"SELECT * FROM print_extension_changes();",
)
- previous_print_extension_changes
== 2
)
assert file_includes_line(
test_base_path_major, MULTI_EXTENSION_OUT, "-- Snapshot of state at 10.2-1"
)
assert file_includes_line(test_base_path_major, MULTI_EXTENSION_OUT, " 10.2devel")
assert (
count_line_in_file(
test_base_path_major,
MULTI_EXTENSION_SQL,
"ALTER EXTENSION citus UPDATE TO '10.2-1';",
)
== 2
)
assert file_includes_line(
test_base_path_major, CONFIG_PY, "MASTER_VERSION = '10.2'"
)
assert file_includes_line(
test_base_path_major, CONFIGURE_IN, "AC_INIT([Citus], [10.2devel])"
)
assert file_includes_line(
test_base_path_major, CONFIGURE, "PACKAGE_VERSION='10.2devel'"
)
assert file_includes_line(
test_base_path_major, CONFIGURE, "PACKAGE_STRING='Citus 10.2devel'"
)
assert file_includes_line(
test_base_path_major,
CONFIGURE,
r"\`configure' configures Citus 10.2devel to adapt to many kinds of systems.",
)
assert file_includes_line(
test_base_path_major,
CONFIGURE,
' short | recursive ) echo "Configuration of Citus 10.2devel:";;',
)
assert file_includes_line(
test_base_path_major, CONFIGURE, "PACKAGE_VERSION='10.2devel'"
)
assert os.path.exists(
f"{test_base_path_major}/{update_release_return_value.upgrade_path_sql_file}"
)
assert os.path.exists(
f"{test_base_path_major}/{update_release_return_value.downgrade_path_sql_file}"
)
assert (
get_last_commit_message(test_base_path_major)
== "Bump citus version to 10.2devel\n"
)
run(f"git checkout {MAIN_BRANCH}")
def test_patch_release():
test_base_path_patch = initialize_env()
resources_to_be_deleted.append(test_base_path_patch)
os.chdir(test_base_path_patch)
project_params = ProjectParams(
project_version="10.0.4",
project_name="citus",
main_branch=MAIN_BRANCH,
schema_version="10.1-5",
)
try:
update_release(
github_token=github_token,
project_params=project_params,
earliest_pr_date=datetime.strptime("2021.03.25 00:00", "%Y.%m.%d %H:%M"),
exec_path=test_base_path_patch,
is_test=True,
)
assert file_includes_line(
test_base_path_patch,
MULTI_EXTENSION_OUT,
f" {project_params.project_version}",
)
assert file_includes_line(
test_base_path_patch,
CONFIGURE_IN,
f"AC_INIT([Citus], [{project_params.project_version}])",
)
assert file_includes_line(
test_base_path_patch,
CONFIGURE,
f"PACKAGE_VERSION='{project_params.project_version}'",
)
assert file_includes_line(
test_base_path_patch,
CONFIGURE,
f"PACKAGE_STRING='Citus {project_params.project_version}'",
)
assert file_includes_line(
test_base_path_patch,
CONFIGURE,
rf"\`configure' configures Citus {project_params.project_version} to adapt to many kinds of systems.",
)
assert file_includes_line(
test_base_path_patch,
CONFIGURE,
f' short | recursive ) echo "Configuration of Citus {project_params.project_version}:";;',
)
assert file_includes_line(
test_base_path_patch,
CONFIGURE,
f"PACKAGE_VERSION='{project_params.project_version}'",
)
assert file_includes_line(
test_base_path_patch,
CITUS_CONTROL,
f"default_version = '{project_params.schema_version}'",
)
run(f"git checkout {MAIN_BRANCH}")
finally:
for path in resources_to_be_deleted:
remove_cloned_code(path)