|
| 1 | +# Integration tests |
| 2 | + |
| 3 | +Everything that exercises the driver from outside the Rust crate: through real |
| 4 | +unixODBC on Linux, and through the real Windows Driver Manager in a VM. |
| 5 | + |
| 6 | +There is no service to start. SQLite is a file, and `rusqlite` links its own |
| 7 | +copy of it into the driver, so the whole suite runs on a bare runner in seconds. |
| 8 | +That is exactly why it gates every pull request while the Trino driver's |
| 9 | +equivalent cannot. |
| 10 | + |
| 11 | +```bash |
| 12 | +./integration-tests/setup.sh # build the driver, create the database, write the ODBC config |
| 13 | +./integration-tests/run-tests.sh # pyodbc through unixODBC, then cargo test |
| 14 | +``` |
| 15 | + |
| 16 | +Both take `--help`. |
| 17 | + |
| 18 | +## Layout |
| 19 | + |
| 20 | +| Path | What it holds | |
| 21 | +|------|---------------| |
| 22 | +| `setup.sh`, `run-tests.sh` | Wrappers. The logic is in `scripts/` | |
| 23 | +| `scripts/lib.sh` | The paths and helpers both scripts share. Sourced, never executed | |
| 24 | +| `scripts/setup.sh` | Builds the driver, creates `test.db`, writes `odbc.ini` / `odbcinst.ini` | |
| 25 | +| `scripts/run-tests.sh` | Runs the suites | |
| 26 | +| `suites/create_test_db.sql` | The schema and rows every suite reads | |
| 27 | +| `suites/test_integration.py` | The pyodbc suite, run once per connection style | |
| 28 | +| `generated/` | Everything `setup.sh` writes. Gitignored | |
| 29 | +| `windows/` | The VM suite, its libvirt definitions, and [WINDOWS.md](windows/WINDOWS.md) | |
| 30 | + |
| 31 | +`generated/` is ignored rather than committed because all three files it holds |
| 32 | +name absolute paths: the driver's `.so`, the database. None of them survives |
| 33 | +being moved to another checkout, so a committed copy would be wrong for |
| 34 | +everyone but its author. |
| 35 | + |
| 36 | +## What gets run |
| 37 | + |
| 38 | +`run-tests.sh` runs the pyodbc suite **twice**, against the same database: |
| 39 | + |
| 40 | +- **DSN-less**, `Driver=...;Database=...`, which exercises this driver's own |
| 41 | + connection-string parsing. |
| 42 | +- **Via a DSN**, `DSN=test_sqlite`, where the Driver Manager resolves the |
| 43 | + keywords out of `odbc.ini` first. |
| 44 | + |
| 45 | +They are separate runs because they fail separately. A driver that reads its |
| 46 | +parameters correctly can still be unreachable through a DSN, and that is a |
| 47 | +configuration most applications actually use. |
| 48 | + |
| 49 | +It then runs `cargo test`, so that one command gives a developer the whole |
| 50 | +suite. CI passes `--skip-cargo-test`, since its pre-commit job has already run |
| 51 | +exactly that via the `cargo-test` hook. |
| 52 | + |
| 53 | +## Options |
| 54 | + |
| 55 | +| Flag | Effect | |
| 56 | +|------|--------| |
| 57 | +| `--skip-build` | Reuse the driver already built. Forwarded to `windows_test.py`, whose build is a separate cross-compile | |
| 58 | +| `--skip-cargo-test` | Run the pyodbc suites only. What CI passes | |
| 59 | +| `--windows` | Additionally run the suite inside the Windows VM | |
| 60 | + |
| 61 | +Any other argument is forwarded to `windows_test.py` (`--host`, `--gateway`, |
| 62 | +`--user`, `--password`) and so is rejected without `--windows`: a flag |
| 63 | +forwarded to a script that never runs is a flag silently ignored. |
| 64 | + |
| 65 | +## Windows |
| 66 | + |
| 67 | +`windows/windows_test.py` deploys the cross-compiled DLL to a provisioned |
| 68 | +libvirt VM over WinRM, registers it, and runs the same |
| 69 | +`suites/test_integration.py` through the Windows Driver Manager, DSN-less and |
| 70 | +then via a DSN. The Windows DM is much stricter than unixODBC and tends to fail |
| 71 | +silently, so this is measured rather than assumed. |
| 72 | + |
| 73 | +See [windows/WINDOWS.md](windows/WINDOWS.md) for provisioning the VM. |
| 74 | + |
| 75 | +## Interactively |
| 76 | + |
| 77 | +`setup.sh` prints these at the end: |
| 78 | + |
| 79 | +```bash |
| 80 | +export ODBCSYSINI=integration-tests/generated |
| 81 | +export ODBCINI=integration-tests/generated/odbc.ini |
| 82 | +isql -3 test_sqlite -v |
| 83 | +``` |
| 84 | + |
| 85 | +Prefix either with `ODBC_LOG_LEVEL=debug` to see which ODBC functions your |
| 86 | +client calls, and in what order. |
0 commit comments