diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2584100..ffcc2cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,20 @@ jobs: uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} + - name: Install Dependenies + run: sudo apt-get update && sudo apt-get install -y --no-install-recommends ca-certificates postgresql-client + - name: Checkout code uses: actions/checkout@v3 + + - name: Add tables + run: PGPASSWORD=testPass psql -U testUser -h localhost -p 5432 -d testDB -c 'CREATE TABLE entries (id BIGSERIAL PRIMARY KEY, amount REAL, user_id VARCHAR(6), entry_date DATE, timestamp TIMESTAMP)'; + + - name: Build binary + run: CGO_ENABLED=0 go build -o server.bin -ldflags="-s -w -X 'main.buildString=${BUILDSTR}'" ./cmd/*.go + + - name: Run binary server + run: ./server.bin --config config.test.toml & + - name: Run tests - run: go test ./cmd -v -covermode=count + run: sleep 5 && go test ./client -v -covermode=count diff --git a/README.md b/README.md index 4def14a..5fade36 100644 --- a/README.md +++ b/README.md @@ -145,13 +145,13 @@ Often times, different queries have different priorities of execution. Some may ```shell # Run the primary worker + HTTP control interface dungbeetle --config /path/to/config.toml --sql-directory /path/to/sql/dir \ - --queue "high_priority" \ + --queue "high_priority" \ --worker-name "high_priority_worker" \ --worker-concurrency 30 # Run another worker on a different queue to handle low priority jobs dungbeetle --config /path/to/config.toml --sql-directory /path/to/sql/dir \ - --queue "low_priority" \ + --queue "low_priority" \ --worker-name "low_priority_worker" \ --worker-concurrency 5 \ --worker-only diff --git a/config.test.toml b/config.test.toml new file mode 100644 index 0000000..e2f2363 --- /dev/null +++ b/config.test.toml @@ -0,0 +1,44 @@ +[app] +log_level = "DEBUG" +default_job_ttl = "60s" + +[job_queue.broker] +type = "redis" +addresses = ["localhost:6379"] +password = "" +db = 1 +max_active = 50 +max_idle = 20 +dial_timeout = "1s" +read_timeout = "1s" +write_timeout = "1s" + +[job_queue.state] +type = "redis" +addresses = ["localhost:6379"] +password = "" +db = 1 +max_active = 50 +max_idle = 20 +dial_timeout = "1s" +read_timeout = "1s" +write_timeout = "1s" +expiry = "30s" +meta_expiry = "3600s" + +[results.my_results] +type = "postgres" +dsn = "postgres://testUser:testPass@localhost:5432/testDB?sslmode=disable" + +max_idle = 10 +max_active = 100 +connect_timeout = "10s" + +results_table = "results_%s" + +[db.my_db] +type = "postgres" +dsn = "postgres://testUser:testPass@127.0.0.1:5432/testDB?sslmode=disable" +max_idle = 10 +max_active = 100 +connect_timeout = "10s"