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

Commit

Permalink
Add .so test (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqii authored Jul 10, 2024
1 parent d76131e commit 2632ded
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 17 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ on:
branches:
- main
env:
VERSION: "0.2.1"
VERSION: "0.2.2"
IMAGE_NAME: "lanterndata/lantern-suite"
LANTERN_VERSION: "0.3.0"
LANTERN_EXTRAS_VERSION: "0.2.2"
PG_CRON_VERSION: "7e91e72b1bebc5869bb900d9253cc9e92518b33f"
jobs:
docker:
runs-on: ubuntu-22.04
Expand Down
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
ARG PG_VERSION=15
ARG LANTERN_VERSION=0.2.5
ARG LANTERN_EXTRAS_VERSION=0.1.5
ARG PG_CRON_VERSION="7e91e72b1bebc5869bb900d9253cc9e92518b33f"

FROM postgres:$PG_VERSION-bookworm
ARG LANTERN_VERSION
ARG LANTERN_EXTRAS_VERSION
ARG LANTERN_VERSION=0.3.0
ARG LANTERN_EXTRAS_VERSION=0.2.3
ARG PG_VERSION
ARG TARGETARCH
ARG PG_CRON_VERSION
ARG PG_CRON_VERSION="7e91e72b1bebc5869bb900d9253cc9e92518b33f"
ENV OS_ARCH="${TARGETARCH:-amd64}"

RUN apt update && apt install -y curl wget make jq pgbouncer procps bc git-all gcc postgresql-server-dev-${PG_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:

test:
image: lantern
command: ./test/extension-count.sh
command: ./test/run-all.sh
volumes:
- ./test:/test
depends_on:
Expand Down
21 changes: 15 additions & 6 deletions test/extension-count.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
count=$(PGPASSWORD=postgres psql -h lantern -U postgres -t -A -c "SELECT COUNT(*) FROM pg_available_extensions WHERE name IN ('lantern', 'lantern_extras', 'pg_cron', 'pg_stat_statements', 'vector');")
echo "Count: $count"
if echo "$count" | grep -q "ERROR"; then
echo "Failed to retrieve extension count" && exit 1
elif [ "$count" -ne 5 ]; then
echo "Extension check failed" && exit 1
#!/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');")

required_extensions=("lantern" "lantern_extras" "pg_cron" "pg_stat_statements" "vector")
missing_extensions=()
for ext in "${required_extensions[@]}"; do
if ! echo "$available_extensions" | grep -q "^${ext}$"; then
missing_extensions+=("$ext")
fi
done

if [ ${#missing_extensions[@]} -ne 0 ]; then
echo "Extension check failed. Missing extensions: ${missing_extensions[*]}"
exit 1
else
echo "Extension check passed"
fi
32 changes: 32 additions & 0 deletions test/run-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

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

echo "Running $test_name..."
if $test_command; then
echo "$test_name PASSED"
else
echo "$test_name FAILED"
return 1
fi
}

# Initialize a variable to track overall test success
overall_success=true

# Test 1: Check PostgreSQL extension count
run_test "Check PostgreSQL extension count" ./test/extension-count.sh || overall_success=false

# Test 2: Check for .so files presence
run_test "Check .so files presence" ./test/so-files-present.sh || overall_success=false

# Exit with an error if any test failed
if [ "$overall_success" = false ]; then
echo "One or more tests failed."
exit 1
else
echo "All tests passed successfully."
fi
22 changes: 22 additions & 0 deletions test/so-files-present.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

PG_VERSION=15

declare -a extensions=("lantern" "lantern_extras" "pg_cron" "pg_stat_statements" "vector")

missing_files=()
for ext in "${extensions[@]}"; do
if ! [ -f "/usr/lib/postgresql/$PG_VERSION/lib/${ext}.so" ]; then
missing_files+=("/usr/lib/postgresql/$PG_VERSION/lib/${ext}.so")
fi
done

if [ ${#missing_files[@]} -ne 0 ]; then
echo "Shared object files missing for the following extensions:"
for file in "${missing_files[@]}"; do
echo "$file"
done
exit 1
else
echo "All necessary shared object files are present"
fi

0 comments on commit 2632ded

Please sign in to comment.