Skip to content

Commit c30e50a

Browse files
- More testing changes.
1 parent 5423057 commit c30e50a

File tree

10 files changed

+170
-80
lines changed

10 files changed

+170
-80
lines changed

.github/workflows/build.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,37 @@ env:
3939

4040
jobs:
4141

42+
test_python_package_build:
43+
# id: test_python_package_build
44+
name: Test Python Package Build
45+
runs-on: ubuntu-22.04
46+
timeout-minutes: ${{ vars.DEFAULT_JOB_TIMEOUT_MIN == '' && 120 || vars.DEFAULT_JOB_TIMEOUT_MIN }}
47+
steps:
48+
49+
- name: Check out code into the Go module directory
50+
uses: actions/[email protected]
51+
52+
- name: Setup Python
53+
uses: actions/[email protected]
54+
with:
55+
cache: pip
56+
python-version: '3.11'
57+
58+
- name: Install Poetry
59+
uses: snok/install-poetry@v1
60+
61+
- name: Build package
62+
run: |
63+
cicd/util/01-build-robot-lib.sh
64+
cicd/util/02-install-robot-lib.sh
65+
66+
- name: Upload python package artifact
67+
uses: actions/[email protected]
68+
with:
69+
name: python-package-dist-folder
70+
path: test/dist
71+
72+
4273
winbuild:
4374
name: Windows Build
4475
runs-on: windows-latest
@@ -170,6 +201,7 @@ jobs:
170201
env:
171202
PSQL_EXE: C:\Program Files\PostgreSQL\13\bin\psql
172203
SQLITE_EXE: C:\ProgramData\chocolatey\lib\SQLite\tools\sqlite3.exe
204+
PYTHONPATH: '${{ env.PYTHONPATH }};${{ github.workspace }}\test\python'
173205
run: |
174206
python cicd/python/build.py --robot-test
175207
@@ -187,6 +219,7 @@ jobs:
187219
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
188220
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
189221
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
222+
PYTHONPATH: '${{ env.PYTHONPATH }};${{ github.workspace }}\test\python'
190223
run: | #Ideally there wiuld be forced kill of flaks here but dont know how to do that in windows
191224
python cicd/python/build.py --robot-test-integration
192225
@@ -398,6 +431,7 @@ jobs:
398431
name: Linux Test
399432
needs:
400433
- linuxbuild
434+
- test_python_package_build
401435
runs-on: ubuntu-22.04
402436
strategy:
403437
matrix:
@@ -448,6 +482,21 @@ jobs:
448482
cache: pip
449483
python-version: '3.11'
450484

