Skip to content

Commit 6463e4e

Browse files
committed
new step for tests using chaining API in github actions
1 parent 91e3636 commit 6463e4e

File tree

4 files changed

+56
-29
lines changed

4 files changed

+56
-29
lines changed

.github/workflows/test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
- name: Execute Python tests
4444
run: tox
4545

46+
- name: Execute Python tests with low level chaining API
47+
run: tox -e chaining
48+
4649
R:
4750
name: core / R ${{ matrix.ver }} on ${{ matrix.os }}
4851
runs-on: ${{ matrix.os }}

test/core/run_tests.py

+41-26
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,15 @@ def construct_cmd_from_click_api(mode):
230230
shutil.rmtree(tempdir)
231231

232232

233-
def run_all(ok_tests, ok_contexts, ok_graphs, debug, num_parallel, inherit_env):
233+
def run_all(
234+
ok_tests,
235+
ok_contexts,
236+
ok_graphs,
237+
debug,
238+
num_parallel,
239+
inherit_env,
240+
use_chaining_api=False,
241+
):
234242

235243
tests = [
236244
test
@@ -247,17 +255,22 @@ def run_all(ok_tests, ok_contexts, ok_graphs, debug, num_parallel, inherit_env):
247255
if debug or num_parallel is None:
248256
for test in tests:
249257
failed.extend(
250-
run_test_cases((test, ok_contexts, ok_graphs, debug, base_env))
258+
run_test_cases(
259+
(test, ok_contexts, ok_graphs, debug, base_env, use_chaining_api)
260+
)
251261
)
252262
else:
253-
args = [(test, ok_contexts, ok_graphs, debug, base_env) for test in tests]
263+
args = [
264+
(test, ok_contexts, ok_graphs, debug, base_env, use_chaining_api)
265+
for test in tests
266+
]
254267
for fail in Pool(num_parallel).imap_unordered(run_test_cases, args):
255268
failed.extend(fail)
256269
return failed
257270

258271

259272
def run_test_cases(args):
260-
test, ok_contexts, ok_graphs, debug, base_env = args
273+
test, ok_contexts, ok_graphs, debug, base_env, use_chaining_api = args
261274
contexts = json.load(open("contexts.json"))
262275
graphs = list(iter_graphs())
263276
test_name = test.__class__.__name__
@@ -288,46 +301,40 @@ def run_test_cases(args):
288301
if enabled_tests and (test_name not in map(str, enabled_tests)):
289302
continue
290303

291-
log("running", formatter, context)
292-
ret, path = run_test(
304+
log(
305+
"running [using chaining api]" if use_chaining_api else "running",
293306
formatter,
294307
context,
295-
debug,
296-
contexts["checks"],
297-
base_env,
298308
)
299-
300-
if ret:
301-
tstid = "%s in context %s" % (formatter, context["name"])
302-
failed.append((tstid, path))
303-
log("failed", formatter, context, real_bad=True)
304-
if debug:
305-
return failed
306-
else:
307-
log("success", formatter, context, real_good=True)
308-
309-
log("running [with chaining api]", formatter, context)
310309
ret, path = run_test(
311310
formatter,
312311
context,
313312
debug,
314313
contexts["checks"],
315314
base_env,
316-
use_chaining_api=True,
315+
use_chaining_api,
317316
)
318317

319318
if ret:
320-
tstid = "%s in context %s [with chaining api]" % (
321-
formatter,
322-
context["name"],
319+
tstid = (
320+
"%s in context %s [using chaining api]"
321+
if use_chaining_api
322+
else "%s in context %s" % (formatter, context["name"])
323323
)
324324
failed.append((tstid, path))
325-
log("failed [with chaining api]", formatter, context, real_bad=True)
325+
log(
326+
"failed [using chaining api]" if use_chaining_api else "failed",
327+
formatter,
328+
context,
329+
real_bad=True,
330+
)
326331
if debug:
327332
return failed
328333
else:
329334
log(
330-
"success [with chaining api]",
335+
"success [using chaining api]"
336+
if use_chaining_api
337+
else "success",
331338
formatter,
332339
context,
333340
real_good=True,
@@ -365,6 +372,12 @@ def run_test_cases(args):
365372
@click.option(
366373
"--inherit-env", is_flag=True, default=False, help="Inherit env variables"
367374
)
375+
@click.option(
376+
"--use-chaining-api",
377+
is_flag=True,
378+
default=False,
379+
help="Use low-level chaining API to generate commands.",
380+
)
368381
@click.option(
369382
"--num-parallel",
370383
show_default=True,
@@ -379,6 +392,7 @@ def cli(
379392
num_parallel=None,
380393
debug=False,
381394
inherit_env=False,
395+
use_chaining_api=False,
382396
):
383397

384398
parse = lambda x: {t.lower() for t in x.split(",") if t}
@@ -390,6 +404,7 @@ def cli(
390404
debug,
391405
num_parallel,
392406
inherit_env,
407+
use_chaining_api,
393408
)
394409

395410
if failed:

test_runner

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@ install_extensions() {
1616
}
1717

1818
run_tests() {
19-
cd test/core && PYTHONPATH=`pwd`/../../ python3 run_tests.py --num-parallel 8 && cd ../../
19+
cd test/core && PYTHONPATH=`pwd`/../../ python3 run_tests.py --num-parallel 8 "$@" && cd ../../
2020
}
2121

2222
# We run realtime cards tests separately because there these tests validate the asynchronous updates to the
2323
# information stored in the datastore. So if there are other processes starving resources then these tests will
2424
# surely fail since a lot of checks have timeouts.
2525
run_runtime_card_tests() {
2626
CARD_GRAPHS="small-foreach,small-parallel,nested-branches,single-linear-step,simple-foreach"
27-
cd test/core && PYTHONPATH=`pwd`/../../ python3 run_tests.py --num-parallel 8 --contexts python3-all-local-cards-realtime --graphs $CARD_GRAPHS && cd ../../
27+
cd test/core && PYTHONPATH=`pwd`/../../ python3 run_tests.py --num-parallel 8 --contexts python3-all-local-cards-realtime --graphs $CARD_GRAPHS "$@" && cd ../../
2828
}
2929

30-
install_deps && install_extensions && run_tests && run_runtime_card_tests
30+
if [[ "$1" == "chain" ]]; then
31+
shift
32+
USE_CHAINING_API="--use-chaining-api"
33+
fi
34+
35+
install_deps && install_extensions && run_tests "$USE_CHAINING_API" && run_runtime_card_tests "$USE_CHAINING_API"

tox.ini

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
[testenv]
44
allowlist_externals = ./test_runner
55
commands = ./test_runner
6+
7+
[testenv:chaining]
8+
allowlist_externals = ./test_runner
9+
commands = ./test_runner chain

0 commit comments

Comments
 (0)