Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cat-gateway): Add integration test to IndexDB #1431

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
test-postgres:
FROM +builder-src

COPY docker-compose.yml .
Expand All @@ -139,4 +139,31 @@ test:
--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
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
2 changes: 1 addition & 1 deletion catalyst-gateway/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
2 changes: 2 additions & 0 deletions catalyst-gateway/bin/src/db/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ pub(crate) mod block;
pub(crate) mod queries;
pub(crate) mod schema;
pub(crate) mod session;
#[cfg(test)]
mod tests;
3 changes: 3 additions & 0 deletions catalyst-gateway/bin/src/db/index/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! Integration tests of the `IndexDB` queries

mod scylla_session;
21 changes: 21 additions & 0 deletions catalyst-gateway/bin/src/db/index/tests/scylla_session.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! 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> {
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"));
};

Ok(())
}
2 changes: 1 addition & 1 deletion catalyst-gateway/blueprint.cue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ project: {
}
ci: {
targets: {
test: privileged: true
"test-postgres": privileged: true
}
}
}
Loading