485+
- name: Download python package dist folder
486+
uses: actions/[email protected]
487+
with:
488+
name: python-package-dist-folder
489+
path: test/dist
490+
491+
- name: Dummy Install python testing package
492+
run: |
493+
echo "Inspecting python package"
494+
for file in test/dist/*.whl; do
495+
# pip3 install "$file"
496+
ls -al "$file"
497+
done
498+
499+
451500
- name: Git Ref Parse
452501
id: git_ref_parse
453502
run: |
@@ -532,6 +581,8 @@ jobs:
532581
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
533582
534583
- name: Run robot mocked functional tests
584+
env:
585+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
535586
if: success()
536587
run: |
537588
if [ "${{ matrix.registry }}" = "test/registry" ]; then
@@ -551,6 +602,8 @@ jobs:
551602
cat ./test/robot/reports/output.xml
552603
553604
- name: Run robot mocked functional tests with aggressive concurrency
605+
env:
606+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
554607
if: success() && matrix.registry != 'test/registry'
555608
run: |
556609
echo "## Stray flask apps to be killed before robot tests ##"
@@ -570,6 +623,7 @@ jobs:
570623
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
571624
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
572625
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
626+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
573627
run: |
574628
echo "## Stray flask apps to be killed before robot tests ##"
575629
pgrep -f flask | xargs kill -9 || true
@@ -588,6 +642,8 @@ jobs:
588642

589643
- name: install and test deb package
590644
if: matrix.registry != 'test/registry'
645+
env:
646+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
591647
run: |
592648
mkdir -p deb_test
593649
cp stackql_${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}}_amd64.deb deb_test/
@@ -604,6 +660,8 @@ jobs:
604660
605661
- name: Output from mocked deb package functional tests
606662
if: always() && matrix.registry != 'test/registry'
663+
env:
664+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
607665
run: |
608666
cat ./test/robot/reports/output.xml
609667
@@ -766,6 +824,8 @@ jobs:
766824
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
767825
768826
- name: Run robot mocked functional tests
827+
env:
828+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
769829
if: success()
770830
run: |
771831
python cicd/python/build.py --robot-test --config='{ "variables": { "SHOULD_RUN_DOCKER_EXTERNAL_TESTS": "true" } }'
@@ -776,6 +836,8 @@ jobs:
776836
cat ./test/robot/reports/output.xml
777837
778838
- name: Run robot mocked functional tests with aggressive concurrency
839+
env:
840+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
779841
if: success()
780842
run: |
781843
echo "## Stray flask apps to be killed before robot tests ##"
@@ -795,6 +857,7 @@ jobs:
795857
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
796858
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
797859
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
860+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
798861
run: |
799862
echo "## Stray flask apps to be killed before robot tests ##"
800863
pgrep -f flask | xargs kill -9 || true
@@ -862,6 +925,7 @@ jobs:
862925
pkgName: 'stackql'
863926
pkgVersion: ${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}}
864927
pkgArchitecture: 'arm64'
928+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
865929
run: |
866930
mkdir -p deb_test
867931
DEB_FILE="${pkgName}_${pkgVersion}_${pkgArchitecture}.deb"
@@ -948,6 +1012,8 @@ jobs:
9481012
9491013
- shell: wsl-bash {0}
9501014
name: Run robot mocked functional tests
1015+
env:
1016+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
9511017
run: |
9521018
. cicd/version.txt
9531019
export BUILDBRANCH="${{github.ref}}"
@@ -976,6 +1042,7 @@ jobs:
9761042
if: env.AZURE_CLIENT_SECRET != ''
9771043
env:
9781044
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
1045+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
9791046
run: |
9801047
. cicd/version.txt
9811048
export AZURE_CLIENT_ID='${{ secrets.AZURE_CLIENT_ID }}'
@@ -1096,6 +1163,8 @@ jobs:
10961163
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
10971164
10981165
- name: Run robot mocked functional tests
1166+
env:
1167+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
10991168
if: success()
11001169
run: |
11011170
python cicd/python/build.py --robot-test
@@ -1112,6 +1181,7 @@ jobs:
11121181
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
11131182
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
11141183
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
1184+
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
11151185
run: |
11161186
echo "## Stray flask apps to be killed before robot tests ##"
11171187
pgrep -f flask | xargs kill -9 || true
@@ -1571,6 +1641,8 @@ jobs:
15711641
openssl req -x509 -keyout cicd/vol/srv/credentials/pg_rubbish_key.pem -out cicd/vol/srv/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
15721642
15731643
- name: Run robot mocked functional tests
1644+
env:
1645+
PYTHONPATH: '${{ env.PYTHONPATH }}:/opt/test/python'
15741646
if: success() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64' && env.BUILD_IMAGE_REQUIRED == 'true' && matrix.db_backend == 'sqlite'
15751647
timeout-minutes: ${{ vars.DEFAULT_STEP_TIMEOUT_MIN == '' && 20 || vars.DEFAULT_STEP_TIMEOUT_MIN }}
15761648
run: |
@@ -1579,6 +1651,8 @@ jobs:
15791651
python cicd/python/build.py --robot-test --config='{ "variables": { "EXECUTION_PLATFORM": "docker" } }'
15801652
15811653
- name: Run POSTGRES BACKEND robot mocked functional tests
1654+
env:
1655+
PYTHONPATH: '${{ env.PYTHONPATH }}:/opt/test/python'
15821656
if: success() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64' && env.BUILD_IMAGE_REQUIRED == 'true' && matrix.db_backend == 'postgres_tcp'
15831657
timeout-minutes: ${{ vars.DEFAULT_LONG_STEP_TIMEOUT_MIN == '' && 40 || vars.DEFAULT_LONG_STEP_TIMEOUT_MIN }}
15841658
run: |
@@ -1610,6 +1684,7 @@ jobs:
16101684
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
16111685
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
16121686
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
1687+
PYTHONPATH: '${{ env.PYTHONPATH }}:/opt/test/python'
16131688
run: |
16141689
sudo rm -rf test/tmp || true
16151690
mkdir -p test/tmp

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ services:
4848
- ./test/assets/input:/opt/stackql/input:ro
4949
- ./test/tmp:/opt/test/tmp:rw
5050
- ./test/server:/opt/test/server:ro
51+
- ./test/python:/opt/test/python:ro
5152
- ${DB_SETUP_SRC:-./test/db/sqlite}:/opt/stackql/db:ro
5253
- ${REGISTRY_SRC:-./test/registry-mocked}:/opt/stackql/registry:ro
5354
- ./cicd/vol/stackql/config:/opt/stackql/.stackql:rw

test/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name = "stackql-test-tooling"
33
version = "0.1.0"
44
description = "Some testing tooling for stackql"
55
authors = ["General Kroll <[email protected]>"]
6-
readme = "robot/lib/README.md"
6+
readme = "python/README.md"
77
packages = [
8-
{include = "*.py", from = "robot/lib", to = "stackql_test_tooling"},
8+
{include = "*.py", from = "python", to = "stackql_test_tooling"},
99
{include = "flask", from = "python", to = "stackql_test_tooling"}
1010
]
1111

test/python/StackQLInterfaces.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from robot.libraries.Process import Process
1313
from robot.libraries.OperatingSystem import OperatingSystem
1414

15-
from stackql_context import RegistryCfg, _TEST_APP_CACHE_ROOT, PSQL_EXE, SQLITE_EXE
15+
from stackql_context import RegistryCfg
1616
from ShellSession import ShellSession
1717
from psycopg_client import PsycoPGClient
1818
from psycopg2_client import PsycoPG2Client
@@ -22,6 +22,11 @@
2222
SQL_BACKEND_POSTGRES_TCP :str = 'postgres_tcp'
2323
SQL_CONCURRENCT_LIMIT_DEFAULT :int = 1
2424

25+
_TEST_APP_CACHE_ROOT = os.path.join("test", ".stackql")
26+
27+
PSQL_EXE :str = os.environ.get('PSQL_EXE', 'psql')
28+
SQLITE_EXE :str = os.environ.get('SQLITE_EXE', 'sqlite3')
29+
2530

2631
@library(scope='SUITE', version='0.1.0', doc_format='reST')
2732
class StackQLInterfaces(OperatingSystem, Process, BuiltIn, Collections):

test/python/registry_cfg.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
import json
3+
import os
4+
5+
from typing import Optional
6+
7+
8+
class RegistryCfg:
9+
10+
_DEFAULT_DOCKER_REG_PATH :str = '/opt/stackql/registry'
11+
12+
def __init__(
13+
self,
14+
cwd: str,
15+
local_path :str,
16+
remote_url :str = '',
17+
nop_verify :bool = True,
18+
src_prefix :str = '',
19+
is_null_registry :bool = False,
20+
docker_reg_path :Optional[str] = None
21+
) -> None:
22+
self._cwd :str = cwd
23+
self.local_path :str = local_path
24+
self.remote_url :str = remote_url
25+
self.nop_verify :bool = nop_verify
26+
self.src_prefix :str = src_prefix
27+
self.is_null_registry :bool = is_null_registry
28+
self._docker_reg_path :str = docker_reg_path if docker_reg_path is not None else self._DEFAULT_DOCKER_REG_PATH
29+
30+
def _get_local_path(self, execution_environment :str) -> str:
31+
if self.local_path == '':
32+
return ''
33+
if execution_environment == "docker":
34+
return self._docker_reg_path
35+
return os.path.join(self._cwd, self.local_path)
36+
37+
def _get_url(self, execution_environment :str) -> str:
38+
if self.remote_url != '':
39+
return self.remote_url
40+
if execution_environment == "docker":
41+
return f'file://{self._docker_reg_path}'
42+
return f'file://{os.path.join(self._cwd, self.local_path)}'
43+
44+
def get_config_str(self, execution_environment :str) -> str:
45+
if self.is_null_registry:
46+
return ''
47+
cfg_dict = {
48+
"url": self._get_url(execution_environment)
49+
}
50+
if self._get_local_path(execution_environment) != "":
51+
cfg_dict["localDocRoot"] = self._get_local_path(execution_environment)
52+
if self.nop_verify:
53+
cfg_dict['verifyConfig'] = {
54+
'nopVerify': True
55+
}
56+
if self.src_prefix != '':
57+
cfg_dict['srcPrefix'] = self.src_prefix
58+
return json.dumps(cfg_dict)
59+
60+
def get_source_path_for_docker(self) -> str:
61+
return self.local_path

0 commit comments

Comments
 (0)