|
| 1 | +# Local Development Setup |
| 2 | + |
| 3 | +This guide will help you set up a local development environment for OpenVoxDB. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- PostgreSQL 16+ installed |
| 8 | +- [pgbox](https://gitlab.com/pgbox-org/pgbox) on your `$PATH` |
| 9 | +- Leiningen (Clojure build tool) |
| 10 | +- Java 17+ |
| 11 | + |
| 12 | +## Quick Start |
| 13 | + |
| 14 | +1. **Configure the helper script** |
| 15 | + |
| 16 | + Copy the example config and set your PostgreSQL path: |
| 17 | + |
| 18 | + ```bash |
| 19 | + cp dev-resources/ovdb.conf.example .ovdb.conf |
| 20 | + ``` |
| 21 | + |
| 22 | + Edit `.ovdb.conf` and set `pg_bin` to your PostgreSQL bin directory: |
| 23 | + |
| 24 | + ```bash |
| 25 | + # Mac (Homebrew) |
| 26 | + pg_bin=/opt/homebrew/opt/postgresql@17/bin |
| 27 | + |
| 28 | + # Mac (Postgres.app) |
| 29 | + pg_bin=/Applications/Postgres.app/Contents/Versions/17/bin |
| 30 | + |
| 31 | + # Linux (Debian/Ubuntu) |
| 32 | + pg_bin=/usr/lib/postgresql/17/bin |
| 33 | + |
| 34 | + # Linux (RHEL/CentOS) |
| 35 | + pg_bin=/usr/pgsql-17/bin |
| 36 | + |
| 37 | + # FreeBSD |
| 38 | + pg_bin=/usr/local/bin |
| 39 | + ``` |
| 40 | + |
| 41 | +2. **Validate your configuration** |
| 42 | + |
| 43 | + ```bash |
| 44 | + ./ovdb doctor |
| 45 | + ``` |
| 46 | + |
| 47 | +3. **Initialize and start the database** |
| 48 | + |
| 49 | + ```bash |
| 50 | + ./ovdb init |
| 51 | + ``` |
| 52 | + |
| 53 | + This creates a default postgres sandbox along with the necessary OpenVoxDB |
| 54 | + configuration inside `dev-resources/sandboxes/tmp_pg`. |
| 55 | + |
| 56 | + If you wish to store your sandboxes in a different directory that can be |
| 57 | + set with the `OVDB_SANDBOX` environment variable or in the `.ovdb.conf` |
| 58 | + file. |
| 59 | + |
| 60 | +4. **Run OpenVoxDB** |
| 61 | + |
| 62 | + ```bash |
| 63 | + ./ovdb run |
| 64 | + ``` |
| 65 | + |
| 66 | + OpenVoxDB will be available at `http://localhost:8080`. |
| 67 | + |
| 68 | +## Common Commands |
| 69 | + |
| 70 | +| Command | Description | |
| 71 | +|---------|-------------| |
| 72 | +| `./ovdb init` | Initialize a new PostgreSQL sandbox | |
| 73 | +| `./ovdb run` | Run OpenVoxDB | |
| 74 | +| `./ovdb start` | Start the PostgreSQL server | |
| 75 | +| `./ovdb stop` | Stop the PostgreSQL server | |
| 76 | +| `./ovdb test` | Run unit tests | |
| 77 | +| `./ovdb integration` | Run integration tests | |
| 78 | +| `./ovdb repl` | Start a Clojure REPL | |
| 79 | +| `./ovdb psql` | Connect to the database with psql | |
| 80 | +| `./ovdb doctor` | Validate configuration | |
| 81 | + |
| 82 | +Run `./ovdb --help` for the full list of commands. |
| 83 | + |
| 84 | +## Multiple Sandboxes |
| 85 | + |
| 86 | +You can create multiple PostgreSQL sandboxes for different purposes: |
| 87 | + |
| 88 | +```bash |
| 89 | +# Create a sandbox named "pg-18-test" |
| 90 | +./ovdb --name pg-18-test --pgver 18 init |
| 91 | + |
| 92 | +# Run against that sandbox |
| 93 | +./ovdb --name pg-18-test run |
| 94 | + |
| 95 | +# Run tests against it |
| 96 | +./ovdb --name pg-18-test test |
| 97 | +``` |
| 98 | + |
| 99 | +## Running Tests |
| 100 | + |
| 101 | +### Unit Tests |
| 102 | + |
| 103 | +Clojure unit tests that verify individual functions and components. These run |
| 104 | +against your PostgreSQL sandbox and test the core logic without requiring |
| 105 | +other openvox projects. |
| 106 | + |
| 107 | +```bash |
| 108 | +./ovdb test |
| 109 | +``` |
| 110 | + |
| 111 | +To run a specific test: |
| 112 | + |
| 113 | +```bash |
| 114 | +./ovdb test :only puppetlabs.puppetdb.scf.migrate-test/some-test |
| 115 | +``` |
| 116 | + |
| 117 | +### Integration Tests |
| 118 | + |
| 119 | +Tests that verify OpenVoxDB works correctly with OpenVox and OpenVox-Server. |
| 120 | +These tests clone and configure the OpenVox and OpenVox-Server repositories, |
| 121 | +then run scenarios that exercise the full command submission and query |
| 122 | +pipeline. |
| 123 | + |
| 124 | +```bash |
| 125 | +./ovdb integration |
| 126 | +``` |
| 127 | + |
| 128 | +### External Tests |
| 129 | + |
| 130 | +Black-box tests that run against a built uberjar. These verify the packaged |
| 131 | +application behaves correctly, including CLI argument handling, database |
| 132 | +migrations, error handling (like OOM and schema mismatches), and upgrade paths. |
| 133 | + |
| 134 | +```bash |
| 135 | +lein uberjar |
| 136 | +./ovdb ext |
| 137 | +``` |
| 138 | + |
| 139 | +## Populating Test Data |
| 140 | + |
| 141 | +Use the benchmark command to populate the database with test data: |
| 142 | + |
| 143 | +```bash |
| 144 | +# Add 10 nodes (default) |
| 145 | +./ovdb benchmark |
| 146 | + |
| 147 | +# Add 100 nodes |
| 148 | +./ovdb benchmark -- 100 |
| 149 | +``` |
| 150 | + |
| 151 | +## Configuration Reference |
| 152 | + |
| 153 | +Configuration is read from (in order of precedence): |
| 154 | + |
| 155 | +1. Command-line flags (`--pgver`, `--port`, etc.) |
| 156 | +2. Environment variables (`OVDB_PG_BIN`, `OVDB_SANDBOX`, etc.) |
| 157 | +3. Config file (`.ovdb.conf` in the repo root) |
| 158 | +4. Built-in defaults |
| 159 | + |
| 160 | +See `dev-resources/ovdb.conf.example` for all options. |
| 161 | + |
| 162 | +## Troubleshooting |
| 163 | + |
| 164 | +### "pg_bin is not configured" |
| 165 | + |
| 166 | +Set the `pg_bin` variable in `.ovdb.conf` to point to your PostgreSQL installation's bin directory. |
| 167 | + |
| 168 | +### "pg_ctl not found" |
| 169 | + |
| 170 | +Ensure `pg_bin` points to the directory containing `pg_ctl`, `psql`, and other PostgreSQL binaries. |
| 171 | + |
| 172 | +### Database won't start after reboot |
| 173 | + |
| 174 | +PostgreSQL sandboxes don't persist across reboots. Start the server with: |
| 175 | + |
| 176 | +```bash |
| 177 | +./ovdb start |
| 178 | +``` |
0 commit comments