diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index 2f1fa30445b..e2b4735ac9e 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -123,47 +123,4 @@ check-builder-src-cache: RUN diff ../src_fingerprint.txt ../src_fingerprint_uncached.txt \ || (echo "ERROR: Source fingerprints do not match. Caching Error Detected!!" && exit 1) \ - && echo "Source fingerprints match. Caching OK." - -test-postgres: - FROM +builder-src - - COPY docker-compose.yml . - - ENV EVENT_DB_URL "postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" - - WITH DOCKER \ - --compose "./docker-compose.yml" \ - --load ./event-db+build \ - --pull alpine:3.20.3 \ - --service event-db-is-running - RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \ - cargo nextest run --release --run-ignored=only signed_docs - END - -# test-scylla - Runs the integration test for scylla. -test-scylla: - FROM +builder-src - - DO +INSTALL_SCYLLA --VERSION=6.2 - - RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \ - scylla --options-file /etc/scylla/scylla.yaml --smp=2 --memory=4G --overprovisioned --developer-mode=1 & \ - cargo nextest run --release --run-ignored=only scylla_session - -# INSTALL_SCYLLA - Installs scylla for bookworm-slim/debian -INSTALL_SCYLLA: - FUNCTION - - ARG --required VERSION - - RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - wget gnupg ca-certificates && \ - mkdir -p /etc/apt/keyrings && \ - gpg --homedir /tmp --no-default-keyring --keyring /etc/apt/keyrings/scylladb.gpg \ - --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys a43e06657bac99e3 && \ - wget -O /etc/apt/sources.list.d/scylla.list http://downloads.scylladb.com/deb/debian/scylla-$VERSION.list && \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - scylla \ No newline at end of file + && echo "Source fingerprints match. Caching OK." \ No newline at end of file diff --git a/catalyst-gateway/bin/src/db/index/tests/mod.rs b/catalyst-gateway/bin/src/db/index/tests/mod.rs index 11dc1da2bcd..d4a2b18023e 100644 --- a/catalyst-gateway/bin/src/db/index/tests/mod.rs +++ b/catalyst-gateway/bin/src/db/index/tests/mod.rs @@ -1,3 +1,4 @@ //! Integration tests of the `IndexDB` queries +mod scylla_schema; mod scylla_session; diff --git a/catalyst-gateway/bin/src/db/index/tests/scylla_schema.rs b/catalyst-gateway/bin/src/db/index/tests/scylla_schema.rs new file mode 100644 index 00000000000..5adc4b046ef --- /dev/null +++ b/catalyst-gateway/bin/src/db/index/tests/scylla_schema.rs @@ -0,0 +1 @@ +//! Integration tests of the `IndexDB` queries testing on its schema setup and integrity diff --git a/catalyst-gateway/docker-compose.yml b/catalyst-gateway/docker-compose.yml index 00b2a348764..0dfb7f3914c 100644 --- a/catalyst-gateway/docker-compose.yml +++ b/catalyst-gateway/docker-compose.yml @@ -21,14 +21,6 @@ services: timeout: 5s retries: 10 -# it is a helper service to wait until the event-db will be ready -# mainly its a trick for Earthly how to wait until service will be fully functional - event-db-is-running: - image: alpine:3.20.3 - depends_on: - event-db: - condition: service_healthy - cat-gateway: image: cat-gateway:latest environment: diff --git a/catalyst-gateway/tests/Earthfile b/catalyst-gateway/tests/Earthfile index 85383a20403..eb6e366c5b8 100644 --- a/catalyst-gateway/tests/Earthfile +++ b/catalyst-gateway/tests/Earthfile @@ -12,3 +12,46 @@ test-lint-openapi: COPY --dir ./openapi-v3.0-lints/* . # Scan the doc directory where type of file is JSON. DO spectral-ci+LINT --dir=./doc + +test-postgres: + FROM +builder-src + + COPY ./docker/docker-compose.postgres.yml docker-compose.yml + + ENV EVENT_DB_URL "postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" + + WITH DOCKER \ + --compose "./docker-compose.yml" \ + --load ../event-db+build \ + --pull alpine:3.20.3 \ + --service event-db-is-running + RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \ + cargo nextest run --release --run-ignored=only signed_docs + END + +# test-scylla - Runs the integration test for scylla. +test-scylla: + FROM +builder-src + + DO +INSTALL_SCYLLA --VERSION=6.2 + + RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \ + scylla --options-file /etc/scylla/scylla.yaml --smp=2 --memory=4G --overprovisioned --developer-mode=1 & \ + cargo nextest run --release --run-ignored=only scylla_session + +# INSTALL_SCYLLA - Installs scylla for bookworm-slim/debian +INSTALL_SCYLLA: + FUNCTION + + ARG --required VERSION + + RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + wget gnupg ca-certificates && \ + mkdir -p /etc/apt/keyrings && \ + gpg --homedir /tmp --no-default-keyring --keyring /etc/apt/keyrings/scylladb.gpg \ + --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys a43e06657bac99e3 && \ + wget -O /etc/apt/sources.list.d/scylla.list http://downloads.scylladb.com/deb/debian/scylla-$VERSION.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + scylla \ No newline at end of file diff --git a/catalyst-gateway/tests/docker/docker-compose.postgres.yml b/catalyst-gateway/tests/docker/docker-compose.postgres.yml new file mode 100644 index 00000000000..4c9801de859 --- /dev/null +++ b/catalyst-gateway/tests/docker/docker-compose.postgres.yml @@ -0,0 +1,30 @@ +services: + event-db: + image: event-db:latest + environment: + - DB_HOST=localhost + - DB_PORT=5432 + - DB_NAME=CatalystEventDev + - DB_DESCRIPTION="Catalyst Event DB" + - DB_SUPERUSER=postgres + - DB_SUPERUSER_PASSWORD=postgres + - DB_USER=catalyst-event-dev + - DB_USER_PASSWORD=CHANGE_ME + + - INIT_AND_DROP_DB=true + - WITH_MIGRATIONS=true + ports: + - 5432:5432 + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${DB_SUPERUSER} -d $${DB_SUPERUSER_PASSWORD}"] + interval: 10s + timeout: 5s + retries: 10 + +# it is a helper service to wait until the event-db will be ready +# mainly its a trick for Earthly how to wait until service will be fully functional + event-db-is-running: + image: alpine:3.20.3 + depends_on: + event-db: + condition: service_healthy