Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dqii committed Jul 23, 2024
1 parent 2632ded commit 8227aad
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 26 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Docker image without cache
run: docker build --no-cache -t lantern-test .
- name: Run the container
run: docker run --rm -v ${{ github.workspace }}/test:/test -e POSTGRES_HOST_AUTH_METHOD=trust -d --name lantern-test-container lantern-test
- name: Run tests
run: |
docker-compose -f docker-compose.test.yml up --exit-code-from test
run: docker exec lantern-test-container bash -c "/test/run-all.sh || exit 1"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN git clone https://github.com/citusdata/pg_cron.git /tmp/pg_cron && \
make -j && \
make install

# Install pgvector
# Install pgvector
RUN git clone --branch narek/array-to-sparsevec-casts https://github.com/Ngalstyan4/pgvector.git /tmp/pgvector && \
cd /tmp/pgvector && \
make && \
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Lantern Suite

## Testing

To build Dockerfile:

```bash
docker build -t lantern-suite:latest .
```

To run tests locally:

```bash
# Build the image without cache
docker build --no-cache -t lantern-test .

# Run the container
docker run --rm -v $(pwd)/test:/test -e POSTGRES_HOST_AUTH_METHOD=trust -d --name lantern-test-container lantern-test

# Run the tests
docker exec lantern-test-container bash -c "/test/run-all.sh || exit 1"

# Delete the image after running the tests
docker rmi lantern-test
```
22 changes: 0 additions & 22 deletions docker-compose.test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion test/extension-count.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

available_extensions=$(PGPASSWORD=postgres psql -h lantern -U postgres -t -A -c "SELECT name FROM pg_available_extensions WHERE name IN ('lantern', 'lantern_extras', 'pg_cron', 'pg_stat_statements', 'vector');")
available_extensions=$(PGPASSWORD=postgres psql -U postgres -t -A -c "SELECT name FROM pg_available_extensions WHERE name IN ('lantern', 'lantern_extras', 'pg_cron', 'pg_stat_statements', 'vector');")

required_extensions=("lantern" "lantern_extras" "pg_cron" "pg_stat_statements" "vector")
missing_extensions=()
Expand Down
15 changes: 15 additions & 0 deletions test/run-all.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/bin/bash

# Wait for PostgreSQL to be ready
wait_for_postgres() {
local max_wait=10
local wait_time=0
until pg_isready -U postgres &> /dev/null; do
sleep 1
wait_time=$((wait_time + 1))
if [ $wait_time -ge $max_wait ]; then
echo "PostgreSQL is not ready after $max_wait seconds, exiting."
exit 1
fi
done
}
wait_for_postgres

# Function to run a test and check its result
run_test() {
local test_name="$1"
Expand Down

0 comments on commit 8227aad

Please sign in to comment.