Skip to content

Commit b1f6e9d

Browse files
scenario-testing-evolution
Summary: - Supporting different testing patterns: - `readonly`; read ops only. - `readwrite`; read and mutate with `stackql`. - `deploy`; lifecycle management with `stackql-deploy`. - CI improvments to elide needless builds.
1 parent fd238be commit b1f6e9d

File tree

8 files changed

+97
-14
lines changed

8 files changed

+97
-14
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
- "**/*.md"
1212
- "docs/**"
1313
- "licenses/**"
14+
- "test/python/markdown_testing/**"
15+
- ".github/workflows/scenario.yaml"
1416
pull_request:
1517
branches:
1618
- main
@@ -20,6 +22,8 @@ on:
2022
- "docs/**"
2123
- "examples/**"
2224
- "licenses/**"
25+
- "test/python/markdown_testing/**"
26+
- ".github/workflows/scenario.yaml"
2327

2428
env:
2529
GOTESTCMD: "go test -timeout 1200s --tags \"sqlite_stackql\" -v ./..."

.github/workflows/scenario.yaml

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77

88
env:
99
TAG_NAME: ${{ github.ref_name }}
10+
RUNTYPE_READ_ONLY: readonly
11+
RUNTYPE_READ_WRITE: readwrite
12+
RUNTYPE_DEPLOY: deploy
13+
RUNTYPE_ALL: all
1014

1115
jobs:
1216
scenario-testing:
@@ -15,8 +19,28 @@ jobs:
1519
steps:
1620
- name: Ref Parse
1721
run: |
22+
_defaultRunType="${{ env.RUNTYPE_READ_ONLY }}"
23+
runID=$(echo -n '${{ github.ref_name }}' | cut -d '-' -f 2)"
24+
runType=$(echo -n '${{ github.ref_name }}' | cut -d '-' -f 3)"
25+
repositoryShorthand=$(echo -n '${{ github.ref_name }}' | rev | cut -d '-' -f 1 | rev)
26+
artifactRepositoryFullName='stackql/stackql'
27+
if [ "$repositoryShorthand" = "devel" ]; then
28+
artifactRepositoryFullName='stackql/stackql-devel'
29+
fi
30+
if [ "$runType" = "" ]; then
31+
runType="$_defaultRunType"
32+
elif [ "$runType" != "${{ env.RUNTYPE_READ_ONLY }}" ] \
33+
&& [ "$runType" != "${{ env.RUNTYPE_READ_WRITE }}" ] \
34+
&& [ "$runType" != "${{ env.RUNTYPE_DEPLOY }}" \
35+
&& [ "$runType" != "${{ env.RUNTYPE_ALL }}" ]
36+
then
37+
echo "Invalid run type: $runType"
38+
exit 1
39+
fi
1840
{
1941
echo "runID=$(echo -n '${{ github.ref_name }}' | cut -d '-' -f 2)"
42+
echo "artifactRepositoryFullName=$artifactRepositoryFullName"
43+
echo "runType=$runType"
2044
} >> "${GITHUB_ENV}"
2145
2246
- name: Check out code into the Go module directory
@@ -28,7 +52,7 @@ jobs:
2852
name: stackql_linux_amd64
2953
path: build
3054
github-token: ${{ secrets.CI_STACKQL_PACKAGE_DOWNLOAD_TOKEN }}
31-
repository: stackql/stackql
55+
repository: ${{ env.artifactRepositoryFullName }}
3256
run-id: ${{ env.runID }}
3357

3458
- name: Stackql permissions
@@ -46,26 +70,45 @@ jobs:
4670
- name: Persist secrets
4771
run: |
4872
echo "$GCP_RO_SECRET" >> cicd/keys/testing/google-ro-credentials.json
73+
echo "$GCP_RW_SECRET" >> cicd/keys/testing/google-rw-credentials.json
4974
shell: bash
5075
env:
5176
GCP_RO_SECRET: ${{ secrets.CI_SCENARIO_GCP_RO_SECRET }}
77+
GCP_RW_SECRET: ${{ secrets.CI_SCENARIO_GCP_RW_SECRET }}
5278

5379
- name: Install Python dependencies
5480
run: |
5581
pip3 install -r cicd/requirements.txt
5682
57-
- name: Run Walkthrough Scenarios
83+
- name: Run Read Only Walkthrough Scenarios
84+
if: ${{ env.runType == env.RUNTYPE_READ_ONLY || env.runType == env.RUNTYPE_ALL }}
5885
env:
5986
AWS_ACCESS_KEY_ID: ${{ secrets.CI_SCENARIO_RO_AWS_ACCESS_KEY_ID }}
6087
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_SCENARIO_RO_AWS_SECRET_ACCESS_KEY }}
6188
run: |
62-
python3 test/python/markdown_testing/markdown_testing.py 2>&1 | tee cicd/log/markdown-testing-results.log
89+
python3 test/python/markdown_testing/markdown_testing.py --test-root=docs/walkthroughs/readonly 2>&1 | tee cicd/log/markdown-readonly-testing-results.log
6390
91+
- name: Run Read Write Walkthrough Scenarios
92+
if: ${{ env.runType == env.RUNTYPE_READ_WRITE || env.runType == env.RUNTYPE_ALL }}
93+
env:
94+
AWS_ACCESS_KEY_ID: ${{ secrets.CI_SCENARIO_RW_AWS_ACCESS_KEY_ID }}
95+
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_SCENARIO_RW_AWS_SECRET_ACCESS_KEY }}
96+
run: |
97+
python3 test/python/markdown_testing/markdown_testing.py --test-root=docs/walkthroughs/readwrite 2>&1 | tee cicd/log/markdown-readwrite-testing-results.log
98+
99+
- name: Run Deploy Walkthrough Scenarios
100+
if: ${{ env.runType == env.RUNTYPE_DEPLOY || env.runType == env.RUNTYPE_ALL }}
101+
env:
102+
AWS_ACCESS_KEY_ID: ${{ secrets.CI_SCENARIO_RW_AWS_ACCESS_KEY_ID }}
103+
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_SCENARIO_RW_AWS_SECRET_ACCESS_KEY }}
104+
run: |
105+
python3 test/python/markdown_testing/markdown_testing.py --test-root=docs/walkthroughs/deploy 2>&1 | tee cicd/log/markdown-deploy-testing-results.log
106+
64107
- name: Upload Test Results
65108
uses: actions/[email protected]
66109
with:
67110
name: scenario_test_results
68-
path: cicd/log/markdown-testing-results.log
111+
path: cicd/log/markdown-*.log
69112

