-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing: Demonstrate test utilities with Python
- Loading branch information
Showing
11 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: SQLAlchemy | ||
|
||
on: | ||
pull_request: | ||
branches: ~ | ||
paths: | ||
- '.github/workflows/testing-testcontainers-python.yml' | ||
- 'testing/testcontainers/python**' | ||
- 'requirements.txt' | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/testing-testcontainers-python.yml' | ||
- 'testing/testcontainers/python**' | ||
- 'requirements.txt' | ||
|
||
# Allow job to be triggered manually. | ||
workflow_dispatch: | ||
|
||
# Run job each night after CrateDB nightly has been published. | ||
schedule: | ||
- cron: '0 3 * * *' | ||
|
||
# Cancel in-progress jobs when pushing to the same branch. | ||
concurrency: | ||
cancel-in-progress: true | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
test: | ||
name: " | ||
Python: ${{ matrix.python-version }} | ||
CrateDB: ${{ matrix.cratedb-version }} | ||
on ${{ matrix.os }}" | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ 'ubuntu-latest' ] | ||
python-version: [ '3.12' ] | ||
cratedb-version: [ 'nightly' ] | ||
|
||
steps: | ||
|
||
- name: Acquire sources | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
architecture: x64 | ||
cache: 'pip' | ||
cache-dependency-path: | | ||
requirements.txt | ||
testing/testcontainers/python-pytest/requirements.txt | ||
testing/testcontainers/python-pytest/requirements-dev.txt | ||
testing/testcontainers/python-unittest/requirements.txt | ||
- name: Install utilities | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Validate testing/testcontainers/python-{pytest,unittest} | ||
run: | | ||
ngr test --accept-no-venv testing/testcontainers/python-pytest | ||
ngr test --accept-no-venv testing/testcontainers/python-unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pueblo>=0.0.4 | ||
pueblo>=0.0.8 | ||
|
||
# Development. | ||
# pueblo @ git+https://github.com/pyveci/pueblo.git@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[tool.pytest.ini_options] | ||
minversion = "2.0" | ||
addopts = """ | ||
-rfEX -p pytester --strict-markers --verbosity=3 | ||
--cov --cov-report=term-missing --cov-report=xml | ||
--capture=no | ||
""" | ||
log_level = "DEBUG" | ||
log_cli_level = "DEBUG" | ||
testpaths = ["*.py"] | ||
xfail_strict = true | ||
markers = [ | ||
] | ||
|
||
|
||
[tool.coverage.run] | ||
branch = false | ||
omit = [ | ||
"test*", | ||
] | ||
|
||
[tool.coverage.report] | ||
fail_under = 0 | ||
show_missing = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pytest<9 | ||
pytest-cov<5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
crash==0.31.2 | ||
# cratedb-toolkit[testing]==0.0.3 | ||
|
||
# Temporary, until a new `cratedb-toolkit` has been released. | ||
cratedb-toolkit[testing] @ git+https://github.com/crate-workbench/cratedb-toolkit@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import shlex | ||
import subprocess | ||
|
||
|
||
def run(command: str): | ||
subprocess.check_call(shlex.split(command)) | ||
|
||
|
||
def test_crash(cratedb_service): | ||
http_url = cratedb_service.get_http_url() | ||
cmd = f"time crash --hosts '{http_url}' --command 'SELECT * FROM sys.summits ORDER BY height DESC LIMIT 3;'" | ||
run(cmd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python-unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PHONY: test | ||
|
||
test: | ||
python -m unittest -vvv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[tool.coverage.run] | ||
branch = false | ||
omit = [ | ||
"test*", | ||
] | ||
|
||
[tool.coverage.report] | ||
fail_under = 0 | ||
show_missing = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
crash==0.31.2 | ||
cratedb-toolkit[testing]==0.0.3 | ||
|
||
# Temporary, until a new `cratedb-toolkit` has been released. | ||
# cratedb-toolkit[testing] @ git+https://github.com/crate-workbench/cratedb-toolkit@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import shlex | ||
import subprocess | ||
from unittest import TestCase | ||
|
||
from cratedb_toolkit.testing.testcontainers.cratedb import CrateDBTestAdapter | ||
|
||
node = CrateDBTestAdapter() | ||
|
||
|
||
def run(command: str): | ||
subprocess.check_call(shlex.split(command)) | ||
|
||
|
||
def setUpModule(): | ||
node.start() | ||
|
||
|
||
def tearDownModule(): | ||
node.stop() | ||
|
||
|
||
class CrashTest(TestCase): | ||
def setUp(self): | ||
node.reset() | ||
|
||
def test_crash(self): | ||
http_url = node.get_http_url() | ||
cmd = f"time crash --hosts '{http_url}' --command 'SELECT * FROM sys.summits ORDER BY height DESC LIMIT 3;'" | ||
run(cmd) |