From c2161c138784c214e1e432ea02a4d1a34a82c304 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Tue, 17 Dec 2024 16:28:27 +0700 Subject: [PATCH 01/17] feat: docker compose file for testing scylla --- .../tests/docker/docker-compose.scylla.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 catalyst-gateway/tests/docker/docker-compose.scylla.yml diff --git a/catalyst-gateway/tests/docker/docker-compose.scylla.yml b/catalyst-gateway/tests/docker/docker-compose.scylla.yml new file mode 100644 index 00000000000..6dcf5bda243 --- /dev/null +++ b/catalyst-gateway/tests/docker/docker-compose.scylla.yml @@ -0,0 +1,14 @@ +services: + scylla-node: + container_name: scylla-node + image: scylladb/scylla:latest + restart: unless-stopped + command: --seeds=scylla-node --smp 2 --memory 1G --overprovisioned 1 --api-address 0.0.0.0 --broadcast-rpc-address ${HOST_IP} + ports: + - "9042:9042" + networks: + cluster: + +networks: + cluster: + driver: bridge \ No newline at end of file From 53917ea09529b39c2cf47ef528b76c9770307d29 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Tue, 17 Dec 2024 20:36:05 +0700 Subject: [PATCH 02/17] feat: docker compose for pg --- catalyst-gateway/Earthfile | 2 +- catalyst-gateway/docker-compose.yml | 8 ----- .../tests/docker/docker-compose.postgres.yml | 29 +++++++++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 catalyst-gateway/tests/docker/docker-compose.postgres.yml diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index bde5adb213f..01d0c2994ea 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -128,7 +128,7 @@ check-builder-src-cache: test: FROM +builder-src - COPY docker-compose.yml . + COPY ./tests/docker/docker-compose.postgres.yml ./docker-compose.yml ENV EVENT_DB_URL "postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" 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/docker/docker-compose.postgres.yml b/catalyst-gateway/tests/docker/docker-compose.postgres.yml new file mode 100644 index 00000000000..64c1929caa4 --- /dev/null +++ b/catalyst-gateway/tests/docker/docker-compose.postgres.yml @@ -0,0 +1,29 @@ +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 From caa067d8b59151cf319aba5a4f5e4fdb19a4c8ae Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Tue, 17 Dec 2024 20:42:11 +0700 Subject: [PATCH 03/17] feat: earthly test target for scylla --- catalyst-gateway/Earthfile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index 01d0c2994ea..f24032c9732 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -125,7 +125,23 @@ check-builder-src-cache: || (echo "ERROR: Source fingerprints do not match. Caching Error Detected!!" && exit 1) \ && echo "Source fingerprints match. Caching OK." -test: +test-pg: + FROM +builder-src + + COPY ./tests/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: FROM +builder-src COPY ./tests/docker/docker-compose.postgres.yml ./docker-compose.yml From f32497a150b656731e8c4694c08ace58a5d5c75e Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Tue, 17 Dec 2024 21:44:20 +0700 Subject: [PATCH 04/17] feat: comment out on scylla --- catalyst-gateway/Earthfile | 22 +++++++++---------- .../tests/docker/docker-compose.scylla.yml | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index f24032c9732..1d66bc1ae1d 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -125,7 +125,7 @@ check-builder-src-cache: || (echo "ERROR: Source fingerprints do not match. Caching Error Detected!!" && exit 1) \ && echo "Source fingerprints match. Caching OK." -test-pg: +test-postgres: FROM +builder-src COPY ./tests/docker/docker-compose.postgres.yml ./docker-compose.yml @@ -144,15 +144,15 @@ test-pg: test-scylla: FROM +builder-src - COPY ./tests/docker/docker-compose.postgres.yml ./docker-compose.yml + # COPY ./tests/docker/docker-compose.postgres.yml ./docker-compose.yml - ENV EVENT_DB_URL "postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" + # 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 \ No newline at end of file + # 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 \ No newline at end of file diff --git a/catalyst-gateway/tests/docker/docker-compose.scylla.yml b/catalyst-gateway/tests/docker/docker-compose.scylla.yml index 6dcf5bda243..a6e932e47d8 100644 --- a/catalyst-gateway/tests/docker/docker-compose.scylla.yml +++ b/catalyst-gateway/tests/docker/docker-compose.scylla.yml @@ -11,4 +11,4 @@ services: networks: cluster: - driver: bridge \ No newline at end of file + driver: bridge From b63de9d6547d3bfa4dc869ac7cd4fdb25cda0fb0 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Wed, 18 Dec 2024 16:57:35 +0700 Subject: [PATCH 05/17] feat: test module --- catalyst-gateway/Earthfile | 21 ++++++++----------- catalyst-gateway/bin/src/db/index/mod.rs | 1 + .../bin/src/db/index/tests/mod.rs | 3 +++ .../bin/src/db/index/tests/scylla_session.rs | 5 +++++ 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 catalyst-gateway/bin/src/db/index/tests/mod.rs create mode 100644 catalyst-gateway/bin/src/db/index/tests/scylla_session.rs diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index 1d66bc1ae1d..bc9c9d3f9b5 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -144,15 +144,12 @@ test-postgres: test-scylla: FROM +builder-src - # COPY ./tests/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 \ No newline at end of file + COPY ./tests/docker/docker-compose.scylla.yml ./docker-compose.yml + + WITH DOCKER \ + --compose "./docker-compose.yml" \ + --pull alpine:3.20.3 \ + --service scylla-node + RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \ + cargo nextest run --release --run-ignored=only scylla_session + END \ No newline at end of file diff --git a/catalyst-gateway/bin/src/db/index/mod.rs b/catalyst-gateway/bin/src/db/index/mod.rs index f4157be8550..c800de6a3f3 100644 --- a/catalyst-gateway/bin/src/db/index/mod.rs +++ b/catalyst-gateway/bin/src/db/index/mod.rs @@ -4,3 +4,4 @@ pub(crate) mod block; pub(crate) mod queries; pub(crate) mod schema; pub(crate) mod session; +pub(crate) mod tests; diff --git a/catalyst-gateway/bin/src/db/index/tests/mod.rs b/catalyst-gateway/bin/src/db/index/tests/mod.rs new file mode 100644 index 00000000000..36030a49024 --- /dev/null +++ b/catalyst-gateway/bin/src/db/index/tests/mod.rs @@ -0,0 +1,3 @@ +//! Integration tests of the `IndexDB` queries + +pub(crate) mod scylla_session; diff --git a/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs b/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs new file mode 100644 index 00000000000..8a3805314e0 --- /dev/null +++ b/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs @@ -0,0 +1,5 @@ +//! Integration tests of the `IndexDB` queries testing on its session + +#[ignore = "An integration test which requires a running Scylla node instance, disabled from `testunit` CI run"] +#[tokio::test] +async fn test_session() {} From fbb72efd973105615218aa21eba9ff48e8880a87 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Wed, 18 Dec 2024 17:46:35 +0700 Subject: [PATCH 06/17] feat: tmp testing --- .../bin/src/db/index/tests/scylla_session.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs b/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs index 8a3805314e0..30cf49ed309 100644 --- a/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs +++ b/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs @@ -2,4 +2,12 @@ #[ignore = "An integration test which requires a running Scylla node instance, disabled from `testunit` CI run"] #[tokio::test] -async fn test_session() {} +async fn test_session() -> Result<(), String> { + use crate::db::index::session::CassandraSession; + + let Some(_) = CassandraSession::get(true) else { + return Err(String::from("Failed to acquire db session")); + }; + + Ok(()) +} From 226dca5ee64ee936ef31cd3c15c2c65ac92da3f6 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Wed, 18 Dec 2024 17:48:23 +0700 Subject: [PATCH 07/17] chore: test cfg --- catalyst-gateway/bin/src/db/index/tests/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/catalyst-gateway/bin/src/db/index/tests/mod.rs b/catalyst-gateway/bin/src/db/index/tests/mod.rs index 36030a49024..02ed2bb95ca 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 +#[cfg(test)] pub(crate) mod scylla_session; From 2bb6b4d2c50d3018fb8aa67a60e20a8ad647746f Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Thu, 19 Dec 2024 15:55:19 +0700 Subject: [PATCH 08/17] refactor: restructure --- catalyst-gateway/Earthfile | 24 +++++++++------ catalyst-gateway/blueprint.cue | 2 +- catalyst-gateway/docker-compose.yml | 8 +++++ .../tests/docker/docker-compose.postgres.yml | 29 ------------------- .../tests/docker/docker-compose.scylla.yml | 14 --------- 5 files changed, 24 insertions(+), 53 deletions(-) delete mode 100644 catalyst-gateway/tests/docker/docker-compose.postgres.yml delete mode 100644 catalyst-gateway/tests/docker/docker-compose.scylla.yml diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index bc9c9d3f9b5..df2218be023 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -128,7 +128,7 @@ check-builder-src-cache: test-postgres: FROM +builder-src - COPY ./tests/docker/docker-compose.postgres.yml ./docker-compose.yml + COPY docker-compose.yml . ENV EVENT_DB_URL "postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" @@ -144,12 +144,18 @@ test-postgres: test-scylla: FROM +builder-src - COPY ./tests/docker/docker-compose.scylla.yml ./docker-compose.yml + # setup scylla + RUN curl -sSL https://repo.scylladb.com/scylla/repo.asc | apt-key add - && \ + echo "deb [arch=$(dpkg --print-architecture)] https://repo.scylladb.com/deb/scylla/${SCYLLA_VERSION} $(lsb_release -c | awk '{print $2}') main" | tee /etc/apt/sources.list.d/scylla.list - WITH DOCKER \ - --compose "./docker-compose.yml" \ - --pull alpine:3.20.3 \ - --service scylla-node - RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \ - cargo nextest run --release --run-ignored=only scylla_session - END \ No newline at end of file + RUN apt-get update && \ + apt-get install -y scylla + + ENV HOST_IP + RUN export HOST_IP="$(ifconfig $(route -n | grep ^0.0.0.0 | awk '{print $NF}') | grep inet | grep -v inet6 | awk '{print $2}')" + + RUN scylla --seeds=scylla-node --smp 2 --memory 1G --overprovisioned 1 --api-address 0.0.0.0 --broadcast-rpc-address ${HOST_IP} + + # run the test + RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \ + cargo nextest run --release --run-ignored=only scylla_session \ No newline at end of file diff --git a/catalyst-gateway/blueprint.cue b/catalyst-gateway/blueprint.cue index 9e36433f3f4..4ee12a924a3 100644 --- a/catalyst-gateway/blueprint.cue +++ b/catalyst-gateway/blueprint.cue @@ -14,7 +14,7 @@ project: { } ci: { targets: { - test: privileged: true + test-postgres: privileged: true } } } diff --git a/catalyst-gateway/docker-compose.yml b/catalyst-gateway/docker-compose.yml index 0dfb7f3914c..00b2a348764 100644 --- a/catalyst-gateway/docker-compose.yml +++ b/catalyst-gateway/docker-compose.yml @@ -21,6 +21,14 @@ 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/docker/docker-compose.postgres.yml b/catalyst-gateway/tests/docker/docker-compose.postgres.yml deleted file mode 100644 index 64c1929caa4..00000000000 --- a/catalyst-gateway/tests/docker/docker-compose.postgres.yml +++ /dev/null @@ -1,29 +0,0 @@ -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 diff --git a/catalyst-gateway/tests/docker/docker-compose.scylla.yml b/catalyst-gateway/tests/docker/docker-compose.scylla.yml deleted file mode 100644 index a6e932e47d8..00000000000 --- a/catalyst-gateway/tests/docker/docker-compose.scylla.yml +++ /dev/null @@ -1,14 +0,0 @@ -services: - scylla-node: - container_name: scylla-node - image: scylladb/scylla:latest - restart: unless-stopped - command: --seeds=scylla-node --smp 2 --memory 1G --overprovisioned 1 --api-address 0.0.0.0 --broadcast-rpc-address ${HOST_IP} - ports: - - "9042:9042" - networks: - cluster: - -networks: - cluster: - driver: bridge From c40acdf0e2d26bef82f82796bed5542074373b24 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Thu, 19 Dec 2024 19:53:46 +0700 Subject: [PATCH 09/17] fix: cue typo --- catalyst-gateway/blueprint.cue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst-gateway/blueprint.cue b/catalyst-gateway/blueprint.cue index 4ee12a924a3..0650ba06ed9 100644 --- a/catalyst-gateway/blueprint.cue +++ b/catalyst-gateway/blueprint.cue @@ -14,7 +14,7 @@ project: { } ci: { targets: { - test-postgres: privileged: true + "test-postgres": privileged: true } } } From 36f45cb49cf8a1056ccedea766e61e99fbda9ca5 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Thu, 19 Dec 2024 20:09:38 +0700 Subject: [PATCH 10/17] fix: test --- catalyst-gateway/bin/src/db/index/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/catalyst-gateway/bin/src/db/index/mod.rs b/catalyst-gateway/bin/src/db/index/mod.rs index c800de6a3f3..a88bd6b387a 100644 --- a/catalyst-gateway/bin/src/db/index/mod.rs +++ b/catalyst-gateway/bin/src/db/index/mod.rs @@ -4,4 +4,5 @@ pub(crate) mod block; pub(crate) mod queries; pub(crate) mod schema; pub(crate) mod session; +#[cfg(test)] pub(crate) mod tests; From e3754b29280e8b98e6c0c747cafb82c30bb6bfff Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Thu, 19 Dec 2024 20:49:37 +0700 Subject: [PATCH 11/17] chore: tmp --- catalyst-gateway/bin/src/db/index/tests/scylla_session.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs b/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs index 30cf49ed309..5ff393201cf 100644 --- a/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs +++ b/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs @@ -1,10 +1,10 @@ //! Integration tests of the `IndexDB` queries testing on its session +use crate::db::index::session::CassandraSession; + #[ignore = "An integration test which requires a running Scylla node instance, disabled from `testunit` CI run"] #[tokio::test] async fn test_session() -> Result<(), String> { - use crate::db::index::session::CassandraSession; - let Some(_) = CassandraSession::get(true) else { return Err(String::from("Failed to acquire db session")); }; From ad85d6e839809a3e990f887bdacb779bb8969b4a Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Thu, 19 Dec 2024 22:10:50 +0700 Subject: [PATCH 12/17] chore: public --- catalyst-gateway/bin/src/db/index/mod.rs | 2 +- catalyst-gateway/bin/src/db/index/tests/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/catalyst-gateway/bin/src/db/index/mod.rs b/catalyst-gateway/bin/src/db/index/mod.rs index a88bd6b387a..d7ab2bb602b 100644 --- a/catalyst-gateway/bin/src/db/index/mod.rs +++ b/catalyst-gateway/bin/src/db/index/mod.rs @@ -5,4 +5,4 @@ pub(crate) mod queries; pub(crate) mod schema; pub(crate) mod session; #[cfg(test)] -pub(crate) mod tests; +mod tests; diff --git a/catalyst-gateway/bin/src/db/index/tests/mod.rs b/catalyst-gateway/bin/src/db/index/tests/mod.rs index 02ed2bb95ca..c0bf9ca08d9 100644 --- a/catalyst-gateway/bin/src/db/index/tests/mod.rs +++ b/catalyst-gateway/bin/src/db/index/tests/mod.rs @@ -1,4 +1,4 @@ //! Integration tests of the `IndexDB` queries #[cfg(test)] -pub(crate) mod scylla_session; +mod scylla_session; From b72a750f6e6d84217f29d8e93d4950667e95ad6c Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Thu, 19 Dec 2024 23:07:46 +0700 Subject: [PATCH 13/17] chore: bump cardano-chain-follower --- catalyst-gateway/bin/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst-gateway/bin/Cargo.toml b/catalyst-gateway/bin/Cargo.toml index 4f664ec101d..75c578f6d92 100644 --- a/catalyst-gateway/bin/Cargo.toml +++ b/catalyst-gateway/bin/Cargo.toml @@ -15,7 +15,7 @@ repository.workspace = true workspace = true [dependencies] -cardano-chain-follower = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.9" } +cardano-chain-follower = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.10" } c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.3" } rbac-registration = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.8" } From 7fecc410ec50ef611b1799953381477c47d1ea70 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Fri, 20 Dec 2024 21:01:17 +0700 Subject: [PATCH 14/17] feat: final setup --- catalyst-gateway/Earthfile | 19 ++++++++++--------- .../bin/src/db/index/tests/scylla_session.rs | 8 ++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index df2218be023..23663d37fab 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -145,17 +145,18 @@ test-scylla: FROM +builder-src # setup scylla - RUN curl -sSL https://repo.scylladb.com/scylla/repo.asc | apt-key add - && \ - echo "deb [arch=$(dpkg --print-architecture)] https://repo.scylladb.com/deb/scylla/${SCYLLA_VERSION} $(lsb_release -c | awk '{print $2}') main" | tee /etc/apt/sources.list.d/scylla.list - RUN apt-get update && \ - apt-get install -y scylla - - ENV HOST_IP - RUN export HOST_IP="$(ifconfig $(route -n | grep ^0.0.0.0 | awk '{print $NF}') | grep inet | grep -v inet6 | awk '{print $2}')" - - RUN scylla --seeds=scylla-node --smp 2 --memory 1G --overprovisioned 1 --api-address 0.0.0.0 --broadcast-rpc-address ${HOST_IP} + 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-6.2.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + scylla # run the test 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 \ No newline at end of file diff --git a/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs b/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs index 5ff393201cf..11679a1ea6e 100644 --- a/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs +++ b/catalyst-gateway/bin/src/db/index/tests/scylla_session.rs @@ -5,6 +5,14 @@ use crate::db::index::session::CassandraSession; #[ignore = "An integration test which requires a running Scylla node instance, disabled from `testunit` CI run"] #[tokio::test] async fn test_session() -> Result<(), String> { + CassandraSession::init(); + + CassandraSession::wait_is_ready(core::time::Duration::from_secs(1)).await; + + if !CassandraSession::is_ready() { + return Err(String::from("Cassandra session is not ready")); + } + let Some(_) = CassandraSession::get(true) else { return Err(String::from("Failed to acquire db session")); }; From 01a9efd92fba4a08a89247b657f1e90e7ee73606 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Mon, 23 Dec 2024 16:28:34 +0700 Subject: [PATCH 15/17] chore: remove test cfg --- catalyst-gateway/bin/src/db/index/tests/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/catalyst-gateway/bin/src/db/index/tests/mod.rs b/catalyst-gateway/bin/src/db/index/tests/mod.rs index c0bf9ca08d9..11dc1da2bcd 100644 --- a/catalyst-gateway/bin/src/db/index/tests/mod.rs +++ b/catalyst-gateway/bin/src/db/index/tests/mod.rs @@ -1,4 +1,3 @@ //! Integration tests of the `IndexDB` queries -#[cfg(test)] mod scylla_session; From bcee15a101954b66cee602a242496498e4e49182 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Mon, 23 Dec 2024 20:21:36 +0700 Subject: [PATCH 16/17] chore: scylla function --- catalyst-gateway/Earthfile | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index 23663d37fab..281f42e70eb 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -141,22 +141,29 @@ test-postgres: cargo nextest run --release --run-ignored=only signed_docs END +# test-scylla - Runs the integration test for scylla. test-scylla: FROM +builder-src - # setup scylla + 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 bookwarm-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-6.2.list && \ + 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 - - # run the test - 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 \ No newline at end of file + scylla \ No newline at end of file From b4b0bce85084bc08da32f33c1246fcd4288abca9 Mon Sep 17 00:00:00 2001 From: Apisit Ritreungroj Date: Mon, 23 Dec 2024 20:33:20 +0700 Subject: [PATCH 17/17] chore: fix cspell --- catalyst-gateway/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index 281f42e70eb..2f1fa30445b 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -151,7 +151,7 @@ test-scylla: 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 bookwarm-slim/debian +# INSTALL_SCYLLA - Installs scylla for bookworm-slim/debian INSTALL_SCYLLA: FUNCTION