70113
- name: Cleanup
71114
if: always()

docs/walkthroughs/deploy/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
## Infra lifecycle managment with `stackql`
3+
4+
File renamed without changes.

docs/walkthroughs/list-google-accelerator-types.md renamed to docs/walkthroughs/readonly/list-google-accelerator-types.md

File renamed without changes.
File renamed without changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
## Infra lifecycle managment with `stackql-deploy`
3+
4+

test/python/markdown_testing/markdown_testing.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
from tabulate import tabulate
1212

13-
_REPOSITORY_ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..'))
13+
import argparse
14+
1415

1516
"""
1617
Intentions:
@@ -19,6 +20,19 @@
1920
- Support sequential markdown code block execution, leveraging [info strings](https://spec.commonmark.org/0.30/#info-string).
2021
"""
2122

23+
24+
def parse_args() -> argparse.Namespace:
25+
"""
26+
Parse the arguments.
27+
"""
28+
parser = argparse.ArgumentParser(description='Create a token.')
29+
parser.add_argument('--test-root', type=str, help='The test root.', default=os.path.join(_REPOSITORY_ROOT_PATH, 'docs', 'walkthroughs'))
30+
return parser.parse_args()
31+
32+
33+
_REPOSITORY_ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..'))
34+
35+
2236
def eprint(*args, **kwargs):
2337
print(*args, file=sys.stderr, **kwargs)
2438

@@ -363,10 +377,6 @@ def run_all(self, walkthrough_inodes: List[str], recursive=True, skip_readme=Tru
363377
e2e: SimpleRunner = SimpleRunner(workload)
364378
result = e2e.run()
365379
results.append(result)
366-
if recursive:
367-
for dir in dirs:
368-
dir_path = os.path.join(root, dir)
369-
results += self.run_all([dir_path], recursive)
370380
continue
371381
is_file = os.path.isfile(inode_path)
372382
if is_file:
@@ -382,7 +392,7 @@ def run_all(self, walkthrough_inodes: List[str], recursive=True, skip_readme=Tru
382392
raise FileNotFoundError(f'Path not tractable: {inode_path}')
383393
return results
384394

385-
def collate_results(results: List[WalkthroughResult]) -> bool:
395+
def _collate_results(results: List[WalkthroughResult]) -> bool:
386396
failed: int = 0
387397
for result in results:
388398
if result.rc != 0 or not result.passes_stdout_check or not result.passes_stderr_check:
@@ -391,14 +401,32 @@ def collate_results(results: List[WalkthroughResult]) -> bool:
391401
print(tabulate([[result.name, result.rc, result.passes_stdout_check, result.passes_stderr_check] for result in results], headers=['Test Name', 'Return Code', 'Passes Stdout Checks', 'Passes Stderr Checks']))
392402
return failed == 0
393403

394-
def main():
404+
def run_tests(root_dir: str) -> List[WalkthroughResult]:
405+
"""
406+
Run all tests.
407+
A decent entry point for a test harness.
408+
409+
:param root_dir: The root directory.
410+
411+
:return: The results.
412+
"""
395413
runner: AllWalkthroughsRunner = AllWalkthroughsRunner()
396-
results: List[WalkthroughResult] = runner.run_all([os.path.join(_REPOSITORY_ROOT_PATH, 'docs', 'walkthroughs')])
397-
if collate_results(results):
414+
results: List[WalkthroughResult] = runner.run_all([root_dir])
415+
return results
416+
417+
418+
def _process_tests(root_dir: str) -> List[WalkthroughResult]:
419+
results: List[WalkthroughResult] = run_tests(root_dir)
420+
if _collate_results(results):
398421
print('All tests passed.')
399422
sys.exit(0)
400423
print('Some tests failed.')
401424
sys.exit(1)
402425

426+
def _main() -> None:
427+
args :argparse.Namespace = parse_args()
428+
_process_tests(args.test_root)
429+
430+
403431
if __name__ == '__main__':
404-
main()
432+
_main()

0 commit comments

Comments
 (0)